/* ===========================================================================
   Quiz — the evaluation layer of Music Lab (/quiz).
   Built on the Music Lab tokens (music-lab.css) and the Practice Lab pieces
   (practice-lab.css: segmented controls, inputs, the fretboard;
   practice-chords.css: the keyboard). Like the labs, nothing here defines a
   colour of its own: it composes tokens, so day and night both work.
   Mobile first; the question screen is touch-first (targets ≥ 48px).
   =========================================================================== */

.ml-qz {
  max-width: var(--ml-max);
  margin: 0 auto;
  padding: 22px 16px calc(64px + env(safe-area-inset-bottom, 0px));
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.ml-qz [hidden] { display: none !important; }

.ml-qz-card {
  border: 1px solid var(--ml-line);
  background: var(--ml-surface);
  border-radius: var(--ml-radius);
  padding: 18px;
}
.ml-qz-card h2, .ml-qz-card h3 { font-size: 1.05rem; margin: 0 0 10px; }
.ml-qz__card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.ml-qz__card-head h2, .ml-qz__card-head h3 { margin: 0; }

.ml-qz__link {
  appearance: none; border: 0; background: none; padding: 0; cursor: pointer;
  color: var(--ml-coral); font: inherit; font-weight: 600; text-decoration: underline; text-underline-offset: 3px;
}

/* ── Header ──────────────────────────────────────────────────────────── */

.ml-qz__head { margin-bottom: 18px; }
.ml-qz__head .ml-crumbs { margin-bottom: 10px; }
.ml-qz__title { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.ml-qz__title h1 { font-size: clamp(1.7rem, 4.6vw, 2.5rem); }
.ml-qz__grad { background: var(--ml-grad-text); -webkit-background-clip: text; background-clip: text; color: transparent; }
.ml-qz__lead { color: var(--ml-muted); margin: 6px 0 0; }
.ml-qz__head-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── Categories ──────────────────────────────────────────────────────── */

.ml-qz__cats {
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(170px, 1fr);
  gap: 10px; margin: 0 0 22px; overflow-x: auto; scroll-snap-type: x proximity;
  padding-bottom: 4px; -webkit-overflow-scrolling: touch; scrollbar-width: thin;
}
.ml-qz-cat {
  scroll-snap-align: start;
  position: relative; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px;
  padding: 16px 12px 12px; border-radius: 16px; border: 1px solid var(--ml-line); background: var(--ml-surface);
  text-decoration: none; color: var(--ml-text);
  transition: border-color .16s, transform .16s, box-shadow .16s;
}
.ml-qz-cat:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--ml-accent, var(--ml-pink)) 50%, transparent); }
.ml-qz-cat.is-on {
  border-color: color-mix(in srgb, var(--ml-accent, var(--ml-pink)) 65%, transparent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ml-accent, var(--ml-pink)) 16%, transparent);
  background: color-mix(in srgb, var(--ml-accent, var(--ml-pink)) 8%, var(--ml-surface));
}
.ml-qz-cat__icon {
  display: grid; place-items: center; width: 44px; height: 44px; border-radius: 13px;
  color: var(--ml-accent, var(--ml-pink)); background: color-mix(in srgb, var(--ml-accent, var(--ml-pink)) 14%, transparent);
}
.ml-qz-cat strong { font-family: "Space Grotesk", sans-serif; font-size: 15px; }
.ml-qz-cat small { color: var(--ml-muted); font-size: 12px; line-height: 1.35; }
.ml-qz-cat__meta {
  margin-top: 6px; font-size: 11px; font-weight: 600; color: var(--ml-dim);
  padding: 3px 9px; border-radius: 999px; border: 1px solid var(--ml-line);
}
.ml-qz-cat--soon { opacity: .55; cursor: default; }
.ml-qz-cat--soon:hover { transform: none; border-color: var(--ml-line); }

/* The way into the Setlist Trainer: one line under the categories. */
.ml-qz__setlist-link { margin: -10px 0 18px; font-size: 14px; color: var(--ml-muted); }

/* ── Setup ───────────────────────────────────────────────────────────── */

