:root {
  --bg: #0e1014;
  --bg-elev: #15181e;
  --bg-elev2: #1b1f27;
  --side: #0a0c10;
  --border: #242934;
  --border-strong: #323846;
  --text: #e8eaef;
  --text-dim: #a2a8b6;
  --text-faint: #6c7383;
  --accent: #7c6cff;
  --accent2: #4f9bff;
  --accent-soft: rgba(124, 108, 255, .14);
  --good: #3ecf8e;
  --warn: #f5b84a;
  --bad: #ff6b6b;
  --user-bubble: #222734;
  --code-bg: #0a0c10;
  --radius: 14px;
  --shadow: 0 10px 40px rgba(0, 0, 0, .45);
  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Inter", sans-serif;
  --mono: "Cascadia Code", "JetBrains Mono", Consolas, ui-monospace, monospace;
  --topbar: 44px;
  --overlay-w: 0px;
}
body.light {
  --bg: #ffffff;
  --bg-elev: #f6f7f9;
  --bg-elev2: #eef0f4;
  --side: #f3f4f7;
  --border: #e3e6ec;
  --border-strong: #d2d6de;
  --text: #15171c;
  --text-dim: #4d5463;
  --text-faint: #8b92a1;
  --accent-soft: rgba(124, 108, 255, .10);
  --user-bubble: #eef0f5;
  --code-bg: #f6f8fa;
  --shadow: 0 10px 40px rgba(20, 24, 40, .15);
}
body.desktop { --overlay-w: 140px; }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 14.5px; -webkit-font-smoothing: antialiased; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.hidden { display: none !important; }
.muted { color: var(--text-dim); }
.faint { color: var(--text-faint); }
.small { font-size: 12.5px; }
.err { color: var(--bad); min-height: 1em; }
.drag { -webkit-app-region: drag; }
.no-drag, .drag button, .drag input, .drag select { -webkit-app-region: no-drag; }
body:not(.desktop) .desktop-only { display: none !important; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 10px; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }
kbd { font-family: var(--mono); font-size: 10.5px; padding: 1px 5px; border-radius: 5px; border: 1px solid var(--border-strong); color: var(--text-faint); }

#app { display: flex; height: 100vh; height: 100dvh; overflow: hidden; }

/* ---------- sidebar ---------- */
#sidebar { width: 272px; flex-shrink: 0; background: var(--side); border-right: 1px solid var(--border); display: flex; flex-direction: column; transition: margin-left .2s ease; z-index: 30; }
body.side-collapsed #sidebar { margin-left: -272px; }
.side-top { height: var(--topbar); display: flex; align-items: center; justify-content: space-between; padding: 0 10px 0 16px; }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 650; letter-spacing: .2px; font-size: 15px; }
.brand img { width: 24px; height: 24px; }
.icon-btn { width: 34px; height: 34px; display: inline-grid; place-items: center; border-radius: 9px; color: var(--text-dim); }
.icon-btn:hover { background: var(--bg-elev2); color: var(--text); }
.new-chat { margin: 6px 12px 8px; display: flex; align-items: center; gap: 9px; padding: 10px 12px; border-radius: 11px; border: 1px solid var(--border-strong); background: var(--bg-elev); font-weight: 550; }
.new-chat:hover { border-color: var(--accent); background: var(--accent-soft); }
.new-chat kbd { margin-left: auto; }
.search { margin: 0 12px 6px; display: flex; align-items: center; gap: 8px; padding: 0 10px; border-radius: 10px; background: var(--bg-elev); color: var(--text-faint); }
.search input { flex: 1; background: none; border: 0; outline: 0; padding: 8px 0; color: var(--text); }
.conv-list { flex: 1; overflow-y: auto; padding: 4px 8px 12px; }
.conv-group { font-size: 11.5px; font-weight: 600; color: var(--text-faint); text-transform: uppercase; letter-spacing: .6px; padding: 14px 10px 6px; }
.conv { position: relative; display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 9px; color: var(--text-dim); cursor: pointer; }
.conv:hover { background: var(--bg-elev); color: var(--text); }
.conv.active { background: var(--bg-elev2); color: var(--text); }
.conv .title { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv .pin { color: var(--accent); width: 14px; height: 14px; }
.conv .spin { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); animation: pulse 1s infinite; }
.conv .acts { display: none; gap: 2px; }
.conv:hover .acts { display: flex; }
.conv .acts button { width: 26px; height: 26px; display: grid; place-items: center; border-radius: 7px; color: var(--text-faint); }
.conv .acts button:hover { background: var(--bg-elev2); color: var(--text); }
.conv .acts svg { width: 15px; height: 15px; }
.conv input { flex: 1; background: var(--bg); border: 1px solid var(--accent); border-radius: 6px; padding: 2px 6px; outline: 0; }
.empty-list { color: var(--text-faint); padding: 16px 10px; font-size: 13px; }
#nav { padding: 8px; border-top: 1px solid var(--border); display: grid; gap: 2px; }
#nav button { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 9px; color: var(--text-dim); text-align: left; }
#nav button:hover { background: var(--bg-elev); color: var(--text); }
#nav button.active { background: var(--accent-soft); color: var(--text); }
#nav button.active svg { color: var(--accent); }
.status-bar { display: flex; align-items: center; gap: 8px; padding: 10px 18px 14px; font-size: 12px; color: var(--text-faint); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-faint); flex-shrink: 0; }
.dot.on { background: var(--good); box-shadow: 0 0 0 3px rgba(62, 207, 142, .18); }
.dot.warn { background: var(--warn); }
.dot.off { background: var(--bad); }
#sideScrim { display: none; }

