@font-face { font-family: "Courier Prime"; font-weight: 400; src: url("../fonts/courier-prime-latin-400-normal.woff2") format("woff2"); font-display: swap; }
@font-face { font-family: "Courier Prime"; font-weight: 700; src: url("../fonts/courier-prime-latin-700-normal.woff2") format("woff2"); font-display: swap; }
@font-face { font-family: "IBM Plex Sans Condensed"; font-weight: 400; src: url("../fonts/ibm-plex-sans-condensed-latin-400-normal.woff2") format("woff2"); font-display: swap; }
@font-face { font-family: "IBM Plex Sans Condensed"; font-weight: 600; src: url("../fonts/ibm-plex-sans-condensed-latin-600-normal.woff2") format("woff2"); font-display: swap; }

:root {
  --bg: #11201F; --panel: #1A2D2E; --ink: #E9E3D0; --muted: #9AAAA8; --rule: #2F4546;
  --brass: #D8B45C; --lamp-off: #3B3A2E; --lamp-on: #FFB940; --bad: #F08A78; --good: #8FD19E;
  --btn: #D8B45C; --btn-ink: #11201F;
  --mono: "Courier Prime", "Courier New", ui-monospace, monospace;
  --sans: "IBM Plex Sans Condensed", "Arial Narrow", system-ui, sans-serif;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root { --bg: #E4EAEA; --panel: #F3F6F5; --ink: #1B2A2D; --muted: #56686B; --rule: #C3CFCF; --brass: #8C6A1F;
    --lamp-off: #CBBF9C; --lamp-on: #F0A92E; --bad: #A3392B; --good: #2F7A45; --btn: #1E3B41; --btn-ink: #F3F6F5; color-scheme: light; }
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }   /* .fld is display:flex, which would otherwise win */
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--sans); font-size: 17px; line-height: 1.45;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
main { max-width: 560px; margin: 0 auto; padding: 14px; display: flex; flex-direction: column; gap: 12px; }
button, select, input { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--brass); outline-offset: 2px; }

.top { display: flex; align-items: center; gap: 12px; }
.title { flex: 1; }
h1 { font-family: var(--mono); font-weight: 700; font-size: 28px; line-height: 1.05; margin: 0; }
.sub { margin: 0; color: var(--muted); font-family: var(--mono); font-size: 14px; }

.stage { background: var(--panel); border: 1px solid var(--rule); border-radius: 14px; padding: 16px; min-height: 190px; display: flex; flex-direction: column; gap: 8px; }
.statusrow { display: flex; align-items: center; gap: 12px; }
.lamp { width: 22px; height: 22px; border-radius: 50%; background: var(--lamp-off); border: 2px solid var(--rule); flex: none; }
.lamp.on { background: var(--lamp-on); box-shadow: 0 0 14px var(--lamp-on); border-color: var(--lamp-on); }
.state { font-family: var(--mono); font-weight: 700; font-size: 30px; line-height: 1.1; }
.state.listening { color: var(--good); }
.info { margin: 0; color: var(--muted); }
.meta { margin: auto 0 0; color: var(--muted); font-size: 14px; font-family: var(--mono); }
.result { border-top: 1px solid var(--rule); padding-top: 8px; }
.said { margin: 0 0 4px; color: var(--muted); font-size: 15px; }
.answer { margin: 0; font-family: var(--mono); font-weight: 700; font-size: 30px; letter-spacing: .04em; word-break: break-word; }
.answer.ok { color: var(--good); } .answer.bad { color: var(--bad); }
.pro { text-decoration: overline; text-decoration-thickness: 2px; }

.controls { display: flex; flex-direction: column; gap: 10px; }
button { cursor: pointer; border-radius: 12px; border: 2px solid var(--btn); background: transparent; padding: 10px 14px; min-height: 48px; touch-action: manipulation; }
button.big { background: var(--btn); color: var(--btn-ink); font-weight: 600; font-size: 26px; min-height: 84px; border-radius: 16px; }
button.sm { font-size: 16px; }
button.ghost { border-color: var(--rule); font-size: 15px; min-height: 40px; }
button:disabled { opacity: .4; cursor: default; }
.row4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.row4 .sm { padding: 10px 4px; }

