/* Tokens. The names --bg --fg --muted --surface --border --accent --accent-fg --danger --radius --font --mono are also
   handed to sandboxed extension frames (see frames.js), so keep them.
   Look: flat, hairline borders, 2px corners, one electric blue, lime for "alive", mono for metadata. */
@font-face { font-family: "Geist"; src: url("/fonts/Geist-Variable.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: "JetBrains Mono"; src: local("JetBrains Mono"), local("JetBrainsMono Nerd Font"), url("/fonts/JetBrainsMono-Variable.woff2") format("woff2"); font-weight: 100 800; font-display: swap; }

:root {
  --bg: #ffffff; --bg-sunk: #f8f9fa; --fg: #0b0d12; --fg-2: #3a3f49; --muted: #5a5f6b; --faint: #7a8190;
  --surface: #f8f9fa; --surface-2: #f1f3f5; --surface-3: #e9ebef; --border: #e9ebef; --border-strong: #d6d9e0;
  --accent: #165fcc; --accent-hover: #1c77ff; --accent-fg: #ffffff; --accent-soft: color-mix(in srgb, var(--accent) 9%, transparent);
  --live: #358f00; --live-soft: color-mix(in srgb, #58e600 18%, transparent);
  --danger: #cc3e3f; --ok: #358f00; --warn: #b26f00;
  --radius: 2px; --radius-lg: 4px;
  --font: "Geist", "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --sidebar-w: 256px;
  --shadow-sm: none;
  --shadow: 0 0 0 1px var(--border), 0 16px 40px -12px rgba(0, 6, 15, .18);
  --ring: 0 0 0 1px var(--accent);
  --scrim: rgba(0, 6, 15, .5);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a1018; --bg-sunk: #00060f; --fg: #ffffff; --fg-2: #b8babc; --muted: #8f9296; --faint: #666a6f;
    --surface: #141a22; --surface-2: #1f242c; --surface-3: #29303a; --border: #1f242c; --border-strong: #33383f;
    --accent: #1c77ff; --accent-hover: #4d94ff; --accent-fg: #ffffff;
    --live: #58e600; --live-soft: color-mix(in srgb, #58e600 14%, transparent);
    --danger: #ff5c5c; --ok: #73e926; --warn: #ffc53d;
    --shadow: 0 0 0 1px var(--border-strong), 0 20px 50px -12px rgba(0, 0, 0, .7);
    --scrim: rgba(0, 6, 15, .7);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0a1018; --bg-sunk: #00060f; --fg: #ffffff; --fg-2: #b8babc; --muted: #8f9296; --faint: #666a6f;
  --surface: #141a22; --surface-2: #1f242c; --surface-3: #29303a; --border: #1f242c; --border-strong: #33383f;
  --accent: #1c77ff; --accent-hover: #4d94ff; --accent-fg: #ffffff;
  --live: #58e600; --live-soft: color-mix(in srgb, #58e600 14%, transparent);
  --danger: #ff5c5c; --ok: #73e926; --warn: #ffc53d;
  --shadow: 0 0 0 1px var(--border-strong), 0 20px 50px -12px rgba(0, 0, 0, .7);
  --scrim: rgba(0, 6, 15, .7);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font: 14px/20px var(--font); font-feature-settings: "ss01", "cv11"; background: var(--bg); color: var(--fg); -webkit-text-size-adjust: 100%; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; overscroll-behavior: none; }
::selection { background: color-mix(in srgb, var(--accent) 35%, transparent); }
a { color: var(--accent-hover); text-decoration: none; } a:hover { text-decoration: underline; text-underline-offset: 3px; }
h1 { font-size: 1.75rem; margin: 0; letter-spacing: -.025em; font-weight: 600; } h2 { font-size: 1.05rem; margin: 0 0 .6rem; font-weight: 600; letter-spacing: -.015em; } h1, h2 { line-height: 1.2; }
code, pre { font-family: var(--mono); font-size: .88em; letter-spacing: 0; font-variant-ligatures: none; }
hr { border: 0; border-top: 1px solid var(--border); margin: 1rem 0; }
[hidden] { display: none !important; }
.muted { color: var(--muted); } .small { font-size: .86em; } .err, .form-error { color: var(--danger); } .form-error:empty { display: none; }
.grow { flex: 1; min-width: 0; } .ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .pad { padding: .5rem .75rem; } .end { justify-content: flex-end; text-align: right; }
.row { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; } .stack { display: flex; flex-direction: column; gap: .75rem; }
.icon { flex: none; }
* { scrollbar-width: thin; scrollbar-color: var(--surface-3) transparent; }

/* ---------- controls */
button, .button, select, input, textarea { font: inherit; letter-spacing: inherit; color: inherit; }
button, .button { display: inline-flex; align-items: center; justify-content: center; gap: .45rem; padding: 0 1rem; background: transparent; border: 1px solid var(--border-strong); border-radius: var(--radius); cursor: pointer; text-decoration: none !important; line-height: 20px; min-height: 36px; font-weight: 500; color: var(--fg-2); transition: background .1s, border-color .1s, color .1s; }
button:hover, .button:hover { background: var(--surface); color: var(--fg); border-color: var(--surface-3); }
button:focus-visible, .button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible, [role="button"]:focus-visible { outline: 2px solid var(--accent-hover); outline-offset: 2px; }
button:disabled { opacity: .45; cursor: default; }
button.primary, .button.primary { background: var(--accent); color: var(--accent-fg); border-color: transparent; }
button.primary:hover, .button.primary:hover { background: var(--accent-hover); color: var(--accent-fg); border-color: transparent; }
button.danger { color: var(--danger); }
button.danger:hover { background: color-mix(in srgb, var(--danger) 10%, transparent); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
button.primary.danger { background: var(--danger); color: #fff; } button.primary.danger:hover { background: color-mix(in srgb, var(--danger) 85%, #fff); }
button.small, .button.small { padding: 0 .65rem; min-height: 28px; font-size: .86em; }
button.wide, .button.wide { width: 100%; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; vertical-align: middle; padding: .35rem; min-height: 30px; min-width: 30px; background: transparent; border-color: transparent; color: var(--muted); }
.icon-btn:hover { color: var(--fg); background: var(--surface-2); border-color: transparent; }
input[type="text"], input[type="search"], input[type="password"], input[type="number"], input[type="time"], input[type="url"], input[type="email"], select, textarea { background: var(--bg-sunk); border: 1px solid var(--border); border-radius: var(--radius); padding: .45rem .7rem; min-height: 36px; max-width: 100%; transition: border-color .1s, box-shadow .1s; }
input:hover, select:hover, textarea:hover { border-color: var(--border-strong); }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: var(--ring); outline: none; }
input::placeholder, textarea::placeholder { color: var(--faint); }
textarea { width: 100%; resize: vertical; line-height: 1.5; }
input.narrow { width: 9rem; }
select { appearance: none; padding-right: 1.9rem; cursor: pointer; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238f9296' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7 10l5 5 5-5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right .5rem center; background-size: 14px; }
/* Custom dropdown (dropdown.js): the <select> stays hidden as the source of truth, .dd-btn stands in for it. */
select.dd-native { display: none !important; }
.dd-btn { justify-content: space-between; gap: .5rem; min-height: 36px; padding: 0 .55rem 0 .7rem; background: var(--bg-sunk); border: 1px solid var(--border); color: var(--fg); font-weight: 400; max-width: 100%; text-align: left; }
.dd-btn:hover { background: var(--bg-sunk); border-color: var(--border-strong); color: var(--fg); }
.dd-btn.on { border-color: var(--accent); box-shadow: var(--ring); }
.dd-btn > .icon { color: var(--faint); flex: none; transition: transform .1s; } .dd-btn.on > .icon { transform: rotate(180deg); }
.dd-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.dd-menu { position: fixed; z-index: 1100; background: var(--surface); border-radius: 6px; box-shadow: var(--shadow); padding: 4px; overflow-y: auto; max-width: min(420px, calc(100vw - 16px)); outline: none; }
.dd-item { display: flex; align-items: center; gap: 1rem; min-height: 30px; padding: 0 .55rem; border-radius: 4px; cursor: pointer; color: var(--fg-2); white-space: nowrap; }
.dd-item.sel { background: var(--surface-2); color: var(--fg); } .dd-item.cur { color: var(--fg); } .dd-item .icon { margin-left: auto; color: var(--accent-hover); }
.dd-item.off { opacity: .45; cursor: default; }
.ctx-menu { min-width: 190px; }
.ctx-menu .dd-item { gap: .6rem; }
.ctx-menu .dd-item .icon { margin-left: 0; color: var(--muted); flex: none; }
.ctx-menu .dd-item.sel .icon { color: var(--fg); }
.ctx-menu .dd-item kbd { margin-left: auto; font-family: var(--mono); font-size: .7rem; color: var(--faint); background: none; border: 0; padding: 0; }
.ctx-menu .dd-item.danger, .ctx-menu .dd-item.danger .icon { color: var(--danger); }
.ctx-menu .dd-item.danger.sel { background: color-mix(in srgb, var(--danger) 14%, transparent); }
.dd-sep { height: 1px; background: var(--border); margin: 4px 2px; }
.session-item.menu-on { background: var(--surface-2); color: var(--fg); }
.dd-text { overflow: hidden; text-overflow: ellipsis; }
.dd-group { font-family: var(--mono); font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); padding: .45rem .55rem .2rem; }
label { font-size: .86em; color: var(--muted); display: flex; flex-direction: column; gap: .35rem; font-weight: 500; } label.check { flex-direction: row; align-items: center; color: var(--fg); font-size: 1em; gap: .5rem; font-weight: 400; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); width: 15px; height: 15px; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius-lg); padding: .75rem 1rem; margin: 0; } legend { padding: 0 .35rem; color: var(--muted); font-family: var(--mono); font-size: .76em; text-transform: uppercase; letter-spacing: .06em; }
progress { appearance: none; width: 100%; height: 4px; border: 0; border-radius: 1px; background: var(--surface-2); overflow: hidden; }
progress::-webkit-progress-bar { background: var(--surface-2); } progress::-webkit-progress-value { background: var(--accent); } progress::-moz-progress-bar { background: var(--accent); }

/* ---------- shell */
.shell { display: flex; height: 100dvh; }
.sidebar { width: var(--sidebar-w); flex: none; display: flex; flex-direction: column; gap: .25rem; padding: .85rem .6rem .6rem; background: var(--bg-sunk); border-right: 1px solid var(--border); overflow: hidden; }
.brand { display: flex; align-items: center; gap: .55rem; padding: 0 .3rem .7rem .45rem; }
.brand img { border-radius: var(--radius); } .brand strong { font-size: 1rem; font-weight: 600; letter-spacing: -.02em; }
.new-btn, .new-btn.primary { width: 100%; justify-content: flex-start; padding-left: .7rem; background: var(--bg); color: var(--fg); border-color: var(--border-strong); }
.new-btn:hover, .new-btn.primary:hover { background: var(--surface); color: var(--fg); border-color: var(--surface-3); } .new-btn .icon { color: var(--accent-hover); }
.ws-select { width: 100%; background-color: transparent; border-color: transparent; color: var(--muted); font-size: .9em; padding-left: .55rem; margin: .2rem 0; }
.ws-select:hover { background-color: var(--surface); border-color: transparent; color: var(--fg); }
.nav-links { display: flex; flex-direction: column; gap: 1px; }
.nav-link { display: flex; align-items: center; gap: .6rem; padding: .4rem .55rem; border-radius: var(--radius); color: var(--muted); text-decoration: none !important; font-weight: 500; transition: background .1s, color .1s; }
.nav-link:hover { background: var(--surface); color: var(--fg); } .nav-link.active { background: var(--surface-2); color: var(--fg); }
.session-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 1px; margin: .6rem -.25rem 0; padding: 0 .25rem; min-height: 80px; }
.session-list::before { content: "Sessions"; font-family: var(--mono); font-size: .7rem; font-weight: 500; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); padding: .5rem .55rem .35rem; }
.session-list > .muted, .session-list > p { padding: .2rem .55rem; font-size: .9em; color: var(--faint); }
.session-item { display: flex; align-items: center; gap: .6rem; padding: .4rem .55rem; border-radius: var(--radius); color: var(--fg-2); text-decoration: none !important; transition: background .1s, color .1s; }
.session-item:hover { background: var(--surface); color: var(--fg); } .session-item.active { background: var(--surface-2); color: var(--fg); }
.side-foot { border-top: 1px solid var(--border); padding-top: .5rem; margin: 0 -.6rem; padding-inline: .6rem; display: flex; flex-direction: column; gap: 1px; }
.me { display: flex; align-items: center; gap: .6rem; padding: .4rem .55rem; border-radius: var(--radius); color: var(--fg-2); }
.avatar { width: 22px; height: 22px; border-radius: var(--radius); background: var(--live); color: #0a1f00; display: grid; place-items: center; font-weight: 600; font-family: var(--mono); font-size: .76em; flex: none; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--bg); }
.topbar { display: none; align-items: center; gap: .5rem; padding: .35rem .6rem; border-bottom: 1px solid var(--border); background: var(--bg); }
.outlet { flex: 1; min-height: 0; overflow: auto; display: flex; flex-direction: column; }
.scrim { display: none; }
.online { color: var(--warn); font-size: .85em; font-family: var(--mono); }
.needs-you { background: color-mix(in srgb, var(--warn) 14%, transparent); color: var(--warn); padding: .1rem .55rem; border-radius: var(--radius); font-size: .8em; font-weight: 500; }
.bell { position: relative; } .bell.has::after { content: attr(data-count); position: absolute; top: 0; right: 0; background: var(--accent); color: #fff; border-radius: var(--radius); font: 600 10px/16px var(--mono); min-width: 16px; height: 16px; display: grid; place-items: center; padding: 0 3px; }
.loading, .empty { padding: 3rem 1.5rem; text-align: center; color: var(--muted); margin: auto; }
.loading { font-family: var(--mono); font-size: .86em; }
.empty h2 { color: var(--fg); font-size: 1.2rem; }
.page .empty { border: 1px dashed var(--border-strong); border-radius: var(--radius-lg); margin: 1rem 0; padding: 2.5rem 1.5rem; }

.dot { width: 7px; height: 7px; border-radius: 1px; background: var(--surface-3); flex: none; display: inline-block; }
.dot.running, .dot.run, .dot.in_progress { background: var(--live); animation: pulse 1.2s infinite; } .dot.waiting { background: var(--warn); } .dot.failed, .dot.bad, .dot.error { background: var(--danger); } .dot.ok, .dot.idle.done { background: var(--ok); }
@keyframes pulse { 50% { opacity: .3; } }

/* ---------- pages */
.page { padding: 2.25rem clamp(1rem, 4vw, 3rem) 4rem; max-width: 1080px; width: 100%; margin: 0 auto; }
.page-head { display: flex; align-items: center; gap: .6rem; padding-bottom: 1.5rem; flex-wrap: wrap; }
.lede { margin-top: 0; color: var(--muted); }
.card { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1rem 1.15rem; }
.section { margin-bottom: 1.5rem; display: flex; flex-direction: column; gap: .7rem; } .section > * { margin-block: 0; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); padding: 1px 0 0 1px; }
.grid > .card { border-radius: 0; margin: -1px 0 0 -1px; }
.grid > .empty { grid-column: 1 / -1; }
.art-card { color: var(--fg); display: flex; flex-direction: column; gap: .4rem; text-decoration: none !important; transition: background .1s; } .art-card:hover { background: var(--surface); }
.type-tag { background: transparent; border: 1px solid var(--border-strong); border-radius: var(--radius); padding: 0 .4rem; font-family: var(--mono); font-size: .72em; font-weight: 500; color: var(--muted); white-space: nowrap; text-transform: lowercase; }
.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.list > li { padding: .5rem 0; border-bottom: 1px solid var(--border); } .list > li:last-child { border-bottom: 0; }
.link-row { cursor: pointer; color: var(--fg); text-decoration: none !important; padding: .55rem .6rem; border-radius: var(--radius); transition: background .1s; } .link-row:hover { background: var(--surface); }
.chips { display: flex; flex-wrap: wrap; gap: .35rem; }
.chip { display: inline-flex; align-items: center; gap: .3rem; padding: .05rem .5rem; border-radius: var(--radius); background: var(--surface-2); font-size: .84em; max-width: 100%; }
.chip.warn { background: color-mix(in srgb, var(--warn) 14%, transparent); color: var(--warn); } .chip.mention { color: var(--accent-hover); background: var(--accent-soft); font-family: var(--mono); font-size: .8em; } .chip.uploading { opacity: .6; } .chip .icon-btn { min-height: 20px; min-width: 20px; padding: 0; }
.chip-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 16ch; }
.chip-btn { padding: 0 .7rem; min-height: 28px; font-size: .85em; }
.badge { padding: 0 .4rem; border-radius: var(--radius); background: var(--surface-2); font-family: var(--mono); font-size: .72em; font-weight: 500; color: var(--muted); } .badge.running { color: var(--live); background: var(--live-soft); } .badge.error { color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, transparent); } .badge.pending-permissions { color: var(--warn); background: color-mix(in srgb, var(--warn) 14%, transparent); }
.tabs { display: flex; gap: 1.25rem; border-bottom: 1px solid var(--border); margin-bottom: 1.5rem; overflow-x: auto; scrollbar-width: none; } .tabs::-webkit-scrollbar { display: none; }
.tab { padding: .6rem 0; color: var(--muted); border-bottom: 1px solid transparent; margin-bottom: -1px; white-space: nowrap; text-decoration: none !important; font-weight: 500; } .tab:hover { color: var(--fg); } .tab.active { color: var(--fg); border-color: var(--fg); }
.field { display: grid; grid-template-columns: minmax(120px, 200px) minmax(0, 1fr); gap: .5rem 1rem; align-items: center; } .field > p { grid-column: 2; margin: 0; }
.field.row { display: flex; } .grow-label { flex: 1; color: var(--fg); font-size: 1em; font-weight: 400; }
@media (max-width: 640px) { .field { grid-template-columns: 1fr; } .field > p { grid-column: 1; } }
.switch { flex-direction: row; align-items: center; gap: .4rem; color: var(--fg); }
.table-wrap { overflow-x: auto; } table { border-collapse: collapse; width: 100%; } th, td { text-align: left; padding: .6rem .75rem; border-bottom: 1px solid var(--border); vertical-align: middle; } th { color: var(--faint); font-family: var(--mono); font-weight: 500; font-size: .72em; text-transform: uppercase; letter-spacing: .07em; }
tr.disabled { opacity: .5; }
.tool-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .25rem .75rem; margin-top: .5rem; }
.routine .prompt-preview { margin: .2rem 0 0; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.runs { display: flex; flex-wrap: wrap; gap: .25rem 1rem; font-family: var(--mono); font-size: .8em; } .run { display: inline-flex; align-items: center; gap: .35rem; color: var(--muted); }

/* ---------- home */
.home { display: flex; flex: 1; align-items: flex-start; justify-content: center; padding: clamp(2rem, 16vh, 8rem) 1.25rem 2rem; }
.home-inner { width: 100%; max-width: 720px; display: flex; flex-direction: column; gap: 1.25rem; }
.home-inner h1 { font-size: clamp(1.75rem, 4.2vw, 2.4rem); letter-spacing: -.03em; font-weight: 600; line-height: 1.15; text-wrap: balance; }
.home-inner h1 .sub { color: var(--faint); }
.home-inner > p.muted { margin: -.5rem 0 .5rem; font-family: var(--mono); font-size: .8em; color: var(--faint); }
.recent { margin-top: 1.25rem; } .recent h2 { color: var(--faint); font-family: var(--mono); font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; font-weight: 500; margin-bottom: .4rem; }
.recent .link-row .muted { font-family: var(--mono); font-size: .8em; color: var(--faint); }

/* ---------- composer */
.composer { position: relative; width: 100%; display: flex; flex-direction: column; gap: .4rem; }
.composer.drop .composer-box { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 6%, var(--bg-sunk)); }
.composer-box { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .25rem; background: var(--bg-sunk); border: 1px solid var(--border-strong); border-radius: var(--radius-lg); padding: .4rem; transition: border-color .1s, box-shadow .1s; }
.composer-box:hover { border-color: var(--surface-3); }
.composer-box:focus-within { border-color: var(--accent); box-shadow: var(--ring); }
.composer-input { border: 0 !important; box-shadow: none !important; background: transparent !important; padding: .5rem .45rem; min-height: 40px; max-height: 240px; resize: none; flex: 1 1 12rem; min-width: 0; outline: none; font-size: 15px; }
.composer-box > .icon-btn { min-height: 36px; min-width: 36px; }
.send-btn { width: 36px; height: 36px; padding: 0; flex: none; }
.model-select { border: 1px solid transparent; background-color: transparent; min-height: 36px; max-width: 14rem; padding-left: .55rem; font-family: var(--mono); font-size: .76em; color: var(--muted); cursor: pointer; text-overflow: ellipsis; }
.model-select:hover { background-color: var(--surface); border-color: var(--border); color: var(--fg); } .model-select:disabled { opacity: .5; cursor: default; }
.icon-btn.on { background: var(--surface-2); color: var(--fg); }
.attach-menu { position: absolute; bottom: calc(100% + 6px); left: 0; min-width: 236px; background: var(--surface); border-radius: 6px; box-shadow: var(--shadow); z-index: 30; padding: 4px; display: flex; flex-direction: column; }
.attach-menu.below { bottom: auto; top: calc(100% + 6px); }
.attach-menu:has(.attach-list) { width: min(300px, 100%); }
.attach-item { justify-content: flex-start; gap: .6rem; border: 0; min-height: 30px; padding: 0 .55rem; border-radius: 4px; text-align: left; color: var(--fg-2); font-weight: 400; width: 100%; white-space: nowrap; }
.attach-item > .icon:first-child { color: var(--muted); } .attach-item > .icon:last-child:not(:first-child) { color: var(--faint); }
.attach-item.sel, .attach-item:hover { background: var(--surface-2); color: var(--fg); border-color: transparent; } .attach-item.sel > .icon:first-child { color: var(--fg); }
.attach-item:focus-visible { outline: 0; }
kbd { font-family: var(--mono); font-size: .74em; color: var(--faint); margin-left: 1rem; }
.attach-label { font-size: .86em; font-weight: 500; color: var(--fg-2); }
.attach-head { display: flex; align-items: center; gap: .15rem; padding-right: .3rem; } .attach-head .icon-btn { min-height: 26px; min-width: 26px; padding: .2rem; }
.attach-search { margin: 2px 2px 4px; min-height: 30px; padding: .25rem .55rem; }
.attach-list { max-height: 240px; overflow-y: auto; display: flex; flex-direction: column; }
.attach-option { display: flex; align-items: center; gap: .75rem; min-height: 30px; padding: 0 .55rem; border-radius: 4px; cursor: pointer; color: var(--fg-2); }
.attach-option.sel { background: var(--surface-2); color: var(--fg); } .attach-option.on .icon { color: var(--live); }
.attach-meta { color: var(--faint); font-family: var(--mono); font-size: .74em; max-width: 45%; flex: none; }
.attach-empty { margin: 0; padding: .45rem .55rem; color: var(--faint); font-size: .88em; }
.chip.skill { color: var(--live); background: var(--live-soft); } .chip.chat { color: var(--fg-2); text-decoration: none !important; }
.composer-actions { display: flex; gap: .35rem; flex-wrap: wrap; } .composer-actions:empty { display: none; }
.mention-menu { position: absolute; bottom: calc(100% - 2.2rem); left: .5rem; right: .5rem; background: var(--bg); border-radius: var(--radius-lg); box-shadow: var(--shadow); z-index: 20; max-height: 240px; overflow: auto; padding: .25rem; }
.mention-item { display: flex; justify-content: space-between; gap: 1rem; padding: .4rem .6rem; cursor: pointer; border-radius: var(--radius); } .mention-item.sel, .mention-item:hover { background: var(--surface-2); }

