/* quizplus area styles (wave 3, quizplus builder). Use app.css tokens; keep the restrained house style.
   Player widgets (matching, ordering, groups, diagram, scenario), builder editors, outcome reports, the bank. */

/* ------------------------------------------------------------------ player */
.qp { --qp-r: 10px; }
.qp-help { font-size: 12.5px; color: var(--ink-3); margin-top: 10px; }
.qp-help-row { gap: 10px; margin-top: 10px; align-items: center; }
.qp-help-row .qp-help { margin: 0; }
.qp-ph { font-size: 12.5px; color: var(--ink-3); font-weight: 500; }

/* chips: the things students move */
.qp-chip { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 6px 12px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--surface);
  font: 500 14px/1.3 var(--font-ui); color: var(--ink); text-align: left; cursor: grab; user-select: none; -webkit-user-select: none; touch-action: none;
  transition: border-color .16s var(--ease), box-shadow .16s var(--ease), background-color .16s var(--ease), opacity .16s var(--ease); }
.qp-chip:hover { border-color: var(--ink-3); }
.qp-chip[aria-pressed="true"] { border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); background: var(--surface-2); }
.qp-chip.lifted { opacity: .35; }
.qp-chip.in { cursor: default; }
button.qp-chip.in { cursor: grab; }
.qp-bank { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; padding: 12px; min-height: 60px; border-radius: var(--r-lg); border: 1px dashed var(--line-2); background: var(--surface-2);
  transition: border-color .16s var(--ease), background-color .16s var(--ease); }
.qp-bank.over { border-color: var(--ink-3); background: var(--surface-3); }
.qp-ghost { position: fixed; z-index: 90; margin: 0; pointer-events: none; box-shadow: var(--sh-3); border-color: var(--ink) !important; background: var(--surface) !important; opacity: .96; list-style: none; }
.qp-dragging { cursor: grabbing; }
.qp-tick { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; flex: none; }
.qp-tick svg { width: 13px; height: 13px; }
.qp-tick.ok { background: var(--ok-tint); color: var(--ok); }
.qp-tick.bad { background: var(--bad-tint); color: var(--bad); }
.qp-fix { font-size: 12.5px; color: var(--ok); font-weight: 600; }

