:root {
  --bg: #0f1115;
  --card: #181b22;
  --card-2: #20242d;
  --text: #eef0f4;
  --muted: #9aa3b2;
  --line: #2b303b;
  --accent: #e3b04b;      /* warm gold */
  --listen: #3fb67a;
  --speak: #4b8fe3;
  --pause: #8a8f99;
  --error: #e35d4b;
  --radius: 16px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 17px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding: max(12px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
  max-width: 720px;
  margin: 0 auto;
}
h1 { font-size: 1.3rem; margin: 0; letter-spacing: .01em; }
h2 { font-size: .85rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 0 0 8px; }
.top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px 12px; margin-bottom: 14px; }
.brand { display: grid; gap: 6px; min-width: 0; }
.version { margin-left: .6em; font-size: .75rem; font-weight: 400; color: var(--muted); letter-spacing: 0; vertical-align: middle; }
.account { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.account-name { background: none; border: 0; padding: 4px 2px; color: var(--muted); font: inherit; font-size: .85rem; cursor: pointer;
  max-width: 11em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-name:hover { color: inherit; text-decoration: underline; }
@media (max-width: 420px) { .account { flex-direction: column; align-items: flex-end; gap: 2px; } }
.badges { display: flex; gap: 6px; flex-wrap: wrap; }
.badge { font-size: .75rem; padding: 3px 9px; border-radius: 999px; background: var(--card-2); color: var(--muted); border: 1px solid var(--line); }
.badge.good { color: var(--listen); border-color: color-mix(in srgb, var(--listen) 50%, transparent); }
.badge.warn { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 50%, transparent); }

main { display: grid; gap: 14px; }
section, .panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }

.status-card { display: flex; align-items: center; gap: 18px; min-height: 120px; }
.orb { flex: none; width: 84px; height: 84px; border-radius: 50%; display: grid; place-items: center; background: var(--card-2); border: 2px solid var(--line); transition: background .2s, border-color .2s; }
.orb span { width: 30px; height: 30px; border-radius: 50%; background: var(--pause); transition: background .2s; }
.orb.listening { border-color: var(--listen); animation: pulse 1.6s ease-in-out infinite; }
.orb.listening span { background: var(--listen); }
.orb.speaking { border-color: var(--speak); }
.orb.speaking span { background: var(--speak); animation: wobble .5s ease-in-out infinite alternate; }
.orb.thinking span { background: var(--accent); }
.orb.paused span { background: var(--pause); }
.orb.error { border-color: var(--error); }
.orb.error span { background: var(--error); }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--listen) 45%, transparent); } 50% { box-shadow: 0 0 0 14px transparent; } }
@keyframes wobble { from { transform: scale(.85); } to { transform: scale(1.1); } }
@media (prefers-reduced-motion: reduce) { .orb, .orb span { animation: none !important; } }
.status { font-size: 1.5rem; font-weight: 650; }
.heard { color: var(--muted); margin-top: 4px; min-height: 1.4em; word-break: break-word; }

.controls { display: flex; gap: 10px; flex-wrap: wrap; background: none; border: 0; padding: 0; }
.btn {
  appearance: none; border: 1px solid var(--line); background: var(--card-2); color: var(--text);
  font: inherit; font-weight: 600; padding: 16px 22px; border-radius: 14px; cursor: pointer; flex: 1 1 140px;
}
.btn.primary { background: var(--accent); color: #1b1606; border-color: transparent; }
.btn.small { padding: 10px 14px; flex: 0 0 auto; font-size: .95rem; }
.btn:disabled { opacity: .45; cursor: default; }
.btn:focus-visible, select:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.ref { color: var(--accent); font-weight: 650; font-size: 1.05rem; margin-bottom: 6px; }
.verse { font-size: 1.35rem; line-height: 1.5; margin: 0; font-family: Georgia, "Times New Roman", serif; }
.verse .read { color: var(--muted); }
.verse .now { color: var(--text); background: color-mix(in srgb, var(--accent) 22%, transparent); border-radius: 4px; padding: 0 2px; }
.verse .ahead { color: color-mix(in srgb, var(--muted) 45%, transparent); }

.log { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 6px; max-height: 240px; overflow-y: auto; }
.log li { font-size: .95rem; padding: 6px 10px; border-radius: 10px; background: var(--card-2); }
.log li.you { color: var(--muted); }
.log li.you::before { content: "You: "; font-weight: 600; }
.log li.app::before { content: "App: "; font-weight: 600; color: var(--accent); }
.log li.sys { color: var(--muted); font-style: italic; background: none; padding: 2px 10px; }
.type-form { display: flex; gap: 8px; }
.type-form input { flex: 1; min-width: 0; }
input[type=text], select {
  font: inherit; color: var(--text); background: var(--card-2); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; width: 100%;
}
input[type=range] { width: 100%; accent-color: var(--accent); }

.panel summary { cursor: pointer; font-weight: 600; }
.panel[open] summary { margin-bottom: 12px; }
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label { color: var(--muted); font-size: .9rem; display: flex; justify-content: space-between; }
.check { display: flex; align-items: center; gap: 10px; padding: 8px 0; }
.check input { width: 22px; height: 22px; accent-color: var(--accent); }
.muted { color: var(--muted); font-size: .9rem; }
.diag { margin: 12px 0 0; padding-left: 18px; font-size: .92rem; }
.diag .ok { color: var(--listen); }
.diag .bad { color: var(--error); }
.diag .meh { color: var(--accent); }
.learned-title { margin: 14px 0 6px; }
.learned { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.learned li { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: .92rem;
  padding: 6px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--card-2); }
.learned li span { min-width: 0; overflow-wrap: anywhere; }
.learned li.empty { color: var(--muted); border-style: dashed; background: none; }
.learned button { background: none; border: 0; color: var(--muted); font: inherit; cursor: pointer; padding: 4px 6px; }
.learned button:hover { color: var(--error); }
.help { padding-left: 18px; margin: 0; display: grid; gap: 6px; }
input[type=file] { color: var(--muted); font: inherit; max-width: 100%; }
code { background: var(--card-2); padding: 1px 5px; border-radius: 5px; font-size: .85em; }
.verse sup { color: var(--accent); font-family: system-ui, sans-serif; font-size: .6em; margin-right: 2px; }
.verse .ctx { color: var(--muted); }
.verse .plain { color: var(--text); }
.passage-card .verse { max-height: 55vh; overflow-y: auto; }

/* access-code gate */
body.locked > header, body.locked > main { display: none; }
.gate { position: fixed; inset: 0; display: grid; place-items: center; padding: 16px; background: var(--bg); z-index: 10; }
.gate[hidden] { display: none; }
.gate-form { width: 100%; max-width: 360px; display: grid; gap: 12px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; }
.gate-form h1 { font-size: 1.4rem; }
.gate-form p { margin: 0; color: var(--muted); }
.gate-form input { font: inherit; color: var(--text); background: var(--card-2); border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.gate-error { color: var(--error) !important; min-height: 1.2em; }
