/* ══ Nexgen AI — light theme, single accent (user decision 2026-09-06) ══
   One brand colour (--accent). No dark mode anywhere; no theme toggle
   exists in the markup, so nothing can re-darken the app.            */
:root {
  --bg: #f6f6f4;
  --panel: #ffffff;
  --panel-2: #efefec;
  --line: #e2e2dc;
  --text: #20242a;
  --muted: #6b7280;
  --accent: #2f6fed;
  --accent-dim: #e3ecfc;
  --red: #c4453f;
  --green: #2f8a4c;
  --radius: 12px;
  --mono: ui-monospace, 'Cascadia Code', Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.6 system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}
.app { display: flex; height: 100%; }
.icon { width: 18px; height: 18px; display: inline-block; flex: none; }
.icon svg { width: 100%; height: 100%; display: block; }

/* ── sidebar ── */
.sidebar {
  width: 260px; flex: none; display: flex; flex-direction: column;
  background: var(--panel); border-right: 1px solid var(--line);
}
.side-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 14px 10px; }
.brand { font-weight: 700; letter-spacing: .3px; display: inline-flex; align-items: center; gap: 7px; }
.brand .icon { color: var(--accent); width: 15px; height: 15px; }
.brand em { color: var(--accent); font-style: normal; }
.convo-list { flex: 1; overflow-y: auto; padding: 4px 8px; }
.convo {
  display: flex; align-items: center; gap: 8px; width: 100%;
  background: none; border: 0; color: var(--muted); text-align: left;
  padding: 9px 10px; border-radius: 8px; cursor: pointer; font: inherit;
}
.convo:hover { background: var(--panel-2); color: var(--text); }
.convo.active { background: var(--accent-dim); color: var(--text); }
.convo .t { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.convo .del { visibility: hidden; color: var(--muted); background: none; border: 0; cursor: pointer; width: 16px; height: 16px; }
.convo:hover .del { visibility: visible; }
.side-foot { padding: 12px 14px; border-top: 1px solid var(--line); }
.side-foot label { font-size: 11px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); }
.side-foot input {
  width: 100%; margin-top: 6px; background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font: inherit;
}
.hint { color: var(--muted); font-size: 11.5px; margin: 6px 0 0; }

/* ── chat column ── */
.chat { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.chat-head {
  display: flex; gap: 8px; align-items: center; padding: 10px 14px;
  border-bottom: 1px solid var(--line); background: var(--panel);
}
.chat-head select {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 7px 8px; font: inherit; font-size: 13px; max-width: 46vw;
}
#menuBtn { display: none; }

.messages { flex: 1; overflow-y: auto; padding: 18px clamp(10px, 4vw, 40px); }
.msg { max-width: 820px; margin: 0 auto 18px; }
.msg .who { font-size: 11px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); margin-bottom: 6px; }
.msg.user .bubble {
  background: var(--accent-dim); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px 14px; white-space: pre-wrap;
}
.msg.assistant .bubble { padding: 2px 2px 0; }