/* matching */
.qp-match { display: grid; gap: 8px; }
.qp-row { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1.1fr); align-items: center; gap: 10px; padding: 8px 8px 8px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.qp-left { font-weight: 550; font-size: 14.5px; line-height: 1.35; }
.qp-arrow { color: var(--ink-3); display: grid; }
.qp-slotcell { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.qp-slot { flex: 1; min-width: 0; min-height: 44px; display: flex; align-items: center; padding: 4px; border-radius: var(--qp-r); border: 1px dashed var(--line-2); background: var(--surface-2); text-align: left;
  transition: border-color .16s var(--ease), background-color .16s var(--ease); }
.qp-slot .qp-ph { padding: 0 8px; }
.qp-slot.filled { border-style: solid; border-color: transparent; background: transparent; padding: 0; }
.qp-slot.filled .qp-chip { width: 100%; }
.qp-slot.ready { border-color: var(--ink-3); }
.qp-slot.ready.filled { box-shadow: inset 0 0 0 1px var(--line-2); }
.qp-slot.over, .qp-slot:hover:not([disabled]) { border-color: var(--ink); }
.qp-row.is-right { border-color: color-mix(in srgb, var(--ok) 40%, transparent); }
.qp-row.is-wrong { border-color: color-mix(in srgb, var(--bad) 40%, transparent); }

/* ordering */
.qp-order { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.qp-step { display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 6px 8px 6px 6px; border: 1px solid var(--line-2); border-radius: 12px; background: var(--surface); }
.qp-step.lifted { opacity: .35; }
.qp-step.is-right { border-color: color-mix(in srgb, var(--ok) 45%, transparent); background: var(--ok-tint); }
.qp-step.is-wrong { border-color: color-mix(in srgb, var(--bad) 45%, transparent); }
.qp-grip { width: 30px; align-self: stretch; display: grid; place-items: center; border: 0; border-radius: 8px; background: none; color: var(--ink-3); cursor: grab; touch-action: none; flex: none; }
.qp-grip:hover { background: var(--surface-2); color: var(--ink); }
.qp-pos { width: 24px; height: 24px; border-radius: 7px; display: grid; place-items: center; font: 600 12.5px/1 var(--font-ui); color: var(--ink-2); border: 1px solid var(--line-2); flex: none; font-variant-numeric: tabular-nums; }
.qp-text { flex: 1; min-width: 0; font-size: 14.5px; font-weight: 500; line-height: 1.35; }
.qp-mv { display: flex; gap: 2px; flex: none; }
.qp-correct { margin-top: 12px; padding: 12px 14px; border-radius: 12px; background: var(--surface-2); }
.qp-correct ol { margin: 6px 0 0 18px; font-size: 13.5px; display: grid; gap: 3px; }

/* categorise */
.qp-groups { display: grid; grid-template-columns: repeat(var(--cols, 2), minmax(0, 1fr)); gap: 10px; }
.qp-group { display: flex; flex-direction: column; border: 1px solid var(--line-2); border-radius: 12px; background: var(--surface); min-height: 130px; transition: border-color .16s var(--ease), box-shadow .16s var(--ease); }
.qp-group.ready { border-style: dashed; border-color: var(--ink-3); }
.qp-group.over { border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); }
.qp-group-h { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px; border: 0; border-bottom: 1px solid var(--line); background: var(--surface-2); border-radius: 12px 12px 0 0; font: 600 13.5px/1.3 var(--font-ui); color: var(--ink); text-align: left; }
.qp-group-h:hover:not([disabled]) { background: var(--surface-3); }
.qp-group-b { display: flex; flex-direction: column; gap: 6px; padding: 10px; flex: 1; }
.qp-placed { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.qp-placed .qp-chip { max-width: 100%; }
.qp-placed.is-wrong .qp-chip { border-color: color-mix(in srgb, var(--bad) 45%, transparent); }
.qp-placed.is-right .qp-chip { border-color: color-mix(in srgb, var(--ok) 45%, transparent); }

/* diagram */
.qp-dia { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(220px, 1fr); gap: 16px; align-items: start; }
.qp-dia-img { position: relative; width: 100%; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); background: var(--surface); }
.qp-dia-img img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; user-select: none; -webkit-user-drag: none; }
.qp-mark { position: absolute; transform: translate(-50%, -50%); width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; border: 2px solid var(--surface); background: var(--ink); color: var(--bg);
  font: 700 13px/1 var(--font-ui); box-shadow: 0 1px 4px rgba(0, 0, 0, .3); transition: background-color .16s var(--ease), box-shadow .16s var(--ease); }