/* ---------- session */
.session-view { display: flex; flex: 1; min-height: 0; }
.session-main { flex: 1; min-width: 0; display: flex; flex-direction: column; min-height: 0; }
.session-view .page-head { padding: .5rem .75rem .5rem 1rem; border-bottom: 1px solid var(--border); flex-wrap: nowrap; min-height: 52px; background: var(--bg); }
.session-title { background: none; border: 0; padding: .2rem .4rem; min-height: 30px; font-weight: 600; font-size: 1rem; letter-spacing: -.015em; color: var(--fg); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; justify-content: flex-start; text-align: left; }
.session-title:hover { background: var(--surface); border: 0; }
.status-pill { font-family: var(--mono); font-size: .72em; font-weight: 500; padding: 0 .45rem; line-height: 20px; border-radius: var(--radius); border: 1px solid var(--border-strong); color: var(--muted); white-space: nowrap; display: inline-flex; align-items: center; gap: .4rem; text-transform: lowercase; }
.status-pill::before { content: ""; width: 6px; height: 6px; border-radius: 1px; background: currentColor; }
.status-pill.running { color: var(--live); border-color: color-mix(in srgb, var(--live) 40%, transparent); background: var(--live-soft); } .status-pill.running::before { animation: pulse 1.2s infinite; }
.status-pill.waiting { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent); } .status-pill.failed { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.scroller { flex: 1; overflow-y: auto; padding: 2rem 1rem 1rem; overscroll-behavior: contain; }
.column { max-width: 760px; margin: 0 auto; }
.messages { display: flex; flex-direction: column; gap: 1.1rem; }
.msg.user { align-self: flex-end; max-width: 85%; display: flex; flex-direction: column; align-items: flex-end; }
.bubble { background: var(--surface); border: 1px solid var(--border); color: var(--fg); padding: .55rem .85rem; border-radius: var(--radius-lg); } .user-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble .chips { margin-top: .4rem; } .bubble .chip { background: var(--bg); }
.msg.assistant { overflow-wrap: anywhere; line-height: 1.65; font-size: 15px; color: var(--fg); }
.msg.thought { color: var(--muted); font-size: .9em; } .msg.thought summary { cursor: pointer; font-family: var(--mono); font-size: .88em; } .thought-body { white-space: pre-wrap; padding: .3rem 0 0 1rem; border-left: 1px solid var(--border-strong); margin-top: .35rem; }
.msg.tool { border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--bg); font-size: .88em; transition: border-color .1s; }
.msg.tool:hover { border-color: var(--border-strong); } .msg.tool[open] { background: var(--bg); border-color: var(--border-strong); }
.msg.tool summary { display: flex; align-items: center; gap: .55rem; padding: .45rem .75rem; cursor: pointer; list-style: none; color: var(--muted); } .msg.tool summary::-webkit-details-marker { display: none; }
.msg.tool summary > .icon:first-child { color: var(--faint); }
.tool-name { font-weight: 500; font-family: var(--mono); font-size: .92em; color: var(--fg); } .tool-brief { color: var(--faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; font-family: var(--mono); font-size: .9em; }
.tool-body { padding: .1rem .75rem .75rem; display: flex; flex-direction: column; gap: .6rem; border-top: 1px solid var(--border); padding-top: .65rem; } .label { font-family: var(--mono); font-size: .68rem; font-weight: 500; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); margin-bottom: .25rem; }
pre.code { margin: 0; padding: .75rem .9rem; background: var(--bg-sunk); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: auto; max-height: 340px; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.55; color: var(--fg-2); }
.msg.tool pre.code { background: var(--bg-sunk); }
.msg.approval { border: 1px solid color-mix(in srgb, var(--warn) 50%, transparent); background: color-mix(in srgb, var(--warn) 6%, var(--bg)); border-radius: var(--radius-lg); padding: .85rem 1rem; display: flex; flex-direction: column; gap: .65rem; }
.msg.approval.allow { border-color: var(--border); background: var(--bg); } .msg.approval.deny, .msg.approval.block { border-color: color-mix(in srgb, var(--danger) 40%, transparent); background: var(--bg); }
.approval-head { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; } .approval-head .icon { color: var(--warn); }
.msg.error { display: flex; gap: .5rem; align-items: flex-start; color: var(--danger); background: color-mix(in srgb, var(--danger) 7%, transparent); border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent); border-radius: var(--radius-lg); padding: .6rem .85rem; }
.msg.file { border: 1px solid var(--border); border-radius: var(--radius-lg); padding: .7rem .9rem; background: var(--bg); display: flex; flex-direction: column; gap: .5rem; } .file-info { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.inline-img { max-width: 100%; max-height: 420px; border-radius: var(--radius); display: block; background: var(--bg-sunk); }
.msg.artifact-card { border: 1px solid var(--border-strong); border-radius: var(--radius-lg); background: var(--bg); transition: border-color .1s, background .1s; } .msg.artifact-card:hover { border-color: var(--accent); background: var(--surface); }
.artifact-card-main { display: flex; align-items: center; gap: .85rem; padding: .75rem .9rem; cursor: pointer; }
.artifact-card-main strong { font-weight: 600; } .artifact-card-main .muted { font-family: var(--mono); font-size: .78em; color: var(--faint); margin-top: .1rem; }
.artifact-card-main > .icon:first-child { background: var(--accent); color: var(--accent-fg); width: 36px; height: 36px; padding: 8px; border-radius: var(--radius); }
.open-hint { display: flex; align-items: center; color: var(--muted); gap: .2rem; font-weight: 500; font-size: .92em; transition: color .1s; } .msg.artifact-card:hover .open-hint { color: var(--accent-hover); }
.working { max-width: 760px; margin: 0 auto; width: 100%; padding: 0 1rem .5rem; color: var(--muted); display: flex; align-items: center; gap: .6rem; font-family: var(--mono); font-size: .78em; }
.dots { display: inline-flex; gap: 3px; } .dots i { width: 5px; height: 5px; border-radius: 1px; background: var(--live); animation: bounce 1.2s infinite; } .dots i:nth-child(2) { animation-delay: .15s; } .dots i:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%, 60%, 100% { opacity: .3; transform: none; } 30% { opacity: 1; transform: translateY(-3px); } }
.composer-dock { padding: .4rem 1rem calc(1rem + env(safe-area-inset-bottom)); max-width: 792px; width: 100%; margin: 0 auto; }
.banner { padding: .5rem 1rem; font-size: .9em; border-bottom: 1px solid var(--border); } .banner.error { background: color-mix(in srgb, var(--danger) 10%, transparent); color: var(--danger); } .banner.warn { background: color-mix(in srgb, var(--warn) 11%, transparent); color: var(--warn); }
.side-pane { width: min(48%, 660px); flex: none; border-left: 1px solid var(--border); overflow-y: auto; background: var(--bg); }

