:root {
  color-scheme: light;
  --canvas:#f7f6fb; --surface:#fff; --text:#221b35; --muted:#655d75; --line:#e4dfed;
  --side:#201833; --side-muted:#bfb3d5; --side-hover:#382c52;
  --accent:#6235ab; --accent-hover:#4d278f; --soft:#eee6ff; --warning:#764e0b;
  --radius:18px; font-family: system-ui, sans-serif;
}
:root[data-theme=dark] {
  color-scheme:dark; --canvas:#171322; --surface:#221b31; --text:#f4efff; --muted:#c0b3d3;
  --line:#3a304a; --side:#110e19; --side-hover:#302342; --accent:#bea1fb; --accent-hover:#d8c6ff;
  --soft:#37294f; --warning:#ffd793;
}
:root[data-size=large] { font-size: 112.5%; }
:root[data-size=small] { font-size: 93.75%; }
* { box-sizing:border-box; }
body { margin:0; color:var(--text); background:var(--canvas); }
button, input, select, textarea { font:inherit; }
button, select { cursor:pointer; }
button { min-height:2.6rem; padding:.55rem .85rem; border:1px solid var(--line); background:var(--surface); color:var(--text); border-radius:11px; }
button:hover { border-color:var(--accent); }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline:3px solid var(--accent); outline-offset:3px; }
button:disabled { opacity:.55; cursor:default; }
button.primary, a.primary { color:#fff; background:#6942b0; border-color:#6942b0; font-weight:650; }
a.primary { display:inline-block; padding:.7rem 1rem; border-radius:11px; text-decoration:none; }
button.primary:hover, a.primary:hover { background:#563197; }
a { color:var(--accent); }
input, textarea, select { background:var(--surface); color:var(--text); border:1px solid var(--line); border-radius:11px; padding:.65rem .75rem; min-width:0; max-width:100%; }
textarea { resize:vertical; }
label { display:grid; gap:.45rem; color:var(--muted); font-weight:600; }
h1,h2,h3,p { margin:0; }
h1 { font-size:clamp(1.7rem, 3.2vw, 2.45rem); letter-spacing:-.045em; }
h2 { font-size:1.2rem; letter-spacing:-.022em; }
p { line-height:1.55; }
small,.muted { color:var(--muted); }
[hidden] { display:none !important; }
.shell { min-height:100dvh; display:grid; grid-template-columns:16rem minmax(0,1fr); }
.shell.collapsed { grid-template-columns:minmax(0,1fr); }
.shell.collapsed .sidebar { display:none; }
.sidebar { position:sticky; top:0; align-self:start; height:100dvh; overflow:auto; padding:1.25rem 1rem; background:var(--side); color:white; display:flex; flex-direction:column; gap:1.8rem; }
.brand { display:flex; align-items:center; gap:.75rem; font-weight:750; letter-spacing:-.02em; }
.brand img { width:2.15rem; height:2.15rem; border-radius:10px; }
nav { display:grid; gap:.22rem; }
nav button { width:100%; text-align:left; color:var(--side-muted); background:transparent; border-color:transparent; display:flex; align-items:center; gap:.65rem; }
nav button:hover, nav button[aria-current=page] { background:var(--side-hover); border-color:transparent; color:white; }
nav span { width:1.2em; text-align:center; }
.sidebar .footer { margin-top:auto; color:var(--side-muted); font-size:.8rem; padding:.65rem; }
.workspace { min-width:0; }
.topbar { position:sticky; top:0; z-index:2; display:flex; align-items:center; justify-content:space-between; gap:.7rem; background:var(--surface); border-bottom:1px solid var(--line); min-height:4rem; padding:.55rem clamp(.8rem,3vw,2rem); }
.topbar .budget { color:var(--accent); background:var(--soft); border:0; font-weight:650; }
.content { max-width:76rem; margin-inline:auto; display:grid; gap:1.25rem; padding:clamp(1rem,3vw,2.4rem); }
.stack { display:grid; gap:1rem; align-content:start; }
.tight { display:grid; gap:.45rem; }
.row { display:flex; gap:.6rem; flex-wrap:wrap; align-items:center; }
.between { justify-content:space-between; }
.panel { background:var(--surface); border:1px solid var(--line); border-radius:var(--radius); padding:1.2rem; min-width:0; }
.hero { padding:clamp(1.4rem,4vw,3rem); color:#fff; border-radius:24px; background:
  radial-gradient(ellipse at 92% 10%,#8661cc 0%,transparent 53%),
  linear-gradient(125deg,#30204e,#4b327b 70%); display:grid; gap:.8rem; }
.hero p { color:#eee4ff; max-width:49ch; }
.hero button { width:max-content; color:#3e285c; font-weight:700; background:#f7eeff; border:0; margin-top:.4rem; }
.grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(min(100%,14rem),1fr)); gap:1rem; }
.metric { font-weight:730; font-size:1.55rem; letter-spacing:-.04em; }
.chat-layout { display:grid; grid-template-columns:minmax(13rem, 1fr) minmax(0,3fr); gap:1rem; }
.chat-list button { width:100%; text-align:left; overflow-wrap:anywhere; }
.chat-list button[aria-current=true] { border-color:var(--accent); background:var(--soft); }
.chat { display:flex; flex-direction:column; gap:1rem; min-height:56vh; }
.message-list { display:flex; flex-direction:column; gap:1rem; flex:1; max-height:56vh; overflow:auto; padding:.15rem; }
.message { background:var(--canvas); border:1px solid var(--line); padding:.85rem 1rem; border-radius:15px; max-width:100%; overflow-wrap:anywhere; white-space:pre-wrap; }
.message.user { background:var(--soft); align-self:end; max-width:90%; }
.message p + p { margin-top:.65rem; }
pre { white-space:pre; overflow:auto; border:1px solid var(--line); border-radius:9px; padding:.75rem; margin:.45rem 0; }
code { font-family:ui-monospace, monospace; }
.composer textarea { width:100%; min-height:5rem; }
.login { min-height:100dvh; display:grid; place-items:center; padding:1rem; }
.login .panel { width:min(30rem,100%); padding:clamp(1rem,5vw,2.1rem); }
.table { width:100%; border-collapse:collapse; }
.table th,.table td { border-bottom:1px solid var(--line); text-align:left; padding:.65rem .55rem; overflow-wrap:anywhere; }
.table-wrap { overflow:auto; }
.notice { color:var(--warning); }
#notification { position:fixed; z-index:3; left:50%; bottom:1rem; transform:translateX(-50%); width:max-content; max-width:90vw; background:var(--side); color:white; padding:.8rem 1rem; border-radius:12px; box-shadow:0 10px 24px #0004; }
@media (max-width:760px) {
  .shell { display:block; }
  .sidebar { position:fixed; z-index:4; inset:0 auto 0 0; width:min(17rem,84vw); box-shadow:0 0 0 100vmax #0007; height:100dvh; }
  .chat-layout { grid-template-columns:1fr; }
  .chat-list nav { max-height:9rem; overflow:auto; }
  .chat { min-height:52vh; }
  .message-list { max-height:50vh; }
  .topbar { position:sticky; }
}

.close-sidebar { display:none; }
.record-text { overflow-wrap:anywhere; white-space:pre-wrap; }
@media (max-width:760px) {
  .close-sidebar { display:inline-grid; place-items:center; background:var(--side-hover); color:white; border:0; }
}