/* ---------- main ---------- */
#main { flex: 1; min-width: 0; display: flex; flex-direction: column; position: relative; }
#topbar { height: var(--topbar); flex-shrink: 0; display: flex; align-items: center; gap: 8px; padding: 0 calc(var(--overlay-w) + 10px) 0 10px; border-bottom: 1px solid transparent; }
#openSide { display: none; }
body.side-collapsed #openSide { display: inline-grid; }
.view-title { font-size: 15px; font-weight: 600; margin: 0 0 0 6px; display: none; }
body:not(.view-chat) .view-title { display: block; }
body:not(.view-chat) #modelPicker, body:not(.view-chat) .top-actions { display: none; }
body:not(.view-chat) #topbar { border-bottom-color: var(--border); }
.top-actions { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 11px; border-radius: 999px; border: 1px solid var(--border-strong); color: var(--text-dim); font-size: 13px; }
.chip:hover { color: var(--text); border-color: var(--text-faint); }
.chip.on { color: var(--text); background: var(--accent-soft); border-color: var(--accent); }
.chip.on svg { color: var(--accent); }
.chip svg { width: 15px; height: 15px; }
.chip:disabled { opacity: .4; cursor: not-allowed; }

.model-picker { position: relative; }
#modelBtn { display: flex; align-items: center; gap: 8px; padding: 7px 12px; border-radius: 10px; font-weight: 600; font-size: 15px; max-width: 46vw; }
#modelBtn:hover { background: var(--bg-elev); }
#modelBtn #modelName { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#modelBtn svg { width: 16px; height: 16px; color: var(--text-faint); }
.mp-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-faint); }
.mp-dot.on { background: var(--good); }
.menu { position: absolute; top: calc(100% + 6px); left: 0; min-width: 380px; max-width: 92vw; max-height: 70vh; overflow-y: auto; background: var(--bg-elev); border: 1px solid var(--border-strong); border-radius: 14px; box-shadow: var(--shadow); padding: 6px; z-index: 50; }
.menu-item { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 10px; cursor: pointer; }
.menu-item:hover { background: var(--bg-elev2); }
.menu-item.sel { background: var(--accent-soft); }
.menu-item .mi-main { flex: 1; min-width: 0; }
.menu-item .mi-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-item .mi-meta { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 5px; }
.menu-item .check { color: var(--accent); }
.menu-sep { font-size: 11px; color: var(--text-faint); text-transform: uppercase; letter-spacing: .6px; padding: 8px 12px 4px; }
.tag { font-size: 11px; padding: 2px 7px; border-radius: 6px; background: var(--bg-elev2); color: var(--text-dim); border: 1px solid var(--border); white-space: nowrap; }
.tag.acc { color: var(--accent); border-color: rgba(124, 108, 255, .35); background: var(--accent-soft); }
.tag.good { color: var(--good); border-color: rgba(62, 207, 142, .35); background: rgba(62, 207, 142, .08); }
.tag.warn { color: var(--warn); border-color: rgba(245, 184, 74, .35); background: rgba(245, 184, 74, .08); }

.view { display: none; flex: 1; min-height: 0; }
.view.active { display: flex; }

/* ---------- chat ---------- */
#view-chat { flex-direction: column; position: relative; }
#scroller { flex: 1; overflow-y: auto; scroll-behavior: auto; }
#messages { max-width: 820px; margin: 0 auto; padding: 18px 24px 30px; }
.msg { margin: 22px 0; display: flex; flex-direction: column; animation: fadeIn .18s ease; }
.msg.user { align-items: flex-end; }
.msg.user .bubble { background: var(--user-bubble); padding: 10px 16px; border-radius: 20px; max-width: 78%; white-space: pre-wrap; word-wrap: break-word; line-height: 1.55; }
.msg.user .imgs { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; margin-bottom: 8px; }
.msg.user .imgs img { max-width: 220px; max-height: 220px; border-radius: 14px; border: 1px solid var(--border); cursor: zoom-in; object-fit: cover; }
.msg .edit-box { width: min(78%, 640px); background: var(--user-bubble); border-radius: 18px; padding: 10px; }
.msg .edit-box textarea { width: 100%; background: none; border: 0; outline: 0; resize: none; line-height: 1.55; min-height: 60px; }
.msg .edit-box .row { display: flex; justify-content: flex-end; gap: 8px; }
.assistant-head { display: flex; align-items: center; gap: 9px; margin-bottom: 6px; color: var(--text-dim); font-size: 13px; }
.avatar { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: linear-gradient(135deg, var(--accent), var(--accent2)); flex-shrink: 0; }
.avatar img { width: 16px; height: 16px; filter: brightness(10); }
.msg-actions { display: flex; gap: 2px; margin-top: 6px; opacity: 0; transition: opacity .15s; align-items: center; }
.msg:hover .msg-actions, .msg.last .msg-actions { opacity: 1; }
.msg-actions button { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 8px; color: var(--text-faint); }
.msg-actions button:hover { background: var(--bg-elev); color: var(--text); }
.msg-actions svg { width: 16px; height: 16px; }
.msg-actions .stats { font-size: 12px; color: var(--text-faint); margin-left: 8px; }

.think { margin: 2px 0 10px; border-left: 2px solid var(--border-strong); padding-left: 14px; }
.think summary { cursor: pointer; color: var(--text-dim); font-size: 13.5px; list-style: none; display: inline-flex; align-items: center; gap: 6px; user-select: none; }
.think summary::-webkit-details-marker { display: none; }
.think summary svg { width: 14px; height: 14px; transition: transform .15s; }
.think[open] summary svg { transform: rotate(90deg); }
.think summary.live { background: linear-gradient(90deg, var(--text-faint), var(--text), var(--text-faint)); background-size: 200% 100%; -webkit-background-clip: text; background-clip: text; color: transparent; animation: shimmer 1.6s linear infinite; }
.think-body { color: var(--text-faint); font-size: 13.5px; line-height: 1.55; white-space: pre-wrap; margin-top: 8px; max-height: 360px; overflow-y: auto; }

