:root {
  color-scheme: dark;
  --bg: #0b090b;
  --panel: rgba(20, 14, 17, .66);
  --line: rgba(255, 90, 105, .14);
  --line-2: rgba(255, 90, 105, .28);
  --text: #efe7e9;
  --muted: #a0949a;
  --dim: #6a5f65;
  --red: #ff2a3f;
  --red-2: #ff5566;
  --ink: #1a0306;
  --serif: 'Instrument Serif', 'Times New Roman', serif;
  --sans: 'Geist', ui-sans-serif, system-ui, sans-serif;
  --mono: 'Geist Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --ease: cubic-bezier(.2, .7, .1, 1);
  --g: clamp(16px, 3.4vw, 40px);
  --dock: 150px;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0; overflow: hidden; background: var(--bg); color: var(--text);
  font: 15px/1.5 var(--sans); -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: rgba(255, 42, 63, .15); touch-action: manipulation;
}
button, textarea, input { font: inherit; color: inherit; }
a { color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--red); outline-offset: 3px; border-radius: 8px; }
::selection { background: var(--red); color: var(--ink); }
.mono { font-family: var(--mono); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: fixed; left: 16px; top: -60px; z-index: 100; padding: 10px 14px; border-radius: 10px; background: var(--red); color: var(--ink); font-weight: 600; text-decoration: none; }
.skip:focus { top: 12px; }
@keyframes pulse { 50% { opacity: .35; } }

#face { position: fixed; inset: 0; width: 100%; height: 100%; display: block; cursor: grab; touch-action: none; }
#face:active { cursor: grabbing; }
.grid-overlay { position: fixed; inset: 0; pointer-events: none; opacity: .5;
  background-image: linear-gradient(rgba(255, 60, 80, .035) 1px, transparent 1px), linear-gradient(90deg, rgba(255, 60, 80, .035) 1px, transparent 1px);
  background-size: 56px 56px; mask-image: radial-gradient(ellipse at center, transparent 30%, #000 85%); }

/* ——— Top bar ——— */
.top { position: fixed; inset: 0 0 auto; z-index: 10; display: flex; align-items: center; gap: 16px; padding: max(16px, env(safe-area-inset-top)) var(--g) 16px; pointer-events: none; }
.top > * { pointer-events: auto; }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; font: 400 24px/1 var(--serif); letter-spacing: -.01em; white-space: nowrap; }
.brand img { border-radius: 7px; box-shadow: 0 0 0 1px rgba(255, 42, 63, .25), 0 0 16px rgba(255, 42, 63, .4); }
.role { margin-left: 4px; padding: 4px 8px; border: 1px solid var(--line-2); border-radius: 999px; font-size: 10px; font-style: normal; letter-spacing: .14em; text-transform: uppercase; color: var(--red-2); }
.top-right { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.chip { display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 12px; border: 1px solid var(--line-2); border-radius: 999px; background: var(--panel); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); font: 500 11px/1 var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
.chip i { width: 7px; height: 7px; border-radius: 50%; background: var(--dim); }
.chip.is-on i { background: var(--red); box-shadow: 0 0 10px var(--red); animation: pulse 1.8s ease-in-out infinite; }
.chip.is-off { color: var(--red-2); }
.icon-btn { position: relative; display: grid; place-items: center; width: 34px; height: 34px; border: 1px solid var(--line-2); border-radius: 50%; background: var(--panel); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); text-decoration: none; transition: border-color .2s ease, background-color .2s ease, color .2s ease; }
.icon-btn:hover { border-color: rgba(255, 90, 105, .55); background: rgba(255, 42, 63, .08); }
.icon-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
#voice .spk { fill: currentColor; stroke: none; }
#voice .mute { display: none; }
#voice[aria-pressed="false"] .wave { display: none; }
#voice[aria-pressed="false"] .mute { display: inline; }
#brief-open.is-set { border-color: rgba(255, 90, 105, .6); color: var(--red-2); }
.x-link { color: var(--text); }
.x-link svg { width: 14px; height: 14px; }
.x-link svg path { fill: currentColor; stroke: none; }
.badge { position: absolute; top: -5px; right: -5px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--red); color: var(--ink); font: 600 10px/18px var(--mono); text-align: center; }
.build { padding: 0 14px; height: 34px; display: inline-flex; align-items: center; border: 1px solid var(--line-2); border-radius: 999px; background: var(--panel); text-decoration: none; font: 500 11px/1 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); white-space: nowrap; transition: color .2s ease, border-color .2s ease; }
.build:hover { color: var(--text); border-color: rgba(255, 90, 105, .55); }

