/* Quest Mode (quests module). Extends the Workshop Shadow Board: quest offers are work orders hung on the pegboard,
   the quest in hand is clamped on the bench, practice progress is a row of tape notches, boss fights carry the
   tool-chest red, and finished work fills with safety-yellow paint. Parent views are the quiet office: tables, ink, blue.
   Tokens only; display face only for h1 and bench titles. */

/* ------------------------------------------------------------------ page scaffolding */
.q-page { min-width: 0; }
.q-back { display: inline-flex; align-items: center; gap: 4px; min-height: 36px; color: var(--ink-2); font-weight: 700; text-decoration: none; align-self: flex-start; border-radius: var(--r-sm); }
.q-back:hover { color: var(--ink); }
.q-back .icon { width: 18px; height: 18px; }

.q-bench { gap: 12px; }
.q-title { font: 800 clamp(1.9rem, 1.4rem + 2vw, 2.6rem)/1 var(--font-display); text-transform: uppercase; letter-spacing: .01em; overflow-wrap: anywhere; }
.q-pitch { color: var(--ink-2); max-width: 62ch; }
.q-pitch .num { font-family: var(--font-mono); font-weight: 500; color: var(--ink); white-space: nowrap; }
.q-bench .bench-facts { align-items: center; }
.q-vise-boss { background: var(--red-soft); color: var(--red); }

/* ------------------------------------------------------------------ step track (inside the stage) */
.q-track { display: flex; gap: 6px; margin: 0; padding: 0; list-style: none; overflow-x: auto; scrollbar-width: none; }
.q-track::-webkit-scrollbar { display: none; }
.q-track li { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px 6px 6px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); font-weight: 700; font-size: .88rem; white-space: nowrap; flex: none; }
.q-track-mark { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; border: 1.5px solid var(--outline); font: 500 .78rem var(--font-mono); }
.q-track-mark .icon { width: 14px; height: 14px; }
.q-track li.is-done { background: transparent; color: var(--ink-3); }
.q-track li.is-done .q-track-mark { background: var(--paint); border-color: var(--paint); color: var(--paint-ink); }
.q-track li.is-current { background: var(--blue-soft); color: var(--blue); }
.q-track li.is-current .q-track-mark { background: var(--blue); border-color: var(--blue); color: var(--blue-ink); }
@media (max-width: 560px) {
  .q-track li:not(.is-current) { padding-right: 6px; }
  .q-track li:not(.is-current) .q-track-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}

/* ------------------------------------------------------------------ stage blocks */
.q-stage { min-width: 0; }
.q-hook-text { font-size: var(--step-1); line-height: 1.5; max-width: 60ch; }
.q-plan { display: flex; gap: 10px; align-items: flex-start; color: var(--ink-2); }
.q-plan .icon { color: var(--blue); }
.q-next { padding-top: 4px; }
.q-next .btn .icon:last-child { margin-left: 2px; }

.q-video { display: grid; grid-template-columns: 48px minmax(0, 1fr) auto; align-items: center; gap: 14px; padding: 12px 14px; max-width: 560px;
  border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); color: var(--ink); text-decoration: none; transition: border-color .15s ease; }
.q-video:hover { border-color: var(--blue); }
.q-video-icon { width: 48px; height: 48px; border-radius: var(--r); display: grid; place-items: center; background: var(--label-tape); color: var(--label-ink); }
.q-video-body { display: grid; gap: 2px; }
.q-video-body strong { overflow-wrap: anywhere; }
.q-video-meta { font: 500 .82rem var(--font-mono); color: var(--ink-2); }
.q-video-note { font-size: .85rem; color: var(--ink-3); }
.q-video-go { color: var(--blue); }