.ml-qz__setup { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; align-items: start; }
.ml-qz__form { display: flex; flex-direction: column; gap: 16px; }
.ml-qz__form-head h2 { font-size: 1.25rem; margin: 0 0 2px; }
.ml-qz__field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.ml-qz__label { font-size: 13px; font-weight: 600; color: var(--ml-muted); letter-spacing: .01em; }
.ml-qz__row { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.ml-qz__seg { display: flex; flex-wrap: wrap; width: 100%; }
.ml-qz__seg .ml-seg__b { flex: 1 1 auto; min-height: 40px; }
.ml-qz__seg .ml-seg__b:disabled { opacity: .5; cursor: not-allowed; }
.ml-qz__level-sum { min-height: 2.6em; }
.ml-qz__form select:disabled { opacity: .6; }

.ml-qz__toggles { border: 0; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.ml-qz__toggles legend { padding: 0; margin-bottom: 6px; }
.ml-qz__check { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--ml-text); cursor: pointer; min-height: 32px; }
.ml-qz__check input { width: 20px; height: 20px; accent-color: var(--ml-pink); flex: none; }

.ml-qz__challenge {
  display: flex; flex-direction: column; gap: 4px; padding: 12px 14px; border-radius: 12px;
  border: 1px solid color-mix(in srgb, var(--ml-amber) 45%, transparent);
  background: color-mix(in srgb, var(--ml-amber) 10%, transparent); font-size: 14px;
}
.ml-qz__challenge strong { color: var(--ml-amber); }
.ml-qz__challenge .ml-qz__link { align-self: flex-start; font-size: 13px; }

.ml-qz__error {
  margin: 0; padding: 10px 12px; border-radius: 10px; font-size: 14px;
  color: var(--ml-rose); background: color-mix(in srgb, var(--ml-rose) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--ml-rose) 35%, transparent);
}
.ml-qz__start { width: 100%; min-height: 52px; }
.ml-qz__start[aria-busy="true"] { opacity: .7; cursor: progress; }
.ml-qz__start-note { text-align: center; }

