/* PARADEE — Factory-style product console
 * Tokens lifted from factory.com: page #f5f5f5, raised #fff, sunken #ebebeb,
 * accent #EF6F2E, ink #161413, hairline borders, Geist sans + Geist Mono,
 * film-grain overlay, mono uppercase micro-labels.
 */

:root {
  --bg: #f5f5f5;
  --sheet: #ffffff;
  --sunken: #ebebeb;
  --elevated: #fafafa;
  --ink: #161413;
  --text: #1f1d1c;
  --muted: #757070;
  --faint: #a29f9a;
  --line: #e4e2df;
  --line-strong: #d6d3d2;
  --border: #d6d3d2;
  --accent: #ef6f2e;
  --accent-200: #ee6018;
  --accent-300: #d15010;
  --accent-wash: rgba(239, 111, 46, 0.1);
  --accent-soft: rgba(239, 111, 46, 0.05);
  --green: #6fab78;
  --red: #d9363e;
  --code-bg: #ebebeb;
  --code-ink: #1f1d1c;
  --paper: #f5f5f5;
  --focus: #a8a29e;
  --mode-bg: #ebebeb;
  --wave-played: #ef6f2e;
  --wave-rest: #d6d3d2;
  --on-ink: #ffffff;
  --sans: "Geist", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "Geist Mono", "SF Mono", "Berkeley Mono", Menlo, Consolas, monospace;
  --serif: "Iowan Old Style", Palatino, Georgia, serif;
  --radius: 0;
  --radius-lg: 0;
  --shadow-sm: 0 1px 2px rgba(22, 20, 19, 0.05);
  --shadow: 0 1px 2px rgba(22, 20, 19, 0.05), 0 8px 24px -16px rgba(22, 20, 19, 0.18);
}

[data-theme="dark"] {
  --bg: #020202;
  --sheet: #101010;
  --sunken: #1c1c1c;
  --elevated: #161616;
  --ink: #eee;
  --text: #fafafa;
  --muted: #a3a09c;
  --faint: #6f6a66;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.14);
  --border: rgba(255, 255, 255, 0.1);
  --accent: #ef6f2e;
  --accent-200: #f57b3d;
  --accent-300: #ee6018;
  --accent-wash: rgba(239, 111, 46, 0.16);
  --accent-soft: rgba(239, 111, 46, 0.08);
  --green: #6fab78;
  --red: #ef4444;
  --code-bg: #1c1c1c;
  --code-ink: #d4d4d4;
  --paper: #020202;
  --focus: #525252;
  --mode-bg: rgba(255, 255, 255, 0.06);
  --wave-rest: #2e2e2e;
  --wave-played: #ef6f2e;
  --on-ink: #0a0a0a;
  --shadow-sm: none;
  --shadow: none;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Factory's film grain */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9990;
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 180px 180px;
}
[data-theme="dark"] body::after { opacity: 0.035; }

button { font: inherit; color: inherit; }

/* ---------- top bar ---------- */

.top {
  max-width: none;
  margin: 0;
  padding: 12px 20px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
}

.top-right { display: flex; align-items: center; gap: 8px; }

.brand { display: flex; align-items: center; gap: 9px; }
.mark { width: 20px; height: 20px; fill: var(--accent); }
.wordmark {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink);
}

.version-tag {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 0;
  background: var(--sheet);
  padding: 5px 10px;
  line-height: 1;
  white-space: nowrap;
}

.theme-button {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 0;
  background: var(--sheet);
  color: var(--muted);
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.theme-button:hover { color: var(--ink); border-color: var(--focus); }
.theme-button svg { width: 14px; height: 14px; grid-area: 1 / 1; }
.theme-button .i-moon { display: none; }
[data-theme="dark"] .theme-button .i-sun { display: none; }
[data-theme="dark"] .theme-button .i-moon { display: block; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  background: var(--sheet);
  border: 1px solid var(--border);
  border-radius: 0;
  padding: 6px 10px 6px 9px;
}

.dot { width: 6px; height: 6px; border-radius: 0; background: var(--line-strong); transition: background 0.25s ease; }
.pill[data-state="busy"] .dot { background: var(--accent); animation: breathe 1.1s ease-in-out infinite; }
.pill[data-state="ready"] .dot { background: var(--green); }
.pill[data-state="error"] .dot { background: var(--red); }

@keyframes breathe {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.35; transform: scale(0.7); }
}

