/* Layout: one narrow notebook column; big tap-to-hear tiles, then the quiz card. */
[hidden] { display: none !important; }
:root {
  --bg: #f3f6fb; --paper: #ffffff; --ink: #1b2333; --muted: #5b6578;
  --accent: #1f5fbf; --accent-ink: #ffffff; --line: #d7dfec; --soft: #e6eefb;
  --ok: #1e8a4c; --bad: #c2402f; --warn: #a86a00;
  --display: "Fraunces", Georgia, serif;
  --body: "Atkinson Hyperlegible", system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121722; --paper: #1b2230; --ink: #e8edf6; --muted: #9aa6bb;
    --accent: #7fb0ff; --accent-ink: #0d1420; --line: #2c3547; --soft: #22304a;
    --ok: #5fd394; --bad: #ff8a78; --warn: #f0b85a;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--body); font-size: 17px; line-height: 1.5;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: max(20px, env(safe-area-inset-top, 0px)) 48px;
}
.wrap { max-width: 600px; margin: 0 auto; display: flex; flex-direction: column; gap: 24px; }
.wrap.wide { max-width: 820px; }

h1 { font-family: var(--display); font-weight: 800; font-size: 2rem; line-height: 1.1; margin: 0; text-wrap: balance; letter-spacing: -0.01em; }
h2 { font-family: var(--display); font-weight: 600; font-size: 1.25rem; margin: 0; }
p { margin: 0; }
.eyebrow { font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; }
.sub, .note { color: var(--muted); }
.note { font-size: .88rem; }
a { color: var(--accent); }

.top { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; }
.top > div { min-width: 0; }

label.small, .field > label { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; }
select, input[type=text], input[type=password], input[type=date], textarea {
  font: inherit; color: var(--ink); background: var(--paper);
  border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; max-width: 100%;
}
textarea { width: 100%; min-height: 220px; resize: vertical; line-height: 1.6; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }

.voice-bar { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; background: var(--soft); border-radius: 12px; padding: 12px 14px; }
.voice-bar select { font-size: .92rem; padding: 6px 8px; min-width: 0; }
.voice-bar #voiceSel { flex: 1 1 200px; }
.voice-bar .note { flex-basis: 100%; }

section { display: flex; flex-direction: column; gap: 12px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.word {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 14px 16px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--paper); color: var(--ink); font: inherit; font-size: 1.15rem; font-weight: 700;
  cursor: pointer; text-align: left; min-width: 0;
}
.word span { overflow-wrap: anywhere; }
.word:hover { border-color: var(--accent); }
.word.playing { background: var(--soft); border-color: var(--accent); }
.word svg { flex: none; width: 22px; height: 22px; fill: var(--accent); }

.card { background: var(--paper); border: 1px solid var(--line); border-radius: 14px; padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.progress { font-size: .88rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.btn {
  text-decoration: none; display: inline-block;
  font: inherit; font-weight: 700; padding: 11px 18px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--accent); background: var(--paper); color: var(--accent);
}
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.quiet { border-color: var(--line); color: var(--ink); }
.btn.danger { border-color: var(--bad); color: var(--bad); }
.btn.small { padding: 6px 12px; font-size: .9rem; }
.btn:disabled { opacity: .5; cursor: default; }
#answer { font-size: 1.4rem; width: 100%; padding: 12px 14px; border-width: 2px; background: var(--bg); }
.result { font-weight: 700; min-height: 1.5em; }
.result.ok { color: var(--ok); } .result.bad { color: var(--bad); } .result.warn { color: var(--warn); }
.hint { font-size: .85rem; color: var(--muted); }
kbd { font-family: var(--body); border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; }
.big-score { font-family: var(--display); font-size: 3rem; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: var(--soft); border-radius: 999px; padding: 3px 10px; font-weight: 700; font-size: .95rem; }

button:focus-visible, select:focus-visible, input:focus-visible, textarea:focus-visible, a:focus-visible {
  outline: 3px solid var(--accent); outline-offset: 2px;
}
/* Quiz dialog: fills the screen with an opaque page so the word tiles stay hidden. */
dialog#quiz {
  position: fixed; inset: 0; width: 100%; height: 100%; max-width: none; max-height: none;
  margin: 0; border: 0; background: var(--bg); color: var(--ink); overflow-y: auto;
  padding: max(20px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) 48px max(16px, env(safe-area-inset-left, 0px));
}
dialog#quiz::backdrop { background: #000; }
body:has(dialog[open]) { overflow: hidden; }
.quiz-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
#quiz h2 { font-size: 1.6rem; }

footer { text-align: center; font-size: .9rem; }

/* Parent page */
.list { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 14px; background: var(--paper); overflow: hidden; }
.list-item { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; justify-content: space-between; padding: 12px 16px; border-top: 1px solid var(--line); }
.list-item:first-child { border-top: 0; }
.list-item.active { background: var(--soft); }
.list-item .meta { min-width: 0; }
.list-item .meta strong { display: block; overflow-wrap: anywhere; }
.form-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 12px; }
@media (max-width: 520px) { .form-grid { grid-template-columns: minmax(0, 1fr); } }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: .95rem; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.error { color: var(--bad); font-weight: 700; }
.toast { color: var(--ok); font-weight: 700; }

@media (prefers-reduced-motion: no-preference) {
  .word, .btn { transition: background-color .15s, border-color .15s; }
}