/* ——— HUD ——— */
.hud { position: fixed; z-index: 5; bottom: calc(var(--dock) + 20px); pointer-events: none; font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--dim); transition: opacity .6s ease; }
.hud p { display: flex; justify-content: space-between; gap: 18px; min-width: 170px; margin: 0; padding: 5px 0; border-bottom: 1px solid rgba(255, 90, 105, .08); }
.hud b { font-weight: 400; color: var(--muted); font-variant-numeric: tabular-nums; }
.hud-left { left: var(--g); }
.hud-right { right: var(--g); width: 170px; }
.meter { display: flex; align-items: flex-end; gap: 3px; height: 44px; margin-bottom: 8px; }
.meter span { flex: 1; height: 100%; border-radius: 1px; background: linear-gradient(to top, var(--red), rgba(255, 42, 63, .15)); transform-origin: bottom; transform: scaleY(.06); }
body[data-mode="thinking"] #t-state, body[data-mode="speaking"] #t-state { color: var(--red); }

/* ——— Last transmission ——— */
.transmission { position: fixed; z-index: 6; left: var(--g); top: 78px; display: grid; gap: 6px; max-width: 300px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); text-decoration: none; font-size: 13px; line-height: 1.4; color: var(--muted); transition: border-color .2s ease, color .2s ease; }
.transmission:hover { border-color: rgba(255, 90, 105, .5); color: var(--text); }
.transmission .mono { font-size: 10px; letter-spacing: .16em; text-transform: uppercase; color: var(--red-2); }
.transmission span:last-child { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

/* ——— Caption ——— */
.caption { position: fixed; z-index: 6; left: 50%; bottom: calc(var(--dock) + 24px); width: min(820px, calc(100vw - 2 * var(--g))); margin: 0; transform: translateX(-50%); text-align: center; pointer-events: none;
  font: 400 clamp(22px, 2.6vw, 34px)/1.25 var(--serif); letter-spacing: -.005em; color: var(--text); text-wrap: balance; text-shadow: 0 0 24px rgba(0, 0, 0, .9), 0 0 2px #000; }
.caption .w { opacity: 0; filter: blur(6px); display: inline-block; transform: translateY(6px); transition: opacity .35s var(--ease), filter .35s var(--ease), transform .35s var(--ease); }
.caption .w.on { opacity: 1; filter: none; transform: none; }
.caption .w.hot { color: #ffd0d5; text-shadow: 0 0 18px rgba(255, 42, 63, .9); }
.caption.is-err { color: var(--red-2); font-family: var(--mono); font-size: 14px; letter-spacing: .02em; }
.caption.fade { opacity: 0; transition: opacity 1.2s ease; }

/* ——— Wake (voice) button ——— */
.wake-btn { position: fixed; z-index: 7; left: 50%; top: 82px; transform: translateX(-50%); display: inline-flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 18px 0 14px; border: 1px solid var(--red); border-radius: 999px; background: rgba(255, 42, 63, .14); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 0 0 4px rgba(255, 42, 63, .08), 0 0 40px -6px rgba(255, 42, 63, .7); font: 500 13px/1 var(--mono); letter-spacing: .08em; text-transform: uppercase; white-space: nowrap; transition: opacity .45s var(--ease), transform .45s var(--ease), background-color .2s ease; }
.wake-btn:hover { background: rgba(255, 42, 63, .26); }
.wake-btn i { width: 8px; height: 8px; border-radius: 50%; background: var(--red); box-shadow: 0 0 12px var(--red); animation: pulse 1.2s ease-in-out infinite; }
.wake-btn small { font-size: 10px; letter-spacing: .1em; color: var(--muted); text-transform: none; }
.wake-btn.is-gone { opacity: 0; transform: translate(-50%, -10px); pointer-events: none; }

/* ——— Side panel ——— */
.side { position: fixed; z-index: 8; top: 76px; right: var(--g); bottom: calc(var(--dock) + 20px); width: 380px; display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 18px; background: var(--panel); backdrop-filter: blur(16px) saturate(130%); -webkit-backdrop-filter: blur(16px) saturate(130%);
  opacity: 0; transform: translateX(16px); pointer-events: none; transition: opacity .35s var(--ease), transform .35s var(--ease); }
.side.is-open { opacity: 1; transform: none; pointer-events: auto; }
.side-tabs { display: flex; align-items: center; gap: 4px; padding: 8px; border-bottom: 1px solid var(--line); font-size: 11px; letter-spacing: .12em; text-transform: uppercase; }
.side-tabs [role="tab"] { min-height: 32px; padding: 0 12px; border: 0; border-radius: 8px; background: none; color: var(--dim); font: inherit; letter-spacing: inherit; }
.side-tabs [role="tab"] b { margin-left: 4px; font-weight: 500; color: var(--red-2); }
.side-tabs [role="tab"][aria-selected="true"] { background: rgba(255, 255, 255, .06); color: var(--text); }
.side-clear { margin-left: auto; min-height: 32px; padding: 0 10px; border: 0; border-radius: 8px; background: none; color: var(--dim); font: inherit; letter-spacing: inherit; }
.side-clear:hover { color: var(--text); background: rgba(255, 255, 255, .05); }
.side [role="tabpanel"] { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.side ol { margin: 0; padding: 12px; list-style: none; display: flex; flex-direction: column; gap: 12px; }
.side .empty { padding: 20px 6px; color: var(--dim); font-size: 13px; text-align: center; }
.log-list li { font-size: 14px; line-height: 1.45; overflow-wrap: anywhere; }
.log-list li small { display: block; margin-bottom: 3px; font: 500 10px/1 var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--dim); }
.log-list li.you { color: var(--muted); }
.log-list li.oracle small { color: var(--red); }
.log-list li.err { color: var(--red-2); }
.draft-group { display: grid; gap: 8px; padding-bottom: 12px; border-bottom: 1px dashed var(--line); }
.draft-group:last-child { border-bottom: 0; }
.draft { border: 1px solid var(--line-2); border-radius: 14px; background: rgba(10, 6, 8, .6); overflow: hidden; transition: border-color .2s ease; }
.draft:focus-within { border-color: rgba(255, 90, 105, .6); }
.draft header { display: flex; justify-content: space-between; padding: 8px 12px 0; font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--dim); }
.draft .count { font-weight: 400; font-variant-numeric: tabular-nums; color: var(--muted); }
.draft .count.over { color: var(--red-2); }
.draft textarea { display: block; width: 100%; min-height: 64px; padding: 6px 12px 10px; border: 0; background: transparent; resize: none; outline: none; font-size: 15px; line-height: 1.45; overflow: hidden; }
.draft footer { display: flex; gap: 6px; padding: 0 10px 10px; }
.mini { display: inline-flex; align-items: center; min-height: 32px; padding: 0 12px; border: 1px solid var(--line-2); border-radius: 999px; background: rgba(255, 255, 255, .03); text-decoration: none; font: 500 11px/1 var(--mono); letter-spacing: .06em; text-transform: uppercase; transition: background-color .2s ease, border-color .2s ease; }
.mini:hover { border-color: rgba(255, 90, 105, .55); background: rgba(255, 42, 63, .08); }
.mini-red { border-color: var(--red); background: var(--red); color: var(--ink); }
.mini-red:hover { background: var(--red-2); border-color: var(--red-2); }

/* ——— Dock: quick asks + input ——— */
.dock { position: fixed; z-index: 9; left: 50%; bottom: max(14px, env(safe-area-inset-bottom)); width: min(720px, calc(100vw - 2 * var(--g))); transform: translateX(-50%); display: grid; gap: 10px; transition: opacity .6s ease, transform .6s var(--ease); }
.quick { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; mask-image: linear-gradient(90deg, #000 90%, transparent); padding: 2px; }
.quick::-webkit-scrollbar { display: none; }
.quick-btn { flex: none; min-height: 34px; padding: 0 14px; border: 1px solid var(--line-2); border-radius: 999px; background: var(--panel); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); font: 500 11px/1 var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); transition: color .2s ease, border-color .2s ease, background-color .2s ease; }
.quick-btn:hover { color: var(--text); border-color: rgba(255, 90, 105, .55); background: rgba(255, 42, 63, .08); }
.ask { display: flex; align-items: flex-end; gap: 8px; padding: 8px; border: 1px solid var(--line-2); border-radius: 22px; background: rgba(16, 11, 14, .72); backdrop-filter: blur(18px) saturate(140%); -webkit-backdrop-filter: blur(18px) saturate(140%);
  box-shadow: 0 30px 80px -30px rgba(0, 0, 0, .9); transition: border-color .25s ease, box-shadow .25s ease; }
.ask:focus-within { border-color: rgba(255, 90, 105, .6); box-shadow: 0 0 0 4px rgba(255, 42, 63, .1), 0 30px 80px -30px rgba(0, 0, 0, .9); }
.ask textarea { flex: 1; min-width: 0; max-height: 140px; padding: 11px 8px 11px 12px; border: 0; background: transparent; resize: none; outline: none; font-size: 16px; line-height: 1.4; }
.ask textarea::placeholder { color: var(--dim); }
.ask .send, .ask .mic { flex: none; display: grid; place-items: center; width: 44px; height: 44px; border: 0; border-radius: 15px; transition: transform .15s ease, background-color .2s ease, opacity .2s ease; }
.ask .send { background: var(--red); color: var(--ink); box-shadow: 0 0 24px -4px rgba(255, 42, 63, .7); }
.ask .send:active, .ask .mic:active { transform: scale(.93); }
.ask .mic { background: rgba(255, 255, 255, .05); color: var(--muted); }
.ask .mic[aria-pressed="true"] { background: rgba(255, 42, 63, .18); color: var(--red); box-shadow: 0 0 0 1px rgba(255, 42, 63, .5), 0 0 22px rgba(255, 42, 63, .45); animation: pulse 1.2s ease-in-out infinite; }
.ask svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ask.is-busy .send { opacity: .45; pointer-events: none; }
.hint { margin: 0; text-align: center; font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--dim); white-space: nowrap; }
body[data-mode="sleep"] .dock, body[data-mode="sleep"] .hud { opacity: 0; pointer-events: none; }
body[data-mode="sleep"] .dock { transform: translate(-50%, 20px); }

/* ——— Brief dialog ——— */
.brief { width: min(460px, calc(100vw - 32px)); padding: 24px; border: 1px solid var(--line-2); border-radius: 20px; background: #120d10; color: var(--text); overscroll-behavior: contain; }
.brief::backdrop { background: rgba(0, 0, 0, .65); backdrop-filter: blur(4px); }
.brief h2 { margin: 0; font: 400 34px/1 var(--serif); }
.brief p { margin: 8px 0 18px; color: var(--muted); font-size: 14px; }
.brief label { display: grid; gap: 6px; margin-bottom: 12px; font: 500 10px/1 var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.brief input { min-height: 46px; padding: 0 14px; border: 1px solid var(--line-2); border-radius: 12px; background: rgba(0, 0, 0, .3); font: 16px/1.2 var(--sans); letter-spacing: 0; text-transform: none; color: var(--text); outline: none; transition: border-color .2s ease, box-shadow .2s ease; }
.brief input:focus { border-color: rgba(255, 90, 105, .6); box-shadow: 0 0 0 3px rgba(255, 42, 63, .12); }
.brief input::placeholder { color: var(--dim); }
.brief-actions { display: flex; gap: 10px; margin-top: 16px; }
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 46px; padding: 0 22px; border: 1px solid var(--line-2); border-radius: 999px; background: rgba(255, 255, 255, .03); font: 500 12px/1 var(--mono); letter-spacing: .08em; text-transform: uppercase; transition: background-color .2s ease, border-color .2s ease, transform .2s var(--ease); }
.btn:hover { border-color: rgba(255, 90, 105, .6); background: rgba(255, 42, 63, .08); }
.btn:active { transform: scale(.97); }
.btn-red { border-color: var(--red); background: var(--red); color: var(--ink); }
.btn-red:hover { background: var(--red-2); border-color: var(--red-2); }

.toast { position: fixed; z-index: 30; left: 50%; top: 84px; padding: 10px 16px; border: 1px solid var(--line-2); border-radius: 12px; background: #1a0b0e; font-size: 12px; transform: translate(-50%, -8px); opacity: 0; pointer-events: none; transition: opacity .25s ease, transform .25s var(--ease); }
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }
.noscript { position: fixed; inset: 0; display: grid; place-items: center; margin: 0; color: var(--muted); font-family: var(--mono); }

@media (max-width: 1100px) { .transmission { display: none; } }
@media (max-width: 900px) {
  .hud, .build, .role { display: none; }
  .side { left: var(--g); width: auto; top: 70px; }
  .caption { font-size: clamp(19px, 5vw, 26px); }
}
@media (max-width: 520px) {
  :root { --dock: 128px; }
  .top { gap: 10px; }
  .brand span { font-size: 21px; }
  .top-right { gap: 6px; }
  .chip { width: 34px; padding: 0; justify-content: center; }
  .chip span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .hint { display: none; }
  .wake-btn small { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