.q-idea { max-width: 66ch; }
.q-idea .section-title { margin-bottom: .2em; }
.q-example { padding: 18px; border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--line); max-width: 760px; }
.q-example-answer { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.q-example-answer .icon { color: var(--good); }

/* a problem: story, code table/data, the code's question line */
.q-problem { min-width: 0; max-width: 760px; }
.q-story { font-size: 1.08rem; }
.q-question { font-weight: 700; font-size: var(--step-1); line-height: 1.35; max-width: 60ch; }
.q-table { max-width: 440px; }
.q-table td, .q-table th { font-family: var(--font-mono); font-size: .95rem; }
.q-table th { font-family: var(--font-body); }
.q-unknown { background: var(--paint-soft); color: var(--ink); font-weight: 700; }
.q-data { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; }
.q-data span { padding: 4px 10px; border-radius: var(--r-sm); background: var(--surface-2); font: 500 1rem var(--font-mono); font-variant-numeric: tabular-nums; }

/* answer box */
.q-answer { display: grid; gap: 6px; }
.q-answer-label { font-weight: 700; font-size: .9rem; color: var(--ink-2); }
.q-answer-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.q-answer-row input { flex: 1 1 12ch; max-width: 22ch; min-height: 52px; font: 500 1.25rem var(--font-mono); font-variant-numeric: tabular-nums; }
.q-unit { font: 500 .9rem var(--font-mono); color: var(--ink-2); max-width: 24ch; }
.q-affix { font: 500 1.25rem var(--font-mono); color: var(--ink-2); }
.q-answer-row .btn { min-height: 52px; }
.q-choices fieldset { min-width: 0; }
.q-choice { min-height: 52px; padding: 8px 18px; font: 500 1.05rem var(--font-mono); }
.q-choice:focus-visible { outline-offset: 3px; }
.q-choice[disabled], .q-mcq-choice[disabled] { opacity: .5; cursor: progress; }

/* feedback + hints */
.q-feedback { display: flex; gap: 10px; align-items: flex-start; border-radius: var(--r); color: var(--ink); max-width: 760px; }
.q-feedback.is-good, .q-feedback.is-warn, .q-feedback.is-info { padding: 12px 14px; }
.q-feedback.is-good { background: var(--good-soft); }
.q-feedback.is-good > .icon { color: var(--good); }
.q-feedback.is-warn { background: var(--warn-soft); }
.q-feedback.is-warn > .icon { color: var(--warn); }
.q-feedback.is-info { background: var(--blue-soft); }
.q-feedback.is-info > .icon { color: var(--blue); }
.q-hints { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; max-width: 760px; }
.q-hints li { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: var(--r); background: var(--paint-soft); }
.q-hints .icon { color: var(--ink-2); flex: none; }
.q-hint-form .btn { gap: 8px; }
.q-count { font: 500 .8rem var(--font-mono); color: var(--ink-3); }
.q-given { color: var(--ink-2); }
.q-steps { margin: 0; padding: 0; list-style: none; counter-reset: qstep; display: grid; gap: 6px; max-width: 760px; }
.q-steps li { counter-increment: qstep; display: grid; grid-template-columns: 28px 1fr; gap: 10px; align-items: baseline; font-variant-numeric: tabular-nums; }
.q-steps li::before { content: counter(qstep); width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); font: 500 .78rem var(--font-mono); color: var(--ink-2); }
.q-how > summary { display: inline-flex; align-items: center; min-height: 40px; cursor: pointer; color: var(--blue); font-weight: 700; border-radius: var(--r-sm); }
.q-how[open] > summary { margin-bottom: 8px; }
.q-passage-mini { padding: 12px 14px; border-radius: var(--r); background: var(--surface-2); }

/* progress notches (tape-measure ticks) */
.q-work-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.q-of { color: var(--ink-3); font-weight: 400; }
.q-notches { display: flex; gap: 6px; }
.q-notches > span { width: 26px; height: 12px; border-radius: 2px; border: 1.5px solid var(--outline); background: transparent; }
.q-notches > span.is-right { background: var(--paint); border-color: var(--paint); }
.q-notches > span.is-seen { background: var(--surface-3); border-color: var(--surface-3); }
.q-notches > span.is-current { box-shadow: 0 0 0 2px var(--ground), 0 0 0 4px var(--blue); }

/* finishing: a freshly hung tool */
.q-finish { max-width: 760px; }
.q-complete { display: grid; grid-template-columns: 72px 1fr; gap: 16px; align-items: center; }
.q-art { width: 64px; height: 64px; flex: none; }
.q-complete .q-art { width: 72px; height: 72px; }
.q-art .q-fill-on, .q-art .q-detail-on { opacity: 1; clip-path: inset(0 0 0 0); }
.q-art.just-hung .q-fill-on { animation: paint-sweep .5s cubic-bezier(.16, 1, .3, 1) both; }