/* Chrome's WebGPU queue can deadlock while a CSS animation keeps the
   compositor busy (seen with LFM3 on AMD/Metal). Freeze all decorative motion
   while the local model is generating. app.js toggles the attribute. */
html[data-llm-busy] *,
html[data-llm-busy] *::before,
html[data-llm-busy] *::after {
  animation: none !important;
}

/* ---------- studio ---------- */

.studio {
  max-width: none;
  margin: 0;
  padding: 0 20px 16px;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 9px 0 10px;
  flex-wrap: wrap;
}

.tools { display: flex; align-items: center; gap: 2px; padding: 2px; }

.tool {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 0;
  cursor: pointer;
  color: var(--muted);
  font-family: var(--serif);
  font-size: 15px;
  transition: background 0.13s ease, color 0.13s ease, border-color 0.13s ease;
}
.tool:hover { background: var(--sheet); border-color: var(--border); color: var(--ink); }
.tool svg { width: 16px; height: 16px; fill: currentColor; }
.tool[data-md="heading"] { font-family: var(--sans); font-size: 12px; font-weight: 600; }

.toolbar-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.ask-button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 550;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink);
  background: var(--sheet);
  border: 1px solid var(--border);
  border-radius: 0;
  padding: 6px 12px 6px 10px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}
.ask-button:hover { border-color: var(--ink); }
.ask-button svg { width: 13px; height: 13px; fill: var(--accent); }
#talk-open { background: var(--ink); border-color: var(--ink); color: var(--sheet); }
#talk-open:hover { border-color: #000; background: #000; color: #fff; }
[data-theme="dark"] #talk-open { background: var(--accent); border-color: var(--accent); color: #fff; }
[data-theme="dark"] #talk-open:hover { background: var(--accent-300); border-color: var(--accent-300); color: #fff; }

.stats { font-family: var(--mono); font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }

.modes {
  display: inline-flex;
  background: var(--mode-bg);
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 2px;
  gap: 2px;
}
[data-theme="dark"] .modes { border-color: var(--border); }

.modes button {
  border: 0;
  background: transparent;
  border-radius: 0;
  padding: 4px 11px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.modes button:hover { color: var(--ink); }
.modes button.on {
  background: var(--sheet);
  color: var(--ink);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  padding: 3px 10px;
}

/* ---------- panes ---------- */

.panes {
  display: grid;
  grid-template-columns: 1.08fr 1fr;
  gap: 12px;
  align-items: stretch;
}

.panes[data-mode="write"] { grid-template-columns: minmax(0, 840px); justify-content: center; }
.panes[data-mode="read"] { grid-template-columns: minmax(0, 840px); justify-content: center; }
.panes[data-mode="read"] .page { display: none; }
.panes[data-mode="write"] .preview { display: none; }

.pane {
  background: var(--sheet);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  min-height: 58vh;
}

.page { padding: 0 30px 26px; }
.page::before {
  content: "EDIT  ·  MARKDOWN";
  display: block;
  margin: 0 -30px 18px;
  padding: 11px 30px 10px;
  border-bottom: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--sheet);
  position: sticky;
  top: 0;
  z-index: 1;
}

.page textarea {
  width: 100%;
  border: 0;
  outline: 0;
  resize: none;
  overflow: hidden;
  background: transparent;
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.75;
  letter-spacing: 0.001em;
  padding: 0;
  display: block;
}

.page textarea::placeholder { color: var(--faint); }

