:root {
  color-scheme: light dark;
  --bg: #f5f5f2;
  --surface: #ffffff;
  --text: #17181b;
  --muted: #62656d;
  --line: #e2e2dc;
  --accent: #2f5bea;
  --accent-text: #ffffff;
  --me: #2f5bea;
  --me-text: #ffffff;
  --mike: #ffffff;
  --danger: #c4372c;
  --ok: #1d7a46;
  --radius: 18px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121316;
    --surface: #1c1d22;
    --text: #ececef;
    --muted: #9a9ca5;
    --line: #2b2d34;
    --accent: #7d9bff;
    --accent-text: #0d1020;
    --me: #3d64f0;
    --me-text: #ffffff;
    --mike: #1f2026;
    --danger: #ff7b70;
    --ok: #5fd08e;
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.error { color: var(--danger); min-height: 1.4em; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; -webkit-tap-highlight-color: transparent; }
button:focus-visible, textarea:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.primary {
  background: var(--accent); color: var(--accent-text); border-radius: 14px;
  padding: 14px 22px; font-weight: 600; min-height: 48px; width: 100%;
}
.primary:disabled { opacity: .5; }

.gate { min-height: 100%; display: grid; place-items: center; padding: 24px 16px calc(24px + var(--safe-b)); }
.gate-card { width: 100%; max-width: 360px; text-align: center; }
.gate-card h1 { font-size: 28px; margin: 16px 0 4px; letter-spacing: -0.01em; }
.gate-card p { margin: 0 0 24px; }
.mark { border-radius: 18px; }

.chat { height: 100dvh; display: flex; flex-direction: column; }
.bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(8px + var(--safe-t)) 12px 8px 16px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(12px); -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 2;
}
.who { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 17px; }
.who img { border-radius: 9px; }
.icon { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; fill: currentColor; flex: none; }
.icon:active { background: var(--line); }

.log { list-style: none; margin: 0; padding: 16px 12px 8px; flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; overscroll-behavior: contain; }
.msg { max-width: 82%; padding: 10px 14px; border-radius: var(--radius); white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.me { align-self: flex-end; background: var(--me); color: var(--me-text); border-bottom-right-radius: 6px; }
.msg.mike { align-self: flex-start; background: var(--mike); border: 1px solid var(--line); border-bottom-left-radius: 6px; }
.msg.status { align-self: flex-start; color: var(--muted); font-size: 14px; padding: 4px 6px; }
.msg.status::after { content: ""; display: inline-block; width: 1.2em; text-align: left; animation: dots 1.2s steps(4) infinite; }
@keyframes dots { 0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75% { content: "..."; } }
@media (prefers-reduced-motion: reduce) { .msg.status::after { animation: none; content: "..."; } }
.day { align-self: center; font-size: 12px; color: var(--muted); padding: 8px 0 2px; }

.card { align-self: stretch; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: grid; gap: 10px; }
.card p { margin: 0; }
.card .label { font-size: 13px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.card .row { display: flex; gap: 8px; }
.card .row button { flex: 1; min-height: 44px; border-radius: 12px; border: 1px solid var(--line); font-weight: 600; }
.card .row .go { background: var(--accent); color: var(--accent-text); border-color: transparent; }
.card.done { opacity: .7; }
.card .result { color: var(--ok); font-weight: 600; }

.composer {
  display: flex; align-items: flex-end; gap: 6px;
  padding: 8px 8px calc(8px + var(--safe-b)); border-top: 1px solid var(--line); background: var(--bg);
}
.composer textarea {
  flex: 1; resize: none; max-height: 140px; min-height: 44px;
  padding: 11px 14px; border-radius: 22px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); font: inherit; font-size: 16px;
}
.send { color: var(--accent); fill: var(--accent); }
.talk.listening { background: var(--danger); fill: #fff; }

.sheet {
  border: 0; border-radius: 22px 22px 0 0; padding: 20px 16px calc(20px + var(--safe-b));
  width: 100%; max-width: 520px; margin: auto auto 0; background: var(--surface); color: var(--text);
}
.sheet::backdrop { background: rgb(0 0 0 / .35); }
.sheet h2 { margin: 0 0 12px; font-size: 20px; }
.sheet > button { display: block; width: 100%; text-align: left; padding: 14px 4px; border-bottom: 1px solid var(--line); min-height: 48px; }
.sheet .danger { color: var(--danger); }
.sheet .ghost { text-align: center; color: var(--muted); border-bottom: 0; }
.stack { display: grid; gap: 8px; padding: 12px 0; }
.stack input { font: inherit; font-size: 16px; padding: 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); color: var(--text); }
.stack output, #device-out { overflow-wrap: anywhere; }