/* ---------- markdown */
.md > :first-child { margin-top: 0; } .md > :last-child { margin-bottom: 0; }
.md p { margin: .65em 0; } .md h1, .md h2, .md h3, .md h4 { margin: 1.3em 0 .45em; line-height: 1.25; letter-spacing: -.02em; font-weight: 600; } .md h1 { font-size: 1.45rem; } .md h2 { font-size: 1.2rem; } .md h3 { font-size: 1.05rem; }
.md strong { font-weight: 600; color: var(--fg); }
.md ul, .md ol { padding-left: 1.3em; margin: .55em 0; } .md li { margin: .25em 0; } .md li::marker { color: var(--faint); } .md ol > li::marker { font-family: var(--mono); font-size: .88em; } .md li > .md { display: inline; }
.md blockquote { margin: .8em 0; padding: .1em 1em; border-left: 2px solid var(--accent); color: var(--fg-2); }
.md code { background: var(--surface-2); padding: .1em .35em; border-radius: var(--radius); font-size: .84em; } .md pre.code code { background: none; padding: 0; font-size: 1em; }
.md pre.code { margin: .8em 0; font-size: .82em; }
.md table { margin: .8em 0; font-size: .92em; } .md th, .md td { border: 1px solid var(--border); } .md th { text-transform: none; letter-spacing: 0; font-family: var(--font); font-size: .92em; font-weight: 600; background: var(--surface); color: var(--fg); } .md hr { margin: 1.4em 0; }
.md a { color: var(--accent-hover); text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; text-decoration-color: color-mix(in srgb, var(--accent-hover) 40%, transparent); } .md a:hover { text-decoration-color: var(--accent-hover); }