.md { line-height: 1.68; word-wrap: break-word; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p { margin: 0 0 .85em; }
.md h1, .md h2, .md h3, .md h4 { margin: 1.2em 0 .5em; line-height: 1.3; }
.md h1 { font-size: 1.45em; } .md h2 { font-size: 1.25em; } .md h3 { font-size: 1.1em; }
.md ul, .md ol { padding-left: 1.5em; margin: .3em 0 .9em; }
.md li { margin: .25em 0; }
.md a { color: var(--accent2); }
.md blockquote { margin: .8em 0; padding: .2em 1em; border-left: 3px solid var(--border-strong); color: var(--text-dim); }
.md table { border-collapse: collapse; margin: .8em 0; display: block; overflow-x: auto; }
.md th, .md td { border: 1px solid var(--border-strong); padding: 6px 12px; text-align: left; }
.md th { background: var(--bg-elev); }
.md hr { border: 0; border-top: 1px solid var(--border); margin: 1.4em 0; }
.md :not(pre) > code { font-family: var(--mono); font-size: .88em; background: var(--bg-elev2); padding: .15em .4em; border-radius: 6px; }
.md img { max-width: 100%; }
.code-block { margin: .8em 0 1em; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--code-bg); }
.code-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 8px 6px 14px; font-size: 12px; color: var(--text-faint); background: var(--bg-elev); border-bottom: 1px solid var(--border); font-family: var(--mono); }
.code-head button { display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px; border-radius: 6px; font-family: var(--font); color: var(--text-dim); }
.code-head button:hover { background: var(--bg-elev2); color: var(--text); }
.code-head svg { width: 14px; height: 14px; }
.code-block pre { margin: 0; padding: 14px 16px; overflow-x: auto; }
.code-block pre code.hljs { background: transparent; padding: 0; font-family: var(--mono); font-size: 13px; line-height: 1.55; }
.cursor::after { content: ""; display: inline-block; width: 9px; height: 9px; margin-left: 4px; border-radius: 50%; background: var(--text); vertical-align: middle; animation: pulse 1s infinite; }
.msg-error { color: var(--bad); background: rgba(255, 107, 107, .08); border: 1px solid rgba(255, 107, 107, .3); padding: 10px 14px; border-radius: 10px; margin-top: 6px; font-size: 13.5px; }
.msg-stopped { color: var(--text-faint); font-size: 12.5px; margin-top: 6px; font-style: italic; }

.welcome { min-height: calc(100vh - 280px); display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 20px; }
.welcome .logo { width: 64px; height: 64px; border-radius: 20px; display: grid; place-items: center; background: linear-gradient(135deg, var(--accent), var(--accent2)); box-shadow: 0 12px 40px rgba(124, 108, 255, .35); margin-bottom: 20px; }
.welcome .logo img { width: 36px; filter: brightness(10); }
.welcome h2 { font-size: 26px; font-weight: 650; margin: 0 0 6px; }
.welcome p { margin: 0 0 26px; color: var(--text-dim); }
.suggestions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; width: 100%; max-width: 640px; }
.suggestion { text-align: left; padding: 14px 16px; border: 1px solid var(--border); border-radius: 14px; background: var(--bg-elev); color: var(--text-dim); line-height: 1.4; }
.suggestion b { display: block; color: var(--text); font-weight: 600; margin-bottom: 2px; }
.suggestion:hover { border-color: var(--border-strong); background: var(--bg-elev2); }

#composerWrap { padding: 0 24px 14px; }
#composer { max-width: 820px; margin: 0 auto; background: var(--bg-elev); border: 1px solid var(--border-strong); border-radius: 24px; padding: 10px 10px 8px 16px; box-shadow: 0 6px 30px rgba(0, 0, 0, .18); transition: border-color .15s; }
#composer:focus-within { border-color: var(--text-faint); }
#input { width: 100%; resize: none; border: 0; outline: 0; background: none; line-height: 1.55; max-height: 40vh; padding: 6px 0; font-size: 15px; }
.composer-bar { display: flex; align-items: center; justify-content: space-between; margin-top: 2px; }
.composer-bar .left { display: flex; align-items: center; gap: 6px; margin-left: -6px; }
.send-btn { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--text); color: var(--bg); transition: opacity .15s, transform .1s; }
.send-btn:disabled { opacity: .25; cursor: default; }
.send-btn:not(:disabled):active { transform: scale(.94); }
.send-btn svg { width: 18px; height: 18px; stroke-width: 2.4; }
.send-btn .i-stop { display: none; fill: currentColor; stroke: none; }
.send-btn.stop .i-send { display: none; }
.send-btn.stop .i-stop { display: block; }
#attachments { display: flex; gap: 8px; flex-wrap: wrap; }
#attachments:not(:empty) { margin: 2px 0 8px; }
.att { position: relative; width: 64px; height: 64px; border-radius: 12px; overflow: hidden; border: 1px solid var(--border-strong); }
.att img { width: 100%; height: 100%; object-fit: cover; }
.att button { position: absolute; top: 3px; right: 3px; width: 20px; height: 20px; border-radius: 50%; background: rgba(0, 0, 0, .7); color: #fff; display: grid; place-items: center; }
.att button svg { width: 12px; height: 12px; }
.disclaimer { text-align: center; font-size: 11.5px; color: var(--text-faint); margin-top: 8px; }
.jump-down { position: absolute; left: 50%; transform: translateX(-50%); bottom: 150px; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--bg-elev); border: 1px solid var(--border-strong); box-shadow: var(--shadow); z-index: 5; }
.drop-zone { position: absolute; inset: 12px; border: 2px dashed var(--accent); border-radius: 20px; background: rgba(124, 108, 255, .08); display: grid; place-items: center; font-size: 18px; font-weight: 600; z-index: 20; pointer-events: none; }

