/* Bench Signs — SER palette (iepmomentum.com tokens, July 2026 refresh) */
:root {
  --deep-teal: #124c51;
  --teal: #1a6b72;
  --amber: #f5a623;
  --amber-ink: #3a2a06;
  --cream: #fdf8f3;
  --panel: #fffdfa;
  --sky: #d4eef7;

  --bg: var(--cream);
  --surface: var(--panel);
  --ink: #1c1c1e;
  --muted: #4f6668;
  --line: rgba(18, 76, 81, 0.14);
  --line-strong: rgba(18, 76, 81, 0.32);
  --accent: var(--deep-teal);
  --accent-ink: #ffffff;
  --accent-soft: var(--sky);
  --cta: var(--amber);
  --cta-ink: var(--amber-ink);
  --good: #2c7a4b;
  --warn: #b0651a;
  --bad: #b23a3a;
  --card: var(--panel);          /* the stage: letters are black line art, so it stays light in both themes */
  --card-ink: #1c1c1e;
  --card-muted: #4f6668;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1f21;
    --surface: #143236;
    --ink: #f3efe8;
    --muted: #a3b8ba;
    --line: rgba(212, 238, 247, 0.16);
    --line-strong: rgba(212, 238, 247, 0.34);
    --accent: #8fd0d8;
    --accent-ink: #0e1f21;
    --accent-soft: #1b4a50;
    --good: #6fd39a;
    --warn: #f0b45f;
    --bad: #ef8a8a;
    --card: var(--cream);
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Atkinson Hyperlegible", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 17px;
  line-height: 1.4;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}
button, input { font: inherit; color: inherit; }
button {
  background: var(--surface);
  border: 1.5px solid var(--line-strong);
  border-radius: 12px;
  padding: 0.6rem 1.1rem;
  font-weight: 700;
  cursor: pointer;
  min-height: 48px;
  touch-action: manipulation;
  color: var(--ink);
}
button:focus-visible, input:focus-visible, a:focus-visible { outline: 3px solid var(--amber); outline-offset: 2px; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button.cta { background: var(--cta); color: var(--cta-ink); border-color: var(--cta); }
button.icon { padding: 0.4rem 0.8rem; font-size: 1.3rem; line-height: 1; }
button.tiny { min-height: 32px; padding: 0.2rem 0.7rem; font-size: 0.85rem; font-weight: 400; }
button[disabled] { opacity: 0.45; cursor: default; }

#app {
  height: 100%;
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

/* ---------- header ---------- */
.bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.9rem;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.brand { display: flex; flex-direction: column; line-height: 1.05; white-space: nowrap; }
.brand-name {
  font-family: "Fraunces", Georgia, serif;
  font-weight: 700;
  font-size: 1.35rem;
  color: var(--accent);
  letter-spacing: -0.01em;
}
.brand-name::after {
  content: "";
  display: inline-block;
  width: 0.55em; height: 0.18em;
  background: var(--amber);
  border-radius: 2px;
  margin-left: 0.35em;
  vertical-align: 0.15em;
}
.brand-by { font-size: 0.68rem; color: var(--muted); letter-spacing: 0.04em; }
.status { display: flex; align-items: center; gap: 0.4rem; font-size: 0.9rem; color: var(--muted); white-space: nowrap; }
.status .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--line-strong); }
.status[data-state="listening"] .dot { background: var(--amber); box-shadow: 0 0 0 4px rgba(245, 166, 35, 0.3); animation: pulse 1.6s infinite; }
.status[data-state="paused"] .dot { background: var(--warn); }
.status[data-state="blocked"] .dot, .status[data-state="unsupported"] .dot { background: var(--bad); }
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.25); } }
@media (prefers-reduced-motion: reduce) { .status .dot { animation: none; } }
.typeform { flex: 1; min-width: 0; }
.typeform input {
  width: 100%;
  border: 1.5px solid var(--line-strong);
  border-radius: 12px;
  padding: 0.55rem 0.8rem;
  background: var(--bg);
  min-height: 44px;
}