.preview {
  padding: 0 30px 28px;
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.75;
  color: var(--text);
  overflow-wrap: break-word;
}
.preview::before {
  content: "READ  ·  SPEECH OUT";
  display: block;
  margin: 0 -30px 18px;
  padding: 11px 30px 10px;
  border-bottom: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--sheet);
  position: sticky;
  top: 0;
  z-index: 1;
}

.preview > :first-child { margin-top: 0; }
.preview h1, .preview h2, .preview h3, .preview h4 {
  font-family: var(--sans);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.3;
  margin: 1.5em 0 0.55em;
  color: var(--ink);
}
.preview h1 { font-size: 1.75em; }
.preview h2 { font-size: 1.35em; }
.preview h3 { font-size: 1.12em; }
.preview p { margin: 0 0 1em; }
.preview ul, .preview ol { margin: 0 0 1em; padding-left: 1.3em; }
.preview li { margin: 0.28em 0; }
.preview li::marker { color: var(--accent); }
.preview a {
  color: var(--accent-300);
  text-decoration: underline;
  text-decoration-style: dotted;
  text-decoration-color: color-mix(in srgb, var(--accent) 55%, transparent);
  text-underline-offset: 3px;
}
.preview a:hover { color: var(--accent-200); text-decoration-style: solid; }
.preview code {
  font-family: var(--mono);
  font-size: 0.82em;
  background: var(--code-bg);
  color: var(--code-ink);
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 0.08em 0.34em;
}
.preview pre {
  background: var(--ink);
  color: #f5f5f5;
  border: 0;
  border-radius: 0;
  padding: 14px 16px;
  overflow-x: auto;
  font-size: 0.84em;
  line-height: 1.6;
}
.preview pre code { background: none; border: 0; padding: 0; color: inherit; }
.preview blockquote {
  margin: 0 0 1em;
  padding: 0.15em 0 0.15em 1.1em;
  border-left: 2px solid var(--accent);
  color: var(--muted);
  font-style: normal;
}
.preview hr { border: 0; border-top: 1px solid var(--line); margin: 2em 0; }
.preview img { max-width: 100%; border-radius: 0; }

.preview [data-p] { transition: background 0.2s ease; border-radius: 0; }
.preview [data-p].speaking { background: var(--accent-wash); box-shadow: 0 0 0 4px var(--accent-wash); }

/* ---------- actions ---------- */

.actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 12px -20px 0;
  padding: 12px 20px 10px;
  border-top: 1px solid var(--line);
  background: var(--sheet);
}

.primary {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-family: var(--mono);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--on-ink);
  background: var(--ink);
  border: 0;
  border-radius: 0;
  padding: 11px 20px;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.15s ease, opacity 0.15s ease;
}
[data-theme="dark"] .primary { border: 1px solid var(--border); }