.ml-qz__side { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.ml-qz__rules ul { margin: 0; padding-left: 18px; color: var(--ml-muted); font-size: 13.5px; display: flex; flex-direction: column; gap: 4px; }
.ml-qz__rules strong { color: var(--ml-text); }

/* ── Leaderboard ─────────────────────────────────────────────────────── */

.ml-qz-board { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.ml-qz-board__head,
.ml-qz-board__row {
  display: grid; grid-template-columns: 28px minmax(0, 1fr) 52px 50px 48px; gap: 6px; align-items: center;
}
.ml-qz-board__head { font-size: 11px; color: var(--ml-dim); text-transform: uppercase; letter-spacing: .05em; padding: 0 8px 4px; }
.ml-qz-board__head span:nth-child(n + 3) { text-align: right; }
.ml-qz-board__row { padding: 7px 8px; border-radius: 10px; font-size: 13.5px; font-variant-numeric: tabular-nums; }
.ml-qz-board__row:nth-child(odd) { background: var(--ml-surface); }
.ml-qz-board__row.is-you { background: color-mix(in srgb, var(--ml-pink) 14%, transparent); outline: 1px solid color-mix(in srgb, var(--ml-pink) 40%, transparent); }
.ml-qz-board__rank {
  display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%;
  font-size: 12px; font-weight: 700; background: var(--ml-surface-2); color: var(--ml-muted);
}
.ml-qz-board__row.is-top-1 .ml-qz-board__rank { background: color-mix(in srgb, var(--ml-amber) 30%, transparent); color: var(--ml-amber); }
.ml-qz-board__row.is-top-2 .ml-qz-board__rank { background: color-mix(in srgb, var(--ml-cyan) 22%, transparent); color: var(--ml-cyan); }
.ml-qz-board__row.is-top-3 .ml-qz-board__rank { background: color-mix(in srgb, var(--ml-coral) 22%, transparent); color: var(--ml-coral); }
.ml-qz-board__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.ml-qz-board__name em { font-style: normal; color: var(--ml-pink); font-weight: 600; }
.ml-qz-board__hits, .ml-qz-board__time, .ml-qz-board__score { text-align: right; color: var(--ml-muted); }
.ml-qz-board__score { color: var(--ml-text); font-weight: 700; }
.ml-qz-board__empty { color: var(--ml-dim); font-size: 13.5px; padding: 8px; }
.ml-qz-board__gap { text-align: center; color: var(--ml-dim); line-height: 1; }

/* ── Playing ─────────────────────────────────────────────────────────── */

.ml-qz__bar {
  position: sticky; top: var(--ml-nav-h); z-index: 5;
  display: grid; grid-template-columns: 1fr auto auto auto; grid-template-areas: "count timer pause quit" "progress progress progress progress";
  align-items: center; gap: 8px 12px; padding: 12px 14px; margin: 0 -4px 14px;
  border: 1px solid var(--ml-line); border-radius: 16px; background: var(--ml-nav-bg);
  backdrop-filter: saturate(160%) blur(14px); -webkit-backdrop-filter: saturate(160%) blur(14px);
}
.ml-qz__count { grid-area: count; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; min-width: 0; }
.ml-qz__count strong { font-family: "Space Grotesk", sans-serif; font-size: 1.1rem; white-space: nowrap; }
.ml-qz__kind { white-space: nowrap; font-size: 12px; color: var(--ml-muted); padding: 2px 9px; border: 1px solid var(--ml-line); border-radius: 999px; }
.ml-qz__progress { grid-area: progress; height: 7px; border-radius: 999px; background: var(--ml-surface-2); overflow: hidden; }
.ml-qz__progress span {
  display: block; height: 100%; width: calc(var(--p, 0) * 100%); border-radius: inherit;
  background: linear-gradient(90deg, var(--ml-emerald), var(--ml-cyan)); transition: width .4s ease;
}
.ml-qz__timer { grid-area: timer; display: flex; align-items: center; gap: 6px; color: var(--ml-text); }
.ml-qz__timer small { font-size: 12px; color: var(--ml-dim); }
.ml-qz__timer svg { color: var(--ml-coral); }
.ml-qz__time { font-family: "Space Grotesk", sans-serif; font-weight: 700; font-size: 1.15rem; font-variant-numeric: tabular-nums; min-width: 3.2em; }
.ml-qz__timer.is-low .ml-qz__time { color: var(--ml-rose); }
.ml-qz__icon-btn {
  display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; cursor: pointer;
  border: 1px solid var(--ml-line); background: var(--ml-surface); color: var(--ml-text);
}
.ml-qz__icon-btn:hover { background: var(--ml-surface-2); }
#ml-qz-pause { grid-area: pause; }
#ml-qz-quit { grid-area: quit; }

.ml-qz__play-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; align-items: start; }
.ml-qz__main { display: flex; flex-direction: column; gap: 14px; min-width: 0; }

/* The audio card: the instrument, the big Play, the plays left. */
.ml-qz__stage {
  position: relative; overflow: hidden; padding: 16px 16px 18px;
  background:
    radial-gradient(420px 200px at 50% 110%, color-mix(in srgb, var(--ml-pink) 18%, transparent), transparent 70%),
    radial-gradient(360px 160px at 50% -20%, color-mix(in srgb, var(--ml-cyan) 12%, transparent), transparent 70%),
    var(--ml-surface);
}
.ml-qz__stage-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.ml-qz__instr {
  display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600;
  padding: 5px 11px; border-radius: 999px; border: 1px solid var(--ml-line-strong); background: var(--ml-bg-2);
}
.ml-qz__plays { font-size: 12.5px; color: var(--ml-muted); letter-spacing: .02em; white-space: pre; }
.ml-qz__stage-mid { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 18px 0 12px; }
.ml-qz__playbtn {
  flex: none; display: grid; place-items: center; width: 96px; height: 96px; border-radius: 50%; border: 0; cursor: pointer;
  color: #fff; background: var(--ml-grad); box-shadow: 0 14px 40px rgba(242, 11, 126, .38);
  transition: transform .15s, box-shadow .15s, opacity .15s;
}
.ml-qz__playbtn svg { margin-left: 4px; }
.ml-qz__playbtn:hover:not(:disabled) { transform: scale(1.04); }
.ml-qz__playbtn:active:not(:disabled) { transform: scale(.97); }
.ml-qz__playbtn:disabled { opacity: .4; cursor: not-allowed; box-shadow: none; filter: saturate(.5); }
.ml-qz__wave { display: flex; align-items: center; gap: 3px; height: 54px; flex: 1; max-width: 170px; justify-content: center; }
.ml-qz__wave i {
  display: block; width: 4px; border-radius: 2px; background: color-mix(in srgb, var(--ml-pink) 55%, var(--ml-cyan));
  height: calc(10px + (var(--i) * 2.2px)); opacity: .35; transform-origin: center;
}
.ml-qz__stage.is-playing .ml-qz__wave i { opacity: .9; animation: ml-qz-wave .9s ease-in-out infinite; animation-delay: calc(var(--i) * -70ms); }
@keyframes ml-qz-wave { 0%, 100% { transform: scaleY(.45); } 50% { transform: scaleY(1.15); } }
.ml-qz__stage-tools { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.ml-qz__refboard { margin-top: 14px; overflow-x: auto; padding: 8px; border-radius: 12px; border: 1px solid var(--ml-line); background: var(--ml-bg-2); }
.ml-qz__refboard .ml-kb { min-width: 320px; max-height: 120px; }
.ml-qz__refboard .ml-fb { min-width: 460px; }

.ml-qz__ask { text-align: center; }
.ml-qz__prompt { font-size: clamp(1.25rem, 3.4vw, 1.6rem); }
.ml-qz__hint { color: var(--ml-muted); margin: 4px 0 0; font-size: 14px; }

/* Answers: big, plain cards. No colour or mark before the answer. */
.ml-qz__options { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
.ml-qz__options--note, .ml-qz__options--notes2, .ml-qz__options--notes3, .ml-qz__options--sequence { grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); }
.ml-qz__options--note.ml-qz__options--n4 { grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); }
.ml-qz__options.is-locked .ml-qz-opt:not(.is-correct):not(.is-wrong):not(.is-selected) { opacity: .6; }
.ml-qz-opt {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 72px; padding: 10px 8px; border-radius: 14px; cursor: pointer;
  border: 1.5px solid var(--ml-line-strong); background: var(--ml-bg-2); color: var(--ml-text);
  font: inherit; touch-action: manipulation; -webkit-tap-highlight-color: transparent;
  transition: border-color .12s, background .12s, transform .12s;
}
.ml-qz-opt:hover:not(:disabled) { border-color: color-mix(in srgb, var(--ml-pink) 55%, transparent); transform: translateY(-1px); }
.ml-qz-opt:active:not(:disabled) { transform: scale(.98); }
.ml-qz-opt:disabled { cursor: default; }
.ml-qz-opt__main { font-family: "Space Grotesk", sans-serif; font-size: 1.35rem; line-height: 1.1; }
.ml-qz-opt__sub { color: var(--ml-muted); font-size: 12.5px; line-height: 1.25; text-align: center; }
.ml-qz-opt__detail { color: var(--ml-dim); font-size: 11px; }
.ml-qz-opt__order {
  position: absolute; top: 6px; right: 7px; min-width: 20px; height: 20px; border-radius: 10px;
  display: grid; place-items: center; font-size: 11px; font-weight: 700; color: #fff; background: var(--ml-grad);
}
.ml-qz-opt__order:empty { display: none; }
.ml-qz-opt.is-selected { border-color: var(--ml-pink); background: color-mix(in srgb, var(--ml-pink) 12%, var(--ml-bg-2)); }
.ml-qz-opt.is-correct { border-color: var(--ml-emerald); background: color-mix(in srgb, var(--ml-emerald) 20%, var(--ml-bg-2)); opacity: 1; }
.ml-qz-opt.is-wrong { border-color: var(--ml-rose); background: color-mix(in srgb, var(--ml-rose) 16%, var(--ml-bg-2)); opacity: 1; }

.ml-qz__answer-row { display: flex; gap: 10px; justify-content: center; }
.ml-qz__answer-row .ml-btn { min-height: 48px; min-width: 130px; }

.ml-qz__feedback {
  display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; text-align: center;
  padding: 12px 14px; border-radius: 12px; font-size: 15px; border: 1px solid var(--ml-line); background: var(--ml-surface);
}
.ml-qz__feedback.is-ok { border-color: color-mix(in srgb, var(--ml-emerald) 50%, transparent); background: color-mix(in srgb, var(--ml-emerald) 12%, transparent); }
.ml-qz__feedback.is-ok strong { color: var(--ml-emerald); }
.ml-qz__feedback.is-bad { border-color: color-mix(in srgb, var(--ml-rose) 50%, transparent); background: color-mix(in srgb, var(--ml-rose) 10%, transparent); }
.ml-qz__feedback.is-bad strong { color: var(--ml-rose); }
.ml-qz__feedback.is-error { color: var(--ml-rose); }
.ml-qz__feedback.is-pending { color: var(--ml-muted); }
.ml-qz__feedback-pts { font-weight: 700; color: var(--ml-emerald); font-family: "Space Grotesk", sans-serif; }
.ml-qz__next-row { display: flex; justify-content: center; }
.ml-qz__next-row .ml-btn { min-height: 48px; min-width: 180px; }

/* Progress and score beside (or under) the question. */
.ml-qz__stats-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 10px; align-items: center; }
.ml-qz__stat { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.ml-qz__stat strong { font-family: "Space Grotesk", sans-serif; font-size: 1.6rem; line-height: 1; }
.ml-qz__stat small { font-size: 12px; color: var(--ml-muted); }
.ml-qz__stat--ok strong { color: var(--ml-emerald); }
.ml-qz__stat--bad strong { color: var(--ml-rose); }
.ml-qz__ring {
  --p: 0;
  width: 92px; height: 92px; border-radius: 50%; display: grid; place-content: center; text-align: center;
  background:
    radial-gradient(closest-side, var(--ml-bg) 76%, transparent 78%),
    conic-gradient(var(--ml-violet) calc(var(--p) * 1%), var(--ml-surface-2) 0);
}
.ml-qz__ring strong { font-family: "Space Grotesk", sans-serif; font-size: 1.25rem; line-height: 1; }
.ml-qz__ring small { font-size: 11px; color: var(--ml-muted); }
.ml-qz__score-row { display: flex; align-items: baseline; gap: 8px; }
.ml-qz__points { font-family: "Space Grotesk", sans-serif; font-size: 2.2rem; line-height: 1; background: var(--ml-grad-text); -webkit-background-clip: text; background-clip: text; color: transparent; }
.ml-qz__score-row small { color: var(--ml-muted); }
.ml-qz__score-dl { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0 0; }
.ml-qz__score-dl div { padding: 8px 10px; border-radius: 10px; background: var(--ml-surface); }
.ml-qz__score-dl dt { font-size: 11.5px; color: var(--ml-dim); }
.ml-qz__score-dl dd { margin: 0; font-weight: 700; font-family: "Space Grotesk", sans-serif; font-size: 1.15rem; }

/* Mobile: during a question only the question matters; the ranking waits
   for the end, the title and categories step aside. */
.ml-qz__board--compact { display: none; }
.ml-qz[data-state="playing"] .ml-qz__cats,
.ml-qz[data-state="answered"] .ml-qz__cats,
.ml-qz[data-state="transition"] .ml-qz__cats,
.ml-qz[data-state="playing"] .ml-qz__lead,
.ml-qz[data-state="answered"] .ml-qz__lead,
.ml-qz[data-state="transition"] .ml-qz__lead,
.ml-qz[data-state="playing"] .ml-qz__head-actions,
.ml-qz[data-state="answered"] .ml-qz__head-actions,
.ml-qz[data-state="transition"] .ml-qz__head-actions { display: none; }
.ml-qz[data-state="playing"] .ml-qz__head,
.ml-qz[data-state="answered"] .ml-qz__head,
.ml-qz[data-state="transition"] .ml-qz__head { margin-bottom: 10px; }
.ml-qz[data-state="playing"] .ml-qz__title h1,
.ml-qz[data-state="answered"] .ml-qz__title h1,
.ml-qz[data-state="transition"] .ml-qz__title h1 { font-size: 1.35rem; }

/* Pause (practice only): the options hide behind a veil. */
.ml-qz__paused {
  position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 16px;
  background: color-mix(in srgb, var(--ml-bg) 78%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.ml-qz__paused .ml-qz-card { max-width: 380px; text-align: center; background: var(--ml-popover-bg); box-shadow: var(--ml-shadow); }
.ml-qz__paused .ml-hint { margin-bottom: 14px; }

/* ── Results ─────────────────────────────────────────────────────────── */

.ml-qz__results { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.ml-qz__results > *, .ml-qz__review > * { min-width: 0; }
.ml-qz-res__head { text-align: center; padding: 22px 18px; }
.ml-qz-res__kicker { margin: 0; font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--ml-emerald); font-weight: 700; }
.ml-qz-res__name { font-size: clamp(1.5rem, 4vw, 2.1rem) !important; margin: 4px 0 2px !important; }
.ml-qz-res__name:focus { outline: none; }
.ml-qz-res__meta { color: var(--ml-muted); margin: 0 0 16px; font-size: 14px; }
.ml-qz-res__big { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 18px 28px; }
.ml-qz-res__ring {
  --p: 0;
  width: 150px; height: 150px; border-radius: 50%; display: grid; place-content: center; text-align: center; flex: none;
  background:
    radial-gradient(closest-side, var(--ml-bg) 80%, transparent 82%),
    conic-gradient(var(--ml-emerald) calc(var(--p) * 1%), var(--ml-surface-2) 0);
}
.ml-qz-res__ring strong { font-family: "Space Grotesk", sans-serif; font-size: 2.3rem; line-height: 1; }
.ml-qz-res__ring small { color: var(--ml-muted); font-size: 1rem; }
.ml-qz-res__stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 10px; flex: 1 1 260px; min-width: 0; max-width: 560px; }
.ml-qz-res__stat { display: flex; flex-direction: column; gap: 2px; padding: 10px; border-radius: 12px; background: var(--ml-surface); border: 1px solid var(--ml-line); }
.ml-qz-res__stat strong { font-family: "Space Grotesk", sans-serif; font-size: 1.35rem; font-variant-numeric: tabular-nums; }
.ml-qz-res__stat small { font-size: 12px; color: var(--ml-muted); }
.ml-qz-res__stat.is-score strong { color: var(--ml-pink); }
.ml-qz-res__stat.is-rank strong { color: var(--ml-amber); }
.ml-qz-res__breakdown { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 16px; margin: 16px 0 0; font-size: 13px; color: var(--ml-muted); }
.ml-qz-res__breakdown div { display: flex; gap: 6px; }
.ml-qz-res__breakdown dd { margin: 0; color: var(--ml-text); font-weight: 700; font-variant-numeric: tabular-nums; }
.ml-qz-res__actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 18px; }
.ml-qz-res__actions .ml-btn { min-height: 46px; }
.ml-qz-res__seed { margin-top: 12px; }
.ml-qz-res__seed code { font-size: 12.5px; padding: 2px 6px; border-radius: 6px; background: var(--ml-surface-2); }
.ml-qz-res__shared { margin: 8px 0 0; font-size: 13.5px; color: var(--ml-emerald); min-height: 1em; }
.ml-qz-res__weak p { color: var(--ml-muted); margin: 0 0 12px; }
.ml-qz-res__areas { list-style: none; margin: 0 0 14px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.ml-qz-res__areas li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; padding: 8px 10px; border-radius: 10px; background: var(--ml-surface); }
.ml-qz-res__area { font-weight: 700; font-family: "Space Grotesk", sans-serif; }
.ml-qz-res__areas small { color: var(--ml-dim); }
.ml-qz-res__areas .ml-qz__link { margin-left: auto; font-size: 13px; }

/* ── Review ──────────────────────────────────────────────────────────── */

.ml-qz-rev__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.ml-qz-rev__head h2 { font-size: 1.3rem; }
.ml-qz-rev { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr)); gap: 12px; }
.ml-qz-rev__item { display: flex; flex-direction: column; gap: 10px; border-left: 4px solid var(--ml-line-strong); }
.ml-qz-rev__item.is-ok { border-left-color: var(--ml-emerald); }
.ml-qz-rev__item.is-bad { border-left-color: var(--ml-rose); }
.ml-qz-rev__top { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; }
.ml-qz-rev__mark { font-weight: 800; }
.ml-qz-rev__item.is-ok .ml-qz-rev__mark { color: var(--ml-emerald); }
.ml-qz-rev__item.is-bad .ml-qz-rev__mark { color: var(--ml-rose); }
.ml-qz-rev__kind { width: 100%; font-size: 12px; color: var(--ml-dim); }
.ml-qz-rev__dl { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; margin: 0; font-size: 13.5px; }
.ml-qz-rev__dl dt { color: var(--ml-dim); font-size: 11.5px; }
.ml-qz-rev__dl dd { margin: 0; font-weight: 600; }
.ml-qz-rev__item .ml-btn { align-self: flex-start; }

