/* Tone trainer - layered on top of reader.css design tokens ---------------- */
body.tones { }

.icon-btn.back { text-decoration: none; font-size: 20px; line-height: 1; }
.mini-select {
  font: inherit; font-size: 13px;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--ink);
  max-width: 46vw;
}

/* mode tabs ---------------------------------------------------------------- */
nav.modes {
  flex: 0 0 auto;
  display: flex;
  gap: 6px;
  padding: 8px 12px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  scrollbar-width: none;
}
nav.modes::-webkit-scrollbar { display: none; }
.mode {
  flex: 1 0 auto;
  font: inherit; font-size: 13.5px; font-weight: 600;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg);
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
}
.mode.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* stage -------------------------------------------------------------------- */
main#stage {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 20px 18px calc(28px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  text-align: center;
}
.prompt-line { color: var(--muted); font-size: 14px; max-width: 40ch; margin: 0; }

/* big play button ---------------------------------------------------------- */
.play-big {
  width: 108px; height: 108px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 40px;
  cursor: pointer;
  box-shadow: var(--shadow);
  display: grid; place-items: center;
  transition: transform .08s ease;
  flex: 0 0 auto;
}
.play-big:active { transform: scale(.94); }
.play-big.small { width: 66px; height: 66px; font-size: 24px; }
.play-big[disabled] { opacity: .5; cursor: default; }
.replay-hint { font-size: 12px; color: var(--muted); margin: 0; }

/* answer grids ------------------------------------------------------------- */
.tone-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 150px));
  gap: 12px;
  width: 100%;
  max-width: 340px;
  justify-content: center;
}
.tone-grid.five { grid-template-columns: repeat(3, minmax(0, 100px)); max-width: 340px; }
.tone-btn {
  font: inherit;
  padding: 14px 8px 12px;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.tone-btn:hover { border-color: var(--accent); }
.tone-btn .glyph { font-size: 26px; line-height: 1; }
.tone-btn .lbl { font-size: 15px; font-weight: 600; }
.tone-btn .sub { font-size: 11px; color: var(--muted); }
.tone-btn.correct { border-color: var(--good); background: color-mix(in srgb, var(--good) 14%, var(--panel)); }
.tone-btn.wrong  { border-color: var(--accent); background: var(--accent-soft); }
.tone-btn[disabled] { cursor: default; }

/* per-syllable rows (pairs mode) ------------------------------------------- */
.syl-rows { display: flex; flex-direction: column; gap: 16px; width: 100%; max-width: 380px; }
.syl-row { }
.syl-row .syl-label { font-size: 13px; color: var(--muted); margin-bottom: 7px; }
.mini-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 7px; }
.mini-btn {
  font: inherit; font-size: 15px; font-weight: 600;
  padding: 12px 0 8px;
  border: 1.5px solid var(--line);
  border-radius: 11px;
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.mini-btn .glyph { font-size: 17px; }
.mini-btn.correct { border-color: var(--good); background: color-mix(in srgb, var(--good) 14%, var(--panel)); }
.mini-btn.wrong  { border-color: var(--accent); background: var(--accent-soft); }
.mini-btn.picked { border-color: var(--accent); }
.mini-btn[disabled] { cursor: default; }

/* reveal card -------------------------------------------------------------- */
.reveal {
  width: 100%; max-width: 380px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}
.reveal .r-pinyin { font-size: 26px; font-weight: 600; }
.reveal .r-pinyin .neutral { color: var(--muted); }
.reveal .r-gloss { color: var(--muted); font-size: 14px; margin-top: 2px; }
.reveal .r-verdict { font-size: 15px; font-weight: 700; margin-bottom: 6px; }
.reveal .r-verdict.good { color: var(--good); }
.reveal .r-verdict.bad { color: var(--accent); }
.reveal .r-note { font-size: 13px; color: var(--muted); margin-top: 8px; line-height: 1.45; }

/* contour canvas ----------------------------------------------------------- */
.contour-wrap { width: 100%; max-width: 380px; }
canvas.contour {
  width: 100%; height: 120px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  display: block;
}
.contour-legend { display: flex; gap: 16px; justify-content: center; font-size: 12px; color: var(--muted); margin-top: 6px; }
.contour-legend .swatch { display: inline-block; width: 14px; height: 3px; border-radius: 3px; vertical-align: middle; margin-right: 5px; }

/* action buttons ----------------------------------------------------------- */
.actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.btn {
  font: inherit; font-size: 15px; font-weight: 600;
  padding: 12px 20px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
}
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.good { border-color: var(--good); color: var(--good); }
.btn[disabled] { opacity: .5; cursor: default; }
.btn.rec { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.rec.recording { animation: pulse 1s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .55; } }

.target-word { font-size: 34px; font-weight: 600; }
.target-word .neutral { color: var(--muted); }
.target-gloss { color: var(--muted); font-size: 15px; margin-top: 2px; }

.hint-box {
  font-size: 13px; color: var(--muted);
  max-width: 42ch; line-height: 1.5;
  border-top: 1px dashed var(--line);
  padding-top: 12px;
}

/* scoreboard --------------------------------------------------------------- */
footer#scoreboard {
  flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center; gap: 16px;
  padding: 9px 16px calc(9px + env(safe-area-inset-bottom));
  font-size: 13px;
  color: var(--muted);
  background: var(--panel);
  border-top: 1px solid var(--line);
}
#streak b, #tally b { color: var(--ink); }
.linkish {
  border: none; background: none; color: var(--muted);
  text-decoration: underline; cursor: pointer; font: inherit; font-size: 12px;
}

@media (min-width: 900px) {
  nav.modes { justify-content: center; }
  .mode { flex: 0 0 auto; }
  main#stage { padding-top: 30px; }
}
