/* CueLight Web: the look of the desktop app (cool violet-tinted neutrals, a blue accent, violet and pink chips, serif
   headings). Mobile first: one column with 16px gutters, nothing scrolls sideways. No inline styles anywhere (the page's
   Content Security Policy forbids them), so everything is here. */

:root {
  color-scheme: dark;
  --bg: #130F20; --surface: #1B1630; --surface-alt: #272046; --border: #2E2750; --border-strong: #413A66;
  --text: #F2EFFC; --text-muted: #ABA6C9; --text-faint: #9690B6;
  --accent: #4C68EE; --accent-hover: #6179F4; --accent-pressed: #3C57D9; --on-accent: #FFFFFF;
  --accent-soft: #222C62; --accent-soft-hover: #2C3A7C; --accent-text: #A9B9FF;
  --violet-soft: #33235F; --violet-text: #C8B4FF; --pink-soft: #4A2044; --pink-text: #FFAED6;
  --success: #4FC592; --success-soft: #1B3A31; --success-text: #9BE5C4; --danger: #F0766E; --danger-soft: #4A2226;
  --warn-soft: #3F3010; --warn-text: #F3D18A;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 6px 18px rgba(0, 0, 0, 0.3);
  --serif: "Young Serif", Georgia, "Times New Roman", serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --gutter: max(16px, env(safe-area-inset-left), env(safe-area-inset-right));
  --radius: 16px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); font: 400 15px/1.45 var(--sans);
  min-height: 100vh; min-height: 100dvh; overflow-x: hidden; -webkit-tap-highlight-color: transparent;
}
h1, h2, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
svg { fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.faint { color: var(--text-faint); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.noscript { padding: 16px; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.app { max-width: 640px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }

/* Header */
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px var(--gutter) 8px; padding-top: max(12px, env(safe-area-inset-top)); background: var(--bg); }
.brand { display: flex; align-items: center; gap: 8px; min-width: 0; }
.logo { color: var(--accent); stroke-width: 2; }
.wordmark { font: 400 22px/1.1 var(--serif); letter-spacing: 0.01em; }
.webtag { font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--violet-text); background: var(--violet-soft); border-radius: 999px; padding: 2px 8px; }
.top-actions { display: flex; gap: 4px; }
.icon-btn { display: inline-grid; place-items: center; width: 40px; height: 40px; border: 0; border-radius: 12px; background: transparent; color: var(--text-muted); cursor: pointer; }
.icon-btn:hover { background: var(--surface-alt); color: var(--text); }
.icon-btn.small { width: 32px; height: 32px; border-radius: 10px; }

.main { flex: 1; padding: 4px var(--gutter) 16px; display: flex; flex-direction: column; gap: 12px; }

/* Chips and status */
.chips { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 8px; min-height: 36px; padding: 6px 14px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-muted); font-weight: 500; }
.chip b { font-weight: 700; letter-spacing: 0.02em; }
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-faint); }
.chip[aria-pressed="true"] { background: var(--success-soft); border-color: var(--success); color: var(--success-text); }
.chip[aria-pressed="true"] .dot { background: var(--success); }
#chip-type[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-text); }
.cost { margin-left: auto; font-size: 13px; color: var(--text-muted); cursor: help; font-variant-numeric: tabular-nums; }
.status { display: flex; align-items: center; gap: 8px; color: var(--text-muted); font-size: 14px; min-height: 22px; }
.status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-faint); flex: none; }
.status[data-kind="listening"] .dot { background: var(--success); }
.status[data-kind="hearing"] { color: var(--success-text); font-weight: 700; letter-spacing: 0.06em; }
.status[data-kind="hearing"] .dot { background: var(--success); animation: pulse 1.1s ease-in-out infinite; }
.status[data-kind="thinking"] .dot { background: var(--accent); animation: pulse 1.1s ease-in-out infinite; }
.status[data-kind="error"] { color: var(--danger); }
@keyframes pulse { 50% { transform: scale(1.6); opacity: 0.5; } }
@media (prefers-reduced-motion: reduce) { .status .dot { animation: none !important; } }