.panel { background: var(--panel); border: 1px solid var(--rule); border-radius: 12px; padding: 0 14px; }
.panel > summary { cursor: pointer; font-weight: 600; padding: 14px 0; min-height: 48px; }
.panel[open] { padding-bottom: 14px; }
.panel[open] > summary { padding-bottom: 8px; }
.panel > * + * { margin-top: 12px; }
.panel > summary + * { margin-top: 4px; }
.fld { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.lbl { font-size: 14px; color: var(--muted); } .lbl b { color: var(--ink); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
select, input[type=text] { width: 100%; min-height: 44px; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--rule); background: var(--bg); }
input[type=range] { width: 100%; min-height: 36px; accent-color: var(--brass); }
.chk { display: flex; gap: 10px; align-items: flex-start; }
.chk input { width: 22px; height: 22px; margin: 1px 0 0; accent-color: var(--brass); flex: none; }
.note { margin: 0; color: var(--muted); font-size: 15px; }
.cmds { margin: 0; padding-left: 20px; } .cmds li { margin: 4px 0; }
.weak { margin: 0; font-family: var(--mono); font-size: 18px; word-spacing: .4em; }
footer { color: var(--muted); font-size: 14px; text-align: center; padding: 8px 0 24px; } footer p { margin: 2px 0; }

/* Drive mode: big, dark, nothing else */
body.drive { --bg: #000; --panel: #000; --ink: #E9E3D0; --muted: #9AAAA8; --rule: #333; --brass: #D8B45C; --lamp-off: #3B3A2E; --lamp-on: #FFB940;
  --bad: #F08A78; --good: #8FD19E; --btn: #D8B45C; --btn-ink: #11201F; color-scheme: dark; background: #000; }
body.drive .settings, body.drive details, body.drive footer, body.drive .row4 .sm:nth-child(2), body.drive .row4 .sm:nth-child(3) { display: none; }
body.drive .stage { border-color: #222; min-height: 40vh; justify-content: center; }
body.drive .state { font-size: 44px; } body.drive .answer { font-size: 44px; }
body.drive .row4 { grid-template-columns: 1fr 1fr; } body.drive .row4 .sm { min-height: 72px; font-size: 22px; }
body.drive button.big { min-height: 120px; font-size: 34px; }
body.drive .top .title, body.drive .top img { opacity: .5; }
@media (prefers-reduced-motion: no-preference) { .lamp { transition: background .04s, box-shadow .04s; } }

/* Log */
.logbox { padding: 0 14px 12px; }
.loghead { display: flex; align-items: center; gap: 8px; padding: 12px 0 6px; }
.loghead .spacer { flex: 1; }
button.tiny { min-height: 34px; padding: 4px 10px; font-size: 14px; }
.logscroll { max-height: 220px; overflow-y: auto; border-top: 1px solid var(--rule); padding-top: 8px; }
#logList { list-style: none; margin: 0; padding: 0; font-size: 15px; }
#logList li { padding: 3px 0; border-bottom: 1px solid color-mix(in srgb, var(--rule) 45%, transparent); }
#logList li:last-child { border-bottom: 0; }
.log-app { color: var(--ink); }
.log-you { color: var(--muted); font-family: var(--mono); font-size: 14px; }
.log-note { color: var(--muted); font-style: italic; font-size: 14px; }
.log-answer { font-style: italic; font-family: var(--mono); color: var(--brass); }
.taphint { margin: -2px 0 0; text-align: center; color: var(--muted); font-size: 14px; }
.hint { display: block; color: var(--muted); font-size: 13.5px; }
.row-extra .sm { font-size: 15px; }

/* Drive mode: big, dark, nothing else. The pause button is the one you must hit without looking. */
body.drive .logbox, body.drive .row-extra, body.drive #bEnd { display: none; }
body.drive button.big { min-height: 160px; font-size: 40px; }
body.drive .row4 { grid-template-columns: 1fr 1fr; }
body.drive .row4 .sm:nth-child(2), body.drive .row4 .sm:nth-child(3) { display: none; }
body.drive .taphint { font-size: 16px; }