.qp-mark::after { content: ''; position: absolute; inset: -8px; border-radius: 50%; }   /* a bigger target than the dot */
.qp-mark.filled { background: var(--info); color: #fff; }
.qp-dia.ready .qp-mark { box-shadow: 0 0 0 3px color-mix(in srgb, var(--ink) 25%, transparent); }
.qp-mark.over { box-shadow: 0 0 0 4px var(--ink); }
.qp-mark.is-right { background: var(--ok); color: #fff; }
.qp-mark.is-wrong { background: var(--bad); color: #fff; }
.qp-dia-list { display: grid; gap: 8px; }
.qp-dia-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.qp-dia-row select { flex: 1; min-width: 150px; }
.qp-num { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--ink); color: var(--bg); font: 700 12.5px/1 var(--font-ui); flex: none; }
.qp-dia-row.is-right .qp-num { background: var(--ok); color: #fff; }
.qp-dia-row.is-wrong .qp-num { background: var(--bad); color: #fff; }

/* scenario: the stem stays in view beside the parts */
.quiz-body.qp-wide { width: min(1160px, 100%); }
.qp-scn { display: grid; grid-template-columns: minmax(0, .95fr) minmax(0, 1.2fr); gap: 24px; align-items: start; margin-top: 12px; }
.qp-stem { position: sticky; top: 76px; max-height: calc(100dvh - 190px); overflow: auto; border: 1px solid var(--line); border-radius: var(--r-xl); background: var(--surface); padding: 16px 18px; }
.qp-stem-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.qp-stem-toggle { display: none; }
.qp-stem-text { white-space: pre-line; font-family: var(--font-read); font-size: 15.5px; line-height: 1.6; }
.qp-stem-img { display: block; width: 100%; height: auto; margin-top: 12px; border-radius: 10px; border: 1px solid var(--line); }
.qp-parts { display: grid; gap: 22px; }
.qp-part { padding-bottom: 20px; border-bottom: 1px solid var(--line); }
.qp-part:last-child { border-bottom: 0; }
.qp-part-h { display: flex; gap: 8px; align-items: baseline; font-weight: 600; font-size: 16px; line-height: 1.4; margin-bottom: 12px; }
.qp-part-k { color: var(--ink-3); flex: none; }
.qp-part-m { margin-left: auto; flex: none; font: 500 12px/1 var(--font-ui); color: var(--ink-3); }
.qp-part .opt { min-height: 48px; }
.qp-pex { margin-top: 8px; }
.qp-short { min-height: 46px; font-size: 15px; }
.feedback.part { border-color: color-mix(in srgb, var(--warn) 45%, transparent); }
.feedback.part .head { color: var(--warn); }

/* review after submitting */
.qp-rvlist { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.qp-rv { display: grid; grid-template-columns: auto minmax(0, 1fr) minmax(0, 1fr); gap: 4px 10px; align-items: start; font-size: 13.5px; }
.qp-rv .qp-tick { margin-top: 1px; }
.qp-rv-l { font-weight: 550; }
.qp-rv-c { grid-column: 2 / -1; font-size: 12.5px; color: var(--ok); font-weight: 600; }
.qp-rvdia { display: grid; grid-template-columns: minmax(0, 260px) minmax(0, 1fr); gap: 14px; align-items: start; }
.qp-dia-img.sm .qp-mark { width: 22px; height: 22px; font-size: 11px; }
.qp-rvorder { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.qp-rvorder ol { margin: 6px 0 0 18px; font-size: 13.5px; display: grid; gap: 3px; }
.qp-rvorder li.is-right { color: var(--ok); }
.qp-rvorder li.is-wrong { color: var(--bad); }
.qp-rvstem summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.qp-rvstem .qp-stem-text { margin-top: 8px; font-size: 14px; }
.qp-rvparts { display: grid; gap: 12px; margin-top: 10px; }
.qp-rvpart { padding-left: 12px; border-left: 2px solid var(--line); }
.qp-rvph { display: flex; gap: 8px; align-items: flex-start; }

@media (max-width: 900px) {
  .qp-scn { grid-template-columns: 1fr; gap: 16px; }
  .qp-stem { top: 62px; z-index: 3; max-height: 34dvh; padding: 12px 14px; box-shadow: var(--sh-2); }
  .qp-stem-text { font-size: 14.5px; line-height: 1.55; }
  .qp-stem-toggle { display: inline-flex; }
  .qp-stem.collapsed .qp-stem-body { display: none; }
  .qp-dia { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .qp-row { grid-template-columns: 1fr; gap: 6px; padding: 10px; }
  .qp-arrow { display: none; }
  .qp-groups { grid-template-columns: 1fr; }
  .qp-group { min-height: 0; }
  .qp-group-b { min-height: 44px; }
  .qp-rv { grid-template-columns: auto minmax(0, 1fr); }
  .qp-rv-a { grid-column: 2; }
  .qp-rvdia, .qp-rvorder { grid-template-columns: 1fr; }
  .qp-mv .iconbtn { width: 32px; height: 32px; }
}

/* ------------------------------------------------------------------ builder */
.qe-block { display: flex; flex-direction: column; gap: 8px; }
.qe-h { font-size: 13px; font-weight: 600; display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; }
.qe-h .tiny { font-weight: 400; }
.qe-pair { display: flex; align-items: center; gap: 8px; }
.qe-pair .input { min-height: 40px; flex: 1; min-width: 0; }
.qe-to { color: var(--ink-3); display: grid; flex: none; }
.qe-n { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); border: 1px solid var(--line-2); font: 600 12px/1 var(--font-ui); flex: none; }
select.qe-sel { width: auto; min-height: 32px; padding: 2px 30px 2px 8px; font-size: 12.5px; flex: none; }
.qe-pair select.qe-sel { min-height: 40px; max-width: 42%; }
.qe-block > .btn.ghost, .qe-part .stack > .btn.ghost, .qe-part > .btn.ghost { align-self: flex-start; }
.qe-part b { white-space: nowrap; }
.qe-dia { position: relative; width: 100%; max-width: 640px; border-radius: 12px; overflow: hidden; border: 1px solid var(--line-2); background: var(--surface-2); cursor: crosshair; }
.qe-dia img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; user-select: none; -webkit-user-drag: none; pointer-events: none; }
.qe-mark { position: absolute; transform: translate(-50%, -50%); width: 30px; height: 30px; border-radius: 50%; border: 2px solid #fff; background: var(--ink); color: var(--bg); font: 700 13px/1 var(--font-ui);
  display: grid; place-items: center; cursor: grab; touch-action: none; box-shadow: 0 1px 4px rgba(0, 0, 0, .3); }
.qe-mark:active { cursor: grabbing; }
.qe-dia-empty { padding: 16px; border: 1px dashed var(--line-2); border-radius: 12px; align-items: flex-start; }
.qe-thumb { width: 120px; height: 72px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.qe-part { border: 1px solid var(--line); border-radius: var(--r-lg); padding: 12px; display: flex; flex-direction: column; gap: 10px; background: var(--surface-2); }
.qe-part .input { background: var(--surface); }
.qe-part .opt-row { display: flex; align-items: center; gap: 10px; }
.qe-part .opt-row .input { min-height: 40px; flex: 1; }
.qe-num { display: flex; flex-wrap: wrap; gap: 8px; }
.qe-num .input:first-child { flex: 1; min-width: 160px; }
.qb-meta { gap: 8px 10px; align-items: center; padding-top: 10px; border-top: 1px solid var(--line); }
.qb-meta select { width: auto; min-height: 32px; max-width: min(360px, 100%); padding: 2px 30px 2px 8px; font-size: 12.5px; }
.qp-flash { animation: qpFlash 1.2s var(--ease) 1; }
@keyframes qpFlash { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--info) 0%, transparent); } 30% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--info) 30%, transparent); } 100% { box-shadow: 0 0 0 0 transparent; } }
.qp-warn { color: var(--warn); display: inline-flex; align-items: center; gap: 4px; }
.qp-bp { display: grid; gap: 8px; }
.qp-bprow { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
.qp-bpt { flex: 1; min-width: 200px; display: flex; flex-wrap: wrap; gap: 2px 8px; align-items: baseline; }
.qp-bpt .tiny { flex-basis: 100%; }

/* ------------------------------------------------------------------ reports */
/* One blue ramp (light = few marks earned, dark = most); values are printed in every cell. Dark mode flips the anchor. */
.qp-heat { --h0: #cde2fb; --h1: #9ec5f4; --h2: #6da7ec; --h3: #256abf; --h4: #184f95; --t-lo: #141416; --t-hi: #fff;
  display: inline-grid; place-items: center; min-width: 46px; height: 28px; padding: 0 6px; border-radius: 6px; font: 650 12.5px/1 var(--font-ui); font-variant-numeric: tabular-nums; }
.qp-heat.b0 { background: var(--h0); color: var(--t-lo); }
.qp-heat.b1 { background: var(--h1); color: var(--t-lo); }
.qp-heat.b2 { background: var(--h2); color: var(--t-lo); }
.qp-heat.b3 { background: var(--h3); color: var(--t-hi); }
.qp-heat.b4 { background: var(--h4); color: var(--t-hi); }
.qp-heat.bnone { background: repeating-linear-gradient(135deg, var(--surface-2) 0 4px, var(--surface-3) 4px 6px); color: var(--ink-3); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .qp-heat { --h0: #0d366b; --h1: #184f95; --h2: #256abf; --h3: #5598e7; --h4: #9ec5f4; --t-lo: #EDEDEF; --t-hi: #141416; }
  :root:not([data-theme="light"]) .qp-heat.b2 { color: var(--t-lo); }
}
:root[data-theme="dark"] .qp-heat { --h0: #0d366b; --h1: #184f95; --h2: #256abf; --h3: #5598e7; --h4: #9ec5f4; --t-lo: #EDEDEF; --t-hi: #141416; }
td .qp-heat { transition: box-shadow .16s var(--ease); }
td .qp-heat:hover { box-shadow: 0 0 0 2px var(--ink); }
.qp-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-top: 12px; }
.qp-key { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-2); }
.qp-key .qp-heat { min-width: 18px; width: 18px; height: 14px; padding: 0; border-radius: 4px; }
.qp-heatwrap { max-height: 640px; }
.qp-heatmap th[scope="row"] { font-weight: 550; font-size: 13px; background: var(--surface); text-align: left; position: sticky; left: 0; z-index: 1; }
.qp-heatmap { width: 100%; }
.qp-heatmap td { padding: 5px 6px; }
select.qp-mini, .input.qp-mini { width: auto; min-height: 32px; padding: 2px 30px 2px 8px; font-size: 12.5px; max-width: 100%; }
.qp-tip { position: fixed; z-index: 95; max-width: 280px; padding: 7px 10px; border-radius: 8px; background: var(--ink); color: var(--bg); font-size: 12.5px; line-height: 1.35; pointer-events: none; box-shadow: var(--sh-2);
  animation: qpTip .16s var(--ease); }
@keyframes qpTip { from { opacity: 0; transform: translateY(3px); } }
.qp-kpis { margin-bottom: 16px; }
.qp-repgrid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr); gap: 16px; align-items: start; }
.qp-hard { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.qp-hard-t { min-width: 0; font-size: 13.5px; line-height: 1.35; }
.qp-hard-t span { color: var(--ink-2); }
.qp-hbar { height: 8px; margin-top: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.qp-hbar.sm { height: 6px; margin-top: 6px; }
.qp-hbar > i { display: block; height: 100%; background: #256abf; border-radius: 0 4px 4px 0; transform-origin: left; transition: transform .42s var(--ease); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .qp-hbar > i { background: #5598e7; } }
:root[data-theme="dark"] .qp-hbar > i { background: #5598e7; }
.qp-iprompt { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; max-width: 460px; font-size: 13px; white-space: normal; }
@media (max-width: 1000px) { .qp-repgrid { grid-template-columns: minmax(0, 1fr); } }

/* ------------------------------------------------------------------ bank + filters */
.qp-filters { display: flex; flex-wrap: wrap; gap: 12px 14px; align-items: flex-end; padding: 14px 16px; }
.qp-filters .field { min-width: 160px; flex: 0 1 220px; }
.qp-filters .qp-grow { flex: 1 1 200px; }
.qp-filters .check { padding-bottom: 8px; }
.qp-strip { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: thin; }
.qp-stripb { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-width: 112px; padding: 10px 12px; border-radius: var(--r-lg); border: 1px solid var(--line); background: var(--surface); text-align: left; font-size: 12.5px; color: var(--ink-2);
  transition: border-color .16s var(--ease), box-shadow .16s var(--ease); }
.qp-stripb b { font-size: 14px; color: var(--ink); }
.qp-stripb:hover { border-color: var(--ink-3); }
.qp-stripb[aria-pressed="true"] { border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); }
.qp-bulk { position: sticky; top: calc(var(--topbar) + 8px); z-index: 4; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-top: 12px; padding: 10px 12px;
  border-radius: var(--r-lg); border: 1px solid var(--line-2); background: var(--surface); box-shadow: var(--sh-2); animation: qpTip .2s var(--ease); }
.qp-banklist { padding: 0; overflow: hidden; }
.qp-bankhead { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.qp-bankrows { list-style: none; margin: 0; padding: 0; }
.qp-bankrow { display: flex; align-items: flex-start; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); transition: background-color .16s var(--ease); }
.qp-bankrow:last-child { border-bottom: 0; }
.qp-bankrow.on { background: var(--surface-2); }
.qp-bankrow > input { margin-top: 4px; width: 18px; height: 18px; flex: none; }
.qp-bankmain { flex: 1; min-width: 0; }
.qp-bankp { color: var(--ink); text-decoration: none; font-weight: 550; font-size: 14px; line-height: 1.45; overflow-wrap: anywhere; }
.qp-bankp:hover { text-decoration: underline; }
.qp-implist { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 6px; max-height: 360px; overflow: auto; }
@media (max-width: 600px) {
  .qp-bankrow { flex-wrap: wrap; }
  .qp-bankrow .btn-row { width: 100%; padding-left: 30px; }
  .qp-filters .field { flex: 1 1 100%; }
}

/* ------------------------------------------------------------------ student: my outcomes */
.qp-mine-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.qp-mine-list .small b { margin-right: 2px; }
.qp-bulk > .row { min-width: 0; max-width: 100%; }
.qp-bulk select.qp-mini { max-width: min(240px, 100%); }
