/* Kiosk theme: dark surface for a bright hall, large type readable from ~2 m.
   Series colours = validated categorical slots 1–2 (dark steps) of the dataviz palette. */
:root {
  color-scheme: dark;
  --surface-0: #111110;
  --surface-1: #1a1a19;
  --surface-2: #262624;
  --line: #3a3936;
  --text-primary: #f0efec;
  --text-secondary: #c3c2b7;
  --text-muted: #8f8e86;
  --series-1: #3987e5;   /* blue: old variant, reference vowels, tree */
  --series-2: #d95926;   /* orange: new variant, live voice */
  --accent: #3987e5;
  --good: #199e70;
  --overlay: rgba(17,17,16,.88);
  --radius: 12px;
  font-size: clamp(14px, 0.8vw + 6px, 20px);
}
/* Light theme: same hues, stepped for a light surface (dataviz palette slots 1–2, light column). */
:root[data-theme="light"] {
  color-scheme: light;
  --surface-0: #f1f0ec;
  --surface-1: #fcfcfb;
  --surface-2: #e6e5df;
  --line: #cfcdc5;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #6f6e68;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --accent: #2a78d6;
  --good: #1baf7a;
  --overlay: rgba(252,252,251,.92);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--surface-0);
  color: var(--text-primary);
  font-family: -apple-system, "Helvetica Neue", "Segoe UI", Roboto, sans-serif;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  user-select: none;
}

header {
  display: flex;
  align-items: center;
  gap: 1.2rem;
  padding: .7rem 1.2rem;
  border-bottom: 1px solid var(--line);
  background: var(--surface-1);
}
header .brand { line-height: 1.15; }
header .brand b { font-size: 1.25rem; display: block; }
header .brand span { color: var(--text-secondary); font-size: .85rem; }
nav { display: flex; gap: .5rem; margin-left: auto; }
nav button {
  font: inherit;
  font-size: 1rem;
  padding: .6rem 1.1rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
}
nav button[aria-selected="true"] {
  background: var(--text-primary);
  color: var(--surface-0);
  border-color: var(--text-primary);
}
#qr { width: 64px; height: 64px; background: #fff; border-radius: 6px; padding: 4px; flex: none; }
#qr svg, #qr img { width: 100%; height: 100%; display: block; }

main { flex: 1; min-height: 0; position: relative; }
section.demo {
  position: absolute; inset: 0;
  display: none;
  grid-template-columns: minmax(0, 1fr) 24rem;
  gap: 1rem;
  padding: 1rem 1.2rem;
}
section.demo.active { display: grid; }

.stage {
  background: var(--surface-1);
  border-radius: var(--radius);
  position: relative;
  min-height: 0;
  overflow: hidden;
}
.side {
  display: flex; flex-direction: column; gap: .9rem;
  min-height: 0; overflow-y: auto;
}
.side h2 { margin: 0; font-size: 1.6rem; line-height: 1.15; }
.side p { margin: 0; color: var(--text-secondary); line-height: 1.4; }
.side .big { font-size: 1.15rem; color: var(--text-primary); }
.card {
  background: var(--surface-1);
  border-radius: var(--radius);
  padding: .8rem 1rem;
}
.card h3 { margin: 0 0 .4rem; font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); }
.courses { display: flex; flex-direction: column; gap: .25rem; font-size: .9rem; }
.courses code { font-family: ui-monospace, Menlo, monospace; color: var(--text-primary); margin-right: .4rem; }
.courses span { color: var(--text-secondary); }

