/* Tessolve AI Workbench
   Brand colours live in the first block. Replace them with values from the
   official Tessolve brand guide if they differ. */
:root {
  --brand-deep: #071a33;   /* sidebar, headings */
  --brand: #0b3a73;        /* primary actions, links */
  --brand-soft: #dfe8f5;   /* selected rows, tags */
  --accent: #e8531f;       /* send button, highlights, wafer fail bins */
  --accent-soft: #fde5da;

  --bg: #f2f4f7;
  --surface: #ffffff;
  --surface-2: #f6f8fb;
  --line: #d9e0ea;
  --line-strong: #b9c4d3;
  --text: #13203a;
  --muted: #5a6a82;
  --ok: #1d8a57;
  --warn: #b7800a;
  --bad: #c23b2e;
  --focus: #2f7bea;

  --font: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --r-s: 6px;
  --r-m: 10px;
  --r-l: 16px;
  --shadow: 0 1px 2px rgba(7, 26, 51, .06), 0 8px 24px rgba(7, 26, 51, .08);
  --sidebar-w: 284px;
}

[data-theme="dark"] {
  --brand: #7fb0ff;
  --brand-soft: #16335c;
  --accent-soft: #3a2016;
  --bg: #0a1424;
  --surface: #0f1c31;
  --surface-2: #13233c;
  --line: #213655;
  --line-strong: #2e4a70;
  --text: #e5ecf6;
  --muted: #93a4bd;
  --ok: #44c28a;
  --warn: #e0b04a;
  --bad: #f07a6d;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px rgba(0, 0, 0, .35);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 400 15px/1.55 var(--font); -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--brand); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
h1, h2, h3 { font-stretch: 88%; letter-spacing: -.01em; line-height: 1.2; margin: 0; }

/* ------------------------------------------------------------------ buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 36px; padding: 0 14px; border-radius: var(--r-s);
  border: 1px solid var(--line-strong); background: var(--surface); cursor: pointer;
  font-weight: 500; font-size: 14px; white-space: nowrap; text-decoration: none; color: var(--text);
}
.btn:hover { border-color: var(--brand); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
[data-theme="dark"] .btn.primary { color: #06152b; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad); }
.btn.danger.solid { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.small { height: 30px; padding: 0 10px; font-size: 13px; }
.btn.block { width: 100%; height: 42px; }
.icon-btn {
  width: 34px; height: 34px; display: inline-grid; place-items: center; border-radius: var(--r-s);
  border: 0; background: transparent; cursor: pointer; color: inherit;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn svg, .btn svg { width: 18px; height: 18px; flex: none; }

/* ------------------------------------------------------------------- forms */
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 13px; font-weight: 600; }
.field .hint { font-size: 12.5px; color: var(--muted); }
input[type=text], input[type=email], input[type=password], input[type=search], textarea, select {
  width: 100%; border: 1px solid var(--line-strong); background: var(--surface);
  border-radius: var(--r-s); padding: 9px 11px; outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
textarea { resize: vertical; min-height: 90px; line-height: 1.5; }
.form-error { color: var(--bad); font-size: 13.5px; min-height: 20px; margin: 0 0 10px; }

/* -------------------------------------------------------------------- auth */
.auth { min-height: 100dvh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-art {
  background: var(--brand-deep); color: #dbe6f7; position: relative; overflow: hidden;
  display: flex; flex-direction: column; justify-content: space-between; padding: 44px 48px;
}
.auth-art .brand-row { color: #fff; }
.wafer { width: min(78%, 460px); align-self: center; margin: 24px 0; }
.wafer .edge { fill: #0d2a52; stroke: #2a4f82; stroke-width: 2; }
.wafer .die { fill: #1d4577; }
.wafer .die.pass { fill: #2b5d99; }
.wafer .die.marginal { fill: #c9962e; }
.wafer .die.fail { fill: var(--accent); }
.wafer .die { animation: probe .35s ease-out both; animation-delay: var(--d); }
@keyframes probe { from { opacity: 0; transform: scale(.4); } to { opacity: 1; transform: none; } }
.wafer .die { transform-box: fill-box; transform-origin: center; }
.auth-art h1 { font-size: clamp(26px, 3vw, 38px); color: #fff; max-width: 18ch; font-weight: 650; }
.auth-art p { max-width: 44ch; color: #a9bddb; margin: 12px 0 0; }
.legend { display: flex; gap: 18px; font-size: 12.5px; color: #a9bddb; margin-top: 18px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.auth-panel { display: grid; place-items: center; padding: 32px 20px; }
.auth-card { width: min(400px, 100%); }
.auth-card h2 { font-size: 28px; margin: 28px 0 6px; }
.auth-card > p { margin: 0 0 24px; }
.auth-card .switch { text-align: center; font-size: 14px; margin-top: 18px; color: var(--muted); }

.brand-row { display: flex; align-items: center; gap: 10px; font-size: 16px; }
.brand-row svg { width: 30px; height: 30px; flex: none; }
.brand-row b { font-weight: 650; }
.brand-row span { line-height: 1.15; }

/* ------------------------------------------------------------------- shell */
.shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; height: 100dvh; }
.sidebar {
  background: var(--brand-deep); color: #d6e1f2; display: flex; flex-direction: column;
  min-height: 0; border-right: 1px solid #0f2a4f;
}
.sidebar .brand-row { padding: 18px 18px 14px; color: #fff; }
.side-actions { padding: 0 14px 10px; display: grid; gap: 10px; }
.side-actions .btn { background: #11325e; border-color: #1f4a80; color: #fff; justify-content: flex-start; }
.side-actions .btn:hover { background: #164074; }
.side-search { position: relative; }
.side-search input {
  background: #0b2445; border-color: #1c3d68; color: #fff; padding-left: 34px; height: 36px;
}
.side-search input::placeholder { color: #7f98bb; }
.side-search svg { position: absolute; left: 10px; top: 9px; width: 16px; height: 16px; color: #7f98bb; }
.conv-list { flex: 1; overflow-y: auto; padding: 4px 8px 12px; scrollbar-width: thin; scrollbar-color: #24466f transparent; }
.conv-group { font-size: 12px; color: #7f98bb; padding: 14px 10px 6px; font-weight: 600; }
.conv {
  display: flex; align-items: center; gap: 6px; border-radius: var(--r-s);
  padding: 7px 6px 7px 10px; color: #d6e1f2; text-decoration: none; font-size: 14px;
}
.conv:hover { background: #0f2c52; }
.conv.active { background: #173a68; color: #fff; }
.conv .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv .acts { display: none; }
.conv:hover .acts, .conv.active .acts, .conv:focus-within .acts { display: flex; }
.conv .icon-btn { width: 26px; height: 26px; color: #9fb4d3; }
.conv .icon-btn:hover { background: #21497c; color: #fff; }
.conv .icon-btn svg { width: 15px; height: 15px; }
.conv-empty { padding: 16px 12px; color: #7f98bb; font-size: 13.5px; }
.side-foot { border-top: 1px solid #12305a; padding: 12px 14px; display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--accent); color: #fff; font-weight: 700; font-size: 13px;
}
.side-foot .who { flex: 1; min-width: 0; line-height: 1.25; }
.side-foot .who b { display: block; color: #fff; font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-foot .who small { color: #7f98bb; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.side-foot .icon-btn { color: #9fb4d3; }
.side-foot .icon-btn:hover { background: #12305a; color: #fff; }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.topbar {
  height: 56px; flex: none; display: flex; align-items: center; gap: 12px; padding: 0 18px;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.topbar .menu-btn { display: none; }
.tabs { display: flex; gap: 4px; }
.tabs a {
  text-decoration: none; color: var(--muted); font-weight: 500; font-size: 14px;
  padding: 7px 12px; border-radius: var(--r-s);
}
.tabs a:hover { color: var(--text); background: var(--surface-2); }
.tabs a.on { color: var(--text); background: var(--brand-soft); }
.topbar .spacer { flex: 1; }
.meter {
  display: flex; align-items: center; gap: 10px; height: 36px; padding: 0 12px; border-radius: var(--r-s);
  border: 1px solid var(--line); background: var(--surface-2); cursor: pointer; font-size: 13px;
}
.meter:hover { border-color: var(--brand); }
.meter .bar { width: 90px; height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; display: flex; }
.meter .bar span { height: 100%; }
.meter .bar .m { background: var(--accent); }
.meter .bar .o { background: var(--brand); }
.meter b { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.meter .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
.meter .dot.off { background: var(--bad); }

#view { flex: 1; min-height: 0; overflow: auto; }

/* ----------------------------------------------------------------- library */
.library { max-width: 1240px; margin: 0 auto; padding: 32px 28px 60px; }
.lib-head { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 16px 32px; margin-bottom: 22px; }
.lib-head .intro { flex: 1 1 420px; }
.lib-head h1 { font-size: 30px; font-weight: 650; }
.lib-head p { margin: 8px 0 0; color: var(--muted); max-width: 62ch; }
.lib-tools { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; flex: 1; }
.chip {
  border: 1px solid var(--line-strong); background: var(--surface); border-radius: 999px;
  padding: 5px 13px; font-size: 13.5px; cursor: pointer; white-space: nowrap;
}
.chip:hover { border-color: var(--brand); }
.chip[aria-pressed="true"] { background: var(--brand-deep); color: #fff; border-color: var(--brand-deep); }
[data-theme="dark"] .chip[aria-pressed="true"] { background: var(--brand); color: #06152b; border-color: var(--brand); }
.lib-tools input[type=search] { width: 240px; height: 34px; }
.offline {
  border: 1px solid var(--bad); background: color-mix(in srgb, var(--bad) 8%, var(--surface));
  color: var(--text); border-radius: var(--r-m); padding: 12px 16px; margin-bottom: 16px; font-size: 14px;
}

.sheet { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-m); overflow: hidden; }
.sheet-row {
  display: grid; align-items: center; gap: 18px; padding: 16px 20px;
  grid-template-columns: minmax(170px, 1.1fr) minmax(240px, 2.3fr) 190px 130px 150px;
  border-top: 1px solid var(--line);
}
.sheet-row:first-child { border-top: 0; }
.sheet-head {
  background: var(--surface-2); font-size: 12.5px; font-weight: 600; color: var(--muted);
  padding-top: 10px; padding-bottom: 10px;
}
.m-name b { display: block; font-size: 15.5px; font-weight: 650; }
.m-name code { font: 12.5px var(--mono); color: var(--muted); }
.m-name .by { font-size: 12.5px; color: var(--muted); display: block; margin-top: 2px; }
.m-good p { margin: 0 0 8px; font-size: 14px; }
.tags { display: flex; flex-wrap: wrap; gap: 5px; }
.tag {
  font-size: 12px; padding: 2px 8px; border-radius: 4px; background: var(--brand-soft); color: var(--text);
}
.tag.v { background: var(--accent-soft); }
.fit-bar { height: 8px; border-radius: 4px; background: var(--surface-2); border: 1px solid var(--line); display: flex; overflow: hidden; }
.fit-bar span { height: 100%; }
.fit-used { background: var(--line-strong); }
.fit-need { background: var(--brand); }
.fit.warn .fit-need { background: var(--warn); }
.fit.bad .fit-need { background: var(--bad); }
.fit.loaded .fit-need { background: var(--ok); }
.fit-label { font-size: 13px; margin-top: 6px; line-height: 1.35; }
.fit-label b { font-variant-numeric: tabular-nums; }
.fit-label span { display: block; color: var(--muted); font-size: 12.5px; }
.fit.warn .fit-label span { color: var(--warn); }
.fit.bad .fit-label span { color: var(--bad); }
.status { font-size: 13.5px; line-height: 1.4; }
.status .s { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.status .s::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--line-strong); }
.status .s.ready::before { background: var(--brand); }
.status .s.loaded::before { background: var(--ok); }
.status .s.busy::before { background: var(--warn); }
.tag.best { background: var(--brand-deep); color: #fff; font-weight: 600; }
[data-theme="dark"] .tag.best { background: var(--brand); color: #06152b; }
.extra-head { border-top: 1px solid var(--line-strong); grid-template-columns: minmax(170px, 1.1fr) 3fr; }
.mem-row { border-bottom: 1px solid var(--line); padding-bottom: 10px; display: grid; gap: 8px; }
.mem-top { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; }
.mem-top small { color: var(--muted); display: block; font-size: 12px; }
.mem-ctl { display: flex; gap: 8px; }
.mem-ctl select { flex: 1; height: 30px; padding: 2px 8px; font-size: 13px; }
.status small { display: block; color: var(--muted); font-size: 12.5px; }
.m-act { display: grid; gap: 6px; justify-items: end; }
.m-act .note { font-size: 12px; color: var(--muted); text-align: right; }
.progress { width: 100%; }
.progress .track { height: 6px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 3px; overflow: hidden; }
.progress .fill { height: 100%; background: var(--accent); transition: width .4s; }
.progress small { display: block; font-size: 12px; color: var(--muted); margin-top: 4px; text-align: right; }
.sheet.simple .m-mem, .sheet.simple .h-mem { display: none; }
.sheet.simple .sheet-row { grid-template-columns: minmax(170px, 1fr) minmax(260px, 2.6fr) 190px 150px; }
.empty-state { padding: 40px 20px; text-align: center; color: var(--muted); }

/* -------------------------------------------------------------------- chat */
.chat { display: flex; flex-direction: column; height: 100%; }
.chat-head {
  display: flex; align-items: center; gap: 10px; padding: 10px 20px; border-bottom: 1px solid var(--line);
  background: var(--surface); flex-wrap: wrap;
}
.chat-head .title {
  flex: 1 1 240px; min-width: 0; border: 1px solid transparent; background: transparent; font-weight: 650;
  font-size: 17px; padding: 5px 8px; border-radius: var(--r-s); font-stretch: 90%;
}
.chat-head .title:hover { border-color: var(--line); }
.chat-head .title:focus { border-color: var(--brand); background: var(--surface); }
.model-pick { width: auto; max-width: 240px; height: 34px; padding: 4px 10px; font-size: 14px; }
.settings {
  background: var(--surface-2); border-bottom: 1px solid var(--line); padding: 18px 20px;
  display: grid; grid-template-columns: minmax(200px, 260px) 1fr; gap: 6px 24px;
}
.settings .full { grid-column: 1 / -1; display: flex; gap: 10px; justify-content: flex-end; }
.settings textarea { min-height: 110px; }
.range-row { display: flex; align-items: center; gap: 10px; }
.range-row input { flex: 1; accent-color: var(--brand); }
.range-row output { font-variant-numeric: tabular-nums; width: 32px; text-align: right; font-weight: 600; }
.switch-row { display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.switch-row input { accent-color: var(--brand); width: 16px; height: 16px; }

.messages { flex: 1; overflow-y: auto; padding: 24px 20px 12px; scroll-behavior: smooth; }
.thread { max-width: 860px; margin: 0 auto; display: grid; gap: 22px; }
.msg.user { justify-self: end; max-width: min(620px, 88%); display: grid; gap: 6px; justify-items: end; }
.msg.user .bubble {
  background: var(--brand-deep); color: #eef3fb; padding: 11px 15px; border-radius: 14px 14px 4px 14px;
  white-space: pre-wrap; word-wrap: break-word;
}
[data-theme="dark"] .msg.user .bubble { background: #1b3a66; }
.msg.user img { max-width: 220px; max-height: 180px; border-radius: var(--r-s); border: 1px solid var(--line); }
.files { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.file-chip {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; padding: 4px 8px;
  border: 1px solid var(--line); border-radius: var(--r-s); background: var(--surface);
}
.file-chip svg { width: 14px; height: 14px; }
.file-chip button { border: 0; background: none; cursor: pointer; padding: 0 0 0 2px; color: var(--muted); font-size: 15px; line-height: 1; }
.msg.bot { display: grid; grid-template-columns: 30px 1fr; gap: 12px; }
.bot-mark {
  width: 30px; height: 30px; border-radius: 8px; background: var(--surface); border: 1px solid var(--line);
  display: grid; place-items: center;
}
.bot-mark svg { width: 18px; height: 18px; }
.bot-body { min-width: 0; }
.reasoning { margin-bottom: 10px; border-left: 2px solid var(--line-strong); padding-left: 12px; }
.reasoning summary { cursor: pointer; font-size: 13px; color: var(--muted); font-weight: 600; list-style: none; }
.reasoning summary::-webkit-details-marker { display: none; }
.reasoning summary::before { content: "▸ "; }
.reasoning[open] summary::before { content: "▾ "; }
.reasoning .rtext { font-size: 13.5px; color: var(--muted); white-space: pre-wrap; margin-top: 6px; max-height: 320px; overflow: auto; }
.msg-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin-top: 8px; font-size: 12.5px; color: var(--muted); }
.msg-meta .icon-btn { width: 28px; height: 28px; }
.msg-meta .icon-btn svg { width: 15px; height: 15px; }
.msg-error { border: 1px solid var(--bad); color: var(--bad); border-radius: var(--r-s); padding: 8px 12px; font-size: 14px; margin-top: 8px; }
.typing { display: inline-flex; gap: 4px; padding: 8px 0; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .2s; }
.typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

/* Markdown */
.md { overflow-wrap: anywhere; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p, .md ul, .md ol { margin: 0 0 12px; }
.md li { margin: 3px 0; }
.md h1, .md h2, .md h3, .md h4 { margin: 18px 0 8px; font-size: 1.1em; }
.md h1 { font-size: 1.3em; }
.md code { font: .88em var(--mono); background: var(--surface-2); border: 1px solid var(--line); padding: 1px 5px; border-radius: 4px; }
.md pre { position: relative; margin: 0 0 14px; background: #0c1a2e; color: #dce6f5; border-radius: var(--r-m); padding: 34px 16px 14px; overflow-x: auto; }
.md pre code { background: none; border: 0; padding: 0; font-size: 13px; line-height: 1.55; color: inherit; }
.md pre .code-bar { position: absolute; top: 0; left: 0; right: 0; display: flex; justify-content: space-between; align-items: center; padding: 5px 8px 0 14px; font: 12px var(--font); color: #8ea3c2; }
.md pre .code-bar button { background: transparent; border: 1px solid #28415f; color: #c4d3ea; border-radius: 4px; font-size: 12px; padding: 2px 8px; cursor: pointer; }
.md pre .code-bar button:hover { background: #1a2f4d; }
.md table { border-collapse: collapse; margin: 0 0 14px; display: block; overflow-x: auto; font-size: 14px; }
.md th, .md td { border: 1px solid var(--line); padding: 6px 10px; text-align: left; }
.md th { background: var(--surface-2); }
.md blockquote { margin: 0 0 12px; border-left: 3px solid var(--line-strong); padding-left: 12px; color: var(--muted); }
.md a { color: var(--brand); }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
/* highlight.js tokens */
.hljs-keyword, .hljs-selector-tag, .hljs-built_in, .hljs-type { color: #ff9e7a; }
.hljs-string, .hljs-attr, .hljs-template-tag { color: #9fe0a8; }
.hljs-number, .hljs-literal { color: #f5c46b; }
.hljs-comment, .hljs-quote { color: #7288a8; font-style: italic; }
.hljs-title, .hljs-function .hljs-title, .hljs-section { color: #8ec5ff; }
.hljs-meta, .hljs-variable, .hljs-params { color: #d7b8ff; }

.welcome { max-width: 760px; margin: 6vh auto 0; }
.welcome h2 { font-size: 26px; font-weight: 650; }
.welcome > p { color: var(--muted); margin: 8px 0 22px; max-width: 60ch; }
.suggest { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px; }
.suggest button {
  text-align: left; border: 1px solid var(--line); background: var(--surface); border-radius: var(--r-m);
  padding: 12px 14px; cursor: pointer; font-size: 14px; line-height: 1.45;
}
.suggest button:hover { border-color: var(--brand); }

.composer-wrap { padding: 8px 20px 18px; }
.composer {
  max-width: 860px; margin: 0 auto; background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--r-l); padding: 10px 10px 8px 14px; box-shadow: var(--shadow);
}
.composer.drag { border-color: var(--accent); border-style: dashed; }
.composer:focus-within { border-color: var(--brand); }
.composer .pending { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.composer .pending:empty { display: none; }
.composer .pending img { width: 52px; height: 52px; object-fit: cover; border-radius: var(--r-s); border: 1px solid var(--line); }
.thumb { position: relative; }
.thumb button { position: absolute; top: -6px; right: -6px; width: 20px; height: 20px; border-radius: 50%; border: 0; background: var(--brand-deep); color: #fff; cursor: pointer; font-size: 13px; line-height: 1; }
.composer textarea:focus, .composer textarea:focus-visible { box-shadow: none; outline: none; }
.composer textarea {
  border: 0; box-shadow: none; padding: 4px 0; min-height: 26px; max-height: 240px; resize: none; background: transparent;
}
.composer-row { display: flex; align-items: center; gap: 6px; }
.composer-row .hint { flex: 1; font-size: 12px; color: var(--muted); }
.send {
  width: 38px; height: 38px; border-radius: 10px; border: 0; background: var(--accent); color: #fff;
  display: grid; place-items: center; cursor: pointer;
}
.send:disabled { opacity: .45; cursor: not-allowed; }
.send svg { width: 18px; height: 18px; }
.send.stop { background: var(--brand-deep); }
[data-theme="dark"] .send.stop { background: #2a4d7e; }


/* Presentation mode */
.tpl-info { margin-bottom: 14px; font-size: 14px; }
.deck-toggle {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px; border-radius: 999px;
  border: 1px solid var(--line-strong); background: transparent; cursor: pointer; font-size: 13px; color: var(--muted);
}
.deck-toggle svg { width: 15px; height: 15px; }
.deck-toggle:hover { border-color: var(--brand); color: var(--text); }
.deck-toggle[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.deck-n { width: auto; height: 30px; padding: 2px 8px; font-size: 13px; }
.composer.deck { border-color: var(--accent); }
.req-tag { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); }
.req-tag svg { width: 13px; height: 13px; }
.deck-progress { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 14px; }
.file-card {
  display: flex; align-items: center; gap: 14px; max-width: 520px; padding: 14px 16px; margin-bottom: 10px;
  background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: var(--r-m);
}
.fc-icon { width: 40px; height: 40px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; flex: none; }
.fc-icon svg { width: 22px; height: 22px; }
.fc-info { flex: 1; min-width: 0; }
.fc-info b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fc-info small { color: var(--muted); font-size: 12.5px; }
.outline { margin-top: 4px; }
.outline summary { cursor: pointer; font-size: 13px; color: var(--muted); font-weight: 600; }
.outline .md { margin-top: 8px; font-size: 14px; }
@media (max-width: 860px) { .composer-row { flex-wrap: wrap; } .composer-row .hint { order: 5; flex-basis: 100%; } }

/* ------------------------------------------------------------------ drawer */
.drawer-scrim { position: fixed; inset: 0; background: rgba(4, 14, 30, .35); z-index: 40; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(420px, 100%); background: var(--surface);
  z-index: 41; box-shadow: var(--shadow); display: flex; flex-direction: column;
  animation: slide .22s ease-out;
}
@keyframes slide { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.drawer-head { display: flex; align-items: center; gap: 10px; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.drawer-head h2 { font-size: 19px; flex: 1; }
.drawer-body { flex: 1; overflow-y: auto; padding: 20px; display: grid; gap: 24px; align-content: start; }
.machine small { display: block; color: var(--muted); font-size: 13px; }
.big-mem { font-size: 34px; font-weight: 650; font-stretch: 85%; font-variant-numeric: tabular-nums; line-height: 1.1; }
.big-mem span { font-size: 16px; color: var(--muted); font-weight: 500; }
.stack { height: 14px; border-radius: 7px; background: var(--surface-2); border: 1px solid var(--line); display: flex; overflow: hidden; margin: 12px 0 8px; }
.stack .m { background: var(--accent); }
.stack .o { background: var(--brand); }
.key { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12.5px; color: var(--muted); }
.key i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; }
.spark { width: 100%; height: 64px; display: block; margin-top: 10px; }
.spark polyline { fill: none; stroke: var(--brand); stroke-width: 1.8; vector-effect: non-scaling-stroke; }
.spark .area { fill: var(--brand-soft); stroke: none; }
.kv { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.kv div { border: 1px solid var(--line); border-radius: var(--r-m); padding: 10px 12px; }
.kv b { display: block; font-size: 20px; font-weight: 650; font-variant-numeric: tabular-nums; }
.kv small { color: var(--muted); font-size: 12.5px; }
.drawer h3 { font-size: 14px; margin-bottom: 8px; }
.loaded-list { display: grid; gap: 8px; }


/* ------------------------------------------------------------------- admin */
.admin { max-width: 1100px; margin: 0 auto; padding: 32px 28px 60px; display: grid; gap: 28px; }
.admin h1 { font-size: 30px; font-weight: 650; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-m); padding: 20px; }
.panel h2 { font-size: 18px; margin-bottom: 4px; }
.panel > p { margin: 0 0 14px; color: var(--muted); font-size: 14px; }
.inline-form { display: flex; gap: 10px; flex-wrap: wrap; }
.inline-form input { flex: 1 1 260px; }
.inline-form .switch-row input { flex: none; }
.inline-form .switch-row { white-space: nowrap; }
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th { text-align: left; font-size: 12.5px; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data td.num { font-variant-numeric: tabular-nums; }
table.data select { width: auto; padding: 4px 8px; }
.online-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); margin-left: 6px; }
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat-row div { border: 1px solid var(--line); border-radius: var(--r-m); padding: 12px 14px; }
.stat-row b { font-size: 24px; font-weight: 650; display: block; font-variant-numeric: tabular-nums; }
.stat-row small { color: var(--muted); }
.bars { display: flex; align-items: flex-end; gap: 6px; height: 120px; padding-top: 10px; border-bottom: 1px solid var(--line); }
.bars div { flex: 1; background: var(--brand); border-radius: 3px 3px 0 0; min-height: 2px; position: relative; }
.bars div:hover { background: var(--accent); }
.bar-labels { display: flex; gap: 6px; font-size: 11px; color: var(--muted); margin-top: 4px; }
.bar-labels span { flex: 1; text-align: center; }

/* ------------------------------------------------------------ modal, toast */
.modal-scrim { position: fixed; inset: 0; background: rgba(4, 14, 30, .45); display: grid; place-items: center; z-index: 60; padding: 20px; }
.modal { background: var(--surface); border-radius: var(--r-l); box-shadow: var(--shadow); width: min(440px, 100%); padding: 22px; }
.modal h2 { font-size: 19px; margin-bottom: 8px; }
.modal p { margin: 0 0 18px; color: var(--muted); }
.modal .row { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }
#toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); display: grid; gap: 8px; z-index: 70; }
.toast { background: var(--brand-deep); color: #fff; padding: 10px 16px; border-radius: var(--r-m); box-shadow: var(--shadow); font-size: 14px; max-width: 90vw; }
.toast.error { background: var(--bad); }

/* -------------------------------------------------------------- responsive */
@media (max-width: 1080px) {
  .sheet-row { grid-template-columns: minmax(150px, 1fr) minmax(200px, 1.7fr) 160px 150px 130px; gap: 14px; }
}
@media (max-width: 860px) {
  .auth { grid-template-columns: 1fr; }
  .auth-art { padding: 28px 24px; }
  .auth-art .wafer { width: 180px; margin: 16px 0; align-self: flex-start; }
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: min(300px, 86vw); z-index: 50; transform: translateX(-100%); transition: transform .2s; }
  .shell.nav-open .sidebar { transform: none; box-shadow: var(--shadow); }
  .shell.nav-open::after { content: ""; position: fixed; inset: 0; background: rgba(4, 14, 30, .35); z-index: 45; }
  .topbar .menu-btn { display: inline-grid; }
  .topbar { padding: 0 8px; gap: 4px; }
  .tabs a { padding: 7px 8px; }
  .meter { padding: 0 8px; gap: 6px; }
  .meter .bar, .meter .lbl { display: none; }
  .sheet-head { display: none; }
  .sheet-row { grid-template-columns: 1fr; gap: 10px; }
  .sheet-row .m-status { display: block; }
  .m-act { justify-items: start; }
  .m-act .note { text-align: left; }
  .settings { grid-template-columns: 1fr; }
  .library, .admin { padding: 22px 16px 48px; }
  .chips { flex-basis: 100%; }
  .lib-tools input[type=search] { width: 100%; }
  .chat-head .btn .lbl { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