/* boss fights: the tool-chest red */
.q-boss-offer { padding: 18px; border-radius: var(--r-lg); background: var(--red-soft); }
.q-boss-offer .section-title { display: flex; align-items: center; gap: 8px; }
.q-boss-offer .section-title .icon { color: var(--red); }
.q-boss-reward { font-family: var(--font-mono); font-weight: 500; white-space: nowrap; }
.q-btn-boss { background: var(--red); color: var(--surface); }
.q-btn-boss-outline .icon { color: var(--red); }
.q-btn-boss-outline:hover { border-color: var(--red); }
.q-hits { display: flex; gap: 8px; margin: 0; padding: 0; list-style: none; }
.q-hits li { width: 36px; height: 36px; border-radius: var(--r); border: 1.5px solid var(--red); display: grid; place-items: center; color: var(--ink-3); }
.q-hits li .icon { width: 18px; height: 18px; }
.q-hits li.is-hit { background: var(--red); color: var(--surface); }
.q-hits li.is-miss { border-color: var(--line); background: var(--surface-2); }
.q-hits li.is-skip { border-style: dashed; border-color: var(--line); }

/* ------------------------------------------------------------------ quest board: work orders on the pegboard */
.q-board { padding: 18px; }
.q-orders { display: grid; gap: 22px; margin: 0; padding: 0; list-style: none; }
.q-order { position: relative; display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; gap: 16px; align-items: center; padding: 18px; border-radius: var(--r-lg);
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-hung); }
.q-order::before { content: ""; position: absolute; top: -8px; left: 50%; translate: -50% 0; width: 22px; height: 12px; border-radius: 6px 6px 2px 2px; border: 2px solid var(--outline); border-bottom: 0; }
.q-order h3 { font-size: var(--step-1); }
.q-order-pitch { color: var(--ink-2); margin-top: 2px; }
.q-order-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin-top: 10px; font: 500 .82rem var(--font-mono); color: var(--ink-2); }
.q-order-actions { display: grid; gap: 8px; justify-items: stretch; }
.q-order-actions form, .q-order-actions .btn { width: 100%; }
.q-order:hover .slot-outline { stroke: var(--blue); }
.q-order.is-stretch .slot-outline { stroke-dasharray: 2.4 1.6; }
.q-ready { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: var(--r-sm); background: var(--paint); color: var(--paint-ink); font-family: var(--font-body); font-weight: 700; }
.q-ready .icon { width: 14px; height: 14px; }
@media (max-width: 680px) {
  .q-board { padding: 16px 12px; }
  .q-order { grid-template-columns: 48px minmax(0, 1fr); padding: 16px 14px; gap: 12px 14px; align-items: start; }
  .q-order .q-art { width: 48px; height: 48px; }
  .q-order-actions { grid-column: 1 / -1; grid-template-columns: 1fr 1fr; }
}
@media (max-width: 380px) { .q-order-actions { grid-template-columns: 1fr; } }
.q-more { color: var(--ink-2); }
.q-rack-line { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; color: var(--ink-2); }
.q-rack-line > .icon { color: var(--ink-3); }
.q-rack-line .num { font-family: var(--font-mono); color: var(--ink); }
/* routes off the board when the offers don't appeal: 44px touch targets on phones. The in-sentence links stay inline
   (vertical padding grows the hit area without changing the line). */
@media (pointer: coarse) {
  .q-back { min-height: 44px; }
  .q-more a { padding-block: 12px; }
  .q-rack-line a { display: inline-flex; align-items: center; min-height: 44px; }
}
.q-row-link { color: var(--ink); text-decoration: none; }
.q-row-link:hover { border-color: var(--blue); }

/* htmx in-flight labels */
.q-ind { font-weight: 700; }
.htmx-request .btn:has(.q-ind) .btn-label, .btn.htmx-request:has(.q-ind) .btn-label { display: none; }

