.muted { color: var(--muted); }

.app { display: flex; height: 100dvh; }

.sidebar {
  width: 290px;
  flex: none;
  background: var(--panel);
  border-inline-end: 1px solid var(--line);
  display: flex;
  flex-direction: column;
}
.side-top { padding: 14px; }
.side-top .btn { width: 100%; }
.conv-list { flex: 1; overflow-y: auto; padding: 0 8px 8px; }
.conv {
  display: flex;
  align-items: center;
  gap: 4px;
  border-radius: 10px;
  padding: 2px 4px 2px 2px;
}
.conv:hover, .conv.active { background: var(--panel-2); }
.conv.active { font-weight: 600; }
.conv-title {
  flex: 1;
  min-width: 0;
  text-align: start;
  background: none;
  border: 0;
  padding: 9px 10px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.conv-del {
  opacity: 0;
  background: none;
  border: 0;
  cursor: pointer;
  color: var(--muted);
  padding: 6px 8px;
  border-radius: 8px;
}
.conv:hover .conv-del, .conv-del:focus-visible { opacity: 1; }
.conv-del:hover { color: var(--bad); background: var(--panel); }
.side-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--line);
  font-size: 0.82rem;
}
#model-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; direction: ltr; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: none;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
.title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.messages { flex: 1; overflow-y: auto; padding: 22px 16px 8px; scroll-behavior: auto; }
.messages > * { max-width: 780px; margin-inline: auto; }
.empty { text-align: center; margin-top: 18vh !important; }
.empty-title { font-size: 1.5rem; font-weight: 700; margin-bottom: 6px; }

.msg { margin-bottom: 18px; display: flex; }
.msg.user { justify-content: flex-start; }
.msg .bubble { max-width: 100%; word-wrap: break-word; overflow-wrap: anywhere; }
.msg.user .bubble {
  background: var(--user-bg);
  color: var(--user-text);
  padding: 10px 14px;
  border-radius: 16px 16px 4px 16px;
  white-space: pre-wrap;
  max-width: 88%;
}
.msg.model .bubble { width: 100%; padding: 2px 2px; }
.msg.error .bubble {
  background: color-mix(in srgb, var(--bad) 12%, var(--panel));
  color: var(--bad);
  border: 1px solid color-mix(in srgb, var(--bad) 40%, transparent);
  padding: 10px 14px;
  border-radius: 12px;
  width: auto;
}

.bubble p, .bubble ul, .bubble ol, .bubble blockquote, .bubble table, .bubble h1, .bubble h2, .bubble h3, .bubble h4, .bubble h5, .bubble h6 { margin: 0 0 10px; }
.bubble > :last-child { margin-bottom: 0; }
.bubble h1 { font-size: 1.35rem; }
.bubble h2 { font-size: 1.2rem; }
.bubble h3, .bubble h4, .bubble h5, .bubble h6 { font-size: 1.05rem; }
.bubble ul, .bubble ol { padding-inline-start: 24px; }
.bubble li { margin: 2px 0; }
.bubble blockquote { border-inline-start: 3px solid var(--line); padding: 2px 12px; color: var(--muted); }
.bubble hr { border: 0; border-top: 1px solid var(--line); margin: 14px 0; }
.bubble a { color: var(--accent); }
.bubble code {
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 0.9em;
  background: var(--panel-2);
  padding: 1px 5px;
  border-radius: 6px;
  direction: ltr;
  unicode-bidi: embed;
}
.bubble table { border-collapse: collapse; display: block; overflow-x: auto; }
.bubble th, .bubble td { border: 1px solid var(--line); padding: 6px 10px; }
.bubble th { background: var(--panel-2); }

.code { margin: 0 0 10px; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--panel); }
.code-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 10px;
  background: var(--panel-2);
  font-size: 0.8rem;
  color: var(--muted);
  direction: ltr;
}
.code pre { margin: 0; padding: 12px 14px; overflow-x: auto; direction: ltr; text-align: left; }
.code pre code { background: none; padding: 0; font-size: 0.88rem; display: block; white-space: pre; }
.copy { background: none; border: 0; cursor: pointer; color: var(--muted); font-size: 0.8rem; }
.copy:hover { color: var(--text); }

.cursor::after { content: "▍"; animation: blink 1s steps(2) infinite; color: var(--muted); }
@keyframes blink { 50% { opacity: 0; } }

.composer { padding: 10px 16px calc(14px + env(safe-area-inset-bottom)); }
.composer-box {
  max-width: 780px;
  margin: 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 8px 8px 8px 10px;
  box-shadow: var(--shadow);
}
.composer-box:focus-within { border-color: var(--accent); }
.composer-box textarea {
  border: 0;
  box-shadow: none !important;
  resize: none;
  max-height: 200px;
  background: transparent;
  padding: 8px 6px;
}
.send { flex: none; border-radius: 12px; padding: 9px 16px; }

.scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.45); z-index: 20; }

@media (max-width: 760px) {
  .topbar { display: flex; }
  .sidebar {
    position: fixed;
    inset-block: 0;
    inset-inline-start: 0;
    z-index: 30;
    transform: translateX(100%);
    transition: transform 0.2s;
    width: min(300px, 86vw);
  }
  [dir="rtl"] .sidebar { transform: translateX(100%); }
  .sidebar.open { transform: translateX(0) !important; }
  .conv-del { opacity: 1; }
  .empty { margin-top: 10vh !important; }
}