/* markdown */
.md p { margin: 0 0 10px; }
.md h3, .md h4, .md h5 { margin: 14px 0 8px; line-height: 1.3; }
.md ul, .md ol { margin: 0 0 10px; padding-left: 22px; }
.md li { margin: 3px 0; }
.md code { background: var(--panel-2); border-radius: 5px; padding: 1px 5px; font-family: var(--mono); font-size: .9em; }
.md pre.code {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px; overflow-x: auto; margin: 0 0 12px;
}
.md pre.code code { background: none; padding: 0; font-size: 13px; line-height: 1.5; }
.md pre.code::before { content: attr(data-lang); display: block; color: var(--muted); font-size: 11px; margin-bottom: 6px; font-family: var(--mono); }
.md pre.code:not([data-lang])::before { content: none; }
.md blockquote { border-left: 3px solid var(--accent); margin: 0 0 10px; padding: 2px 12px; color: var(--muted); }
.md a { color: var(--accent); }
.md strong { color: #000; }

/* thinking — sits inline in the chat flow, no card, still clickable */
.think { margin-bottom: 8px; }
.think-head {
  display: inline-flex; align-items: center; gap: 7px; padding: 2px 0; cursor: pointer;
  color: var(--muted); font-size: 13px; user-select: none; background: none; border: 0;
}
.think-head:hover { color: var(--text); }
.think-head .icon { width: 12px; height: 12px; color: var(--accent); }
.think-body { display: none; margin: 4px 0 6px; padding-left: 19px; border-left: 2px solid var(--line); max-height: 320px; overflow-y: auto; }
.think.open .think-body { display: block; }
.think.live .think-body { display: block; }
.think-single {
  margin: 0; color: var(--muted); font-size: 12.5px;
  white-space: pre-wrap; font-family: inherit;
}
.think-step { margin-top: 4px; }
.think-step-head {
  padding: 3px 0; cursor: pointer; color: var(--muted); font-size: 12.5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.think-step-head:hover { color: var(--text); }
.think-step-body {
  display: none; margin: 0; padding: 0 0 8px; color: var(--muted); font-size: 12.5px;
  white-space: pre-wrap; font-family: inherit;
}
.think-step.open .think-step-body { display: block; }

/* tool rows */
.tools { margin-bottom: 10px; }
.tool-row {
  display: flex; align-items: center; gap: 8px; padding: 7px 12px; margin-bottom: 6px;
  background: var(--accent-dim); border: 1px solid var(--line); border-radius: 10px;
  color: var(--text); font-size: 13px;
}
.tool-row .icon { width: 14px; height: 14px; color: var(--accent); }
.tool-row .q { color: var(--muted); font-family: var(--mono); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* source chips */
.sources { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 4px 0 10px; }
.src-label { font-size: 11px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); margin-right: 2px; }
.src-chip {
  display: inline-flex; align-items: center; gap: 6px; text-decoration: none;
  background: var(--panel); border: 1px solid var(--line); border-radius: 999px;
  color: var(--muted); font-size: 12px; padding: 3px 10px 3px 4px; max-width: 220px;
}
.src-chip:hover { color: var(--text); border-color: var(--accent); }
.src-chip .txt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.src-chip .tile {
  width: 20px; height: 20px; border-radius: 50%; flex: none; overflow: hidden;
  background: var(--accent-dim); color: var(--accent); font-size: 11px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
}
.src-chip .tile img { width: 20px; height: 20px; border-radius: 50%; }

.err { border: 1px solid var(--red); color: #7a201c; background: #fbeeec; border-radius: 10px; padding: 10px 12px; font-size: 13.5px; white-space: pre-wrap; }
.note {
  border: 1px solid var(--line); background: var(--accent-dim); color: var(--text);
  border-radius: 10px; padding: 8px 12px; font-size: 13px; margin: 8px 0 10px;
}

/* composer */
.composer {
  display: flex; gap: 8px; align-items: flex-end; padding: 10px clamp(10px, 4vw, 40px);
  border-top: 1px solid var(--line); background: var(--panel);
}
.composer textarea {
  flex: 1; resize: none; background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
  font: inherit; max-height: 40vh;
}
.btn {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
  border-radius: 9px; padding: 9px 12px; cursor: pointer; font: inherit;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.ghost { background: none; }
.btn.small { padding: 6px 9px; font-size: 13px; }
.btn[disabled] { opacity: .45; cursor: default; }
.statusbar { padding: 4px 14px 8px; background: var(--panel); color: var(--muted); font-family: var(--mono); font-size: 12px; }
.statusbar.error { color: var(--red); }
.statusbar.done { color: var(--green); }

.empty { color: var(--muted); text-align: center; margin-top: 18vh; }
.empty .big { font-size: 22px; color: var(--text); margin-bottom: 6px; display: flex; align-items: center; justify-content: center; gap: 9px; }
.empty .big .icon { width: 18px; height: 18px; color: var(--accent); }

/* mobile */
@media (max-width: 760px) {
  .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 5; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; }
  #menuBtn { display: inline-flex; }
  .chat-head select:first-of-type { max-width: 52vw; }
}

/* ── accounts ── */
.auth-row { display: flex; gap: 8px; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.auth-row .hint { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-back { position: fixed; inset: 0; background: rgba(20, 24, 32, .35); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal-back[hidden] { display: none; }
.modal { background: var(--panel, #fff); border: 1px solid var(--line, #e3e6ec); border-radius: 12px; padding: 20px; width: min(92vw, 340px); display: flex; flex-direction: column; gap: 8px; }
.modal h2 { font-size: 16px; margin: 0 0 4px; }
.modal input { width: 100%; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 6px; }
.error-text { color: #b3261e; min-height: 1em; }