.notice { display: flex; gap: 8px; align-items: flex-start; padding: 12px 12px 12px 14px; border-radius: 14px; background: var(--warn-soft); color: var(--warn-text); border: 1px solid transparent; }
.notice[data-kind="error"] { background: var(--danger-soft); color: var(--danger); }
.notice-text { flex: 1; font-size: 14px; line-height: 1.4; overflow-wrap: anywhere; }
.notice-actions { display: flex; align-items: center; gap: 4px; flex: none; }
.notice .icon-btn { color: inherit; }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.eyebrow { font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-faint); margin-bottom: 8px; }
.empty { color: var(--text-faint); font-size: 14px; }
.turns { display: flex; flex-direction: column; gap: 8px; max-height: 38vh; overflow-y: auto; overscroll-behavior: contain; }
.turn { display: grid; grid-template-columns: 52px 1fr; gap: 8px; font-size: 15px; }
.turn .who { font-size: 13px; font-weight: 500; color: var(--text-muted); padding-top: 1px; }
.turn .who.me { color: var(--accent-text); }
.turn .said { overflow-wrap: anywhere; }
.turn.live { margin-top: 8px; opacity: 0.8; }
.turn.live .said { font-style: italic; }

.listen-state { font-size: 14px; color: var(--text-muted); margin-bottom: 10px; }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.help { font-size: 13px; color: var(--text-faint); margin-top: 10px; line-height: 1.45; }
.help:empty { display: none; }

.area-row { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.area-icon { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; background: var(--surface-alt); color: var(--text-muted); flex: none; }
.area-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.area-text b { font-weight: 600; }
.area-text span { font-size: 13px; overflow-wrap: anywhere; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 8px 16px; border-radius: 12px; cursor: pointer;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font-weight: 500; }
.btn:hover { background: var(--surface-alt); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
.btn.primary:hover { background: var(--accent-hover); }
.btn.primary:active { background: var(--accent-pressed); }
.btn.quiet { border-color: transparent; background: transparent; color: var(--text-muted); }
.btn.small { min-height: 34px; padding: 4px 12px; font-size: 14px; }
.btn[disabled], .link-btn[disabled], .send[disabled] { opacity: 0.45; cursor: not-allowed; }
.link-btn { display: inline-flex; align-items: center; gap: 6px; border: 0; background: transparent; padding: 6px 4px; min-height: 32px; cursor: pointer; color: var(--text-muted); font-size: 14px; }
.link-btn:hover:not([disabled]) { color: var(--text); }
.panic { border-color: var(--accent); color: var(--accent-text); background: var(--accent-soft); }
.panic:hover { background: var(--accent-soft-hover); }

/* Suggestions */
.sec-head { display: flex; justify-content: space-between; align-items: center; }
.sec-head .eyebrow { margin: 0; }
.sections { display: flex; flex-direction: column; gap: 16px; }
.section-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 13px; color: var(--text-faint); }
.tag { font-size: 11px; font-weight: 700; letter-spacing: 0.06em; padding: 3px 10px; border-radius: 999px; cursor: help; }
.tag.say { background: var(--accent-soft); color: var(--accent-text); }
.tag.answer { background: var(--pink-soft); color: var(--pink-text); }
.tag.type { background: var(--violet-soft); color: var(--violet-text); }
.option { display: flex; gap: 12px; align-items: flex-start; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 14px 14px 16px; margin-bottom: 8px; box-shadow: var(--shadow); }
.option p { flex: 1; font: 400 17px/1.45 var(--serif); overflow-wrap: anywhere; white-space: pre-wrap; }
.option.note p { font: 400 14px/1.45 var(--sans); color: var(--text-muted); }
.option .copy { flex: none; border: 0; background: transparent; color: var(--text-muted); font-size: 13px; padding: 4px 6px; cursor: pointer; border-radius: 8px; min-height: 32px; }
.option .copy:hover { background: var(--surface-alt); color: var(--text); }
.option.streaming p::after { content: " ▍"; color: var(--accent); animation: pulse 1s steps(2) infinite; }
@media (prefers-reduced-motion: reduce) { .option.streaming p::after { animation: none; } }

/* Bottom dock */
.dock { position: sticky; bottom: 0; z-index: 4; padding: 10px var(--gutter) 10px; padding-bottom: max(10px, env(safe-area-inset-bottom)); background: linear-gradient(to top, var(--bg) 78%, transparent); }
.direction { display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 999px; padding: 4px 4px 4px 16px; box-shadow: var(--shadow); }
.hint { flex: 1; min-width: 0; border: 0; background: transparent; padding: 8px 0; outline: none; font-size: 16px; }
.hint::placeholder { color: var(--text-faint); }
.direction:focus-within { border-color: var(--accent); }
.send { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--accent); color: var(--on-accent); cursor: pointer; flex: none; }
.send:hover:not([disabled]) { background: var(--accent-hover); }
.dock-row { display: flex; align-items: center; gap: 12px; margin-top: 8px; flex-wrap: wrap; }
.dock-row .link-btn:last-child { margin-left: auto; }