/* ---------- main ---------- */
.main {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(280px, 1fr);
  gap: 0.9rem;
  padding: 0.9rem;
  min-height: 0;
}
.stage {
  position: relative;
  background: var(--card);
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  color: var(--card-ink);
}
.stage > * { display: none; }
.stage[data-mode="idle"] .idle { display: block; }
.stage[data-mode="video"] #signVideo { display: block; }
.stage[data-mode="spell"] .spell { display: flex; }
.stage[data-mode="video"] .stage-caption, .stage[data-mode="spell"] .stage-caption { display: block; }
.idle { padding: 2rem; text-align: center; color: var(--card-ink); max-width: 30rem; }
.idle-big { font-family: "Fraunces", Georgia, serif; font-weight: 600; font-size: 1.6rem; margin: 0 0 0.6rem; }
.idle-small { color: var(--card-muted); margin: 0; }
#signVideo { width: 100%; height: 100%; object-fit: contain; background: #000; }
.spell { flex-direction: column; align-items: center; justify-content: center; height: 100%; width: 100%; gap: 0.25rem; }
#bigLetter { height: 62%; max-width: 80%; object-fit: contain; }
#bigLetter[hidden] { display: none; }
.big-letter-text {
  font-family: "Fraunces", Georgia, serif;
  font-weight: 700;
  font-size: clamp(2.5rem, 9vh, 6rem);
  line-height: 1;
  color: var(--card-ink);
}
.spell-row { display: none; flex-direction: column; align-items: center; justify-content: center; width: 100%; padding: 0 2%; }
.spell-line { display: flex; align-items: flex-end; justify-content: center; }
.spell[data-phase="word"] .spell-row { display: flex; }
.spell[data-phase="word"] #bigLetter { display: none; }
.spell[data-phase="word"] .big-letter-text { font-size: clamp(1.8rem, 6.5vh, 4rem); margin-top: 0.4rem; }
.spell-row .l { display: flex; flex-direction: column; align-items: center; gap: 0.15rem; min-width: 0; flex: 0 0 auto; }
.spell-row .l img { width: 100%; height: auto; object-fit: contain; }
.spell-row .l span { font-weight: 700; color: var(--card-muted); text-transform: uppercase; line-height: 1; }
.spell-row .gap { flex: 0 0 auto; }
.stage-caption {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 0.4rem 0.9rem;
  font-size: 0.85rem;
  color: var(--card-muted);
  background: linear-gradient(transparent, rgba(253, 248, 243, 0.92));
}

