:root {
  --bg: #faf9f7; --surface: #ffffff; --sidebar: #f2f1ed; --elev: #ffffff;
  --text: #1d1c1a; --text-2: #3d3c38; --muted: #75736d; --faint: #a19e96;
  --border: #e5e2db; --border-2: #d6d2c9; --hover: rgba(0,0,0,.045); --active: rgba(0,0,0,.075);
  --accent: #b5582f; --accent-2: #9a4824; --accent-soft: rgba(181,88,47,.10);
  --ok: #2f7d4f; --warn: #a86a0b; --err: #b3352b; --info: #2c5f9e;
  --ok-soft: rgba(47,125,79,.11); --warn-soft: rgba(168,106,11,.12); --err-soft: rgba(179,53,43,.10); --info-soft: rgba(44,95,158,.10);
  --code-bg: #f4f2ee; --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.06);
  --shadow-lg: 0 10px 40px rgba(0,0,0,.14);
  --radius: 10px; --radius-lg: 16px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Code", "SF Mono", Menlo, Consolas, monospace;
  --sidebar-w: 272px; --panel-w: 46vw;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1c1b19; --surface: #232220; --sidebar: #171614; --elev: #2a2927;
    --text: #ecebe6; --text-2: #d4d2cb; --muted: #9f9c94; --faint: #75726b;
    --border: #33312d; --border-2: #45423d; --hover: rgba(255,255,255,.05); --active: rgba(255,255,255,.09);
    --accent: #d9774c; --accent-2: #e48a62; --accent-soft: rgba(217,119,76,.14);
    --code-bg: #2a2926; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25); --shadow-lg: 0 12px 40px rgba(0,0,0,.5);
    --ok: #5cb27e; --warn: #d9a441; --err: #e26a5f; --info: #6f9fdb;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1c1b19; --surface: #232220; --sidebar: #171614; --elev: #2a2927;
  --text: #ecebe6; --text-2: #d4d2cb; --muted: #9f9c94; --faint: #75726b;
  --border: #33312d; --border-2: #45423d; --hover: rgba(255,255,255,.05); --active: rgba(255,255,255,.09);
  --accent: #d9774c; --accent-2: #e48a62; --accent-soft: rgba(217,119,76,.14);
  --code-bg: #2a2926; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25); --shadow-lg: 0 12px 40px rgba(0,0,0,.5);
  --ok: #5cb27e; --warn: #d9a441; --err: #e26a5f; --info: #6f9fdb;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); }
.grow { flex: 1; min-width: 0; }
.row { display: flex; align-items: center; gap: 8px; }
.col { display: flex; flex-direction: column; gap: 8px; }
.wrap { flex-wrap: wrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
svg.i.sm { width: 15px; height: 15px; }

/* ---------- buttons & inputs ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 34px; padding: 0 12px; border-radius: 9px; border: 1px solid var(--border-2); background: var(--surface); cursor: pointer; white-space: nowrap; transition: background .12s, border-color .12s; }
.btn:hover { background: var(--hover); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--text); color: var(--bg); border-color: var(--text); }
.btn.primary:hover { opacity: .88; }
.btn.accent { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.danger { color: var(--err); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--hover); }
.btn.sm { height: 28px; padding: 0 9px; font-size: 13px; border-radius: 7px; }
.icon-btn { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; border: 0; background: transparent; color: var(--muted); cursor: pointer; }
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn.active { background: var(--active); color: var(--text); }
.input, .select, textarea.input { width: 100%; height: 36px; padding: 0 11px; border-radius: 9px; border: 1px solid var(--border-2); background: var(--surface); outline: none; }
textarea.input { height: auto; padding: 9px 11px; resize: vertical; }
.input:focus, .select:focus, textarea.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.select { padding-right: 28px; appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 15px) 15px, calc(100% - 10px) 15px; background-size: 5px 5px; background-repeat: no-repeat; }
label.field { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--text-2); }
label.check { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.kbd { font: 11px var(--mono); padding: 1px 5px; border: 1px solid var(--border-2); border-bottom-width: 2px; border-radius: 5px; color: var(--muted); }
.badge { display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 7px; border-radius: 99px; font-size: 11.5px; font-weight: 550; background: var(--hover); color: var(--text-2); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.err { background: var(--err-soft); color: var(--err); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.accent { background: var(--accent-soft); color: var(--accent); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex: none; }
.dot.ok { background: var(--ok); } .dot.warn { background: var(--warn); } .dot.err { background: var(--err); }
.dot.run { background: var(--accent); animation: pulse 1.2s infinite ease-in-out; }
@keyframes pulse { 50% { opacity: .35; } }
.spinner { width: 14px; height: 14px; border: 2px solid var(--border-2); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- layout ---------- */
.scrim { display: none; }
#app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr) auto; height: 100vh; height: 100dvh; }
#app.sidebar-collapsed { grid-template-columns: 0 minmax(0, 1fr) auto; }
#app.sidebar-collapsed #sidebar { visibility: hidden; }

/* sidebar */
#sidebar { background: var(--sidebar); border-right: 1px solid var(--border); display: flex; flex-direction: column; min-width: 0; overflow: hidden; }
.sb-top { padding: 10px 10px 6px; display: flex; flex-direction: column; gap: 4px; }
.brand { display: flex; align-items: center; gap: 9px; padding: 4px 6px 8px; font-weight: 650; font-size: 15px; letter-spacing: -.01em; }
.brand-mark { width: 26px; height: 26px; border-radius: 8px; background: var(--accent); color: #fff; display: grid; place-items: center; }
.brand-mark svg { width: 16px; height: 16px; }
.sb-item { display: flex; align-items: center; gap: 9px; height: 34px; padding: 0 9px; border-radius: 8px; cursor: pointer; color: var(--text-2); border: 0; background: none; width: 100%; text-align: left; }
.sb-item:hover { background: var(--hover); }
.sb-item.active { background: var(--active); color: var(--text); }
.sb-search { position: relative; margin: 2px 0 4px; }
.sb-search input { height: 34px; padding-left: 32px; background: transparent; }
.sb-search svg { position: absolute; left: 10px; top: 9px; color: var(--muted); }
.sb-scroll { flex: 1; overflow-y: auto; padding: 0 10px 10px; scrollbar-width: thin; }
.sb-section { margin-top: 12px; }
.sb-head { display: flex; align-items: center; justify-content: space-between; padding: 4px 9px; font-size: 12px; font-weight: 600; color: var(--muted); }
.sb-head .icon-btn { width: 24px; height: 24px; }
.conv { position: relative; display: flex; align-items: center; gap: 8px; height: 34px; padding: 0 6px 0 9px; border-radius: 8px; cursor: pointer; color: var(--text-2); }
.conv:hover { background: var(--hover); }
.conv.active { background: var(--active); color: var(--text); }
.conv .title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv .more { opacity: 0; width: 26px; height: 26px; }
.conv:hover .more, .conv.active .more { opacity: 1; }
.conv .agent-tag { font-size: 10.5px; color: var(--faint); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.sb-group { padding: 10px 9px 4px; font-size: 11.5px; font-weight: 600; color: var(--faint); }
.sb-bottom { border-top: 1px solid var(--border); padding: 8px 10px; display: flex; align-items: center; gap: 6px; }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 650; font-size: 12.5px; flex: none; }

/* main */
#main { display: flex; flex-direction: column; min-width: 0; background: var(--bg); position: relative; }
.topbar { height: 52px; flex: none; display: flex; align-items: center; gap: 6px; padding: 0 10px; border-bottom: 1px solid transparent; }
.topbar.scrolled { border-bottom-color: var(--border); }
.topbar .title-btn { max-width: 42vw; display: flex; align-items: center; gap: 6px; padding: 6px 8px; border-radius: 8px; border: 0; background: none; cursor: pointer; font-weight: 550; }
.topbar .title-btn:hover { background: var(--hover); }
.topbar .crumb { color: var(--muted); font-weight: 450; }
.topbar .spacer { flex: 1; }
.usage-pill { display: flex; align-items: center; gap: 7px; height: 30px; padding: 0 10px; border-radius: 99px; border: 1px solid var(--border); background: var(--surface); font-size: 12.5px; color: var(--text-2); cursor: pointer; }
.usage-pill:hover { background: var(--hover); }
.meter { width: 46px; height: 5px; border-radius: 9px; background: var(--border); overflow: hidden; }
.meter > i { display: block; height: 100%; background: var(--ok); border-radius: 9px; }
.meter.warn > i { background: var(--warn); } .meter.err > i { background: var(--err); }

/* transcript */
#scroller { flex: 1; overflow-y: auto; scroll-behavior: auto; }
.transcript { max-width: 820px; margin: 0 auto; padding: 18px 24px 40px; display: flex; flex-direction: column; gap: 14px; }
.msg-user { align-self: flex-end; max-width: 85%; background: var(--sidebar); border: 1px solid var(--border); padding: 10px 14px; border-radius: 18px 18px 6px 18px; white-space: pre-wrap; word-wrap: break-word; }
.msg-user .src { font-size: 11.5px; color: var(--muted); margin-bottom: 3px; }
.msg-user .atts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.att { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 9px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); font-size: 12.5px; max-width: 240px; }
.att img { width: 20px; height: 20px; object-fit: cover; border-radius: 4px; }
.msg-assistant { line-height: 1.65; font-size: 15px; word-wrap: break-word; }
.msg-wrap { display: flex; flex-direction: column; gap: 2px; }
.msg-wrap.user { align-items: flex-end; }
.msg-wrap.user .msg-user { align-self: flex-end; }
.msg-actions { display: flex; gap: 0; opacity: 0; transition: opacity .12s; margin-left: -6px; }
.msg-wrap.user .msg-actions { margin: 0 -4px 0 0; }
.msg-actions .icon-btn { width: 28px; height: 28px; }
.msg-wrap:hover .msg-actions, .msg-actions:focus-within { opacity: 1; }
@media (hover: none) { .msg-actions { opacity: .75; } }
.msg-assistant.streaming::after { content: ""; display: inline-block; width: 8px; height: 15px; margin-left: 2px; background: var(--text); vertical-align: -2px; animation: pulse 1s infinite; border-radius: 1px; }
.md > :first-child { margin-top: 0; } .md > :last-child { margin-bottom: 0; }
.md p { margin: 0 0 12px; }
.md h1, .md h2, .md h3, .md h4 { line-height: 1.3; margin: 20px 0 8px; letter-spacing: -.01em; }
.md h1 { font-size: 1.45em; } .md h2 { font-size: 1.25em; } .md h3 { font-size: 1.08em; }
.md ul, .md ol { padding-left: 24px; margin: 0 0 12px; }
.md li { margin: 3px 0; }
.md blockquote { margin: 0 0 12px; padding: 2px 14px; border-left: 3px solid var(--border-2); color: var(--text-2); }
.md code { font-family: var(--mono); font-size: .88em; background: var(--code-bg); padding: 1.5px 5px; border-radius: 5px; }
.md pre { position: relative; margin: 0 0 14px; background: var(--code-bg); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.md pre .code-head { display: flex; align-items: center; justify-content: space-between; height: 32px; padding: 0 6px 0 12px; font: 12px var(--font); color: var(--muted); border-bottom: 1px solid var(--border); }
.md pre code { display: block; padding: 12px 14px; overflow-x: auto; background: none; font-size: 13px; line-height: 1.55; }
.md table { border-collapse: collapse; margin: 0 0 14px; display: block; overflow-x: auto; font-size: 14px; }
.md th, .md td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; }
.md th { background: var(--sidebar); font-weight: 600; }
.md hr { border: 0; border-top: 1px solid var(--border); margin: 18px 0; }
.md a { text-decoration: underline; text-underline-offset: 2px; }
.md img { max-width: 100%; border-radius: 8px; }

.block { border: 1px solid var(--border); border-radius: 12px; background: var(--surface); overflow: hidden; }
.block-head { display: flex; align-items: center; gap: 8px; min-height: 38px; padding: 6px 10px 6px 12px; cursor: pointer; user-select: none; font-size: 13.5px; }
.block-head:hover { background: var(--hover); }
.block-head .chev { transition: transform .15s; color: var(--muted); }
.block.open .block-head .chev { transform: rotate(90deg); }
.block-body { display: none; border-top: 1px solid var(--border); padding: 10px 12px; font-size: 13px; }
.block.open .block-body { display: block; }
.block-body pre { margin: 0; max-height: 360px; overflow: auto; font: 12.5px/1.5 var(--mono); white-space: pre-wrap; word-break: break-word; color: var(--text-2); }
.block-body .lbl { font-size: 11.5px; font-weight: 600; color: var(--muted); margin: 6px 0 4px; text-transform: uppercase; letter-spacing: .04em; }
.tool-name { font-weight: 600; }
.tool-sum { color: var(--muted); font-family: var(--mono); font-size: 12.5px; }
.thinking { color: var(--muted); }
.thinking .block-head { color: var(--muted); }
.thinking .block-body { white-space: pre-wrap; font-size: 13.5px; line-height: 1.6; }
.diff-line { display: block; font: 12.5px/1.45 var(--mono); white-space: pre-wrap; }
.diff-line.add { background: var(--ok-soft); color: var(--ok); } .diff-line.del { background: var(--err-soft); color: var(--err); }
.perm { border: 1px solid var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); border-radius: 12px; background: var(--surface); padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; }
.perm.resolved { border-color: var(--border); box-shadow: none; }
.perm pre { margin: 0; background: var(--code-bg); border-radius: 8px; padding: 8px 10px; font: 12.5px/1.5 var(--mono); white-space: pre-wrap; word-break: break-word; max-height: 240px; overflow: auto; }
.perm .q { font-weight: 600; }
.perm .opts { display: flex; flex-wrap: wrap; gap: 6px; }
.notice { display: flex; align-items: flex-start; gap: 8px; font-size: 13px; padding: 8px 12px; border-radius: 10px; background: var(--info-soft); color: var(--info); }
.notice.warn { background: var(--warn-soft); color: var(--warn); }
.notice.err { background: var(--err-soft); color: var(--err); }
.result-line { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; color: var(--faint); padding: 0 2px; }
.plan-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 4px; }
.plan-list li { display: flex; gap: 8px; align-items: flex-start; }
.session-line { font-size: 12px; color: var(--faint); display: flex; gap: 10px; flex-wrap: wrap; padding: 0 2px; cursor: pointer; }
.working { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 13.5px; padding: 2px; }