button.action, .chips button {
  font: inherit;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text-primary);
  padding: .6rem 1rem;
  cursor: pointer;
}
button.action.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.action:active, .chips button:active { transform: scale(.97); }
.row { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.chips { display: flex; gap: .4rem; flex-wrap: wrap; }
.chips button { padding: .35rem .7rem; font-size: .9rem; }

label.slider { display: flex; flex-direction: column; gap: .2rem; font-size: .9rem; color: var(--text-secondary); }
label.slider .lab { display: flex; justify-content: space-between; }
label.slider b { color: var(--text-primary); font-weight: 600; }
input[type=range] { width: 100%; accent-color: var(--accent); height: 1.6rem; }

.legend { display: flex; gap: 1rem; flex-wrap: wrap; font-size: .9rem; color: var(--text-secondary); }
.legend i { display: inline-block; width: .8rem; height: .8rem; border-radius: 3px; margin-right: .35rem; vertical-align: -1px; }

/* SVG chart text: text tokens only, never series colours */
svg text { fill: var(--text-secondary); font-family: inherit; }
.axis path, .axis line { stroke: var(--line); }
.axis text { fill: var(--text-muted); font-size: 12px; }
.grid line { stroke: var(--surface-2); }
.axis-title { fill: var(--text-muted); font-size: 13px; }

.overlay {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1rem;
  background: var(--overlay);
  text-align: center; padding: 2rem;
  z-index: 5;
}
.overlay[hidden] { display: none; }
.overlay p { color: var(--text-secondary); max-width: 32rem; margin: 0; line-height: 1.4; }

.tooltip {
  position: absolute; pointer-events: none;
  background: var(--surface-2); color: var(--text-primary);
  border: 1px solid var(--line); border-radius: 8px;
  padding: .35rem .6rem; font-size: .85rem; white-space: nowrap;
  opacity: 0; transition: opacity .1s;
}

/* Predictor */
.prompt-line {
  display: flex; gap: .5rem; align-items: center;
  position: absolute; top: 1rem; left: 1rem; right: 1rem; z-index: 2;
}
.prompt-line input {
  flex: 1; font: inherit; font-size: 1.35rem;
  padding: .55rem .9rem; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface-0); color: var(--text-primary);
  user-select: text;
}
.backoff { position: absolute; left: 1rem; bottom: .8rem; font-size: .85rem; color: var(--text-muted); z-index: 2; }
.node rect { fill: var(--surface-2); stroke: var(--line); }
.node.root rect { fill: var(--text-primary); }
.node.root text.word { fill: var(--surface-0); font-weight: 700; }
.node text.word { fill: var(--text-primary); font-size: 17px; }
.node text.prob { fill: var(--text-muted); font-size: 12px; }
.node.clickable { cursor: pointer; }
.node.clickable:hover rect { stroke: var(--text-primary); }
.link { fill: none; stroke: var(--series-1); stroke-linecap: round; }

/* Vowels */
.vowel-ref circle { fill: var(--surface-2); stroke: var(--series-1); stroke-width: 2; }
.vowel-ref circle.hit-area { fill: transparent; stroke: none; }
.vowel-ref text { fill: var(--text-primary); font-size: 22px; font-family: "Charis SIL", "Doulos SIL", "Times New Roman", serif; }
.vowel-ref.target circle { fill: var(--series-1); }
.vowel-ref.hit circle { fill: var(--good); stroke: var(--good); }
.live-dot { fill: var(--series-2); stroke: var(--surface-1); stroke-width: 2; }
.trail { fill: var(--series-2); }
.envelope path { fill: none; stroke: var(--text-secondary); stroke-width: 2; }
.envelope line.fmark { stroke: var(--series-2); stroke-width: 2; }
.meter { height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.meter div { height: 100%; width: 0; background: var(--text-secondary); transition: width .05s; }
.score { font-size: 2.4rem; font-weight: 700; line-height: 1; }
.target-word { font-size: 1.4rem; }
.target-word .ipa { font-family: "Charis SIL", "Doulos SIL", "Times New Roman", serif; }

/* Simulation */
#sim-canvas { position: absolute; top: 0; left: 0; }
.sim-layout { display: grid; grid-template-rows: minmax(0, 1fr) 34%; height: 100%; }
.sim-layout > div { position: relative; min-height: 0; }
.big-pct { font-size: 2.4rem; font-weight: 700; }

@media (max-width: 900px) {
  section.demo { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) auto; overflow-y: auto; }
  nav button { padding: .5rem .7rem; font-size: .85rem; }
  #qr { display: none; }
}

.chips button[aria-pressed="true"] { background: var(--text-primary); color: var(--surface-0); border-color: var(--text-primary); }
#theme-toggle {
  font: inherit; font-size: .9rem; flex: none;
  padding: .5rem .8rem; border-radius: 999px;
  border: 1px solid var(--line); background: transparent; color: var(--text-secondary); cursor: pointer;
}