/* ------------------------------------------------------------------ skill rack */
.q-rack { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.q-rack-row { display: grid; grid-template-columns: minmax(0, 1fr) 150px auto; gap: 10px 16px; align-items: center; padding: 12px 14px; border-radius: var(--r); background: var(--surface); border: 1px solid var(--line); }
.q-rack-title { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.q-rack-main .subtle { margin-top: 2px; }
.q-rack-state { display: flex; align-items: center; gap: 8px; }
.q-rack-actions { display: flex; gap: 6px; justify-content: flex-end; }
.q-pct { font: 500 .85rem var(--font-mono); color: var(--ink-2); min-width: 4ch; }
.q-meter { position: relative; display: inline-block; width: 92px; height: 12px; border-radius: 2px; background: var(--tape-case); overflow: hidden; flex: none; }
.q-meter-fill { position: absolute; inset: 0; clip-path: inset(0 calc(100% - var(--pct) * 1%) 0 0); background-color: var(--paint);
  background-image: repeating-linear-gradient(90deg, rgba(0, 0, 0, .45) 0 1px, transparent 1px 10%); }
@media (max-width: 680px) {
  .q-rack-row { grid-template-columns: minmax(0, 1fr) auto; }
  .q-rack-main { grid-column: 1 / -1; }
}

.q-due { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.q-due li, .q-skill-line { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.q-skill-line { color: var(--ink-2); font-weight: 700; }

/* ------------------------------------------------------------------ forging / failed */
.q-forge { justify-items: center; text-align: center; }
.q-elapsed { font: 500 .9rem var(--font-mono); color: var(--ink-2); }
.q-skeleton { display: grid; gap: 10px; width: min(100%, 460px); }
.q-skeleton .skeleton { display: block; height: 14px; }
.q-wait-alt { display: grid; justify-items: center; gap: 8px; padding-top: 6px; }
/* a slow forge (60 s+): a calm way out that never cancels the build */
.q-wait-long { align-items: center; align-self: center; text-align: center; max-width: 52ch; padding-top: 6px; color: var(--ink-2); }
.q-wait-long .row { justify-content: center; }

/* kid write stage: the "not yet" note is amber (.form-error.calm), and the always-present alert slot hides while empty */
.q-work .form-error.calm:empty { display: none; }

/* ------------------------------------------------------------------ widgets (lab contract) */
.q-widget { padding: 18px; border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--line); max-width: 860px; }
.q-widget-mount { min-height: 120px; }
.q-fallback > summary { display: inline-flex; align-items: center; min-height: 40px; cursor: pointer; color: var(--blue); font-weight: 700; }
.q-fallback[open] > summary { margin-bottom: 8px; }
.q-fallback input { max-width: 22ch; }

/* ------------------------------------------------------------------ reading quests */
.q-passage { padding: 18px 20px; border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--line); font-size: 1.06rem; }
.q-mcq { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; max-width: 640px; }
.q-mcq-choice { display: grid; grid-template-columns: 32px 1fr; gap: 12px; align-items: center; width: 100%; min-height: 52px; padding: 10px 14px; text-align: left;
  border-radius: var(--r); border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; cursor: pointer; transition: border-color .15s ease, background-color .15s ease; }
button.q-mcq-choice:hover { border-color: var(--blue); }
button.q-mcq-choice:active { background: var(--blue-soft); }
.q-mcq-key { width: 30px; height: 30px; border-radius: var(--r-sm); display: grid; place-items: center; background: var(--surface-2); font: 500 .85rem var(--font-mono); }
.q-mcq-result .q-mcq-choice { cursor: default; }
.q-mcq-choice.is-answer { background: var(--good-soft); border-color: var(--good); }
.q-mcq-choice.is-answer .q-mcq-key { background: var(--good); color: var(--surface); }
.q-mcq-choice.is-picked { background: var(--warn-soft); }
.q-rubric { padding: 12px 14px; border-radius: var(--r); background: var(--surface-2); max-width: 640px; }
.q-rubric ul { margin: 6px 0 0; padding: 0; list-style: none; display: grid; gap: 4px; }
.q-rubric li { display: flex; gap: 8px; align-items: flex-start; }
.q-rubric .icon { color: var(--good); }
.q-written { margin: 0; padding: 12px 14px; border-radius: var(--r); background: var(--surface-2); white-space: pre-wrap; max-width: 640px; }
.q-practice-note { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; color: var(--ink-2); font-size: .92rem; max-width: 70ch; }

/* ------------------------------------------------------------------ parent office */
.q-office-sum { display: flex; flex-wrap: wrap; gap: 6px 18px; color: var(--ink-2); }
.q-office-sum .num { font-family: var(--font-mono); color: var(--ink); font-weight: 500; }
.q-office-meter { display: inline-block; vertical-align: middle; width: 48px; height: 6px; margin-right: 8px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
.q-office-meter span { display: block; height: 100%; width: calc(var(--pct) * 1%); background: var(--blue); }
.q-mtable td { vertical-align: middle; }
.q-mtable td.num { white-space: nowrap; font-family: var(--font-mono); font-size: .88rem; }
.q-office-recent { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; font-size: .92rem; }
.q-office-recent li { display: grid; grid-template-columns: 9ch minmax(0, 1fr) auto; gap: 10px; align-items: center; }
.q-office-when { font: 500 .8rem var(--font-mono); color: var(--ink-3); }
.q-office-result { color: var(--ink-2); white-space: nowrap; }
.q-office-link { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; align-self: flex-start; }
.q-office-link .icon { width: 16px; height: 16px; }
.q-office-stats { display: flex; flex-wrap: wrap; gap: 10px 28px; margin: 0; }
.q-office-stats div { display: grid; gap: 2px; }
.q-office-stats dt { font-size: .8rem; font-weight: 700; color: var(--ink-2); }
.q-office-stats dd { margin: 0; font: 500 1.05rem var(--font-mono); }
@media (max-width: 560px) { .q-office-recent li { grid-template-columns: minmax(0, 1fr) auto; } .q-office-when { grid-column: 1 / -1; } }

@media (prefers-reduced-motion: reduce) { .q-art.just-hung .q-fill-on { animation: none; } }
.q-widget-wait { display: grid; gap: 12px; }
.q-widget-wait .skeleton { display: block; height: 180px; }
.q-widget-wait .skeleton + .skeleton { height: 44px; width: 70%; }
.q-widget-mount.lw ~ .q-fallback { display: none; }  /* the widget has its own answer box once it mounts */
.q-stage { scroll-margin-top: 72px; }
.q-hook-text { font-size: var(--step-2); font-weight: 700; line-height: 1.35; }
.q-fact-text { font-family: var(--font-body); font-weight: 700; color: var(--ink-2); }
.q-bench-list { list-style: none; margin: 0; padding: 0; }
.q-bench-list .list-row { grid-template-columns: auto minmax(0, 1fr) auto; }
.q-bench-list .q-row-sub { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.q-status { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: var(--r-sm); background: var(--surface-2); color: var(--ink); font-size: .8rem; font-weight: 700; white-space: nowrap; }
.q-status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); flex: none; }
.q-status.is-mastered { background: var(--good-soft); }
.q-status.is-mastered::before { background: var(--good); }
.q-status.is-learning { background: var(--blue-soft); }
.q-status.is-learning::before { background: var(--blue); }
.q-status.is-due { background: var(--warn-soft); }
.q-status.is-due::before { background: var(--warn); }

/* ------------------------------------------------------------------ round 1: honest pay, comebacks, boss-it-now, start modes */
.q-cap-note { display: flex; align-items: flex-start; gap: 8px; color: var(--ink-2); font-size: .95rem; max-width: 70ch; }
.q-cap-note > .icon { color: var(--ink-3); flex: none; margin-top: 2px; }
.q-cap-note .num { font-family: var(--font-mono); font-weight: 500; color: var(--ink); }
.q-empty .chips { justify-content: center; }

.q-comeback { display: flex; align-items: center; gap: 8px; margin: 0; color: var(--blue); font-weight: 700; }
.q-comeback .icon { width: 18px; height: 18px; }

/* an inline exit from practice, a step quieter than the Next button above it */
.q-boss-now { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px 18px; align-items: center; padding: 14px 16px; border-radius: var(--r-lg);
  background: var(--red-soft); max-width: 760px; }
.q-boss-now h3 { font-size: 1.02rem; }
.q-boss-now .muted { margin-top: 2px; font-size: .92rem; color: var(--ink-2); }
@media (max-width: 560px) { .q-boss-now { grid-template-columns: 1fr; } .q-boss-now .btn { width: 100%; } }

.q-start-list { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; max-width: 760px; }
.q-start-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px 16px; align-items: center; padding: 12px 14px; border-radius: var(--r);
  background: var(--surface); border: 1px solid var(--line); }
.q-start-row .subtle { margin-top: 2px; }
.q-not-built { display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 560px) { .q-not-built { grid-template-columns: 1fr; } .q-not-built .q-art { width: 48px; height: 48px; } }

/* parent dashboard panel: a two-line list (no clipped status column at phone width) */
.q-mlist { display: grid; margin: 0; padding: 0; list-style: none; border-top: 1px solid var(--line); }
.q-mlist li { display: grid; gap: 4px; padding: 10px 2px; border-bottom: 1px solid var(--line); }
.q-mlist-top { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.q-mlist-pct { margin-left: auto; font: 500 .88rem var(--font-mono); font-variant-numeric: tabular-nums; color: var(--ink); }
.q-mlist-name { color: var(--ink-2); font-size: .95rem; overflow-wrap: anywhere; }

/* full mastery table: status + mastery in one cell; standard column stays put while the rest scrolls on phones */
.q-mtable tbody th { background: transparent; font-size: inherit; font-weight: 400; color: var(--ink); white-space: nowrap; }
.q-mcell { white-space: nowrap; }
.q-mcell-pct { display: inline-flex; align-items: center; margin-left: 10px; font: 500 .88rem var(--font-mono); font-variant-numeric: tabular-nums; }
.q-scroll-cue { display: none; align-items: center; gap: 6px; font-size: .85rem; }
.q-scroll-cue .icon { width: 14px; height: 14px; }
@media (max-width: 560px) {
  .q-mtable thead th:first-child, .q-mtable tbody th { position: sticky; left: 0; z-index: 1; box-shadow: 1px 0 0 var(--line); }
  .q-mtable thead th:first-child { background: var(--surface-2); }
  .q-mtable tbody th { background: var(--surface); }
  .q-scroll-cue { display: flex; }
  .q-mcell { white-space: normal; }
  .q-mcell-pct { display: flex; margin: 6px 0 0; }
  .q-mtable td:nth-child(3) { min-width: 16ch; }
  .q-recent td:first-child, .q-recent td:nth-child(4) { white-space: nowrap; }
}

/* parent settings: starting level per learner */
.q-level legend { display: flex; align-items: baseline; gap: 10px; margin-bottom: 4px; }
.q-level legend .subtle { font: 500 .85rem var(--font-mono); }
.q-level-opt { display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 12px; align-items: start; padding: 10px 12px; border-radius: var(--r);
  border: 1px solid var(--line); background: var(--surface); cursor: pointer; }
.q-level-opt:has(input:checked) { border-color: var(--blue); box-shadow: 0 0 0 1px var(--blue); }
.q-level-opt input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--blue); }
.q-level-opt > span { display: grid; gap: 2px; }