/* ---------- right panel ---------- */
.panel { width: 320px; flex-shrink: 0; border-left: 1px solid var(--border); background: var(--bg); display: flex; flex-direction: column; }
.panel-head { height: var(--topbar); display: flex; align-items: center; justify-content: space-between; padding: 0 10px 0 18px; border-bottom: 1px solid var(--border); }
body.desktop .panel-head { margin-top: var(--topbar); border-top: 1px solid var(--border); }
.panel-head h3 { margin: 0; font-size: 14px; }
.panel-body { padding: 16px 18px; overflow-y: auto; display: grid; gap: 16px; align-content: start; }
.field { display: grid; gap: 7px; }
.field > span { font-size: 13px; color: var(--text-dim); display: flex; justify-content: space-between; }
.field > span b { color: var(--text); font-weight: 600; font-family: var(--mono); font-size: 12px; }
.field textarea, .field input[type=text], .field input[type=number], .field input[type=password], .field select, .input {
  width: 100%; background: var(--bg-elev); border: 1px solid var(--border-strong); border-radius: 10px; padding: 9px 11px; outline: 0; resize: vertical; }
.field textarea:focus, .field input:focus, .field select:focus, .input:focus { border-color: var(--accent); }
input[type=range] { width: 100%; accent-color: var(--accent); }
.hint { font-size: 12px; color: var(--text-faint); margin: 0; line-height: 1.5; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 8px 14px; border-radius: 10px; font-weight: 550; font-size: 13.5px; border: 1px solid var(--border-strong); background: var(--bg-elev); white-space: nowrap; }
.btn:hover { background: var(--bg-elev2); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; }
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent2)); border-color: transparent; color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--bad); }
.btn.danger:hover { background: rgba(255, 107, 107, .1); border-color: rgba(255, 107, 107, .4); }
.btn.sm { padding: 5px 10px; font-size: 12.5px; border-radius: 8px; }
.switch { position: relative; display: inline-block; vertical-align: middle; width: 40px; height: 23px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch i { position: absolute; inset: 0; border-radius: 99px; background: var(--border-strong); transition: background .15s; cursor: pointer; }
.switch i::after { content: ""; position: absolute; width: 17px; height: 17px; left: 3px; top: 3px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked + i { background: var(--accent); }
.switch input:checked + i::after { transform: translateX(17px); }

/* ---------- pages (models / server / settings) ---------- */
.page { overflow-y: auto; }
.page-inner { max-width: 1040px; margin: 0 auto; padding: 26px 28px 60px; width: 100%; }
.page h2 { font-size: 22px; margin: 0 0 4px; }
.page .sub { color: var(--text-dim); margin: 0 0 22px; }
.card { background: var(--bg-elev); border: 1px solid var(--border); border-radius: 16px; padding: 18px 20px; margin-bottom: 16px; }
.card h3 { margin: 0 0 4px; font-size: 15.5px; display: flex; align-items: center; gap: 8px; }
.card .card-sub { color: var(--text-dim); font-size: 13px; margin: 0 0 14px; line-height: 1.5; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid2 > .card { margin-bottom: 0; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.setting { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 13px 0; border-top: 1px solid var(--border); }
.setting:first-of-type { border-top: 0; }
.setting .s-label { font-weight: 550; }
.setting .s-desc { font-size: 12.5px; color: var(--text-dim); margin-top: 3px; line-height: 1.45; }
.setting .s-ctl { flex-shrink: 0; min-width: 0; }
.setting .s-ctl.wide { width: 320px; }

.model-card { display: flex; gap: 16px; align-items: center; padding: 14px 16px; border: 1px solid var(--border); border-radius: 14px; background: var(--bg); margin-bottom: 10px; }
.model-card.is-default { border-color: rgba(124, 108, 255, .5); }
.model-card .mc-icon { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: var(--bg-elev2); font-weight: 700; color: var(--accent); flex-shrink: 0; font-size: 15px; }
.model-card .mc-main { flex: 1; min-width: 0; }
.model-card .mc-name { font-weight: 650; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.model-card .mc-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.model-card .mc-acts { display: flex; gap: 6px; flex-shrink: 0; }
.gpu { display: grid; gap: 8px; }
.bar { height: 8px; border-radius: 99px; background: var(--bg-elev2); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--accent), var(--accent2)); transition: width .4s; }
.file-row { display: flex; align-items: center; gap: 12px; padding: 10px 4px; border-top: 1px solid var(--border); }
.file-row:first-child { border-top: 0; }
.file-row .fr-main { flex: 1; min-width: 0; }
.file-row .fr-name { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-row .fr-path { font-size: 12px; color: var(--text-faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder-chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 6px 5px 11px; border-radius: 999px; background: var(--bg-elev2); border: 1px solid var(--border); font-size: 12.5px; }
.folder-chip button { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; color: var(--text-faint); }
.folder-chip button:hover { background: var(--border-strong); color: var(--text); }
.folder-chip svg { width: 12px; height: 12px; }

.server-hero { display: flex; align-items: center; gap: 18px; }
.big-dot { width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; background: var(--bg-elev2); }
.big-dot.on { background: rgba(62, 207, 142, .12); color: var(--good); }
.big-dot.off { color: var(--text-faint); }
.big-dot svg { width: 26px; height: 26px; }
.server-hero .sh-main { flex: 1; }
.server-hero .sh-title { font-size: 18px; font-weight: 650; }
.qr-wrap { display: grid; grid-template-columns: 260px 1fr; gap: 22px; align-items: start; }
.qr-box { background: #fff; border-radius: 16px; padding: 12px; display: grid; place-items: center; aspect-ratio: 1; }
.qr-box img { width: 100%; image-rendering: pixelated; }
.qr-box.blur img { filter: blur(8px); }
.tabs { display: inline-flex; gap: 2px; background: var(--bg-elev2); border-radius: 10px; padding: 3px; margin-bottom: 12px; }
.tabs button { padding: 6px 12px; border-radius: 8px; color: var(--text-dim); font-size: 13px; }
.tabs button.active { background: var(--bg); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .2); }
.addr { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border: 1px solid var(--border); border-radius: 10px; margin-bottom: 7px; background: var(--bg); }
.addr .a-kind { font-size: 11.5px; color: var(--text-faint); min-width: 150px; }
.addr code { flex: 1; font-family: var(--mono); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.token-box { display: flex; align-items: center; gap: 8px; }
.token-box code { flex: 1; font-family: var(--mono); font-size: 12.5px; padding: 9px 12px; background: var(--bg); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.option { display: flex; gap: 12px; padding: 13px 14px; border: 1px solid var(--border); border-radius: 12px; cursor: pointer; margin-bottom: 8px; background: var(--bg); }
.option:hover { border-color: var(--border-strong); }
.option.sel { border-color: var(--accent); background: var(--accent-soft); }
.option input { accent-color: var(--accent); margin-top: 3px; }
.option .o-title { font-weight: 600; display: flex; gap: 8px; align-items: center; }
.option .o-desc { font-size: 12.5px; color: var(--text-dim); margin-top: 3px; line-height: 1.45; }
.logs { font-family: var(--mono); font-size: 12px; background: var(--code-bg); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; height: 220px; overflow-y: auto; white-space: pre-wrap; color: var(--text-dim); }
.logs .t { color: var(--text-faint); }
pre.snippet { font-family: var(--mono); font-size: 12px; background: var(--code-bg); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; overflow-x: auto; margin: 8px 0 0; color: var(--text-dim); }
.device { display: flex; align-items: center; gap: 12px; padding: 9px 0; border-top: 1px solid var(--border); font-size: 13px; }
.device:first-child { border-top: 0; }
.callout { display: flex; gap: 10px; padding: 11px 14px; border-radius: 10px; font-size: 13px; line-height: 1.5; background: rgba(245, 184, 74, .08); border: 1px solid rgba(245, 184, 74, .3); color: var(--text); margin-top: 10px; }
.callout.info { background: var(--accent-soft); border-color: rgba(124, 108, 255, .3); }
.callout svg { color: var(--warn); margin-top: 1px; }
.callout.info svg { color: var(--accent); }

/* ---------- GPU ---------- */
.gpu-mini { padding: 10px 18px 0; cursor: pointer; }
.gpu-mini:hover { color: var(--text); }
.gpu-mini + .status-bar { padding-top: 6px; }
.tiles { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 1250px) { .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.tile { background: var(--bg); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; }
.tile .t-label { font-size: 12px; color: var(--text-dim); }
.tile .t-value { font-size: 24px; font-weight: 650; margin: 4px 0 2px; font-variant-numeric: tabular-nums; }
.tile .t-value small { font-size: 13px; font-weight: 500; color: var(--text-dim); }
.tile .t-sub { font-size: 12px; color: var(--text-faint); min-height: 1.3em; }
.lvl { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; }
.lvl svg { width: 13px; height: 13px; }
.lvl.good { color: var(--good); } .lvl.warn { color: var(--warn); } .lvl.bad { color: var(--bad); }
.chart-title { font-size: 13px; color: var(--text-dim); margin-bottom: 6px; }
.chart { position: relative; background: var(--bg); border: 1px solid var(--border); border-radius: 12px; padding: 6px 4px 0; }
.chart svg { width: 100%; height: 170px; display: block; overflow: visible; stroke: none; fill: none; }
.chart .hit { stroke: none; }
.chart .gl { stroke: var(--border); stroke-width: 1; vector-effect: non-scaling-stroke; }
.chart .ax { fill: var(--text-faint); font-size: 11px; font-family: var(--font); }
.chart .ln { fill: none; stroke: var(--accent); stroke-width: 2; vector-effect: non-scaling-stroke; stroke-linejoin: round; stroke-linecap: round; }
.chart .ref { stroke: var(--text-faint); stroke-width: 1; stroke-dasharray: 4 4; vector-effect: non-scaling-stroke; }
.chart .xh { stroke: var(--text-faint); stroke-width: 1; vector-effect: non-scaling-stroke; }
.chart .pt { fill: var(--accent); stroke: var(--bg); stroke-width: 2; vector-effect: non-scaling-stroke; }
.chart .tip { position: absolute; transform: translateX(-50%); background: var(--bg-elev2); border: 1px solid var(--border-strong); border-radius: 8px; padding: 5px 9px; font-size: 12px; pointer-events: none; display: grid; white-space: nowrap; box-shadow: var(--shadow); }
.chart .tip span { color: var(--text-faint); }
.pl-val { min-width: 80px; text-align: right; color: var(--text-dim); }
.pl-val b { font-size: 22px; color: var(--text); font-variant-numeric: tabular-nums; }

.card.conflict { border-color: rgba(245, 184, 74, .45); }
.card.conflict h3 svg { color: var(--warn); }
.helper-row { display: flex; align-items: center; gap: 12px; margin-top: 14px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg); }
.pw-row { padding: 10px 0; border-top: 1px solid var(--border); }
.pw-row:first-of-type { border-top: 0; }
.pw-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.cal-table { width: 100%; border-collapse: collapse; margin-top: 14px; font-size: 13px; font-variant-numeric: tabular-nums; }
.cal-table th { text-align: left; font-weight: 550; color: var(--text-dim); padding: 7px 10px; border-bottom: 1px solid var(--border-strong); }
.cal-table td { padding: 7px 10px; border-bottom: 1px solid var(--border); }
.cal-table tr.rec td { background: var(--accent-soft); }

/* ---------- personas ---------- */
.persona-btn { display: flex; align-items: center; gap: 7px; padding: 6px 11px; border-radius: 10px; border: 1px solid var(--border-strong); font-weight: 600; font-size: 14px; }
.persona-btn:hover { background: var(--bg-elev); }
.persona-btn svg { width: 15px; height: 15px; color: var(--text-faint); }
.pe-emoji { font-size: 16px; }
.pe-big { font-size: 22px; width: 30px; text-align: center; flex-shrink: 0; }
body:not(.view-chat) #personaPicker { display: none; }
.avatar.emoji { background: var(--bg-elev2); font-size: 15px; }
.pe-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 14px; }
.pe-tile { border: 1px solid var(--border); border-radius: 12px; padding: 12px; background: var(--bg); text-align: left; }
.pe-tile .pe-voice { flex: 1; padding: 6px 8px; font-size: 13px; }
.pe-new { display: grid; place-items: center; color: var(--text-dim); border-style: dashed; min-height: 92px; font-weight: 600; }
.pe-new:hover { border-color: var(--accent); color: var(--text); }
.voice-row { display: flex; align-items: center; gap: 12px; padding: 9px 0; border-top: 1px solid var(--border); }
.voice-row:first-child { border-top: 0; }
@media (max-width: 820px) { .pe-grid { grid-template-columns: 1fr; } .persona-btn .pe-name { display: none; } }

/* ---------- confirmations + Google ---------- */
.tool-call.confirm { border-color: var(--accent); background: var(--bg); }
.tool-call .tc-head { display: flex; align-items: center; gap: 8px; padding: 9px 12px; }
.tc-preview { margin: 0; padding: 10px 12px; border-top: 1px solid var(--border); max-height: 340px; overflow: auto; font-family: inherit; font-size: 13.5px; white-space: pre-wrap; color: var(--text); }
.tc-actions { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--border); }
.tc-actions .btn svg { width: 15px; height: 15px; }
.vo-confirm { margin-top: 14px; max-width: 520px; width: 100%; text-align: left; border: 1px solid var(--accent); border-radius: 14px; background: var(--bg-elev); }
.vo-confirm .vc-title { padding: 10px 14px 0; font-weight: 600; }
.vo-confirm pre { margin: 0; padding: 8px 14px; max-height: 200px; overflow: auto; white-space: pre-wrap; font-family: inherit; font-size: 13.5px; }
.g-steps { margin: 12px 0 10px; padding-left: 20px; display: grid; gap: 7px; font-size: 13.5px; color: var(--text-dim); }
.g-steps a { color: var(--accent); }
.tools-group { margin: 16px 0 8px; font-weight: 600; font-size: 13.5px; }
.tools-wrap.off { opacity: .45; pointer-events: none; }
.tools-grid.na { opacity: .5; }

/* ---------- answer stats ---------- */
.modal-card.wide { max-width: 680px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; }
.msg-actions button.stats { width: auto; height: auto; padding: 3px 8px; border-radius: 8px; font-size: 12px; color: var(--text-faint); font-variant-numeric: tabular-nums; }
.msg-actions button.stats:hover { color: var(--text); background: var(--bg-elev); }
.st-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 18px; }
.st-kv { display: flex; justify-content: space-between; gap: 10px; padding: 5px 0; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.st-kv span { color: var(--text-dim); }
.st-kv b { font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }
.st-h { margin: 18px 0 8px; font-size: 14.5px; }
.st-table { width: 100%; border-collapse: collapse; font-size: 13.5px; font-variant-numeric: tabular-nums; }
.st-table th { text-align: right; font-weight: 600; color: var(--text-dim); padding: 6px 8px; border-bottom: 1px solid var(--border-strong); }
.st-table td { text-align: right; padding: 6px 8px; border-bottom: 1px solid var(--border); }
.st-table td:first-child, .st-table th:first-child { text-align: left; color: var(--text-dim); }
@media (max-width: 600px) { .st-grid { grid-template-columns: 1fr; } .st-table { font-size: 12.5px; } }

/* ---------- documents, reminders, quick window ---------- */
.att.doc { width: auto; max-width: 240px; height: 64px; display: flex; align-items: center; gap: 8px; padding: 0 30px 0 12px; background: var(--bg-elev); }
.att.doc svg { width: 22px; height: 22px; color: var(--accent); flex-shrink: 0; }
.att.doc span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.att.doc small { color: var(--text-faint); font-size: 11px; white-space: nowrap; }
.file-chips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; margin-bottom: 6px; }
.file-chip { display: flex; align-items: center; gap: 7px; max-width: 320px; padding: 7px 11px; border: 1px solid var(--border-strong); border-radius: 12px; background: var(--bg-elev); font-size: 13px; }
.file-chip svg { width: 18px; height: 18px; color: var(--accent); flex-shrink: 0; }
.file-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-chip small { color: var(--text-faint); white-space: nowrap; }
.rem-row { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-top: 1px solid var(--border); font-size: 13.5px; }
.rem-row b { min-width: 150px; font-weight: 600; font-variant-numeric: tabular-nums; }
.rem-row span { flex: 1; }
.rem-row.done { opacity: .6; }
.rem-past { margin-top: 8px; }
.toast.reminder { border-color: var(--accent); }
body.quick #sidebar, body.quick #chatPanel, body.quick #openSide, body.quick #chatSettingsBtn, body.quick #loadChip, body.quick #sideScrim { display: none !important; }
body.quick #topbar { padding-left: 12px; }
body.quick .quick-actions { display: flex; gap: 6px; align-items: center; margin-left: 8px; }
.quick-actions { display: none; }
body.quick .welcome .suggestions, body.quick .welcome-logo { display: none; }

/* ---------- memory ---------- */
.mem-box:not(:empty) { margin: 0 0 8px; }
.mem-used { font-size: 12.5px; color: var(--text-faint); }
.mem-used summary { list-style: none; display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.mem-used summary::-webkit-details-marker { display: none; }
.mem-used svg { width: 14px; height: 14px; color: var(--accent); }
.mem-used ul { margin: 6px 0 0; padding-left: 22px; color: var(--text-dim); }
.card h3 svg { width: 18px; height: 18px; color: var(--accent); }
.mem-list { margin-top: 12px; display: grid; gap: 6px; max-height: 420px; overflow-y: auto; }
.mem-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); }
.mem-item .mem-text { flex: 1; min-width: 0; cursor: text; }
.mem-item .input { flex: 1; padding: 5px 8px; }
.mem-item .icon-btn { width: 28px; height: 28px; }
.mem-item .icon-btn svg { width: 15px; height: 15px; }
.mem-item .icon-btn.on { color: var(--accent); }

/* ---------- tool calls ---------- */
.tool-calls:not(:empty) { display: grid; gap: 6px; margin: 2px 0 12px; }
.tool-call { border: 1px solid var(--border); border-radius: 10px; background: var(--bg-elev); font-size: 13px; }
.tool-call summary { list-style: none; display: flex; align-items: center; gap: 8px; padding: 7px 11px; cursor: pointer; color: var(--text-dim); }
.tool-call summary::-webkit-details-marker { display: none; }
.tool-call .tc-icon { display: inline-grid; color: var(--accent); }
.tool-call .tc-icon svg, .tool-opt .tc-icon svg { width: 16px; height: 16px; }
.tool-call .tc-label { color: var(--text); font-weight: 550; }
.tool-call .tc-args { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tool-call .tc-ms { color: var(--text-faint); font-size: 12px; }
.tool-call .tc-ok { color: var(--good); display: inline-grid; } .tool-call .tc-err { color: var(--bad); display: inline-grid; }
.tool-call .tc-ok svg, .tool-call .tc-err svg { width: 15px; height: 15px; }
.tc-spin { width: 13px; height: 13px; border-radius: 50%; border: 2px solid var(--border-strong); border-top-color: var(--accent); animation: spin .8s linear infinite; }
.tool-call.running summary .tc-label { background: linear-gradient(90deg, var(--text-faint), var(--text), var(--text-faint)); background-size: 200% 100%; -webkit-background-clip: text; background-clip: text; color: transparent; animation: shimmer 1.6s linear infinite; }
.tc-result { margin: 0; padding: 10px 12px; border-top: 1px solid var(--border); max-height: 260px; overflow: auto; font-family: var(--mono); font-size: 12px; white-space: pre-wrap; color: var(--text-dim); }
.tools-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 14px; }
.tools-grid.off { opacity: .45; pointer-events: none; }
.tool-opt { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); cursor: pointer; }
.tool-opt .tc-icon { color: var(--accent); display: inline-grid; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (max-width: 820px) { .tools-grid { grid-template-columns: 1fr; } }

/* ---------- voice ---------- */
.via-voice { display: inline-flex; vertical-align: -2px; margin-right: 6px; color: var(--text-faint); }
.via-voice svg { width: 14px; height: 14px; }
.composer-bar .right { display: flex; align-items: center; gap: 6px; }
.mic-btn.rec { color: #fff; background: var(--bad); box-shadow: 0 0 0 calc(var(--lvl, 0) * 10px) rgba(255, 107, 107, .25); }
.mic-btn.busy { opacity: .6; animation: pulse 1s infinite; }
.msg-actions button.on { color: var(--accent); background: var(--accent-soft); }
.voice-overlay { position: fixed; inset: 0; z-index: 95; background: radial-gradient(ellipse at 50% 40%, #1a1740 0%, #0b0c12 70%); color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: space-between; padding: 40px 20px calc(30px + env(safe-area-inset-bottom)); }
body.light .voice-overlay { background: radial-gradient(ellipse at 50% 40%, #ece9ff 0%, #ffffff 70%); color: var(--text); }
.vo-close { position: absolute; top: 14px; right: 14px; color: inherit; }
body.desktop .vo-close { top: 52px; }
.vo-center { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; width: 100%; max-width: 640px; text-align: center; }
.vo-orb { --lvl: 0; position: relative; width: 190px; height: 190px; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.orb-core { position: absolute; inset: 0; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #b8afff, var(--accent) 45%, var(--accent2) 100%); box-shadow: 0 0 80px rgba(124, 108, 255, .55); transform: scale(calc(0.86 + var(--lvl) * 0.28)); transition: transform .08s linear; }
.orb-ring { position: absolute; inset: -14px; border-radius: 50%; border: 2px solid rgba(124, 108, 255, .35); opacity: 0; }
.voice-overlay[data-stage="listening"] .orb-ring { opacity: 1; animation: ring 1.8s ease-out infinite; }
.voice-overlay[data-stage="transcribing"] .orb-core, .voice-overlay[data-stage="thinking"] .orb-core, .voice-overlay[data-stage="loading"] .orb-core { animation: breathe 1.2s ease-in-out infinite; }
.voice-overlay[data-stage="speaking"] .orb-core { background: radial-gradient(circle at 35% 30%, #a8d8ff, var(--accent2) 45%, var(--accent) 100%); }
.voice-overlay[data-stage="paused"] .orb-core { filter: grayscale(.8) brightness(.7); }
.vo-status { font-size: 17px; font-weight: 600; opacity: .9; min-height: 1.4em; }
.vo-caption { font-size: 15px; line-height: 1.5; max-height: 20vh; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; }
.vo-caption.user { opacity: .65; font-style: italic; }
.vo-caption.user:not(:empty)::before { content: "„"; }
.vo-caption.user:not(:empty)::after { content: "”"; }
.vo-notice { font-size: 12.5px; color: var(--warn); min-height: 1em; }
.vo-controls { display: flex; gap: 22px; }
.vo-btn { width: 60px; height: 60px; border-radius: 50%; display: grid; place-items: center; background: rgba(255, 255, 255, .1); color: inherit; }
body.light .vo-btn { background: rgba(0, 0, 0, .06); }
.vo-btn svg { width: 24px; height: 24px; }
.vo-btn.on { background: var(--bad); color: #fff; }
.vo-btn.end { background: rgba(255, 107, 107, .18); color: var(--bad); }
@keyframes ring { from { transform: scale(.9); opacity: .8; } to { transform: scale(1.25); opacity: 0; } }
@keyframes breathe { 0%, 100% { transform: scale(.86); } 50% { transform: scale(.95); } }

/* ---------- login / modal / toast ---------- */
.login { position: fixed; inset: 0; display: grid; place-items: center; background: var(--bg); z-index: 100; padding: 20px; }
.login-card { width: 100%; max-width: 380px; display: grid; gap: 14px; text-align: center; }
.login-card img { width: 56px; margin: 0 auto; }
.login-card h2 { margin: 0; }
.login-card p { margin: 0; }
.login-card input { background: var(--bg-elev); border: 1px solid var(--border-strong); border-radius: 12px; padding: 12px 14px; outline: 0; text-align: center; }
.modal { position: fixed; inset: 0; background: rgba(0, 0, 0, .55); display: grid; place-items: center; z-index: 90; padding: 20px; backdrop-filter: blur(3px); }
.modal-card { width: 100%; max-width: 520px; background: var(--bg-elev); border: 1px solid var(--border-strong); border-radius: 18px; padding: 22px; box-shadow: var(--shadow); display: grid; gap: 14px; max-height: 90vh; overflow-y: auto; }
.modal-card h3 { margin: 0; font-size: 17px; }
.modal-card .actions { display: flex; justify-content: flex-end; gap: 8px; }
.modal-card img.full { max-width: 100%; border-radius: 10px; }
#toasts { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); display: grid; gap: 8px; z-index: 120; }
.toast { background: var(--bg-elev2); border: 1px solid var(--border-strong); padding: 10px 16px; border-radius: 12px; box-shadow: var(--shadow); font-size: 13.5px; animation: fadeIn .2s ease; }
.toast.error { border-color: rgba(255, 107, 107, .5); }

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ---------- mobile (web UI on phones) ---------- */
@media (max-width: 820px) {
  #sidebar { position: fixed; top: 0; bottom: 0; left: 0; margin-left: -272px; box-shadow: var(--shadow); }
  body.side-open #sidebar { margin-left: 0; }
  body.side-open #sideScrim { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .5); z-index: 25; }
  #openSide { display: inline-grid; }
  #collapseSide { display: none; }
  #messages { padding: 10px 14px 20px; }
  #composerWrap { padding: 0 10px calc(10px + env(safe-area-inset-bottom)); }
  .msg.user .bubble { max-width: 88%; }
  .suggestions { grid-template-columns: 1fr; }
  .panel { position: fixed; right: 0; top: 0; bottom: 0; width: min(340px, 92vw); z-index: 40; box-shadow: var(--shadow); }
  .menu { min-width: 300px; }
  .chip span:not(.mp-dot) { display: none; }
  .grid2, .qr-wrap { grid-template-columns: 1fr; }
}

/* pictures produced by tools (charts from run_python, browser screenshots) */
.tc-images { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 10px; }
.tc-images img { max-width: min(100%, 520px); max-height: 380px; border-radius: 10px; border: 1px solid var(--border); background: #fff; cursor: zoom-in; }
.tag.bad { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, transparent); }
.modal-card.wide { max-width: min(92vw, 1100px); }

/* artifacts */
.art-box:empty { display: none; }
.art-box { display: flex; flex-direction: column; gap: 10px; margin: 10px 0 4px; }
.art-card { display: flex; gap: 14px; align-items: stretch; border: 1px solid var(--border); border-radius: 14px; padding: 10px; background: var(--panel, rgba(127,127,127,.06)); max-width: 640px; }
.art-thumb { width: 200px; flex: none; aspect-ratio: 16 / 10; border-radius: 10px; overflow: hidden; cursor: pointer; background: #0b0d12; border: 1px solid var(--border); }
.art-thumb img { width: 100%; height: 100%; object-fit: cover; object-position: top; display: block; transition: transform .2s; }
.art-thumb:hover img { transform: scale(1.03); }
.art-ph { height: 100%; display: grid; place-items: center; color: #9aa3b2; font-size: 13px; }
.art-info { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.art-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.art-acts { display: flex; gap: 6px; flex-wrap: wrap; margin-top: auto; }
.btn.sm { padding: 5px 10px; font-size: 12.5px; }
.tag.good { color: var(--good, #3fb950); border-color: color-mix(in srgb, var(--good, #3fb950) 45%, transparent); }
.modal-card.art-viewer { width: min(96vw, 1400px); max-width: none; height: min(92vh, 1000px); display: flex; flex-direction: column; padding: 10px; }
.art-viewer-head { display: flex; gap: 8px; align-items: center; padding: 0 2px 8px; }
.art-frame { flex: 1; width: 100%; border: 1px solid var(--border); border-radius: 10px; background: #fff; }
.art-code { max-height: 65vh; overflow: auto; margin: 0; border-radius: 10px; font-size: 12.5px; }
@media (max-width: 620px) { .art-card { flex-direction: column; } .art-thumb { width: 100%; } }
.seg { display: inline-flex; gap: 4px; }
.seg button { border: 1px solid var(--border); background: transparent; color: var(--text-dim); border-radius: 8px; padding: 4px 10px; font-size: 12.5px; cursor: pointer; }
.seg button.on { background: var(--bg-elev2); color: var(--text); }

/* generated media and jobs */
.media-box:empty { display: none; }
.media-box { display: flex; flex-wrap: wrap; gap: 10px; margin: 10px 0 4px; }
.gen-img, .gen-vid { margin: 0; position: relative; }
.gen-img img { max-width: min(100%, 420px); max-height: 420px; border-radius: 12px; border: 1px solid var(--border); cursor: zoom-in; display: block; }
.gen-img .btn { position: absolute; right: 8px; bottom: 8px; opacity: .85; }
.gen-vid video { max-width: min(100%, 640px); max-height: 420px; border-radius: 12px; border: 1px solid var(--border); background: #000; display: block; }
.gen-vid .btn { margin-top: 6px; }
.file-chip.dl { text-decoration: none; color: inherit; cursor: pointer; }
.job-row { border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; min-width: 260px; max-width: 420px; display: flex; flex-direction: column; gap: 6px; }
.job-row.error { border-color: color-mix(in srgb, var(--bad) 50%, transparent); }
.job-row .bar { height: 6px; border-radius: 4px; background: var(--bg-elev2); overflow: hidden; }
.job-row .bar i { display: block; height: 100%; background: var(--accent, #7c5cff); transition: width .4s; }
.job-row .btn { align-self: flex-start; }
.col { display: flex; flex-direction: column; }