.primary svg { width: 16px; height: 16px; }
.primary:hover { transform: translateY(-1px); background: #000; }
[data-theme="dark"] .primary:hover { background: #1f1f1f; }
.primary:active { transform: translateY(0); }
.primary .i-stop { display: none; }
.primary.reading { background: var(--accent); color: #fff; }
.primary.reading .i-speak { display: none; }
.primary.reading .i-stop { display: block; }

.ghost {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--mono);
  font-size: 11.5px;
  font-weight: 550;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--sheet);
  border: 1px solid var(--border);
  border-radius: 0;
  padding: 9px 14px;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}
.ghost:hover { color: var(--ink); border-color: var(--focus); }
.ghost svg { width: 14px; height: 14px; fill: currentColor; }
.ghost.icon-only { padding: 9px; }

.mic .i-stop { display: none; }
.mic.recording { color: #fff; background: var(--red); border-color: var(--red); }
.mic.recording .i-mic { display: none; }
.mic.recording .i-stop { display: block; }
.mic.recording svg { fill: #fff; }

.speed {
  display: flex;
  align-items: center;
  gap: 9px;
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.speed output { font-variant-numeric: tabular-nums; min-width: 40px; color: var(--ink); letter-spacing: 0; }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 108px;
  height: 18px;
  background: transparent;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track { height: 3px; background: var(--line-strong); border-radius: 0; }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px; height: 14px; margin-top: -5.5px;
  border-radius: 0; background: var(--ink); border: 0;
}
input[type="range"]::-moz-range-track { height: 3px; background: var(--line-strong); border-radius: 0; }
input[type="range"]::-moz-range-thumb { width: 14px; height: 14px; border: 0; border-radius: 0; background: var(--ink); }

.note {
  flex: 1 1 auto;
  margin: 0 6px;
  min-width: 0;
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.5;
  color: var(--muted);
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.note::before { content: "/ "; color: var(--faint); }
.note.error { color: var(--red); }

.now {
  margin: 6px 20px 4px;
  min-height: 0;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.now:empty { display: none; }

.track { height: 3px; background: var(--line); border-radius: 0; overflow: hidden; margin: 8px 20px 2px; }
.track + .track { margin-top: 5px; }
.track span { display: block; height: 100%; width: 0%; background: var(--accent); transition: width 0.18s ease; }
.track.asr span { background: var(--green); }

/* ---------- player ---------- */

.player {
  margin: 12px -20px 0;
  padding: 10px 20px;
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 14px;
  background: var(--sheet);
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.play {
  width: 38px; height: 38px;
  border-radius: 0;
  border: 0;
  background: var(--ink);
  color: var(--on-ink);
  display: grid; place-items: center;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.12s ease;
}
.play:hover { background: var(--accent); }
[data-theme="dark"] .play:hover { background: var(--accent-300); }
.play:active { transform: scale(0.95); }
.play svg { width: 18px; height: 18px; fill: currentColor; }
.play .i-pause { display: none; }
.player.playing .play .i-play { display: none; }
.player.playing .play .i-pause { display: block; }

.wave-wrap { min-width: 0; }
canvas { display: block; width: 100%; height: 52px; cursor: pointer; }

.times { display: flex; gap: 6px; font-family: var(--mono); font-size: 11px; font-variant-numeric: tabular-nums; color: var(--muted); }
.times span:last-child::before { content: "/ "; color: var(--faint); }

.icon {
  width: 34px; height: 34px;
  border-radius: 0;
  border: 1px solid var(--border);
  color: var(--muted);
  background: var(--sheet);
  display: grid; place-items: center;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.icon:hover { color: var(--accent); border-color: var(--accent); }
.icon svg { width: 16px; height: 16px; }

/* ---------- ask modal ---------- */

.ask {
  border: 0;
  padding: 0;
  background: transparent;
  max-width: min(680px, calc(100vw - 32px));
  width: 100%;
  color: var(--ink);
}

.ask::backdrop { background: rgba(22, 20, 19, 0.45); backdrop-filter: blur(2px); }

.ask-shell {
  background: var(--sheet);
  border: 1px solid var(--line-strong);
  border-radius: 0;
  box-shadow: 0 24px 64px -24px rgba(22, 20, 19, 0.35);
  overflow: hidden;
}

.ask-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px 13px;
  border-bottom: 1px solid var(--line);
}

.ask-head h2 {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0;
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.ask-head h2 svg { width: 15px; height: 15px; fill: var(--accent); }

.ask-close {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.ask-close:hover { color: var(--ink); border-color: var(--focus); }
.ask-close svg { width: 14px; height: 14px; }

.ask-body { padding: 16px 18px 18px; }

.ctx {
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 10px 13px 11px;
  background: var(--bg);
}

.ctx-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.ctx-head button {
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.ctx-head button:hover { color: var(--accent-300); }

.ctx-text {
  margin: 7px 0 0;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--text);
  max-height: 88px;
  overflow-y: auto;
  white-space: pre-wrap;
}
.ctx-text:empty::before { content: "Nothing selected — the question goes on its own."; color: var(--faint); }

.presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 12px 0 10px;
}

.presets button {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 550;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 0;
  padding: 5px 11px;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}
.presets button:hover { color: var(--accent-300); border-color: var(--accent); background: var(--accent-soft); }

#prompt {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 0;
  padding: 11px 13px;
  background: var(--sheet);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.55;
  resize: vertical;
  outline: 0;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
#prompt:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.ask-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 12px 0 0;
}

.ask-actions .primary { padding: 9px 18px; font-size: 12px; }

.ask-status {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ask-status.error { color: var(--red); }

.think-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}
.think-toggle input { accent-color: var(--accent); width: 13px; height: 13px; margin: 0; }

.think {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: var(--bg);
  font-size: 12.5px;
}

.think summary {
  cursor: pointer;
  list-style: none;
  padding: 9px 13px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 8px;
}
.think summary::-webkit-details-marker { display: none; }
.think summary::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 0;
  background: var(--accent);
  animation: breathe 1.2s ease-in-out infinite;
}
.think:not([open]) summary { border-bottom: 0; }

.think-body {
  padding: 0 13px 12px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.6;
  color: var(--muted);
  max-height: 26vh;
  overflow-y: auto;
  white-space: pre-wrap;
}

.answer {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 13px 15px;
  background: var(--bg);
  font-size: 14px;
  line-height: 1.65;
  max-height: 40vh;
  overflow-y: auto;
}
.answer:empty { display: none; }
.answer.streaming { white-space: pre-wrap; }
.answer h1, .answer h2, .answer h3 { font-weight: 600; letter-spacing: -0.01em; font-size: 1.05em; margin: 0.7em 0 0.35em; }
.answer p { margin: 0 0 0.6em; }
.answer ul, .answer ol { margin: 0 0 0.6em; padding-left: 1.25em; }
.answer code {
  font-family: var(--mono);
  font-size: 0.85em;
  background: var(--code-bg);
  border-radius: 0;
  padding: 0.1em 0.3em;
}
.answer a { color: var(--accent-300); }

.insert {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.insert button {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 550;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 0;
  padding: 6px 12px;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}
.insert button:hover { color: var(--ink); border-color: var(--focus); }
.insert button:first-child { color: var(--on-ink); background: var(--ink); border-color: var(--ink); }
[data-theme="dark"] .insert button:first-child { background: var(--accent); border-color: var(--accent); color: #fff; }
.insert button:first-child:hover { opacity: 0.88; border-color: transparent; }

/* ---------- realtime ---------- */

.talk-head { display: flex; align-items: center; gap: 4px; }
.talk-clear {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 0;
  padding: 5px 10px;
  cursor: pointer;
}
.talk-clear:hover { color: var(--ink); background: var(--sunken); }
.talk-clear:focus:not(:focus-visible),
.talk-mic:focus:not(:focus-visible),
.ask-close:focus:not(:focus-visible) { outline: none; }
.talk-clear:focus-visible,
.talk-mic:focus-visible,
.ask-close:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.talk-log {
  display: flex;
  flex-direction: column;
  gap: 9px;
  height: min(48vh, 380px);
  min-height: 220px;
  overflow-y: auto;
  padding: 2px 2px 6px;
  scrollbar-width: thin;
}
.talk-log:empty::before {
  content: "Hold Shift, say something, and release to send. Your voice stays on the device.";
  margin: auto;
  max-width: 34ch;
  text-align: center;
  color: var(--faint);
  font-size: 12.5px;
  line-height: 1.55;
}
.talk-msg {
  max-width: 86%;
  padding: 9px 13px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: var(--sheet);
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.talk-msg.user {
  align-self: flex-end;
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}
[data-theme="dark"] .talk-msg.user { background: var(--accent); border-color: var(--accent); color: #fff; }
.talk-msg.assistant { align-self: flex-start; background: var(--bg); font-size: 13.5px; }
.talk-msg.streaming::after { content: "▍"; color: var(--accent); animation: breathe 1s ease-in-out infinite; }
.talk-msg.error { color: var(--red); border-color: var(--red); }

.talk-foot {
  margin-top: 12px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.talk-mic {
  width: 56px;
  height: 56px;
  border-radius: 0;
  display: grid;
  place-items: center;
  border: 0;
  background: var(--ink);
  color: var(--on-ink);
  cursor: pointer;
  touch-action: none;
  user-select: none;
  transition: background 0.15s ease, color 0.15s ease;
}
.talk-mic svg { width: 23px; height: 23px; fill: currentColor; }
.talk-mic .i-stop { display: none; }
.talk-mic.recording { background: var(--red); color: #fff; animation: talk-pulse 1.4s ease-out infinite; }
.talk-mic.recording .i-mic { display: none; }
.talk-mic.recording .i-stop { display: block; }
.talk-mic.busy { opacity: 0.5; cursor: default; }

.talk-status {
  margin: 0;
  min-height: 1.2em;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  text-align: center;
}
.talk-status.error { color: var(--red); }

.talk-meter {
  width: 160px;
  height: 3px;
  border-radius: 0;
  background: var(--line-strong);
  overflow: hidden;
  opacity: 0;
  transition: opacity 0.15s ease;
}
.talk[data-state="listening"] .talk-meter { opacity: 1; }
.talk-meter span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 0;
  background: var(--accent);
  transition: width 0.08s linear;
}

@keyframes talk-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(217, 54, 62, 0.35); }
  50% { box-shadow: 0 0 0 9px rgba(217, 54, 62, 0); }
}

/* ---------- footer ---------- */

.foot {
  max-width: none;
  margin: 0;
  padding: 10px 20px 12px;
  border-top: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.02em;
  color: var(--faint);
}
.foot p { margin: 0; }
.foot a { color: var(--muted); text-decoration: none; border-bottom: 1px solid var(--border); }
.foot a:hover { color: var(--accent-300); border-color: var(--accent); }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

@media (min-width: 901px) {
  /* the page fills the window: the panes take the room that is left */
  html, body { height: 100%; }
  body { display: flex; flex-direction: column; overflow: auto; }
  .top, .studio, .foot { flex: 0 0 auto; width: 100%; }
  .studio { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
  .panes { flex: 1 1 auto; min-height: 300px; }
  .pane { min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
  .page { overflow: hidden; }
  .page textarea { flex: 1 1 auto; height: 100%; min-height: 0; overflow-y: auto; }
  .preview { overflow-y: auto; }
}

@media (max-width: 900px) {
  .panes { grid-template-columns: minmax(0, 1fr); }
  .panes[data-mode="split"] .preview { display: none; }
  .page, .preview { padding: 0 20px 24px; min-height: 52vh; }
  .page::before, .preview::before { margin: 0 -20px 16px; padding: 10px 20px 9px; }
  .speed { margin-left: 0; }
  .note { flex-basis: 100%; text-align: left; margin: 2px 0 0; }
}

@media (max-width: 560px) {
  .top { padding: 12px 16px 10px; }
  .studio { padding: 0 16px 12px; }
  .page, .preview { padding: 0 18px 22px; min-height: 48vh; }
  .page::before, .preview::before { margin: 0 -18px 14px; padding: 9px 18px 8px; }
  .page textarea, .preview { font-size: 15.5px; }
  .actions { gap: 7px; margin: 10px -16px 0; padding: 10px 16px 8px; }
  .now { margin: 6px 16px 4px; }
  .track { margin: 8px 16px 2px; }
  .player { grid-template-columns: auto 1fr auto; row-gap: 10px; margin: 10px -16px 0; padding: 9px 16px; }
  .times { grid-column: 2; font-size: 11px; }
  .icon { grid-row: 1; grid-column: 3; }
  .toolbar-right { width: 100%; justify-content: space-between; }
  .version-tag { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}
