/* venostudio UI — cool gray shell, slate controls, charcoal workroom. */
:root {
  color-scheme: light;
  --bg: #e8ebee;
  --panel: #f2f4f6;
  --paper: #fafbfc;
  --pop: #353742;
  --border: rgba(53, 55, 66, .13);
  --border2: rgba(53, 55, 66, .23);
  --edge: inset 0 1px 0 rgba(255, 255, 255, .65);
  --in-bg: rgba(255, 255, 255, .74);
  --in-line: rgba(53, 55, 66, .2);
  --in-line-h: #4e535c;
  --acc: #4e535c;
  --on-acc: #f7f9fa;
  --acc-h: #5c626d;
  --acc-a: rgba(78, 83, 92, .08);
  --acc-line: rgba(78, 83, 92, .42);
  --txt: #2f313a;
  --read: #4e535c;
  --mut: #69717b;
  --dim: #606976;
  --ok: #457061;
  --bad: #9a4b52;
  --info: #4a6b86;
  --warn: #8a6a3f;
  --lavender: #7f8896;
  --r-lg: 18px;
  --r-md: 14px;
  --r-sm: 10px;
  --r-in: 9px;
  --sans: "Be Vietnam Pro", "Segoe UI", system-ui, sans-serif;
  --name: "Lora", Georgia, serif;
  --mono: "JetBrains Mono", "Cascadia Mono", Consolas, monospace;
  --top: 70px;
  --mobile-nav: 0px;
  --shadow: 0 12px 32px rgba(53, 55, 66, .10), 0 2px 5px rgba(53, 55, 66, .06);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
html { background: var(--bg); }
body {
  height: 100vh; height: 100dvh;
  background: var(--bg); color: var(--txt); font: 13px/1.55 var(--sans); overflow: hidden;
  background-image: radial-gradient(900px 540px at 85% -10%, rgba(255,255,255,.58), transparent 65%), radial-gradient(700px 500px at -15% 100%, rgba(142,62,66,.08), transparent 65%);
}
body::before { content: ""; position: fixed; inset: 0; pointer-events: none; opacity: .22; z-index: 100; background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.12'/%3E%3C/svg%3E"); mix-blend-mode: multiply; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
button, a, input, select, textarea, summary { outline: none; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible { outline: 2px solid var(--acc); outline-offset: 3px; }
button:disabled { cursor: default; }
a { color: var(--acc); text-underline-offset: 3px; }
code, pre, .mono { font-family: var(--mono); font-size: 12px; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
::selection { background: rgba(78,83,92,.18); }
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: rgba(127,136,150,.30); border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

/* Top editorial masthead */
#top {
  height: calc(var(--top) + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 18px 0;
  display: flex; align-items: center; gap: 14px; position: relative; z-index: 10;
  border-bottom: 1px solid var(--border2); background: rgba(242,244,246,.90); backdrop-filter: blur(18px);
  box-shadow: 0 3px 16px rgba(53,55,66,.06);
}
#top::after { content: ""; position: absolute; left: 18px; right: 18px; bottom: 3px; height: 1px; background: rgba(78,83,92,.16); pointer-events: none; }
.brand { display: flex; align-items: center; gap: 9px; white-space: nowrap; flex: none; }
.wordmark {
  position: relative; padding-right: 11px; color: var(--acc);
  font: italic 600 28px/1 var(--name); letter-spacing: -.065em;
}
.wordmark::after {
  content: ""; position: absolute; right: 0; top: -2px; width: 8px; height: 8px; background: currentColor;
  clip-path: polygon(50% 0,62% 38%,100% 50%,62% 62%,50% 100%,38% 62%,0 50%,38% 38%);
}
.ver { align-self: flex-start; margin-top: 8px; color: var(--dim); font: 9px/1 var(--mono); }
.pick {
  display: flex; align-items: center; gap: 9px; max-width: 230px; min-width: 150px; padding: 6px 9px;
  border-radius: var(--r-sm); border: 1px solid var(--border); background: rgba(255,255,255,.58); text-align: left;
  transition: border-color .16s, background .16s, transform .16s;
}
.pick:hover { border-color: var(--acc-line); background: var(--paper); }
.pick:active { transform: translateY(1px); }
.pick > svg:first-child { color: var(--acc); width: 17px; }
.pick-copy { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.pick-copy small { color: var(--dim); font: 500 8px/1.3 var(--mono); letter-spacing: .1em; }
#projName { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; font-size: 12px; }
.pick .caret { width: 14px; height: 14px; color: var(--mut); }
#tabs { display: flex; align-items: center; justify-content: center; gap: 3px; margin-left: auto; }
#tabs button {
  position: relative; display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 7px 10px;
  border: 1px solid transparent; border-radius: 9px; background: none; color: var(--mut); white-space: nowrap;
  font-size: 12px; font-weight: 500; transition: color .16s, background .16s, border-color .16s, transform .16s;
}
#tabs button::after { content: attr(data-step); color: var(--dim); font: 8px/1 var(--mono); align-self: flex-start; margin-top: 2px; }
#tabs button svg { width: 15px; height: 15px; }
#tabs button:hover { color: var(--txt); background: rgba(255,255,255,.4); }
#tabs button:active { transform: translateY(1px); }
#tabs button.on { color: var(--acc); background: var(--acc-a); border-color: rgba(78,83,92,.18); }
#tabs button.on::after { color: var(--acc); }
.tab-badge { min-width: 16px; height: 16px; display: inline-grid; place-items: center; padding: 0 4px; border-radius: 99px; background: var(--bad); color: #fff; font: 9px/1 var(--mono); }
.top-actions { display: flex; gap: 6px; align-items: center; }
.top-action { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px; padding: 7px 10px; border-radius: 9px; border: 1px solid var(--border); background: transparent; color: var(--read); font-size: 11px; font-weight: 600; transition: .16s; }
.top-action:hover { color: var(--acc); border-color: var(--acc-line); background: var(--acc-a); }
.top-action:active { transform: translateY(1px); }
.top-action.icon { width: 36px; padding: 0; }

/* Two-room studio */
#main {
  height: calc(100dvh - var(--top) - env(safe-area-inset-top));
  display: grid; grid-template-columns: minmax(350px, .90fr) minmax(450px, 1.10fr); gap: 14px; padding: 14px 16px 16px;
}
#main.playing { grid-template-columns: 1fr; }
.pane {
  min-width: 0; min-height: 0; display: flex; flex-direction: column; position: relative; isolation: isolate;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow); overflow: hidden;
}
.pane > * { position: relative; z-index: 1; }
#chatPane, #play {
  color: var(--txt);
  color-scheme: dark;
  --panel: #2b2e37; --paper: #333743; --pop: #2b2e37;
  --on-acc: #23262c; --acc-h: #c6cfd5;
  --border: rgba(175,186,193,.14); --border2: rgba(175,186,193,.24);
  --edge: inset 0 1px 0 rgba(255,255,255,.06);
  --in-bg: rgba(17,19,24,.34); --in-line: rgba(175,186,193,.20); --in-line-h: rgba(198,207,213,.60);
  --acc: #afbac1; --acc-a: rgba(175,186,193,.13); --acc-line: rgba(175,186,193,.5);
  --txt: #eef1f3; --read: #c3ccd2; --mut: #aab5be; --dim: #99a5af;
  --ok: #93c2ab; --bad: #d99a9e; --info: #9dbccf; --warn: #c9ae84;
}
#chatPane { background: radial-gradient(620px 360px at 0 0, rgba(127,136,150,.20), transparent 70%), radial-gradient(500px 440px at 100% 100%, rgba(78,83,92,.16), transparent 72%), #2b2e37; border-color: rgba(175,186,193,.24); box-shadow: 0 16px 40px rgba(28,31,37,.26), inset 0 0 50px rgba(175,186,193,.04); }
#chatPane::before { content: ""; position: absolute; z-index: 0; inset: 7px; border: 1px solid rgba(199,209,216,.06); border-radius: 12px; pointer-events: none; }
#chatPane::after { content: ""; position: absolute; z-index: 0; width: 110px; height: 110px; right: -40px; top: -45px; border: 1px solid rgba(175,186,193,.16); border-radius: 50%; box-shadow: 0 0 0 12px rgba(175,186,193,.03), 0 0 45px rgba(127,136,150,.12); pointer-events: none; }
#work { background-color: var(--panel); background-image: linear-gradient(rgba(53,55,66,.03) 1px, transparent 1px); background-size: 100% 28px; }
#work::before { content: ""; position: absolute; z-index: 2; top: 0; left: 22px; width: 76px; height: 3px; background: var(--acc); pointer-events: none; }
#work::after { content: ""; position: absolute; z-index: 0; right: 14px; bottom: 14px; width: 36px; height: 36px; border-right: 1px solid rgba(78,83,92,.18); border-bottom: 1px solid rgba(78,83,92,.18); pointer-events: none; }
.pane-head { min-height: 54px; display: flex; align-items: center; gap: 8px; padding: 9px 13px; border-bottom: 1px solid var(--border); flex-wrap: wrap; background: rgba(255,255,255,.18); }
#chatPane .pane-head, #play .pane-head { background: rgba(15,17,22,.20); }
#work .pane-head { background: rgba(251,252,253,.75); }
.pane-head h2 { margin: 0; }
.grow { flex: 1; }
.scroll { overflow: auto; min-height: 0; flex: 1; overscroll-behavior: contain; }
.pad { padding: 14px 16px 20px; }
.eyebrow { color: var(--dim); font: 500 8px/1.2 var(--mono); letter-spacing: .15em; white-space: nowrap; }

/* Controls */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 7px 12px; border-radius: var(--r-sm); border: 1px solid var(--border2); background: rgba(255,255,255,.26); color: var(--txt); font-weight: 500; min-height: 34px; white-space: nowrap; transition: color .15s, border-color .15s, background .15s, transform .15s, box-shadow .15s; }
.btn svg { width: 15px; height: 15px; }
.btn:hover { border-color: var(--in-line-h); background: var(--acc-a); }
.btn:active { transform: translateY(1px) scale(.99); }
.btn.pri { background: var(--acc); color: var(--on-acc); border-color: var(--acc); box-shadow: 0 3px 10px rgba(53,55,66,.18); }
.btn.pri:hover { background: var(--acc-h); border-color: var(--acc-h); color: var(--on-acc); box-shadow: 0 4px 14px rgba(53,55,66,.26); }
#chatPane .btn.pri:hover, #play .btn.pri:hover { background: var(--acc-h); }
.btn.ghost { background: none; border-color: transparent; color: var(--mut); box-shadow: none; }
.btn.ghost:hover { color: var(--txt); border-color: var(--border); background: var(--acc-a); }
.btn.danger { color: var(--bad); border-color: rgba(154,75,82,.3); }
.btn.sm { padding: 4px 9px; min-height: 29px; font-size: 11px; border-radius: 8px; }
.btn:disabled { opacity: .42; cursor: default; transform: none; box-shadow: none; }
.icon { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: var(--r-sm); border: 1px solid var(--border); background: var(--in-bg); color: var(--read); flex: none; transition: .15s; }
.icon:hover { color: var(--acc); border-color: var(--acc-line); }
input[type=text], input[type=password], input[type=number], input[type=url], select, textarea { width: 100%; background: var(--in-bg); border: 1px solid var(--in-line); border-radius: var(--r-in); padding: 7px 9px; outline: none; transition: border-color .15s, box-shadow .15s, background .15s; }
input:focus, select:focus, textarea:focus { border-color: var(--in-line-h); box-shadow: 0 0 0 3px var(--acc-a); }
input[type=checkbox] { width: 14px; height: 14px; margin: 0; accent-color: var(--acc); flex: none; }
select { cursor: pointer; color: var(--txt); background-color: var(--in-bg); }
select option { color: #2f313a; background: #f7f9fb; }
#chatPane select option, #play select option { color: #eef1f3; background: #333743; }
textarea { resize: vertical; line-height: 1.55; }
textarea.code, input.code { font-family: var(--mono); font-size: 12px; }
label.f { display: block; margin: 0 0 11px; min-width: 0; }
label.f > span { display: flex; align-items: center; gap: 7px; font-size: 11px; color: var(--mut); margin-bottom: 4px; }
label.f > span .grow { flex: 1; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; min-width: 0; }
.row:has(> label.f) { align-items: flex-end; }
.row > label.f { flex: 1; min-width: 125px; }
.chk { display: inline-flex; gap: 6px; align-items: center; color: var(--read); font-size: 11px; min-height: 28px; }
.hint { color: var(--dim); font-size: 11px; }
.muted { color: var(--mut); }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 7px; border-radius: 999px; border: 1px solid var(--border2); font-size: 10px; line-height: 1.35; color: var(--read); white-space: nowrap; text-decoration: none; background: rgba(255,255,255,.12); }
a.chip:hover { border-color: var(--acc-line); color: var(--acc); }
.chip.ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, transparent); }
.chip.bad { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, transparent); }
.chip.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent); }
.chip.info { color: var(--info); border-color: color-mix(in srgb, var(--info) 40%, transparent); }
.chip button { font: inherit; }
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; background: var(--dim); flex: none; box-shadow: 0 0 0 2px rgba(127,136,150,.10); }
.dot.confirmed { background: var(--ok); } .dot.proposed { background: var(--warn); } .dot.open { background: var(--info); } .dot.empty { background: var(--dim); opacity: .4; padding: 0; margin: 0; }
h2 { font: 600 19px/1.25 var(--name); letter-spacing: -.02em; margin: 0 0 10px; }
h3 { font-size: 11px; line-height: 1.3; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; margin: 18px 0 8px; color: var(--mut); }
.card-name { font: 500 italic 28px/1.15 var(--name); color: var(--acc); letter-spacing: -.035em; }