/* ---------- artifacts, frames */
.artifact-view { display: flex; flex-direction: column; min-height: 0; } .artifact-head { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; padding: .6rem .5rem; border-bottom: 1px solid var(--border); }
.artifact-title { display: flex; align-items: center; gap: .5rem; flex: 1; min-width: 0; flex-wrap: wrap; } .artifact-title strong { font-weight: 600; letter-spacing: -.015em; } .artifact-title .muted { font-family: var(--mono); font-size: .76em; color: var(--faint); } .artifact-tools { display: flex; align-items: center; gap: .15rem; flex-wrap: wrap; }
.artifact-view.compact .artifact-head { padding: .55rem .75rem; min-height: 52px; position: sticky; top: 0; background: var(--bg); z-index: 2; }
.export-select { min-height: 30px; padding-top: .15rem; padding-bottom: .15rem; font-size: .86em; }
.ext-frame { width: 100%; border: 0; display: block; background: transparent; color-scheme: normal; } .ext-frame.fill { height: 70vh; }
.frame-status { padding: .75rem; font-family: var(--mono); font-size: .8em; color: var(--faint); } .frame-error { margin: .75rem; padding: .7rem .9rem; border: 1px solid color-mix(in srgb, var(--danger) 45%, transparent); border-radius: var(--radius-lg); color: var(--danger); } .frame-error pre { white-space: pre-wrap; margin: .3rem 0 0; font-size: .82em; }
.renderer { margin-top: .25rem; }

