/* 2nd Brain app. Jonspire colours, light and dark. */
:root {
  --bg: #f5f8f4; --bg-2: #eaf1ea; --panel: #ffffff; --panel-2: #faf7f1; --ink: #1b2233; --ink-2: #3a4356; --muted: #6b7385;
  --line: #dfe5dc; --line-2: #c9d5c8; --navy: #0b3b2c; --accent: #10b981; --accent-ink: #052e22; --accent-soft: rgba(16, 185, 129, .13);
  --link: #1d4ed8; --ok: #1f7a4d; --err: #a8322d; --code-bg: #0c2219; --code-ink: #e6f4ec; --user-bg: #0b3b2c; --user-ink: #ecfccb;
  --shadow: 0 18px 50px -24px rgba(15, 31, 58, .35); --r: 14px;
  --serif: 'Cormorant Garamond', Georgia, serif; --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #07140f; --bg-2: #0a1c15; --panel: #0e231a; --panel-2: #112a20; --ink: #e6f4ec; --ink-2: #c3d9cc; --muted: #86a194;
    --line: #1b3a2d; --line-2: #24503d; --accent: #34d399; --accent-ink: #052e22; --accent-soft: rgba(52, 211, 153, .14);
    --link: #86efac; --code-bg: #04100b; --user-bg: #14533d; --user-ink: #ecfccb; --shadow: 0 18px 50px -24px rgba(0, 0, 0, .7);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #07140f; --bg-2: #0a1c15; --panel: #0e231a; --panel-2: #112a20; --ink: #e6f4ec; --ink-2: #c3d9cc; --muted: #86a194;
  --line: #1b3a2d; --line-2: #24503d; --accent: #34d399; --accent-ink: #052e22; --accent-soft: rgba(52, 211, 153, .14);
  --link: #86efac; --code-bg: #04100b; --user-bg: #14533d; --user-ink: #ecfccb; --shadow: 0 18px 50px -24px rgba(0, 0, 0, .7);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.6 var(--sans); -webkit-font-smoothing: antialiased; overflow: hidden; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--link); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- buttons & inputs ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 16px; border-radius: 10px; border: 1px solid transparent; font-weight: 600; font-size: .9rem; text-decoration: none; transition: background .15s, border-color .15s, transform .15s; white-space: nowrap; }
.btn:disabled { opacity: .55; cursor: progress; }
.btn-accent { background: var(--accent); color: var(--accent-ink); }
.btn-accent:hover { filter: brightness(1.06); }
.btn-line { border-color: var(--line-2); background: transparent; }
.btn-line:hover { border-color: var(--accent); }
.btn-quiet { background: transparent; color: var(--ink-2); }
.btn-quiet:hover { background: var(--accent-soft); }
.btn-danger { border-color: color-mix(in srgb, var(--err) 35%, transparent); color: var(--err); background: transparent; }
.btn-sm { padding: 6px 11px; font-size: .82rem; border-radius: 8px; }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; border: 0; background: transparent; color: var(--ink-2); }
.icon-btn:hover { background: var(--accent-soft); color: var(--ink); }
.icon-btn.on { background: var(--accent-soft); color: var(--accent); }
.field { display: grid; gap: 6px; margin-bottom: 12px; font-size: .85rem; color: var(--ink-2); }
.field input, .field textarea, .field select, .input { width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--panel); outline: none; }
.field input:focus, .field textarea:focus, .input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { resize: vertical; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.tiny { font-size: .76rem; }
.status { padding: 10px 12px; border-radius: 10px; font-size: .86rem; margin: 10px 0; }
.status.err { background: color-mix(in srgb, var(--err) 12%, transparent); color: var(--err); }
.status.ok { background: color-mix(in srgb, var(--ok) 12%, transparent); color: var(--ok); }
.status.busy { background: var(--accent-soft); color: var(--ink-2); }

/* ---------- gate (sign in / subscribe) ---------- */
.gate { position: fixed; inset: 0; overflow: auto; background: radial-gradient(1200px 600px at 80% -10%, rgba(52, 211, 153, .22), transparent 60%), linear-gradient(160deg, #0b3b2c, #04140e 70%); color: #e6f4ec; }
.gate-inner { width: min(1100px, 100% - 32px); margin: 0 auto; padding: 48px 0 64px; display: grid; grid-template-columns: 1.15fr .85fr; gap: 48px; align-items: start; }
.gate-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 36px; color: #ecfccb; text-decoration: none; font-weight: 600; letter-spacing: .04em; }
.gate-brand img { width: 52px; height: 52px; border-radius: 14px; box-shadow: 0 10px 30px -10px rgba(16, 185, 129, .6); }
.gate-brand small { display: block; font-weight: 400; font-size: .78rem; letter-spacing: .02em; color: #a7f3d0; }
.gate h1 { font: 600 clamp(2.6rem, 6vw, 4.2rem)/1.02 var(--serif); margin: 0 0 18px; color: #fff; }
.gate h1 em { color: #6ee7b7; font-style: italic; }
.gate .lead { font-size: 1.12rem; color: #c3d9cc; max-width: 34em; margin: 0 0 28px; }
.caps { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 0; padding: 0; list-style: none; }
.caps li { padding: 14px 16px; border-radius: 12px; background: rgba(255, 255, 255, .04); border: 1px solid rgba(110, 231, 183, .14); font-size: .9rem; color: #c3d9cc; }
.caps b { display: block; color: #ecfccb; font-weight: 600; margin-bottom: 2px; }
.gate-card { background: var(--panel); color: var(--ink); border-radius: 18px; padding: 26px; box-shadow: 0 30px 80px -30px rgba(0, 0, 0, .6); }
.gate-card h2 { font: 600 1.7rem/1.15 var(--serif); margin: 0 0 6px; color: var(--ink); }
.tabs { display: flex; gap: 4px; padding: 4px; border-radius: 12px; background: var(--bg-2); margin-bottom: 18px; }
.tabs button { flex: 1; border: 0; background: transparent; padding: 8px; border-radius: 9px; font-weight: 600; font-size: .86rem; color: var(--muted); }
.tabs button.on { background: var(--panel); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.price { display: flex; align-items: baseline; gap: 6px; margin: 4px 0 12px; }
.price b { font: 700 2rem var(--serif); color: var(--accent); }
.kv { display: grid; grid-template-columns: 120px 1fr auto; gap: 8px; align-items: center; padding: 8px 0; border-bottom: 1px dashed var(--line); font-size: .9rem; }
.kv span { color: var(--muted); }
.kv .num { font-family: var(--mono); letter-spacing: .04em; }
.kv .big { font-size: 1.15rem; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: .82rem; color: var(--ink-2); margin: 6px 0 14px; }
.check input { margin-top: 3px; }
.link-btn { border: 0; background: none; color: var(--link); padding: 0; font-size: .85rem; text-decoration: underline; }

/* ---------- app shell ---------- */
.app { display: grid; grid-template-columns: 272px minmax(0, 1fr) auto; height: 100dvh; }
.side { display: flex; flex-direction: column; min-height: 0; background: var(--bg-2); border-right: 1px solid var(--line); }
.side-top { display: flex; align-items: center; gap: 10px; padding: 14px 14px 8px; }
.logo { display: flex; align-items: center; gap: 10px; font: 600 1.35rem var(--serif); color: var(--ink); text-decoration: none; flex: 1; }
.logo img { width: 32px; height: 32px; border-radius: 9px; }
.credit { font-size: .7rem; color: var(--muted); padding: 6px 10px 0; }
.gate-credit { margin-top: 28px; font-size: .8rem; color: #86a194; }
.gate-credit a { color: #a7f3d0; }
.new-chat { margin: 6px 14px 10px; justify-content: flex-start; }
.search { margin: 0 14px 8px; position: relative; }
.search input { width: 100%; padding: 8px 10px 8px 32px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); font-size: .86rem; }
.search svg { position: absolute; left: 9px; top: 9px; width: 16px; height: 16px; color: var(--muted); }
.threads { flex: 1; overflow: auto; padding: 4px 8px 12px; }
.threads h3 { font: 600 .7rem var(--sans); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin: 14px 8px 6px; }
.thread { display: flex; align-items: center; gap: 6px; border-radius: 9px; padding: 0 4px 0 10px; color: var(--ink-2); }
.thread a { flex: 1; min-width: 0; padding: 8px 0; color: inherit; text-decoration: none; font-size: .88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread:hover { background: var(--accent-soft); }
.thread.on { background: var(--panel); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, .06); }
.thread .icon-btn { width: 28px; height: 28px; opacity: 0; }
.thread:hover .icon-btn, .thread.on .icon-btn, .thread .icon-btn[aria-expanded="true"] { opacity: 1; }
.side-foot { border-top: 1px solid var(--line); padding: 10px; display: grid; gap: 2px; }
.side-foot .btn { justify-content: flex-start; width: 100%; font-weight: 500; }
.who { display: flex; align-items: center; gap: 10px; padding: 8px 10px; font-size: .84rem; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-weight: 700; font-size: .85rem; flex: none; }
.meter { height: 6px; border-radius: 6px; background: var(--line); overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--accent); border-radius: 6px; }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); }
.top { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--line); min-height: 56px; }
.top .title { flex: 1; min-width: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menu-btn { display: none; }
.scroll { flex: 1; overflow: auto; scroll-behavior: smooth; }
.feed { width: min(820px, 100% - 32px); margin: 0 auto; padding: 24px 0 40px; }

/* ---------- empty state ---------- */
.hello { padding: 8vh 0 24px; text-align: center; }
.hello h1 { font: 600 clamp(2.2rem, 5vw, 3.2rem)/1.05 var(--serif); margin: 0 0 8px; }
.hello p { color: var(--muted); margin: 0 auto 28px; max-width: 36em; }
.starters { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; text-align: left; }
.starter { border: 1px solid var(--line); background: var(--panel); border-radius: 12px; padding: 14px; font-size: .88rem; color: var(--ink-2); transition: border-color .15s, transform .15s; text-align: left; }
.starter:hover { border-color: var(--accent); transform: translateY(-2px); }
.starter b { display: block; color: var(--ink); margin-bottom: 4px; font-size: .92rem; }

/* ---------- messages ---------- */
.turn { margin: 0 0 22px; animation: rise .25s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.turn.user { display: flex; flex-direction: column; align-items: flex-end; }
.bubble { background: var(--user-bg); color: var(--user-ink); padding: 11px 16px; border-radius: 18px 18px 4px 18px; max-width: 85%; white-space: pre-wrap; overflow-wrap: anywhere; }
.att-row { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; margin-bottom: 6px; }
.att { display: inline-flex; align-items: center; gap: 8px; max-width: 240px; padding: 6px 10px; border-radius: 10px; background: var(--panel); border: 1px solid var(--line); font-size: .8rem; color: var(--ink-2); text-decoration: none; }
.att img { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; }
.att span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.turn-actions { display: flex; gap: 2px; margin-top: 4px; opacity: 0; transition: opacity .15s; }
.turn:hover .turn-actions, .turn:focus-within .turn-actions { opacity: 1; }
.turn-actions .icon-btn { width: 30px; height: 30px; }
.ai { display: flex; gap: 14px; }
.ai .avatar { background: transparent; padding: 0; overflow: hidden; }
.ai .avatar img { width: 30px; height: 30px; border-radius: 9px; }
.ai-body { flex: 1; min-width: 0; }

.md { overflow-wrap: anywhere; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p, .md ul, .md ol, .md blockquote, .md table, .md pre { margin: 0 0 .85em; }
.md h1, .md h2, .md h3, .md h4 { font-family: var(--sans); font-weight: 700; line-height: 1.3; margin: 1.2em 0 .5em; }
.md h1 { font-size: 1.35rem; } .md h2 { font-size: 1.18rem; } .md h3 { font-size: 1.04rem; } .md h4 { font-size: .96rem; }
.md ul, .md ol { padding-left: 1.4em; }
.md li { margin: .2em 0; }
.md li > ul, .md li > ol { margin: .2em 0; }
.md blockquote { border-left: 3px solid var(--accent); padding: 2px 0 2px 14px; color: var(--ink-2); }
.md code { font-family: var(--mono); font-size: .86em; background: var(--accent-soft); padding: 1px 5px; border-radius: 5px; }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 1.4em 0; }
.md table { border-collapse: collapse; display: block; overflow-x: auto; max-width: 100%; font-size: .9rem; }
.md th, .md td { border: 1px solid var(--line); padding: 6px 10px; text-align: left; vertical-align: top; }
.md th { background: var(--panel-2); }
.md img { max-width: 100%; border-radius: 10px; }
.code { margin: 0 0 .9em; border-radius: 12px; overflow: hidden; background: var(--code-bg); border: 1px solid var(--line); }
.code-head { display: flex; align-items: center; gap: 6px; padding: 6px 8px 6px 14px; background: rgba(255, 255, 255, .05); color: #9fb0cf; font: 500 .75rem var(--mono); }
.code-head span { flex: 1; }
.code-head button { border: 0; background: transparent; color: #c9d4ea; padding: 4px 8px; border-radius: 6px; font: 600 .74rem var(--sans); display: inline-flex; gap: 5px; align-items: center; }
.code-head button:hover { background: rgba(255, 255, 255, .1); }
.code-head svg.i { width: 14px; height: 14px; }
.code pre { margin: 0; padding: 14px; overflow: auto; color: var(--code-ink); font: .84rem/1.55 var(--mono); max-height: 520px; }
.code pre code { background: none; padding: 0; font-size: inherit; }
.tok-k { color: #f5c97a; } .tok-s { color: #9fe0a8; } .tok-c { color: #7f8db0; font-style: italic; } .tok-n { color: #ffb3a1; }
.cursor::after { content: ''; display: inline-block; width: 8px; height: 1.05em; background: var(--accent); vertical-align: -2px; margin-left: 2px; animation: blink 1s steps(2) infinite; border-radius: 2px; }
@keyframes blink { 50% { opacity: 0; } }
.cites { display: flex; flex-wrap: wrap; gap: 6px; margin: 2px 0 12px; }
.cite { display: inline-flex; align-items: center; gap: 6px; max-width: 260px; padding: 3px 9px; border-radius: 99px; background: var(--panel); border: 1px solid var(--line); font-size: .75rem; color: var(--ink-2); text-decoration: none; }
.cite span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* thinking & activity */
.think, .act { margin: 0 0 10px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel-2); font-size: .86rem; }
.think > summary, .act > summary { list-style: none; display: flex; align-items: center; gap: 8px; padding: 8px 12px; cursor: pointer; color: var(--ink-2); user-select: none; }
.think > summary::-webkit-details-marker, .act > summary::-webkit-details-marker { display: none; }
.think > summary .chev, .act > summary .chev { margin-left: auto; transition: transform .2s; }
.think[open] > summary .chev, .act[open] > summary .chev { transform: rotate(90deg); }
.think .inner, .act .inner { padding: 0 14px 12px; color: var(--ink-2); }
.think .inner { white-space: pre-wrap; max-height: 360px; overflow: auto; font-size: .84rem; }
.act summary b { font-weight: 600; color: var(--ink); }
.act summary .what { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.act .inner pre { margin: 6px 0; padding: 10px; border-radius: 8px; background: var(--code-bg); color: var(--code-ink); font: .78rem/1.5 var(--mono); overflow: auto; max-height: 300px; white-space: pre-wrap; }
.act .inner pre.err { color: #ffb3a1; }
.act ol { margin: 4px 0; padding-left: 1.2em; }
.act ol a { text-decoration: none; }
.spin { width: 14px; height: 14px; border: 2px solid var(--line-2); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.dot-ok { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); flex: none; }
.dot-err { width: 8px; height: 8px; border-radius: 50%; background: var(--err); flex: none; }
.pulse { display: inline-flex; gap: 4px; padding: 10px 0; }
.pulse i { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); animation: pulse 1.2s infinite ease-in-out; }
.pulse i:nth-child(2) { animation-delay: .15s; } .pulse i:nth-child(3) { animation-delay: .3s; }
@keyframes pulse { 0%, 80%, 100% { opacity: .25; transform: scale(.8); } 40% { opacity: 1; transform: none; } }
.files { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 12px; }
.file-card { display: inline-flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 12px; border: 1px solid var(--line-2); background: var(--panel); text-decoration: none; color: var(--ink); font-size: .86rem; }
.file-card:hover { border-color: var(--accent); }
.notice { font-size: .82rem; color: var(--muted); font-style: italic; margin: 0 0 10px; }
.err-box { padding: 10px 14px; border-radius: 12px; background: color-mix(in srgb, var(--err) 10%, transparent); color: var(--err); font-size: .88rem; margin: 0 0 10px; display: flex; gap: 10px; align-items: center; }

/* ---------- composer ---------- */
.composer-wrap { padding: 0 16px 14px; }
.composer { width: min(820px, 100%); margin: 0 auto; background: var(--panel); border: 1px solid var(--line-2); border-radius: 18px; box-shadow: var(--shadow); padding: 8px; position: relative; transition: border-color .15s; }
.composer:focus-within { border-color: var(--accent); }
.composer.drag { border-color: var(--accent); border-style: dashed; background: var(--accent-soft); }
.composer textarea { width: 100%; border: 0; outline: none; background: transparent; resize: none; padding: 8px 10px; max-height: 40vh; min-height: 44px; line-height: 1.5; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 4px 6px 0; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 6px 4px 8px; border-radius: 9px; background: var(--bg-2); font-size: .78rem; max-width: 220px; }
.chip img { width: 26px; height: 26px; object-fit: cover; border-radius: 5px; }
.chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip button { border: 0; background: transparent; padding: 2px; border-radius: 5px; display: grid; }
.chip.busy { opacity: .7; }
.chip.bad { color: var(--err); }
.bar { display: flex; align-items: center; gap: 4px; }
.bar .grow { flex: 1; }
.depth { border: 1px solid var(--line); background: transparent; border-radius: 9px; padding: 5px 8px; font-size: .8rem; color: var(--ink-2); }
.send { width: 38px; height: 38px; border-radius: 11px; border: 0; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; }
.send:disabled { opacity: .4; cursor: default; }
.send.stop { background: var(--ink); color: var(--bg); }
.hint { text-align: center; font-size: .72rem; color: var(--muted); margin-top: 8px; }
.slash { position: absolute; left: 8px; right: 8px; bottom: calc(100% + 6px); background: var(--panel); border: 1px solid var(--line-2); border-radius: 12px; box-shadow: var(--shadow); max-height: 260px; overflow: auto; padding: 6px; z-index: 5; }
.slash button { display: block; width: 100%; text-align: left; border: 0; background: transparent; padding: 8px 10px; border-radius: 8px; font-size: .86rem; }
.slash button.on, .slash button:hover { background: var(--accent-soft); }
.slash small { display: block; color: var(--muted); }
.rec { color: var(--err) !important; animation: blink 1.2s steps(2) infinite; }

/* ---------- right panel ---------- */
.panel { width: 0; overflow: hidden; border-left: 1px solid var(--line); background: var(--panel); display: flex; flex-direction: column; min-height: 0; transition: width .25s ease; }
.panel.open { width: min(46vw, 760px); }
.panel.narrow.open { width: 420px; }
.panel-head { display: flex; align-items: center; gap: 6px; padding: 10px 12px; border-bottom: 1px solid var(--line); min-height: 56px; }
.panel-head h2 { flex: 1; margin: 0; font: 600 1.05rem var(--sans); }
.seg { display: inline-flex; padding: 3px; border-radius: 9px; background: var(--bg-2); }
.seg button { border: 0; background: transparent; padding: 4px 10px; border-radius: 7px; font-size: .8rem; font-weight: 600; color: var(--muted); }
.seg button.on { background: var(--panel); color: var(--ink); }
.panel-body { flex: 1; min-height: 0; overflow: auto; }
.preview-frame { width: 100%; height: 100%; border: 0; background: #fff; display: block; }
.preview-code { margin: 0; padding: 16px; font: .82rem/1.55 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; color: var(--code-ink); background: var(--code-bg); min-height: 100%; }
.pad { padding: 16px; }
.list { display: grid; gap: 8px; }
.item { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; background: var(--panel-2); }
.item h4 { margin: 0 0 4px; font-size: .95rem; }
.item p { margin: 0; font-size: .84rem; color: var(--ink-2); }
.item .row { display: flex; gap: 8px; align-items: center; }
.item .row > :first-child { flex: 1; min-width: 0; }
button.item { width: 100%; text-align: left; color: inherit; }
button.item:hover { border-color: var(--accent); }
.tag { display: inline-block; font-size: .7rem; padding: 1px 7px; border-radius: 99px; background: var(--accent-soft); color: var(--ink-2); margin: 4px 4px 0 0; }
.section-title { font: 600 .72rem var(--sans); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin: 22px 0 10px; display: flex; align-items: center; gap: 8px; }
.section-title:first-child { margin-top: 0; }
.section-title span { flex: 1; }
.mem { display: flex; gap: 8px; align-items: flex-start; padding: 8px 10px; border-radius: 10px; font-size: .86rem; }
.mem:hover { background: var(--panel-2); }
.mem p { flex: 1; margin: 0; }
.mem code { font-size: .72rem; color: var(--muted); }
.stat { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.stat div { border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.stat b { display: block; font-size: 1.3rem; }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; font-size: .9rem; }

/* toast */
.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); display: grid; gap: 8px; z-index: 60; pointer-events: none; }
.toast { background: var(--navy); color: #ecfccb; padding: 10px 16px; border-radius: 12px; font-size: .86rem; box-shadow: var(--shadow); animation: rise .2s ease-out; display: flex; gap: 8px; align-items: center; }

/* menus & dialogs */
.pop { position: fixed; z-index: 40; min-width: 180px; background: var(--panel); border: 1px solid var(--line-2); border-radius: 12px; box-shadow: var(--shadow); padding: 6px; }
.pop button { display: flex; width: 100%; gap: 10px; align-items: center; border: 0; background: transparent; padding: 8px 10px; border-radius: 8px; font-size: .86rem; text-align: left; }
.pop button:hover { background: var(--accent-soft); }
.pop button.danger { color: var(--err); }
dialog.modal { border: 0; border-radius: 16px; padding: 0; width: min(520px, 100% - 32px); background: var(--panel); color: var(--ink); box-shadow: var(--shadow); }
dialog.modal::backdrop { background: rgba(5, 10, 20, .55); backdrop-filter: blur(2px); }
.modal-body { padding: 22px; }
.modal-body h2 { margin: 0 0 12px; font: 600 1.3rem var(--sans); }
.row-end { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; }
.scrim { display: none; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .panel.open { position: fixed; inset: 0 0 0 auto; width: min(560px, 100vw); z-index: 30; box-shadow: var(--shadow); }
  .panel.narrow.open { width: min(420px, 100vw); }
}
@media (max-width: 820px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .side { position: fixed; inset: 0 auto 0 0; width: 290px; z-index: 35; transform: translateX(-100%); transition: transform .25s ease; box-shadow: var(--shadow); }
  .side.open { transform: none; }
  .scrim.on { display: block; position: fixed; inset: 0; background: rgba(5, 10, 20, .45); z-index: 25; }
  .menu-btn { display: inline-grid; }
  .panel.open, .panel.narrow.open { width: 100vw; }
  .starters { grid-template-columns: 1fr 1fr; }
  .gate-inner { grid-template-columns: 1fr; gap: 28px; padding-top: 28px; }
  .caps { grid-template-columns: 1fr; }
  .feed { width: calc(100% - 32px); }
  .ai { gap: 0; }
  .ai > .avatar { display: none; }
  .bubble { max-width: 92%; }
  .composer-wrap { padding: 0 10px 10px; }
  .hint { display: none; }
  .turn-actions { opacity: 1; }
}
@media (max-width: 420px) { .starters { grid-template-columns: 1fr; } .kv { grid-template-columns: 1fr auto; } .kv span { grid-column: 1 / -1; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
.md .al-center { text-align: center; } .md .al-right { text-align: right; }

/* Chat / Code workspaces */
.modes { flex: none; }
.modes button { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; }
.modes svg.i { width: 15px; height: 15px; }
.code-mode .feed { width: min(980px, 100% - 32px); }
.code-mode .composer { width: min(980px, 100%); }
.code-mode .code pre { max-height: 680px; }
@media (max-width: 820px) { .top .title { display: none; } }