.side {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  min-height: 0;
  overflow: auto;
}
.word {
  font-family: "Fraunces", Georgia, serif;
  font-weight: 700;
  font-size: clamp(2.2rem, 6vw, 4.6rem);
  line-height: 1.05;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
  color: var(--accent);
}
.letters { display: flex; flex-wrap: wrap; gap: 0.35rem; min-height: 56px; }
.letters .l {
  display: flex; flex-direction: column; align-items: center; gap: 0.1rem;
  background: var(--card); border: 1px solid var(--line-strong); border-radius: 8px; padding: 0.25rem 0.3rem;
  cursor: pointer;
}
.letters .l img { height: 44px; width: auto; }
.letters .l span { font-size: 0.8rem; font-weight: 700; color: var(--card-ink); text-transform: uppercase; }
.letters .l.active { outline: 3px solid var(--amber); }
.letters .gap { width: 0.6rem; }
.source { font-size: 0.85rem; color: var(--muted); min-height: 1.2em; }
.controls { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.controls button { flex: 1 1 auto; font-size: 1.1rem; min-height: 56px; }
.controls.secondary button, .controls.secondary .linkbtn { font-size: 0.95rem; min-height: 44px; }
.linkbtn {
  display: inline-flex; align-items: center; justify-content: center;
  border: 1.5px solid var(--line-strong); border-radius: 12px; padding: 0.4rem 1rem;
  text-decoration: none; color: var(--accent); font-weight: 700; background: var(--surface);
}
.interim { font-size: 0.95rem; color: var(--muted); min-height: 1.3em; font-style: italic; }
.heard { font-size: 0.8rem; color: var(--muted); display: none; max-height: 6em; overflow: auto; white-space: pre-line; }
.heard.on { display: block; }

/* ---------- today ---------- */
.today {
  border-top: 1px solid var(--line);
  background: var(--surface);
  padding: 0.5rem 0.9rem 0.6rem;
}
.today-head { display: flex; justify-content: space-between; align-items: center; font-size: 0.85rem; color: var(--muted); margin-bottom: 0.35rem; }
.today-head .count { color: var(--muted); }
.chips { display: flex; gap: 0.4rem; overflow-x: auto; padding-bottom: 0.2rem; }
.chip {
  flex: 0 0 auto;
  border: 1.5px solid var(--line-strong); border-radius: 999px;
  padding: 0.35rem 0.9rem; background: var(--bg);
  font-weight: 700; min-height: 40px;
}
.chip.has-video { border-color: var(--amber); }
.chip small { font-weight: 400; color: var(--muted); margin-left: 0.3rem; }

/* ---------- dialogs ---------- */
dialog.panel {
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  background: var(--surface);
  color: var(--ink);
  padding: 1.25rem 1.4rem;
  width: min(92vw, 34rem);
  max-height: 90vh;
  overflow: auto;
}
dialog::backdrop { background: rgba(18, 76, 81, 0.5); }
dialog h2 { margin: 0 0 0.9rem; font-family: "Fraunces", Georgia, serif; font-weight: 700; font-size: 1.4rem; color: var(--accent); }
dialog h3 { margin: 1.2rem 0 0.4rem; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
dialog label { display: block; margin-bottom: 0.9rem; font-size: 0.95rem; }
dialog label input[type="range"] { width: 100%; display: block; margin-top: 0.3rem; accent-color: var(--amber); }
dialog label.check { display: flex; align-items: center; gap: 0.5rem; }
dialog label.check input { accent-color: var(--deep-teal); }
dialog .row { display: flex; gap: 0.5rem; justify-content: flex-end; margin-top: 1rem; flex-wrap: wrap; }
.unknown, .recorded { display: flex; flex-wrap: wrap; gap: 0.4rem; font-size: 0.9rem; }
.unknown .chip, .recorded .chip { min-height: 36px; padding: 0.25rem 0.7rem; font-size: 0.9rem; }
.recorded .chip button { min-height: 0; padding: 0 0.3rem; border: 0; background: none; color: var(--bad); font-size: 0.85rem; }
.rec-stage { position: relative; background: #000; border-radius: 12px; overflow: hidden; aspect-ratio: 4 / 3; }
.rec-stage video { width: 100%; height: 100%; object-fit: cover; display: block; }
.rec-stage video[hidden] { display: none; }
.countdown {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-family: "Fraunces", Georgia, serif; font-size: 6rem; font-weight: 700; color: #fff;
  text-shadow: 0 2px 12px rgba(0,0,0,0.6);
}
.countdown[hidden] { display: none; }
.countdown.recording { font-size: 1.2rem; align-items: flex-start; justify-content: flex-start; padding: 0.8rem; color: #ff5b5b; }
.rec-help { font-size: 0.9rem; color: var(--muted); }

/* ---------- portrait / small ---------- */
@media (max-width: 760px), (orientation: portrait) {
  .main { grid-template-columns: 1fr; grid-template-rows: minmax(220px, 1fr) auto; }
  .bar { flex-wrap: wrap; }
  .typeform { order: 5; flex-basis: 100%; }
  .word { font-size: clamp(2rem, 10vw, 3.5rem); }
}