/* ── History dialog and heatmap ──────────────────────────────────────── */

.ml-qz-dialog {
  width: min(760px, calc(100vw - 24px)); max-height: calc(100dvh - 32px); padding: 0; border-radius: var(--ml-radius);
  border: 1px solid var(--ml-line-strong); background: var(--ml-popover-bg); color: var(--ml-text); box-shadow: var(--ml-shadow);
}
.ml-qz-dialog::backdrop { background: rgba(0, 0, 0, .55); }
.ml-qz-dialog__in { padding: 18px; }
.ml-qz-dialog__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.ml-qz-dialog__head h2 { font-size: 1.3rem; }
.ml-qz-dialog h3 { font-size: 1rem; margin: 18px 0 8px; }
.ml-qz-hist__wrap { overflow-x: auto; margin-top: 10px; }
.ml-qz-hist { width: 100%; border-collapse: collapse; font-size: 13.5px; font-variant-numeric: tabular-nums; }
.ml-qz-hist th { text-align: left; font-size: 11.5px; color: var(--ml-dim); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; padding: 6px 8px; border-bottom: 1px solid var(--ml-line); }
.ml-qz-hist td { padding: 8px; border-bottom: 1px solid var(--ml-line); white-space: nowrap; }
.ml-qz-hist__empty { color: var(--ml-muted); }
.ml-qz-hist__practice { margin-top: 14px; }
.ml-qz-heat__notes { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.ml-qz-heat__cell {
  display: flex; flex-direction: column; align-items: center; padding: 8px 4px; border-radius: 10px; border: 1px solid var(--ml-line);
  background: var(--ml-surface);
}
.ml-qz-heat__cell strong { font-family: "Space Grotesk", sans-serif; }
.ml-qz-heat__cell small { font-size: 11px; color: var(--ml-dim); }
.ml-qz-heat__cell span { font-weight: 700; font-size: 13px; }
.ml-qz-heat__cell.is-good { background: color-mix(in srgb, var(--ml-emerald) 18%, transparent); border-color: color-mix(in srgb, var(--ml-emerald) 40%, transparent); }
.ml-qz-heat__cell.is-mid { background: color-mix(in srgb, var(--ml-amber) 16%, transparent); border-color: color-mix(in srgb, var(--ml-amber) 40%, transparent); }
.ml-qz-heat__cell.is-low { background: color-mix(in srgb, var(--ml-rose) 16%, transparent); border-color: color-mix(in srgb, var(--ml-rose) 40%, transparent); }
.ml-qz-heat__cell.is-none span { color: var(--ml-dim); }
.ml-qz-heat__chips { display: flex; flex-wrap: wrap; gap: 6px; }
.ml-qz-heat__chip { font-size: 13px; padding: 5px 10px; border-radius: 999px; border: 1px solid var(--ml-line); }
.ml-qz-heat__chip small { color: var(--ml-dim); }
.ml-qz-heat__chip.is-good { border-color: color-mix(in srgb, var(--ml-emerald) 45%, transparent); }
.ml-qz-heat__chip.is-mid { border-color: color-mix(in srgb, var(--ml-amber) 45%, transparent); }
.ml-qz-heat__chip.is-low { border-color: color-mix(in srgb, var(--ml-rose) 45%, transparent); }

/* Phones: the bar keeps to one line of count and clock. */
@media (max-width: 520px) {
  .ml-qz__bar { padding: 10px 12px; gap: 8px; }
  .ml-qz__timer small, .ml-qz__kind { display: none; }
  .ml-qz__icon-btn { width: 40px; height: 40px; }
}

/* ── Larger screens ──────────────────────────────────────────────────── */

@media (min-width: 640px) {
  .ml-qz__options--note.ml-qz__options--n12,
  .ml-qz__options--notes2.ml-qz__options--n12,
  .ml-qz__options--notes3.ml-qz__options--n12,
  .ml-qz__options--sequence.ml-qz__options--n12 { grid-template-columns: repeat(6, 1fr); }
  .ml-qz__options--n7 { grid-template-columns: repeat(7, 1fr); }
  .ml-qz-heat__notes { grid-template-columns: repeat(12, 1fr); }
  .ml-qz-opt { min-height: 80px; }
}

/* iPad portrait and up: the categories fit in one row. */
@media (min-width: 760px) {
  .ml-qz__cats { grid-auto-flow: initial; grid-template-columns: repeat(3, 1fr); overflow: visible; }
  .ml-qz__bar { grid-template-columns: auto minmax(120px, 1fr) auto auto auto; grid-template-areas: "count progress timer pause quit"; }
  .ml-qz__playbtn { width: 110px; height: 110px; }
}

/* iPad landscape and desktop: setup and play get their side column. */
@media (min-width: 1000px) {
  .ml-qz__cats { grid-template-columns: repeat(6, 1fr); }
  .ml-qz__setup { grid-template-columns: minmax(0, 1fr) 360px; }
  .ml-qz__play-grid { grid-template-columns: minmax(0, 1fr) 320px; }
  .ml-qz__board--compact { display: block; }
  .ml-qz__side--play { position: sticky; top: calc(var(--ml-nav-h) + 84px); }
  .ml-qz[data-state="playing"] .ml-qz__cats,
  .ml-qz[data-state="answered"] .ml-qz__cats,
  .ml-qz[data-state="transition"] .ml-qz__cats { display: grid; }
  .ml-qz[data-state="playing"] .ml-qz-cat small,
  .ml-qz[data-state="answered"] .ml-qz-cat small,
  .ml-qz[data-state="transition"] .ml-qz-cat small,
  .ml-qz[data-state="playing"] .ml-qz-cat__meta,
  .ml-qz[data-state="answered"] .ml-qz-cat__meta,
  .ml-qz[data-state="transition"] .ml-qz-cat__meta { display: none; }
  .ml-qz[data-state="playing"] .ml-qz-cat,
  .ml-qz[data-state="answered"] .ml-qz-cat,
  .ml-qz[data-state="transition"] .ml-qz-cat { flex-direction: row; padding: 8px 10px; gap: 8px; }
  .ml-qz[data-state="playing"] .ml-qz-cat__icon,
  .ml-qz[data-state="answered"] .ml-qz-cat__icon,
  .ml-qz[data-state="transition"] .ml-qz-cat__icon { width: 32px; height: 32px; }
}

@media (prefers-reduced-motion: reduce) {
  .ml-qz__stage.is-playing .ml-qz__wave i { animation: none; opacity: .8; }
  .ml-qz__progress span, .ml-qz-cat, .ml-qz-opt, .ml-qz__playbtn { transition: none; }
}