.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 14px; color: var(--text-muted); min-height: 32px; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { position: relative; width: 38px; height: 22px; border-radius: 999px; background: var(--border-strong); transition: background 0.15s; flex: none; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform 0.15s; }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Dialogs */
.dialog { border: 0; padding: 0; background: var(--bg); color: var(--text); width: min(560px, 100vw); max-width: 100vw; max-height: 100dvh; border-radius: 20px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35); }
.dialog::backdrop { background: rgba(19, 15, 32, 0.55); }
.dialog-body { padding: 20px var(--gutter) 0; max-height: min(88dvh, 100dvh); overflow-y: auto; overscroll-behavior: contain; }
@media (max-width: 560px) { .dialog { width: 100vw; height: 100dvh; max-height: 100dvh; border-radius: 0; } .dialog-body { max-height: 100dvh; min-height: 100dvh; display: flex; flex-direction: column; } }
.title { font: 400 24px/1.2 var(--serif); margin-bottom: 14px; }
.display { font: 400 34px/1.1 var(--serif); margin: 14px 0 10px; }
.lede { color: var(--text-muted); font-size: 17px; line-height: 1.45; margin-bottom: 20px; }
.welcome-mark { display: grid; place-items: center; width: 64px; height: 64px; border-radius: 18px; background: var(--accent-soft); color: var(--accent); margin-top: 8px; }
.welcome-mark svg { stroke-width: 2; }
.dialog-foot { position: sticky; bottom: 0; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0 max(14px, env(safe-area-inset-bottom)); margin-top: 16px; background: linear-gradient(to top, var(--bg) 80%, transparent); font-size: 13px; }

.field { margin-bottom: 16px; }
.field > label, .field > .label, .legend { display: block; font-weight: 600; margin-bottom: 6px; font-size: 14px; }
.section-title { font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-faint); margin: 24px 0 10px; }
.section-title:first-child { margin-top: 4px; }
.caption { font-size: 13px; color: var(--text-muted); margin-top: 6px; }
.caption.faint { color: var(--text-faint); }
.warn { font-size: 13px; color: var(--warn-text); background: var(--warn-soft); border-radius: 10px; padding: 8px 10px; margin-top: 8px; }
.input { width: 100%; min-height: 44px; border: 1px solid var(--border-strong); border-radius: 12px; background: var(--surface); padding: 10px 12px; font-size: 16px; }
textarea.input { min-height: 84px; resize: vertical; }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.keybox { display: flex; gap: 8px; }
.keybox .input { flex: 1; min-width: 0; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 15px; }
.msg { font-size: 13px; margin-top: 8px; color: var(--text-muted); overflow-wrap: anywhere; }
.msg.bad { color: var(--danger); }
.msg.good { color: var(--success-text); }
.linkish { color: var(--accent-text); text-decoration: underline; text-underline-offset: 2px; background: none; border: 0; padding: 0; cursor: pointer; font-size: inherit; }
a { color: var(--accent-text); }

/* Segmented controls */
.seg { display: flex; flex-wrap: wrap; gap: 2px; background: var(--surface-alt); border-radius: 12px; padding: 3px; }
.seg label { flex: 1 1 auto; position: relative; text-align: center; cursor: pointer; }
.seg input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.seg span { display: block; padding: 8px 10px; border-radius: 10px; font-size: 14px; color: var(--text-muted); white-space: nowrap; }
.seg input:checked + span { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgba(28, 26, 51, 0.12); }
.seg input:focus-visible + span { outline: 2px solid var(--accent); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 420px) { .two { grid-template-columns: 1fr; } }
.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.check input { margin-top: 3px; width: 18px; height: 18px; accent-color: var(--accent); flex: none; }
.check b { display: block; font-weight: 600; }
.check span { display: block; font-size: 13px; color: var(--text-muted); }
.danger-link { color: var(--danger); }

/* Choosing the text area */
.picker { width: min(960px, 100vw); }
.picker-stage { position: relative; line-height: 0; margin: 8px 0 0; background: #000; border-radius: 12px; overflow: hidden; touch-action: none; user-select: none; cursor: crosshair; }
.picker-stage canvas { display: block; width: 100%; height: auto; }
.picker-box { position: absolute; border: 2px solid var(--accent); background: rgba(76, 104, 238, 0.22); pointer-events: none; }

/* Offscreen video the shared screen plays into; it is only ever sampled */
.sampler { position: fixed; width: 2px; height: 2px; left: 0; top: 0; opacity: 0; pointer-events: none; }