/* ---------- auth */
.auth-screen { min-height: 100dvh; display: grid; place-items: center; padding: 1rem; background: var(--bg-sunk); }
.auth-card { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: .75rem; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1.75rem; }
.auth-card h1 { font-size: 1.4rem; letter-spacing: -.02em; }
.auth-card input { width: 100%; } .auth-card button { min-height: 38px; }
.pw-details { border-top: 1px solid var(--border); padding-top: .75rem; display: flex; flex-direction: column; gap: .5rem; } .pw-details summary { cursor: pointer; color: var(--muted); margin-bottom: .5rem; font-size: .9em; } .pw-details summary:hover { color: var(--fg); } .switch { text-align: center; }

/* ---------- overlays */
.modal { border: 0; border-radius: var(--radius-lg); background: var(--bg); color: var(--fg); padding: 0; width: min(480px, calc(100vw - 2rem)); max-height: calc(100dvh - 2rem); box-shadow: var(--shadow); overflow: auto; }
.modal.wide { width: min(720px, calc(100vw - 2rem)); } .modal::backdrop { background: var(--scrim); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: .6rem .6rem .6rem 1.25rem; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--bg); z-index: 1; } .modal-head h2 { margin: 0; font-size: 1rem; }
.modal-body { padding: 1.15rem 1.25rem 1.25rem; display: flex; flex-direction: column; gap: .85rem; }
.toasts { position: fixed; bottom: calc(1rem + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: .4rem; z-index: 1000; width: min(92vw, 420px); pointer-events: none; }
.toast { background: var(--fg); color: var(--bg); padding: .6rem .9rem; border-radius: var(--radius-lg); box-shadow: var(--shadow); font-size: .9em; font-weight: 500; } .toast.error { background: var(--danger); color: #fff; }
.popover { position: fixed; top: 52px; right: 12px; width: min(380px, calc(100vw - 24px)); max-height: 70dvh; overflow: auto; background: var(--bg); border-radius: var(--radius-lg); box-shadow: var(--shadow); z-index: 900; }
.pop-head { padding: .6rem 1rem; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--bg); font-weight: 600; }
.notif { display: flex; flex-direction: column; gap: .1rem; padding: .65rem 1rem; border-bottom: 1px solid var(--border); color: var(--fg); text-decoration: none !important; } .notif:hover { background: var(--surface); } .notif.unread { box-shadow: inset 2px 0 0 var(--accent); }
.palette-list { display: flex; flex-direction: column; gap: 1px; } .palette-item { display: flex; justify-content: space-between; gap: 1rem; padding: .5rem .7rem; border-radius: var(--radius); cursor: pointer; } .palette-item.sel, .palette-item:hover { background: var(--surface-2); }
.md-box { max-height: 60dvh; overflow: auto; }

/* ---------- small screens */
@media (max-width: 900px) {
  .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 800; transform: translateX(-100%); transition: transform .18s ease; width: min(86vw, 320px); box-shadow: var(--shadow); padding-top: calc(.85rem + env(safe-area-inset-top)); }
  .scrim { position: fixed; inset: 0; background: var(--scrim); z-index: 700; display: none; }
  body.nav-open .sidebar { transform: none; } body.nav-open .scrim { display: block; }
  .topbar { display: flex; padding-top: calc(.35rem + env(safe-area-inset-top)); }
  .side-pane { display: none; }
  .msg.user { max-width: 94%; }
  .home { padding-top: 2.5rem; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* connectors */
.section h3 { margin: .6rem 0 0; font-size: .95em; font-weight: 600; }
.connector { gap: .4rem; } .connector > p { margin: 0; }
.connector .fp { color: var(--muted); overflow-wrap: anywhere; }
.pair-box { padding: .6rem .75rem; border: 1px dashed var(--border); border-radius: var(--radius); } .pair-box p { margin: 0; }
.pair-code { font-size: 1.15em; letter-spacing: .12em; padding: .05rem .35rem; background: var(--surface-2); border-radius: var(--radius); user-select: all; }
textarea.mono { font-family: var(--mono); font-size: .82em; }
/* library (extensions & skills) */
.settings-body.drop { outline: 2px dashed var(--accent); outline-offset: 4px; border-radius: var(--radius); }
.skill-name { cursor: pointer; } .skill-name:hover { color: var(--accent-hover); }
.skill-detail { border-left: 2px solid var(--border); padding-left: .75rem; }
.skill-preview { min-height: 12rem; border: 1px solid var(--border); border-radius: var(--radius); padding: .5rem .75rem; }
/* tool calls: bounded bodies, live preview while arguments stream, collapsible approvals */
.msg.tool .tool-body pre.code, .msg.approval pre.code { max-height: 22rem; overflow: auto; }
.live-preview { border: 1px solid var(--border); border-radius: var(--radius); padding: .5rem .75rem; margin-bottom: .5rem; }
.live-preview .label { display: flex; align-items: center; gap: .4rem; }
.live-body { max-height: 20rem; overflow: auto; }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--live); animation: live-pulse 1.2s ease-in-out infinite; }
@keyframes live-pulse { 50% { opacity: .25; } }
@media (prefers-reduced-motion: reduce) { .live-dot { animation: none; } }
details.msg.approval > summary { list-style: none; cursor: pointer; }
details.msg.approval > summary::-webkit-details-marker { display: none; }
details.msg.approval:not([open]) { padding-top: .5rem; padding-bottom: .5rem; }
details.msg.approval > summary .tool-brief { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
details.msg.approval > summary.approval-head { flex-wrap: nowrap; }

/* artifacts used in a conversation, on the right */
.art-rail { width: 248px; flex: none; border-left: 1px solid var(--border); background: var(--bg); display: flex; flex-direction: column; min-height: 0; }
.rail-head { display: flex; align-items: center; gap: .4rem; padding: 0 .5rem 0 .9rem; min-height: 52px; border-bottom: 1px solid var(--border); font-weight: 600; }
.rail-head .muted { font-weight: 400; font-family: var(--mono); font-size: .8em; }
.rail-list { overflow-y: auto; padding: .4rem; display: flex; flex-direction: column; gap: 2px; }
.rail-item { display: flex; align-items: flex-start; justify-content: flex-start; min-height: 0; gap: .55rem; width: 100%; text-align: left; padding: .5rem .55rem; border: 0; border-radius: var(--radius); background: none; color: var(--fg); cursor: pointer; font: inherit; }
.rail-item:hover { background: var(--surface); }
.rail-item.sel { background: var(--surface-2); box-shadow: inset 2px 0 0 var(--accent); }
.rail-item .icon { flex: none; margin-top: .15rem; color: var(--muted); }
.rail-text { display: flex; flex-direction: column; min-width: 0; gap: .1rem; }
.rail-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail-toggle.on { color: var(--accent); }
.session-view.with-pane.with-rail .side-pane { width: min(42%, 600px); }
@media (max-width: 1100px) {
  .art-rail { position: fixed; inset: 0 0 0 auto; z-index: 750; width: min(86vw, 300px); box-shadow: var(--shadow); padding-top: env(safe-area-inset-top); }
  .session-view.with-pane .art-rail { display: none; }
}