/* ------------------------------------------------------------------ ideas round 1: arena mode (a boss-fight skin) + free bench */
.q-boss-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 18px; }
.q-boss-foot .q-pitch { flex: 1 1 34ch; }

/* the Arena mode switch: a real switch (role=switch), 44px tall, machinist blue when on (blue = everything you press) */
.q-arena-switch { flex: none; }
.q-switch { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; padding: 6px 14px 6px 8px; border-radius: var(--r); border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font: 700 .95rem/1.2 var(--font-body); cursor: pointer; transition: border-color .15s ease, background-color .15s ease; }
.q-switch:hover { border-color: var(--ink-3); }
.q-switch:active { background: var(--surface-2); }
.q-switch[disabled] { opacity: .6; cursor: progress; }
.q-switch-track { position: relative; flex: none; width: 42px; height: 26px; border-radius: 13px; background: var(--surface-3); border: 1.5px solid var(--field-line);
  transition: background-color .2s ease, border-color .2s ease; }
.q-switch-thumb { position: absolute; top: 2.5px; left: 2.5px; width: 18px; height: 18px; border-radius: 50%; background: var(--surface); border: 1px solid var(--field-line);
  transition: transform .2s cubic-bezier(.16, 1, .3, 1); }
.q-switch[aria-checked="true"] .q-switch-track { background: var(--blue); border-color: var(--blue); }
.q-switch[aria-checked="true"] .q-switch-thumb { transform: translateX(16px); background: var(--blue-ink); border-color: var(--blue-ink); }