/* home / empty */
.home { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; gap: 22px; }
.home h1 { font-size: 30px; font-weight: 500; letter-spacing: -.02em; margin: 0; text-align: center; font-family: ui-serif, Georgia, "Times New Roman", serif; }
.home .composer-wrap { width: 100%; max-width: 760px; }
.suggestions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; max-width: 760px; }
.suggestion { display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 12px; border-radius: 99px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; color: var(--text-2); font-size: 13.5px; }
.suggestion:hover { background: var(--hover); }

/* getting-started checklist */
.setup-card { width: 100%; max-width: 760px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; }
.setup-items { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 10px; }
.setup-item { display: flex; align-items: center; gap: 8px; border: 0; background: none; text-align: left; padding: 6px 4px; border-radius: 8px; cursor: pointer; color: var(--text-2); font-size: 13px; }
.setup-item:hover { background: var(--hover); }
.setup-item.ok { cursor: default; color: var(--muted); }
.setup-item.ok:hover { background: none; }
.setup-dot { width: 18px; height: 18px; border-radius: 50%; border: 1.5px solid var(--border-2); display: grid; place-items: center; flex: none; }
.setup-item.ok .setup-dot { background: var(--ok); border-color: var(--ok); color: #fff; }
@media (max-width: 900px) { .setup-items { grid-template-columns: 1fr; } }

/* composer */
.composer-dock { padding: 0 24px 16px; }
.composer-wrap { max-width: 820px; margin: 0 auto; position: relative; }
.composer { border: 1px solid var(--border-2); border-radius: 22px; background: var(--surface); box-shadow: var(--shadow); padding: 10px 10px 8px 14px; display: flex; flex-direction: column; gap: 6px; transition: border-color .12s; }
.composer:focus-within { border-color: var(--faint); }
.composer.drag { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.composer textarea { border: 0; outline: none; resize: none; background: transparent; min-height: 26px; max-height: 40vh; padding: 4px 2px; font-size: 15px; line-height: 1.5; }
.composer .atts { display: flex; flex-wrap: wrap; gap: 6px; }
.composer .att .x { border: 0; background: none; cursor: pointer; color: var(--muted); padding: 0; display: grid; }
.composer-bar { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 5px; height: 30px; padding: 0 10px; border-radius: 99px; border: 1px solid transparent; background: transparent; color: var(--text-2); cursor: pointer; font-size: 13px; white-space: nowrap; max-width: 230px; }
.chip:hover { background: var(--hover); }
.chip.outlined { border-color: var(--border); }
.chip .v { overflow: hidden; text-overflow: ellipsis; }
.chip.warn { color: var(--warn); }
.send-btn { width: 34px; height: 34px; border-radius: 50%; border: 0; background: var(--text); color: var(--bg); display: grid; place-items: center; cursor: pointer; flex: none; }
.send-btn:disabled { opacity: .3; cursor: default; }
.send-btn.stop { background: var(--text); }
.composer-foot { text-align: center; font-size: 11.5px; color: var(--faint); margin-top: 7px; }

/* popovers / menus */
.pop { position: fixed; z-index: 60; min-width: 220px; max-width: 380px; max-height: 70vh; overflow-y: auto; background: var(--elev); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 5px; }
.pop .mi { display: flex; align-items: flex-start; gap: 9px; width: 100%; padding: 7px 9px; border-radius: 8px; border: 0; background: none; cursor: pointer; text-align: left; color: var(--text); }
.pop .mi:hover, .pop .mi.sel { background: var(--hover); }
.pop .mi .sub { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: 12px; color: var(--muted); margin-top: 1px; }
.pop .mi .check { margin-left: auto; color: var(--accent); }
.pop .mi.danger { color: var(--err); }
.pop .mi:disabled { opacity: .45; cursor: default; }
.pop .sep { height: 1px; background: var(--border); margin: 5px 2px; }
.pop .ph { padding: 6px 9px 3px; font-size: 11.5px; font-weight: 600; color: var(--faint); text-transform: uppercase; letter-spacing: .04em; }
.slash-pop { position: absolute; bottom: calc(100% + 8px); left: 0; right: 0; max-height: 320px; }

/* side panel */
#panel { width: var(--panel-w); min-width: 340px; max-width: 75vw; border-left: 1px solid var(--border); background: var(--surface); display: flex; flex-direction: column; position: relative; }
#panel.hidden { display: none; }
.resizer { position: absolute; left: -4px; top: 0; bottom: 0; width: 8px; cursor: col-resize; z-index: 5; }
.resizer:hover, .resizer.drag { background: linear-gradient(90deg, transparent 3px, var(--accent) 3px, var(--accent) 5px, transparent 5px); }
.panel-tabs { height: 48px; flex: none; display: flex; align-items: center; gap: 2px; padding: 0 6px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.ptab { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 10px; border-radius: 8px; border: 0; background: none; color: var(--muted); cursor: pointer; white-space: nowrap; font-size: 13px; }
.ptab:hover { background: var(--hover); color: var(--text); }
.ptab.active { background: var(--active); color: var(--text); }
.panel-body { flex: 1; min-height: 0; position: relative; }
.pview { position: absolute; inset: 0; display: flex; flex-direction: column; }
.ptool { display: flex; align-items: center; gap: 6px; padding: 8px 10px; border-bottom: 1px solid var(--border); flex-wrap: wrap; min-height: 48px; }
.pscroll { flex: 1; overflow: auto; min-height: 0; }
.empty { padding: 28px 20px; text-align: center; color: var(--muted); font-size: 13.5px; }

/* files */
.crumbs { display: flex; align-items: center; gap: 2px; font-size: 13px; overflow-x: auto; white-space: nowrap; scrollbar-width: none; }
.crumbs button { border: 0; background: none; padding: 3px 5px; border-radius: 6px; cursor: pointer; color: var(--text-2); }
.crumbs button:hover { background: var(--hover); }
.flist { list-style: none; margin: 0; padding: 4px; }
.frow { display: flex; align-items: center; gap: 9px; height: 34px; padding: 0 8px; border-radius: 7px; cursor: pointer; font-size: 13.5px; }
.frow:hover { background: var(--hover); }
.frow.sel { background: var(--accent-soft); }
.frow .meta { margin-left: auto; color: var(--faint); font-size: 12px; white-space: nowrap; }
.frow .ic { color: var(--muted); }
.frow.dir .ic { color: var(--accent); }
.drop-hint { margin: 10px; border: 1.5px dashed var(--border-2); border-radius: 12px; padding: 14px; text-align: center; color: var(--muted); font-size: 13px; }
.drop-hint.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.preview-box { padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.preview-box video, .preview-box img, .preview-box audio { max-width: 100%; max-height: 60vh; border-radius: 10px; background: #000; }
.preview-box iframe { width: 100%; height: 70vh; border: 1px solid var(--border); border-radius: 8px; background: #fff; }

/* editor */
.editor-host { flex: 1; min-height: 0; }
.tabsbar { display: flex; overflow-x: auto; border-bottom: 1px solid var(--border); scrollbar-width: thin; flex: none; }
.etab { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 6px 0 12px; border-right: 1px solid var(--border); font-size: 12.5px; cursor: pointer; color: var(--muted); white-space: nowrap; }
.etab.active { color: var(--text); background: var(--bg); }
.etab .dirty { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }

/* terminal */
.term-host { flex: 1; min-height: 0; background: #151514; padding: 6px 0 0 8px; }
.term-host .xterm { height: 100%; }

/* preview */
.device-frame { flex: 1; min-height: 0; display: flex; justify-content: center; align-items: flex-start; background: var(--sidebar); overflow: auto; padding: 12px; }
.device-frame iframe { background: #fff; border: 1px solid var(--border); border-radius: 10px; height: 100%; width: 100%; }
.device-frame.mobile iframe { width: 390px; height: 844px; max-height: 100%; border-radius: 28px; border: 10px solid #222; }
.device-frame.tablet iframe { width: 820px; height: 1180px; max-height: 100%; border-radius: 18px; border: 10px solid #222; }

/* cards & lists */
.card { border: 1px solid var(--border); border-radius: 12px; background: var(--surface); padding: 12px 14px; }
.card + .card { margin-top: 10px; }
.card h4 { margin: 0 0 6px; font-size: 14px; }
.list { display: flex; flex-direction: column; gap: 8px; padding: 10px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; font-size: 13px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; word-break: break-all; }
.progress { height: 7px; border-radius: 9px; background: var(--border); overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--accent); transition: width .3s; }
.progress.ok > i { background: var(--ok); } .progress.warn > i { background: var(--warn); } .progress.err > i { background: var(--err); }
pre.log { margin: 0; padding: 10px 12px; font: 12px/1.5 var(--mono); white-space: pre-wrap; word-break: break-word; background: var(--code-bg); border-radius: 8px; max-height: 300px; overflow: auto; }
.seg { display: inline-flex; border: 1px solid var(--border-2); border-radius: 9px; overflow: hidden; }
.seg button { border: 0; background: none; padding: 0 10px; height: 30px; cursor: pointer; color: var(--muted); font-size: 13px; }
.seg button.on { background: var(--active); color: var(--text); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table th { color: var(--muted); font-weight: 600; font-size: 12px; }

/* modal */
.modal-back { position: fixed; inset: 0; background: rgba(10,10,8,.42); z-index: 50; display: grid; place-items: center; padding: 16px; animation: fade .12s; }
@keyframes fade { from { opacity: 0; } }
.modal { width: 100%; max-width: 560px; max-height: 88vh; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); }
.modal.wide { max-width: 980px; height: 86vh; }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px 10px; }
.modal-head h3 { margin: 0; font-size: 16px; flex: 1; }
.modal-body { padding: 4px 16px 16px; overflow: auto; display: flex; flex-direction: column; gap: 12px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border); }
.settings { display: grid; grid-template-columns: 210px 1fr; flex: 1; min-height: 0; border-top: 1px solid var(--border); }
.settings nav { border-right: 1px solid var(--border); padding: 8px; display: flex; flex-direction: column; gap: 2px; overflow: auto; }
.settings .content { padding: 16px 20px; overflow: auto; display: flex; flex-direction: column; gap: 14px; }
.settings h2 { margin: 0; font-size: 17px; }
.settings h3 { margin: 6px 0 0; font-size: 14px; }
.callout { border-radius: 10px; padding: 10px 12px; background: var(--sidebar); border: 1px solid var(--border); font-size: 13px; color: var(--text-2); }
.callout.warn { background: var(--warn-soft); border-color: transparent; color: var(--text); }
.code-inline { font-family: var(--mono); font-size: 12.5px; background: var(--code-bg); padding: 1px 5px; border-radius: 5px; word-break: break-all; }
.device-code { font: 600 26px/1 var(--mono); letter-spacing: .12em; padding: 14px; text-align: center; border: 1px dashed var(--border-2); border-radius: 12px; background: var(--sidebar); }

/* palette */
.palette { position: fixed; top: 12vh; left: 50%; transform: translateX(-50%); width: min(640px, calc(100vw - 24px)); z-index: 70; background: var(--elev); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg); overflow: hidden; display: flex; flex-direction: column; max-height: 70vh; }
.palette input { border: 0; outline: none; background: transparent; height: 52px; padding: 0 16px; font-size: 16px; border-bottom: 1px solid var(--border); }
.palette .res { overflow-y: auto; padding: 6px; }
.palette .mi { display: flex; gap: 10px; align-items: center; width: 100%; padding: 8px 10px; border-radius: 8px; border: 0; background: none; text-align: left; cursor: pointer; }
.palette .mi.sel { background: var(--hover); }
.palette .mi .sub { color: var(--muted); font-size: 12.5px; }

/* toast */
#toasts { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 90; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { pointer-events: auto; background: var(--text); color: var(--bg); padding: 9px 14px; border-radius: 10px; box-shadow: var(--shadow-lg); font-size: 13.5px; max-width: 90vw; animation: fade .15s; }
.toast.err { background: var(--err); color: #fff; }

/* login */
.auth-page { min-height: 100%; display: grid; place-items: center; padding: 20px; overflow: auto; }
.auth-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow); padding: 28px; display: flex; flex-direction: column; gap: 14px; }
.auth-card h1 { margin: 0; font-size: 22px; font-weight: 600; letter-spacing: -.01em; }
.err-text { color: var(--err); font-size: 13px; min-height: 18px; }

/* responsive */
.only-mobile { display: none !important; }
@media (max-width: 900px) {
  #app, #app.sidebar-collapsed { grid-template-columns: minmax(0, 1fr); }
  #sidebar { position: fixed; z-index: 40; inset: 0 auto 0 0; width: min(300px, 86vw); transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow-lg); visibility: visible !important; }
  #app.sidebar-open #sidebar { transform: none; }
  #app.sidebar-open .scrim { display: block; }
  .scrim { display: none; position: fixed; inset: 0; z-index: 39; background: rgba(0,0,0,.35); }
  #panel { position: fixed; inset: 0; z-index: 45; width: 100% !important; max-width: none; min-width: 0; border-left: 0; }
  .resizer { display: none; }
  .only-mobile { display: inline-grid !important; }
  .hide-mobile { display: none !important; }
  .transcript { padding: 12px 14px 28px; }
  .composer-dock { padding: 0 10px 10px; }
  .msg-user { max-width: 92%; }
  .settings { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .settings nav { flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--border); }
  .modal.wide { height: 92vh; }
  .grid2 { grid-template-columns: 1fr; }
  .topbar .title-btn { max-width: 52vw; }
}