/* Discussion */
.chat-head { flex-wrap: nowrap; min-height: 58px; padding: 8px 12px; }
.mode-wrap { display: flex; align-items: center; gap: 10px; min-width: 0; }
.seg { display: flex; gap: 3px; align-items: center; min-width: 0; padding: 3px; border: 1px solid var(--border); border-radius: 10px; background: rgba(8,5,14,.15); }
.seg button, .subtabs button { border: 1px solid transparent; background: none; padding: 5px 9px; border-radius: 7px; color: var(--mut); white-space: nowrap; font-size: 11px; transition: .15s; }
.seg button.on, .subtabs button.on { color: var(--txt); background: var(--acc-a); border-color: var(--border2); }
.seg button:hover, .subtabs button:hover { color: var(--txt); }
#modeSeg select { width: auto; max-width: 174px; min-height: 28px; padding: 4px 25px 4px 7px; border: 0; background-color: transparent; color: var(--mut); font-size: 11px; }
#modeSeg select:focus, #modeSeg select:focus-visible { outline: none; box-shadow: none; }
#modeSeg:focus-within { border-color: var(--acc-line); box-shadow: 0 0 0 2px color-mix(in srgb, var(--acc) 28%, transparent); }
.chat-state { display: inline-flex; align-items: center; gap: 5px; color: var(--dim); font: 9px/1 var(--mono); white-space: nowrap; }
.chat-state i { width: 5px; height: 5px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 8px color-mix(in srgb, var(--ok) 60%, transparent); }
.chat-state.busy { color: var(--warn); }
.chat-state.busy i { background: var(--warn); animation: breathe 1.2s ease-in-out infinite; }
.clear-chat { flex: none; }
.msgs { flex: 1; overflow: auto; min-height: 0; padding: 18px 18px 22px; display: flex; flex-direction: column; gap: 14px; overflow-wrap: anywhere; overscroll-behavior: contain; scrollbar-gutter: stable; }
.mes { max-width: 88%; border-radius: 15px; padding: 10px 13px; border: 1px solid var(--border); background: rgba(255,255,255,.035); overflow-wrap: anywhere; animation: message-in .22s ease-out both; }
.mes.user { align-self: flex-end; background: #dfe5e9; border-color: #dfe5e9; color: #2b2e36; border-radius: 15px 15px 4px 15px; white-space: pre-wrap; box-shadow: 3px 3px 0 rgba(53,55,66,.28); }
.mes.bot { align-self: stretch; max-width: 100%; position: relative; padding: 2px 0 2px 34px; border: 0; background: none; }
.mes.bot::before { content: "IF"; position: absolute; left: 0; top: 2px; width: 24px; height: 24px; display: grid; place-items: center; border: 1px solid rgba(175,186,193,.38); border-radius: 6px; color: #c3ccd2; background: rgba(175,186,193,.09); font: 500 9px/1 var(--name); }
.mes.err { border-color: rgba(217,154,158,.35); color: var(--bad); background: rgba(217,154,158,.07); }
.mes .who { font: 500 9px/1.4 var(--mono); letter-spacing: .05em; text-transform: uppercase; color: var(--dim); margin-bottom: 6px; display: flex; gap: 7px; flex-wrap: wrap; align-items: center; }
.mes.user .who { color: #5f6672; }
.md { color: var(--read); font-size: 12.5px; line-height: 1.65; }
.mes.user .md { color: inherit; }
.md p { margin: 0 0 8px; } .md p:last-child { margin-bottom: 0; }
.md ul, .md ol { margin: 4px 0 8px; padding-left: 20px; } .md li { margin: 3px 0; }
.md pre { background: rgba(12,14,19,.34); border: 1px solid var(--border); border-radius: var(--r-in); padding: 10px; overflow: auto; white-space: pre-wrap; color: var(--read); }
#work .md pre { background: rgba(53,55,66,.05); }
.md code { background: rgba(127,136,150,.14); padding: 1px 4px; border-radius: 4px; }
.md pre code { background: none; padding: 0; }
.md table { border-collapse: collapse; margin: 7px 0; font-size: 11px; max-width: 100%; display: block; overflow: auto; }
.md td, .md th { border: 1px solid var(--border2); padding: 4px 7px; text-align: left; }
.md h2, .md h3, .md h4, .md h5 { font: 600 14px/1.4 var(--sans); letter-spacing: 0; text-transform: none; margin: 12px 0 6px; color: var(--txt); }
.md q, .md .q { color: var(--txt); font-weight: 500; }
.box { margin-top: 10px; border: 1px solid var(--border); border-radius: var(--r-sm); padding: 9px 10px; background: rgba(14,16,21,.18); }
#work .box { background: rgba(255,255,255,.4); }
.box .op { display: flex; gap: 8px; align-items: flex-start; padding: 4px 0; font-size: 11px; }
.box .op input { margin-top: 4px; }
.box details summary { cursor: pointer; color: var(--mut); font-size: 10px; }
.box pre { max-height: 240px; overflow: auto; font-size: 10px; white-space: pre-wrap; margin: 6px 0 0; }
.typing { color: var(--mut); font-style: italic; }
.typing::after { content: ""; animation: dots 1.2s steps(4,end) infinite; }

/* Tool/MCP activity: one calm row, details on demand. */
.toolline:empty { display: none; }
.toolline, .tool-history { display: grid; gap: 4px; margin: 6px 0; }
.tool-call { min-width: 0; border: 1px solid var(--border); border-radius: 8px; background: rgba(175,186,193,.05); overflow: hidden; }
.tool-call summary { display: flex; align-items: center; gap: 7px; min-width: 0; padding: 6px 8px; cursor: pointer; list-style: none; color: var(--mut); font: 10px/1.35 var(--mono); }
.tool-call summary::-webkit-details-marker { display: none; }
.tool-call summary::after { content: "+"; margin-left: auto; color: var(--dim); font-size: 13px; }
.tool-call[open] summary::after { content: "−"; }
.tool-call summary:hover { background: rgba(175,186,193,.07); color: var(--read); }
.tool-status { display: grid; place-items: center; width: 15px; height: 15px; border-radius: 50%; border: 1px solid color-mix(in srgb, var(--ok) 42%, transparent); color: var(--ok); font-size: 9px; flex: none; }
.tool-status::before { content: "✓"; }
.tool-name { color: var(--read); font-weight: 500; flex: none; }
.tool-call[data-tool="codegraph_explore"] .tool-name { color: #a8b8c4; }
.tool-preview { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--dim); }
.tool-detail { padding: 0 8px 8px 30px; }
.tool-detail-label { display: block; margin: 4px 0 3px; color: var(--dim); font: 8px/1 var(--mono); letter-spacing: .12em; text-transform: uppercase; }
.tool-detail pre { margin: 0; max-height: 180px; overflow: auto; white-space: pre-wrap; word-break: break-word; padding: 7px 8px; border-radius: 6px; background: rgba(10,12,17,.26); color: var(--read); font-size: 10px; }

/* Composer */
#composer { border-top: 1px solid var(--border); padding: 10px 12px 9px; background: rgba(15,17,22,.24); }
.comp { display: flex; gap: 6px; align-items: flex-end; padding: 5px; border: 1px solid var(--in-line); border-radius: 13px; background: rgba(15,17,22,.27); transition: border-color .16s, box-shadow .16s; }
.comp:focus-within { border-color: var(--acc); box-shadow: 0 0 0 2px color-mix(in srgb, var(--acc) 32%, transparent); }
.comp textarea { max-height: 40vh; min-height: 36px; font-size: 16px; resize: none; border: 0; background: transparent; box-shadow: none; padding: 8px 6px; }
.comp textarea:focus, .comp textarea:focus-visible { outline: none; box-shadow: none; }
.comp .icon { width: 34px; height: 34px; border: 0; background: transparent; }
.comp .btn { min-height: 34px; flex: none; }
.composer-foot { display: flex; align-items: flex-start; gap: 10px; margin-top: 6px; }
.composer-foot .hint { flex: 1; min-width: 0; }
.composer-foot .hint b { color: var(--mut); font-weight: 500; }
.key-hint { flex: none; color: var(--dim); font: 8px/1.5 var(--mono); white-space: nowrap; }
.attach-row { display: flex; gap: 5px; flex-wrap: wrap; margin-bottom: 6px; }
.attach-row:empty { display: none; }
.attach-row .chip { max-width: 100%; }
.attach-row .chip button { background: none; border: 0; color: var(--dim); padding: 0 1px; min-width: 14px; }
.attach-row .chip button:hover { color: var(--txt); }
.media-chip { gap: 6px; padding: 3px 8px; border-color: color-mix(in srgb, var(--lavender) 48%, transparent); background: rgba(175,186,193,.12); }
.media-mini { width: 20px; height: 20px; object-fit: cover; border-radius: 4px; flex: none; }
.media-tag { font: 600 9px/1 var(--mono); padding: 2px 4px; border-radius: 4px; background: rgba(175,186,193,.24); color: var(--txt); }
.msg-media { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }
.msg-media-thumb { margin: 0; width: 78px; border-radius: 7px; overflow: hidden; border: 1px solid rgba(53,55,66,.16); background: rgba(53,55,66,.06); }
.msg-media-thumb img { display: block; width: 100%; height: 54px; object-fit: cover; }
.msg-media-thumb figcaption { padding: 2px 4px; font: 9px/1.2 var(--mono); color: #5f6672; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg-media-pill { display: inline-flex; align-items: center; padding: 3px 7px; border-radius: 6px; background: rgba(53,55,66,.1); color: #464c55; font: 500 10px/1.2 var(--mono); }

/* Editorial empty states */
#chatPane { container-type: inline-size; }
.welcome { width: 100%; max-width: 690px; margin: auto; display: grid; grid-template-columns: minmax(150px,.8fr) minmax(220px,1.2fr); align-items: center; gap: 20px; padding: 10px 0; }
.welcome-art { position: relative; margin: 0; min-height: 250px; overflow: hidden; border-radius: 3px 16px 3px 3px; border: 1px solid rgba(175,186,193,.36); box-shadow: 7px 7px 0 rgba(35,38,44,.18); transform: rotate(-1deg); background: #dfe4e8; }
.welcome-art img { width: 100%; height: 100%; position: absolute; inset: 0; object-fit: cover; }
.art-slot { display: inline-flex; align-items: center; gap: 5px; color: inherit; font: 500 8px/1.4 var(--mono); letter-spacing: .08em; text-transform: uppercase; }
.welcome-art .art-slot { position: absolute; left: 8px; bottom: 8px; padding: 4px 6px; background: rgba(43,46,54,.80); color: #e6eaed; border-radius: 3px; backdrop-filter: blur(6px); }
.welcome-copy .eyebrow { display: block; color: #7f8896; margin-bottom: 8px; }
.welcome h2 { margin: 0 0 9px; font: 500 29px/1.08 var(--name); letter-spacing: -.04em; color: var(--txt); }
.welcome h2 .card-name { font-size: inherit; }
.welcome p { margin: 0 0 10px; color: var(--mut); font-size: 11.5px; }
.welcome ol { color: var(--read); padding-left: 18px; margin: 10px 0; font-size: 11px; }
.welcome li { margin: 5px 0; padding-left: 2px; }
.welcome li::marker { color: #7f8896; font-family: var(--mono); font-size: 9px; }
.welcome .hint { line-height: 1.55; }
.empty { color: var(--dim); text-align: center; padding: 40px 20px; margin: auto; }

/* Workspace */
.gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 12px; }
.gallery-card { min-width: 0; border: 1px solid var(--border2); border-radius: var(--r-sm); padding: 8px; }
.gallery-open { display: grid; width: 100%; gap: 5px; border: 0; padding: 0; background: none; text-align: left; overflow-wrap: anywhere; }
.gallery-open img, .gallery-placeholder { width: 100%; aspect-ratio: 2/3; object-fit: cover; border-radius: 6px; background: var(--in-bg); }
.gallery-placeholder { display: grid; place-items: center; color: var(--mut); }
.gallery-open small { color: var(--mut); }
.subtabs { display: flex; gap: 3px; flex-wrap: wrap; }
#work .subtabs { width: 100%; overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; }
#work .subtabs::-webkit-scrollbar { display: none; }
#work .subtabs button { flex: none; }
.list { display: flex; flex-direction: column; gap: 3px; }
.item { display: flex; align-items: center; gap: 7px; padding: 7px 9px; border-radius: 8px; border: 1px solid transparent; background: none; text-align: left; width: 100%; color: var(--read); min-height: 32px; font-size: 11px; transition: .15s; }
.item:hover { background: var(--acc-a); }
.item.on { background: var(--acc-a); border-color: var(--acc-line); color: var(--acc); }
#play .item.on { color: var(--txt); }
.item .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.split { display: grid; grid-template-columns: minmax(145px, 190px) minmax(0,1fr); gap: 13px; min-height: 0; }
.split > div { min-width: 0; }
.sec { border: 1px solid var(--border); border-radius: var(--r-sm); padding: 10px 11px; margin-bottom: 9px; background: rgba(255,255,255,.55); box-shadow: 0 2px 4px rgba(53,55,66,.03); }
.sec.locked { border-color: var(--acc-line); box-shadow: inset 3px 0 0 var(--acc-a); }
.sec-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.sec-head b { font-weight: 600; flex: 1; min-width: 100px; font-size: 12px; }
.sec-head select { min-height: 27px; font-size: 10px; }
.sec .body { white-space: pre-wrap; color: var(--read); margin-top: 7px; font-size: 12px; line-height: 1.65; }
.sec textarea { margin-top: 7px; min-height: 110px; }
.find { padding: 8px 10px; border-left: 3px solid var(--dim); background: rgba(255,255,255,.28); border-radius: 0 var(--r-in) var(--r-in) 0; margin-bottom: 7px; font-size: 11px; overflow-wrap: anywhere; }
#chatPane .find, #play .find { background: rgba(255,255,255,.03); }
.find.bad { border-left-color: var(--bad); } .find.warn { border-left-color: var(--warn); } .find.info { border-left-color: var(--info); }
.find .where { color: var(--mut); font-size: 10px; margin-bottom: 2px; }
.kv { display: grid; grid-template-columns: 105px minmax(0,1fr); gap: 5px 10px; font-size: 11px; margin: 10px 0; }
pre.map { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 10.5px; line-height: 1.55; color: var(--read); background: rgba(53,55,66,.05); border: 1px solid var(--border); border-radius: var(--r-in); padding: 10px; max-height: 50vh; overflow: auto; }
.avatar { width: 150px; aspect-ratio: 2/3; object-fit: cover; border-radius: 4px 12px 4px 4px; border: 1px solid var(--border2); background: #dfe4e8; }
.export-art { position: relative; width: 150px; flex: none; }
.export-art .avatar { display: block; }
.export-art .art-slot { margin-top: 5px; color: var(--dim); }
.export-art.is-mock .avatar { filter: saturate(.88); }
.export-art.is-mock::after { content: "MÔ PHỎNG"; position: absolute; top: 7px; left: 7px; padding: 3px 5px; border-radius: 3px; background: rgba(53,55,66,.78); color: #eef1f3; font: 8px/1 var(--mono); letter-spacing: .1em; }

/* Roleplay room */
#play { background: radial-gradient(800px 480px at 70% 20%, rgba(127,136,150,.18), transparent 70%), #262a31; }
.play-grid { display: grid; grid-template-columns: 210px minmax(0,1fr); height: 100%; min-height: 0; }
.play-side { border-right: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; background: rgba(15,17,22,.22); }
.play-main { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
#plMsgs { padding: 20px clamp(14px,3vw,34px); gap: 17px; }
.rp { max-width: 780px; width: calc(100% - 4px); align-self: center; color: var(--read); border-style: solid; border-width: 20px; border-image: url('/assets/chat-frame.svg') 32 fill / 20px / 0 stretch; }
.rp .name { font: 500 italic 17px/1.3 var(--name); color: #c6cfd5; }
.rp .text { color: var(--read); white-space: pre-wrap; font-size: 12.5px; line-height: 1.7; }
.rp .text q, .rp .text .q { color: var(--txt); font-weight: 500; quotes: none; }
.rp .text em { color: #a8b2b9; }
.rp iframe { width: 100%; border: 0; border-radius: 6px; background: transparent; display: block; min-height: 60px; }
.swipe { display: flex; align-items: center; gap: 6px; font: 10px/1 var(--mono); color: var(--dim); margin-top: 7px; }
.swipe button { background: rgba(175,186,193,.07); border: 1px solid var(--border); border-radius: 7px; color: var(--read); min-width: 29px; min-height: 27px; }
#plComp { border-top: 1px solid var(--border); padding: 10px 12px; background: rgba(15,17,22,.26); }
#plComp .comp { max-width: 850px; margin: auto; }
#plComp > .hint { display: block; max-width: 850px; margin: 5px auto 0; }
.drawer { border-top: 1px solid var(--border); max-height: 42%; overflow: auto; padding: 10px 13px; background: rgba(12,14,19,.34); }
.pmsg { border: 1px solid var(--border); border-radius: var(--r-in); padding: 6px 8px; margin-bottom: 6px; font-size: 11px; }
.pmsg summary { cursor: pointer; color: var(--read); }
.pmsg pre { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 220px; overflow: auto; }

/* Overlay, dialogs and feedback */
.ov { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 50; background: rgba(26,29,35,.58); backdrop-filter: blur(6px); display: flex; flex-direction: column; overflow-y: auto; box-sizing: border-box; padding: 12px; padding-top: max(12px, env(safe-area-inset-top)); padding-bottom: max(12px, env(safe-area-inset-bottom)); animation: fade-in .16s ease-out; }
.modal {
  color-scheme: dark;
  --border: rgba(175,186,193,.15); --border2: rgba(175,186,193,.25); --in-bg: rgba(17,19,24,.34); --in-line: rgba(175,186,193,.22); --in-line-h: rgba(198,207,213,.60);
  --acc: #afbac1; --on-acc: #23262c; --acc-h: #c6cfd5; --acc-a: rgba(175,186,193,.13); --acc-line: rgba(175,186,193,.5);
  --txt: #eef1f3; --read: #c3ccd2; --mut: #aab5be; --dim: #99a5af; --ok: #93c2ab; --bad: #d99a9e; --info: #9dbccf; --warn: #c9ae84;
  margin: auto; width: min(680px,100%); max-height: 86vh; max-height: calc(100dvh - 24px); overflow: auto;
  background: radial-gradient(500px 220px at 100% 0, rgba(127,136,150,.14), transparent 75%), var(--pop); color: var(--txt);
  border: 1px solid var(--border2); border-radius: var(--r-lg); box-shadow: 0 24px 80px rgba(18,20,25,.5), inset 0 1px 0 rgba(255,255,255,.05); padding: 18px; animation: modal-in .2s cubic-bezier(.2,.8,.2,1);
}
.modal.wide { width: min(960px,100%); }
.modal.compact { width: min(440px,100%); }
.dialog-message { margin: 8px 0 0; color: var(--read); white-space: pre-line; overflow-wrap: anywhere; }
.notice-dialog .modal-foot { margin-top: 20px; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; flex-wrap: wrap; }
.prof { border: 1px solid var(--border); border-radius: var(--r-sm); padding: 10px 11px; margin-bottom: 9px; background: rgba(255,255,255,.025); }
#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 80; max-width: min(390px,calc(100% - 32px)); }
.toast { background: #2f333b; color: #eef1f3; border: 1px solid rgba(175,186,193,.26); border-radius: var(--r-sm); padding: 10px 13px; box-shadow: 0 12px 35px rgba(24,26,31,.34); font-size: 11px; animation: toast-in .2s ease-out; }
.toast.bad { border-color: rgba(217,154,158,.55); } .toast.ok { border-color: rgba(147,194,171,.5); }

/* Skill branch strip & Regex Studio preview */
.skill-strip { display: flex; flex-direction: column; gap: 5px; padding: 7px 12px; border-bottom: 1px solid var(--border); background: rgba(15,17,22,.14); }
.skill-pills { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.skill-pills::-webkit-scrollbar { display: none; }
.skill-pill { display: inline-flex; align-items: center; gap: 5px; flex: none; padding: 3px 9px; min-height: 26px; border-radius: 999px; border: 1px solid var(--border); background: rgba(255,255,255,.03); color: var(--mut); font-size: 11px; white-space: nowrap; transition: .15s; }
.skill-pill:hover { color: var(--txt); border-color: var(--border2); }
.skill-pill.on { color: var(--txt); background: var(--acc-a); border-color: var(--acc-line); }
.skill-pill span { font: 9px/1 var(--mono); color: var(--dim); }
.skill-pill.on span { color: var(--txt); }
.skill-pill.fork { padding: 0 4px 0 9px; border-style: dashed; }
.skill-pill.fork > button:first-child { background: none; border: 0; color: inherit; display: inline-flex; align-items: center; gap: 5px; padding: 3px 2px; }
.skill-pill .pill-x { background: none; border: 0; color: var(--dim); padding: 2px 5px; font-size: 12px; line-height: 1; border-radius: 99px; }
.skill-pill .pill-x:hover { color: var(--bad); background: rgba(217,154,158,.14); }
.ctx-btn.on { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 42%, transparent); }
.msg-acts { display: flex; justify-content: flex-end; gap: 6px; margin-top: 6px; }
.msg-act { border: 0; background: rgba(53,55,66,.08); color: #5f6672; font: 500 10px/1.2 var(--mono); padding: 3px 7px; border-radius: 6px; transition: .15s; }
.msg-act:hover { background: rgba(78,83,92,.16); color: #353742; }
.skill-desc { font-size: 10.5px; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rs-frame { border: 1px solid var(--border2); border-radius: var(--r-md); padding: 10px; background: radial-gradient(500px 260px at 80% 0, rgba(127,136,150,.15), transparent 70%), #262a31; overflow: auto; }
.rs-frame.mobile { max-width: 395px; margin: 0 auto; border-width: 2px; border-radius: 22px; }
.rs-frame iframe { width: 100%; border: 0; display: block; min-height: 90px; background: transparent; border-radius: 8px; }
.rs-text { color: #dfe4e8; white-space: pre-wrap; font-size: 12.5px; line-height: 1.65; }
.rs-refs { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.rs-ref { position: relative; margin: 0; width: 108px; border: 1px solid var(--border2); border-radius: var(--r-sm); overflow: hidden; background: var(--paper); }
.rs-ref img { display: block; width: 100%; height: 74px; object-fit: cover; background: #262a31; }
.rs-ref figcaption { padding: 4px 6px; font: 9.5px/1.3 var(--mono); color: var(--mut); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rs-ref-del { position: absolute; top: 4px; right: 4px; width: 20px; height: 20px; border: 0; border-radius: 99px; background: rgba(43,46,54,.80); color: #fff; font-size: 13px; line-height: 1; display: grid; place-items: center; }
.rs-ref-del:hover { background: var(--bad); }
.rs-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 270px), 1fr)); gap: 10px; align-items: start; }
.rs-col { min-width: 0; }
.rs-sub { margin-top: 4px; padding: 6px 8px; border: 1px dashed var(--border); border-radius: var(--r-in); background: rgba(255,255,255,.35); }
.rs-chat { max-height: 220px; overflow: auto; display: flex; flex-direction: column; gap: 6px; margin-top: 8px; padding: 8px; border: 1px solid var(--border); border-radius: var(--r-in); background: rgba(53,55,66,.04); }
.rs-turn { padding: 7px 9px; border-radius: 8px; font-size: 12px; }
.rs-turn.user { background: var(--acc-a); border: 1px solid color-mix(in srgb, var(--acc) 22%, transparent); }
.rs-turn.assistant { background: rgba(255,255,255,.58); border: 1px solid var(--border); }
.rs-turn .who { font: 600 9.5px/1.3 var(--mono); text-transform: uppercase; letter-spacing: .06em; color: var(--mut); margin-bottom: 3px; }

/* Unified Studio subtabs + Image Studio */
.studio-bar { display: flex; align-items: center; gap: 8px; padding: 7px 13px; border-bottom: 1px solid var(--border); background: rgba(251,252,253,.88); flex: none; }
.studio-mount { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.is-lora-list { display: flex; flex-direction: column; gap: 5px; max-height: 220px; overflow: auto; }
.is-lora-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 5px 8px; border: 1px solid var(--border); border-radius: var(--r-in); background: rgba(255,255,255,.48); }
.is-lora-row.on { border-color: var(--acc-line); background: var(--acc-a); }
.is-lora-name { font-weight: 600; font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 200px; }
.is-lora-w { width: 66px !important; padding: 4px 6px !important; font: 11px var(--mono); }
.is-lora-trig { flex: 1; min-width: 140px; padding: 4px 7px !important; font-size: 11px; }
.is-prog { display: flex; align-items: center; gap: 10px; margin: 0 0 10px; }
.is-prog-bar { flex: 1; height: 7px; border-radius: 99px; background: rgba(53,55,66,.12); overflow: hidden; }
.is-prog-bar i { display: block; height: 100%; background: var(--acc); border-radius: 99px; transition: width .25s ease; }
.is-hero { margin-top: 10px; text-align: center; background: #262a31; border-radius: var(--r-sm); padding: 10px; }
.is-hero img { max-width: 100%; max-height: 520px; border-radius: 8px; display: inline-block; }
.is-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 190px), 1fr)); gap: 10px; }
.is-gcard { margin: 0; border: 1px solid var(--border); border-radius: var(--r-sm); overflow: hidden; background: var(--paper); display: flex; flex-direction: column; }
.is-gcard img { width: 100%; aspect-ratio: 3/4; object-fit: cover; cursor: pointer; background: #262a31; }
.is-gcard figcaption { padding: 8px; }

/* Composer effort + live context size bar (Claude Code / OpenCode style) */
.comp-bar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 7px; }
.effort-wrap { display: inline-flex; align-items: center; }
.effort-sel { width: auto; min-height: 26px; padding: 3px 22px 3px 8px; font: 500 10.5px/1.2 var(--mono); color: var(--read); border: 1px solid var(--border); border-radius: 999px; background: rgba(255,255,255,.04); }
.effort-sel:hover { border-color: var(--border2); color: var(--txt); }
.ctx-btn { display: inline-flex; align-items: center; gap: 6px; min-height: 26px; padding: 3px 9px; border-radius: 999px; border: 1px solid var(--border); background: rgba(255,255,255,.035); color: var(--mut); font: 500 10px/1.2 var(--mono); transition: .15s; }
.ctx-btn:hover:not(:disabled) { border-color: var(--border2); color: var(--txt); }
.ctx-btn.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 45%, transparent); }
.ctx-btn.bad { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 50%, transparent); }
.ctx-bar { width: 34px; height: 5px; border-radius: 99px; background: rgba(255,255,255,.09); overflow: hidden; display: inline-block; flex: none; }
.ctx-bar i { display: block; height: 100%; background: var(--ok); border-radius: 99px; transition: width .2s ease; }
.ctx-btn.warn .ctx-bar i { background: var(--warn); }
.ctx-btn.bad .ctx-bar i { background: var(--bad); }
.comp-model { margin-left: auto; max-width: 190px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--dim); font: 500 10px/1.2 var(--mono); }

/* Coding-harness style Thinking & Tool Execution Trace box */
.harness-box { margin: 4px 0 10px; border: 1px solid var(--border); border-left: 2px solid color-mix(in srgb, var(--lavender) 55%, transparent); border-radius: var(--r-sm); background: rgba(14,16,21,.30); overflow: hidden; }
.harness-box.studio { background: rgba(53,55,66,.05); border-left-color: var(--acc-line); }
.harness-head { display: flex; align-items: center; gap: 7px; padding: 6px 10px; cursor: pointer; list-style: none; user-select: none; color: var(--mut); font: 500 11px/1.35 var(--mono); transition: background .15s, color .15s; }
.harness-head::-webkit-details-marker { display: none; }
.harness-head:hover { background: rgba(175,186,193,.08); color: var(--txt); }
.harness-head::after { content: "▸"; margin-left: 4px; color: var(--dim); font-size: 10px; transition: transform .15s; }
.harness-box[open] > .harness-head::after { transform: rotate(90deg); }
.harness-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--lavender); flex: none; opacity: .8; }
.harness-box.live .harness-dot { background: var(--warn); opacity: 1; animation: breathe 1.1s ease-in-out infinite; }
.harness-box.live .harness-label { color: var(--txt); }
.harness-meta { margin-left: auto; color: var(--dim); font-size: 10px; white-space: nowrap; }
.harness-body { padding: 4px 10px 9px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 6px; }
.harness-steps { display: flex; flex-direction: column; gap: 3px; }
.harness-step { display: flex; align-items: center; gap: 7px; padding: 4px 7px; border-radius: 6px; background: rgba(255,255,255,.03); font: 10.5px/1.35 var(--mono); color: var(--read); min-width: 0; }
.harness-step .step-ic { width: 14px; text-align: center; flex: none; color: var(--ok); }
.harness-step.running .step-ic { color: var(--warn); animation: breathe 1s infinite; }
.harness-step.err .step-ic { color: var(--bad); }
.harness-step .step-name { font-weight: 600; color: var(--txt); flex: none; }
.harness-step .step-arg { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--dim); }
.harness-step .step-ms { margin-left: auto; flex: none; color: var(--dim); font-size: 9.5px; white-space: nowrap; }
.harness-thought { margin: 0; padding: 8px 9px; max-height: 240px; overflow: auto; white-space: pre-wrap; word-break: break-word; border-radius: 7px; background: rgba(10,12,17,.30); color: var(--mut); font: 11px/1.6 var(--mono); }
.harness-box.studio .harness-thought { background: rgba(255,255,255,.68); color: var(--read); }

#mobileSwitch { display: none; }
@keyframes message-in { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(.985); } to { opacity: 1; transform: none; } }
@keyframes toast-in { from { opacity: 0; transform: translateX(8px); } to { opacity: 1; transform: none; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes dots { 0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75%,100% { content: "..."; } }
@keyframes breathe { 50% { opacity: .35; box-shadow: 0 0 2px currentColor; } }

@container (max-width: 500px) {
  .welcome { grid-template-columns: 1fr; gap: 16px; max-width: 360px; }
  .welcome-art { min-height: 145px; max-height: 165px; }
  .welcome-art img { object-position: center 31%; }
  .welcome h2 { font-size: 26px; }
}
@media (min-width: 901px) { .comp textarea { font-size: 13px; } }
@media (max-width: 1240px) {
  #top { gap: 8px; padding-left: 12px; padding-right: 12px; }
  .wordmark { font-size: 24px; }
  .ver { display: none; }
  #tabs button { padding: 6px 8px; }
  #tabs button::after { display: none; }
  .pick { max-width: 185px; min-width: 130px; }
  #main { grid-template-columns: minmax(330px,.86fr) minmax(410px,1.14fr); padding: 11px; gap: 11px; }
  .chat-state { display: none; }
}
@media (max-width: 1050px) and (min-width: 901px) {
  .wordmark { font-size: 22px; }
  .action-label { display: none; }
  .top-action { width: 36px; padding: 0; }
  #tabs button svg { display: none; }
  .pick { max-width: 160px; }
}
@media (max-width: 900px) {
  :root { --top: 106px; --mobile-nav: 62px; }
  #top { display: grid; grid-template-columns: auto minmax(0,1fr) auto; grid-template-rows: 55px 45px; gap: 0 8px; padding: env(safe-area-inset-top) 9px 0; }
  #top::after { left: 9px; right: 9px; }
  .ver { display: none; }
  .wordmark { font-size: 21px; }
  .pick { max-width: none; width: 100%; min-width: 0; height: 38px; }
  .pick-copy small { display: none; }
  #tabs { grid-column: 1/-1; grid-row: 2; width: 100%; margin: 0; justify-content: flex-start; overflow-x: auto; padding: 4px 0 6px; scrollbar-width: none; border-top: 1px solid rgba(53,55,66,.08); }
  #tabs::-webkit-scrollbar { display: none; }
  #tabs button { flex: 1 0 auto; min-height: 34px; padding: 5px 10px; }
  #tabs button::after { display: none; }
  .top-actions { grid-column: 3; grid-row: 1; }
  #main { grid-template-columns: 1fr; height: calc(100dvh - var(--top) - var(--mobile-nav) - env(safe-area-inset-top) - env(safe-area-inset-bottom)); padding: 8px; gap: 8px; }
  #main.playing { height: calc(100dvh - var(--top) - env(safe-area-inset-top)); }
  #main:not(.playing) > .pane:not(.mshow) { display: none; }
  #mobileSwitch { display: flex; position: fixed; left: 0; right: 0; bottom: 0; height: calc(var(--mobile-nav) + env(safe-area-inset-bottom)); padding: 6px 10px max(6px,env(safe-area-inset-bottom)); gap: 7px; background: rgba(242,244,246,.96); backdrop-filter: blur(16px); border-top: 1px solid var(--border2); z-index: 20; }
  #mobileSwitch button { flex: 1; display: flex; align-items: center; justify-content: center; gap: 7px; border-radius: 10px; border: 1px solid transparent; background: none; min-height: 42px; color: var(--mut); font-size: 11px; font-weight: 600; }
  #mobileSwitch button.on { color: var(--acc); background: var(--acc-a); border-color: var(--acc-line); }
  .pane { border-radius: 14px; }
  .chat-head { min-height: 51px; }
  .mode-wrap > .eyebrow { display: none; }
  .clear-chat span { display: none; }
  .clear-chat { width: 31px; padding: 0; }
  .msgs { padding: 14px 13px 18px; scrollbar-gutter: auto; }
  .mes { max-width: 94%; }
  .mes.bot { max-width: 100%; }
  .key-hint { display: none; }
  .split, .play-grid { grid-template-columns: 1fr; }
  .play-side { border-right: 0; border-bottom: 1px solid var(--border); max-height: 190px; }
  .play-side .scroll { max-height: 78px; }
  .play-side > .pad { padding: 7px 10px; }
  .play-side > .pad .hint { display: none; }
  #plMsgs { padding: 14px 8px; }
  .rp { border-width: 17px; border-image-width: 17px; }
  input, select, textarea { font-size: 16px; }
  #modeSeg select { font-size: 12px; }
  .seg button, .subtabs button { font-size: 12px; min-height: 30px; }
  .btn { min-height: 38px; }
  .comp .btn { min-height: 38px; }
  .btn.sm { min-height: 32px; }
  .pad { padding: 12px; }
  #toasts { bottom: calc(var(--mobile-nav) + 12px + env(safe-area-inset-bottom)); }
}
@media (max-width: 560px) {
  .wordmark { font-size: 18px; padding-right: 8px; }
  .wordmark::after { width: 6px; height: 6px; }
  .top-action { width: 35px; min-height: 35px; padding: 0; }
  .action-label { display: none; }
  #top { grid-template-columns: auto minmax(0,1fr) auto; }
  #tabs button { gap: 5px; padding: 5px 8px; }
  #tabs button svg { width: 14px; height: 14px; }
  #main { padding: 6px; }
  .chat-head { padding: 7px 8px; gap: 5px; }
  #modeSeg { max-width: calc(100vw - 74px); }
  #modeSeg select { max-width: 145px; }
  .msgs { padding: 12px 10px 16px; }
  .mes.bot { padding-left: 30px; }
  .mes.bot::before { width: 22px; height: 22px; }
  #composer, #plComp { padding: 8px; }
  .comp { gap: 3px; padding: 4px; }
  .send-btn, .stop-btn { width: 38px; padding: 0; }
  .send-btn span, .stop-btn span { display: none; }
  .composer-foot .hint { font-size: 10px; }
  .kv { grid-template-columns: 92px minmax(0,1fr); }
  .export-art, .avatar { width: 125px; }
  .modal { padding: 14px; border-radius: 14px; }
  .tool-preview { max-width: 42vw; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; transition-duration: .01ms !important; }
}

/* Auth page */
.auth-page { min-height: 100dvh; display: grid; place-items: center; padding: 18px; }
.auth-card { width: min(420px, 100%); background: var(--panel); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow); padding: 26px 24px; display: flex; flex-direction: column; gap: 12px; }
.auth-card .brand { margin-bottom: 4px; }
.auth-card form { display: flex; flex-direction: column; gap: 2px; }
.auth-card .modal-foot { justify-content: space-between; }