/* the arena: his bot (paint + ink) vs the house bot (boss red) wearing armor plates; tokens only */
.q-arena-wrap { max-width: 580px; }
/* the figure is the arena floor itself (no box inside a box); the SVG holds only the bots, so letterboxing is invisible */
.q-arena { display: grid; gap: 4px; max-width: 580px; margin: 0; padding: 10px 14px 12px; border-radius: var(--r-lg); background: var(--surface-2); border: 1px solid var(--line); }
.q-arena-cap { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: start; gap: 10px; }
.q-arena-name { min-width: 0; overflow-wrap: anywhere; line-height: 1.3; }
.q-arena-name.is-house { display: grid; justify-items: end; gap: 2px; text-align: right; }
.q-arena-vs { padding-top: 2px; font: 500 .78rem/1.4 var(--font-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); }
.q-arena-plates { font: 500 .8rem/1.3 var(--font-mono); color: var(--red); white-space: nowrap; }
.q-arena-svg { display: block; width: 100%; height: auto; max-height: 132px; overflow: visible; }
.q-arena-seam { fill: none; stroke: var(--line); stroke-width: 1.5; stroke-dasharray: 4 5; }
.q-arena-start { fill: none; stroke: var(--outline); stroke-width: 1.5; stroke-linecap: round; stroke-dasharray: var(--outline-dash); opacity: .4; }
.q-bot-body { fill: var(--paint); stroke: var(--ink); stroke-width: 2; stroke-linejoin: round; }
.q-bot-wheel { fill: var(--label-tape); stroke: var(--ink); stroke-width: 1.5; }  /* tires: black in both themes, rimmed in ink */
.q-bot-emblem { fill: none; stroke: var(--paint-ink); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.q-house-body { fill: var(--red-soft); stroke: var(--red); stroke-width: 2; stroke-linejoin: round; }
.q-house-wheel { fill: var(--red); }
.q-plate-socket { fill: none; stroke: var(--red); stroke-width: 1.2; stroke-dasharray: 2.5 2; opacity: .7; }
.q-plate rect { fill: var(--red); }
.q-plate circle { fill: var(--red-soft); }
/* the plate drop: a 200 ms state transition (htmx settles the old class into the new one across the #boss swap) */
.q-plate { transition: opacity .2s ease-out, transform .2s cubic-bezier(.16, 1, .3, 1); }
.q-plate.is-off { opacity: 0; transform: translateY(14px); }
/* KO: out of plates, knocked off its wheels (a static pose, not a new animation) */
.q-arena.is-ko .q-arena-house { transform: rotate(6deg); transform-box: fill-box; transform-origin: 100% 100%; }
.q-arena.is-ko .q-house-body { fill: var(--surface-3); }

/* naming row: inline under the arena (open the first time it's switched on), never a modal */
.q-arena-tune > summary { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; cursor: pointer; color: var(--blue); font-weight: 700; list-style: none; border-radius: var(--r-sm); }
.q-arena-tune > summary::-webkit-details-marker { display: none; }
.q-arena-tune > summary .icon { width: 16px; height: 16px; }
.q-arena-setup { display: grid; gap: 12px; margin-top: 4px; padding: 14px; border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--line); }
.q-arena-field input { max-width: 30ch; }
.q-arena-shapes .label { display: block; margin-bottom: 6px; }
.q-shape { position: relative; }
.q-shape .icon { width: 18px; height: 18px; }
.q-shape:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }
.q-arena-note { max-width: 62ch; }
@media (max-width: 420px) { .q-arena { padding: 10px 10px 8px; } }

/* the plate drop and the switch are instant for anyone who asked for less motion */
@media (prefers-reduced-motion: reduce) {
  .q-plate, .q-switch, .q-switch-track, .q-switch-thumb { transition: none; }
}

/* free bench: subjects that never pay */
.q-free-set legend { display: flex; align-items: baseline; gap: 10px; margin-bottom: 4px; }
.q-free-set legend .subtle { font: 500 .85rem var(--font-mono); }
.q-free-opts { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 0 24px; }
.q-free-opt { min-height: 44px; font-weight: 400; }
.q-free-opt .subtle { font: 500 .78rem var(--font-mono); }
