/* ICF Practice Simulator — themes and layout */

:root {
  --bg: #ffffff;
  --fg: #111111;
  --muted: #6b7280;
  --border: #d4d4d8;
  --panel: #f5f5f5;
  --accent: #1e40af;
  --accent-soft: #dbeafe;
  --flag: #b45309;
  --flag-soft: #fef3c7;
  --shadow: 0 1px 2px rgba(0,0,0,.04);
  --radius: 4px;
  --font: ui-monospace, "SF Mono", Menlo, Consolas, "Courier New", monospace;
  --serif: ui-monospace, "SF Mono", Menlo, Consolas, "Courier New", monospace;
}

/* ─── Themes ─── */
/* Foreground / background only — UI scaffolding stays neutral within each. */

.theme-light          { --bg:#ffffff; --fg:#111111; --panel:#f5f5f5; --border:#d4d4d8; --muted:#6b7280; --accent:#1e40af; --accent-soft:#dbeafe; }
.theme-dark           { --bg:#0b0f14; --fg:#e5e7eb; --panel:#111827; --border:#334155; --muted:#9ca3af; --accent:#60a5fa; --accent-soft:#1e3a8a; }
.theme-cream          { --bg:#fbf5e3; --fg:#1f1a10; --panel:#f4ecd0; --border:#dcd1ad; --muted:#7a6a52; --accent:#7c4a1e; --accent-soft:#ead4a8; }
.theme-yellow         { --bg:#fff7c2; --fg:#1a1500; --panel:#fff09e; --border:#d8c97a; --muted:#5b4e16; --accent:#5b4002; --accent-soft:#ffeb84; }
.theme-pink           { --bg:#fde6ee; --fg:#1a0810; --panel:#facdda; --border:#e3a3b8; --muted:#6f3b4c; --accent:#7c1d3f; --accent-soft:#f4b8cb; }
.theme-green          { --bg:#e6f4ea; --fg:#0b1c10; --panel:#cde9d6; --border:#9bc8aa; --muted:#3e6a4d; --accent:#1f5132; --accent-soft:#b6dec3; }
.theme-blue           { --bg:#e3edff; --fg:#06112d; --panel:#cddafd; --border:#a6bcf0; --muted:#3f5478; --accent:#1e3a8a; --accent-soft:#bccdf9; }
.theme-grey           { --bg:#ebebeb; --fg:#1a1a1a; --panel:#dcdcdc; --border:#aeaeae; --muted:#555555; --accent:#0f172a; --accent-soft:#c8c8c8; }
.theme-sepia          { --bg:#f4ecd8; --fg:#3b2f1f; --panel:#ede1c4; --border:#d6c7a3; --muted:#7a6a52; --accent:#7c4a1e; --accent-soft:#e8d4ab; }
.theme-yellow-on-black{ --bg:#000000; --fg:#ffeb3b; --panel:#1a1a00; --border:#5a5a18; --muted:#bda74a; --accent:#fde047; --accent-soft:#3a3a08; }
.theme-green-on-black { --bg:#000000; --fg:#7fff7f; --panel:#001a00; --border:#1a5a1a; --muted:#5a9a5a; --accent:#aaffaa; --accent-soft:#063e06; }
.theme-amber          { --bg:#1a1308; --fg:#ffb74d; --panel:#241b0c; --border:#5a431f; --muted:#a68a55; --accent:#ffd180; --accent-soft:#3b2a14; }
.theme-high-contrast  { --bg:#fffae6; --fg:#000000; --panel:#fff4b8; --border:#000000; --muted:#4b3b00; --accent:#1a1a1a; --accent-soft:#ffe89a; }

/* ─── Plain / ASCII theme ─── */
/* Activates a monospaced, low-chrome appearance in addition to colour. */
.theme-plain {
  --bg: #f7f7f0; --fg: #111; --panel: #ecece2; --border: #888; --muted: #555;
  --accent: #111; --accent-soft: #d4d4c8; --radius: 0;
}
.theme-plain .option,
.theme-plain .zone { border-width: 1px; border-style: solid; box-shadow: none; }
.theme-plain .option-letter { border-radius: 0; background: transparent; border: 1px solid var(--fg); }
.theme-plain .clock { border-radius: 0; background: transparent; border: 1px solid var(--fg); }
.theme-plain button { border-radius: 0; box-shadow: none; }
.theme-plain .flag-btn { border-radius: 0; }
.theme-plain h1, .theme-plain h2, .theme-plain h3 { font-weight: 700; }
.theme-plain .topbar { border-bottom: 1px solid var(--fg); }
.theme-plain .actionbar { border-top: 1px solid var(--fg); }

/* ─── Reset / global ─── */

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
}
body { display: flex; flex-direction: column; }
main { background: transparent; position: relative; z-index: 1; }
.topbar, .actionbar { background: var(--panel); color: var(--fg); position: relative; z-index: 2; }

button, select, input, textarea {
  font: inherit;
  color: inherit;
  background: var(--bg);
}

button {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 14px;
  cursor: pointer;
  transition: background 0.15s;
  color: var(--fg);
}
button:hover { background: var(--accent-soft); }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button.primary {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}
button.primary:hover { filter: brightness(1.1); background: var(--accent); }

select {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 8px;
}

a { color: var(--accent); }

/* ─── Watermark bar (above topbar) ─── */
.watermark-bar {
  padding: 4px 22px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  font-size: 0.75em;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.watermark-bar:empty { display: none; }

/* ─── Tiled diagonal watermark ───
   Repeating SVG background painted across the viewport at -30° with the
   tester's email, IP (when available behind Cloudflare), and the date.
   pointer-events:none so it doesn't intercept drag/drop or clicks; z-index
   sits above page content but below modals (which use higher z-indices).
   The actual `background-image` is set from JS in paintTiledWatermark().
*/
.watermark-tile {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 100;
  background-repeat: repeat;
  background-position: top left;
  /* Faint by default; theme can tune via the CSS var below. */
}
.watermark-tile:empty { /* will still tile if background-image is set */ }
@media print {
  /* Make sure printouts / Save-As-PDF carry the watermark too. */
  .watermark-tile { z-index: 9999; }
}

/* ─── Floating Report-a-problem button ─── */
/* The action bar is fixed at bottom: 0 with padding 12+12 + button height ~32 ≈ 60px tall.
   We anchor the report button above it with breathing room, plus iOS safe-area insets. */
.report-btn {
  position: fixed;
  right: max(18px, env(safe-area-inset-right, 18px));
  bottom: calc(88px + env(safe-area-inset-bottom, 0px));
  z-index: 50;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel);
  color: var(--fg);
  font: inherit;
  font-size: 0.9em;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0,0,0,0.18);
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.report-btn:hover { background: var(--accent-soft); border-color: var(--accent); }
.report-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.report-btn:active { transform: translateY(1px); }
.report-icon { font-size: 1.05em; line-height: 1; }

/* When the action bar is hidden (setup / break / review-after-finalize / results),
   move the button down — no need to clear an action bar that isn't there.
   We rely on a body[data-actionbar-visible] flag set by app.js. */
body[data-actionbar-visible="false"] .report-btn {
  bottom: calc(22px + env(safe-area-inset-bottom, 0px));
}

@media (max-width: 720px) {
  /* Compact pill on narrow screens — just the bug icon, smaller pad. */
  .report-btn { padding: 9px 11px; gap: 0; font-size: 0.85em; }
  .report-btn .report-label { display: none; }
  /* The .actionbar wraps slightly tighter on mobile too; keep extra clearance. */
  .report-btn { bottom: calc(80px + env(safe-area-inset-bottom, 0px)); }
}

/* Report dialog content */
.report-modal h2 { margin-top: 0; }
.report-modal label { display: block; margin: 12px 0; font-size: 0.95em; }
.report-modal label > div:first-child { font-weight: 600; margin-bottom: 4px; }
.report-modal textarea {
  width: 100%;
  min-height: 56px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 10px;
  background: var(--bg);
  color: var(--fg);
  font: inherit;
  resize: vertical;
}
.report-modal select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 10px;
  background: var(--bg);
  color: var(--fg);
}
.report-modal .modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 14px;
}

/* ─── Disclaimer footer ─── */
.disclaimer-footer {
  padding: 18px 32px 90px 32px;
  font-size: 0.78em;
  color: var(--muted);
  border-top: 1px dotted var(--border);
  width: 100%;
  line-height: 1.5;
}
.disclaimer-footer a { color: var(--accent); text-decoration: underline; }

/* ─── Topbar ─── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-left, .topbar-right, .topbar-center {
  display: flex; align-items: center; gap: 12px;
}
#brand-home { cursor: pointer; border-radius: var(--radius); padding: 2px 6px; margin-left: -6px; transition: background 0.12s; }
#brand-home:hover { background: var(--accent-soft); }
#brand-home:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.vendor {
  font-size: 0.75em;
  letter-spacing: 0.12em;
  color: var(--muted);
  text-transform: uppercase;
}
.brand { font-weight: 700; letter-spacing: 0.01em; }
.muted { color: var(--muted); font-size: 0.92em; }
#progress { font-weight: 600; font-variant-numeric: tabular-nums; }

.clock {
  font-variant-numeric: tabular-nums;
  font-weight: 400;
  font-size: 1em;
  color: var(--fg);
  padding: 0;
  background: transparent;
  border: none;
  min-width: 60px;
  text-align: right;
}
.clock.warning { color: var(--flag); }
.clock.danger  { color: var(--flag); font-weight: 700; }

.flag-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--fg);
  padding: 4px 10px;
  font-size: 0.9em;
  border-radius: var(--radius);
}
.flag-btn:hover { background: var(--flag-soft); border-color: var(--flag); color: var(--flag); }
.flag-btn.flagged {
  background: var(--flag-soft);
  border-color: var(--flag);
  color: var(--flag);
  font-weight: 600;
}

/* ─── Main / layout ─── */
main {
  flex: 1;
  max-width: 1180px;
  margin: 0 auto;
  width: 100%;
  padding: 22px 28px 120px 28px;
}

h1 { font-size: 1.6em; margin: 0 0 16px 0; }
h2 { font-size: 1.25em; margin: 18px 0 10px 0; }
h3 { font-size: 1.05em; margin: 14px 0 6px 0; }
p { margin: 0 0 10px 0; }
ul, ol { margin: 0 0 10px 0; padding-left: 22px; }
li { margin: 4px 0; }

/* ─── Setup screen ─── */
.setup-main {
  max-width: 760px;
  margin: 14px 0 0 0;
}

.study-sheet {
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}
.study-sheet > h2 { margin-top: 0; }
.study-sheet-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-top: 10px;
}
@media (max-width: 900px) {
  .study-sheet-grid { grid-template-columns: 1fr; }
}
.study-sheet-grid .study-panel {
  margin: 0;
}

/* ─── Study-sheet drawer (slide-in from right; available from any screen) ─── */
.study-sheet-btn {
  font-size: 0.92em;
  padding: 6px 10px;
}
.drawer-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 110;
  opacity: 0;
  transition: opacity 180ms ease;
}
.drawer-backdrop.open { opacity: 1; }
.drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(460px, 92vw);
  background: var(--bg);
  color: var(--fg);
  border-left: 1px solid var(--border);
  box-shadow: -8px 0 32px rgba(0,0,0,0.28);
  z-index: 120;
  transform: translateX(100%);
  transition: transform 220ms ease;
  display: flex; flex-direction: column;
  overflow-y: auto;
}
.drawer.open { transform: translateX(0); }
.drawer-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  position: sticky; top: 0;
}
.drawer-header h2 { margin: 0; font-size: 1.15em; }
.drawer-close {
  border: 0; background: transparent;
  font-size: 1.6em; line-height: 1;
  cursor: pointer; padding: 2px 8px;
  color: var(--fg);
}
.drawer-body { padding: 16px 20px 28px; }
.drawer-body .study-panel {
  margin: 0 0 14px 0;
}
.drawer-body p.muted {
  font-size: 0.9em;
  margin-bottom: 14px;
}

/* ─── Rationale reveal (drill / study mode only) ─── */
.rationale-reveal {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin: 18px 0 0 0;
  padding: 14px 16px;
  background: var(--panel);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}
.rationale-reveal #btn-reveal-rationale {
  font-weight: 600;
}
.rationale-reveal .muted { font-size: 0.88em; }

.setup-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin: 0 0 14px 0;
}
.setup-card h2 { margin-top: 0; margin-bottom: 10px; }

.mode-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}
.mode-option {
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  background: var(--bg);
  cursor: pointer;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
}
.mode-option:hover { border-color: var(--accent); }
.mode-option.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.mode-option h3 { margin: 0 0 2px 0; font-size: 1em; }
.mode-option p { margin: 0; font-size: 0.88em; }

.setup-start-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 18px;
  background: var(--accent-soft);
  border: 2px solid var(--accent);
  border-radius: var(--radius);
  margin: 14px 0;
}
.setup-start-row .primary {
  font-size: 1.1em;
  padding: 12px 28px;
  font-weight: 700;
}
.setup-start-row .start-meta {
  flex: 1;
  font-size: 0.88em;
  color: var(--muted);
}

label { display: inline-flex; align-items: center; gap: 8px; margin-right: 16px; }
input[type="checkbox"], input[type="radio"] { transform: scale(1.1); }

textarea {
  width: 100%;
  min-height: 90px;
  border: 1px solid var(--border);
  padding: 10px;
  border-radius: var(--radius);
  font: inherit;
  resize: vertical;
}

/* ─── Exam item ─── */
.item-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 440px;
  gap: 28px;
}
@media (max-width: 920px) {
  .item-grid { grid-template-columns: 1fr; }
}

.scenario {
  grid-column: 1 / -1;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  font-family: var(--serif);
  font-size: 1.05em;
  line-height: 1.65;
  margin-bottom: 4px;
}

.options-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-left: 44px;
  margin-bottom: 22px;
}

.option {
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 12px;
  align-items: start;
  background: var(--bg);
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  cursor: grab;
  transition: opacity 0.25s ease, background 0.15s, border-color 0.15s;
  user-select: none;
  position: relative;
}
.option:hover { border-color: var(--accent); }
.option:active { cursor: grabbing; }
.option.dragging { opacity: 0.4; }
.option.placed {
  opacity: 0.45;
  background: var(--panel);
}
.option.placed .option-letter {
  background: var(--border);
  color: var(--muted);
}
.option.placed::after {
  content: attr(data-placed-label);
  position: absolute;
  top: 6px;
  right: 10px;
  font-size: 0.7em;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}

.option-letter {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--fg);
  font-weight: 700;
}

.option-text { padding-top: 4px; }

/* Drop zones — right column */
.zones {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-self: start;
}
.zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  min-height: 130px;
  background: var(--panel);
  transition: background 0.15s, border-color 0.15s;
  display: flex;
  flex-direction: column;
}
.zone.has-answer { border-style: solid; border-color: var(--border); background: var(--bg); }
.zone.drag-over  { border-style: solid; border-color: var(--accent); background: var(--accent-soft); }
.zone-label {
  font-weight: 700;
  letter-spacing: 0.1em;
  font-size: 0.8em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}
.zone-content { font-family: var(--serif); line-height: 1.45; flex: 1; }

.zone-content .placed-chip {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 8px;
  align-items: start;
  cursor: grab;
  opacity: 0.65;
}
.zone-content .placed-chip:hover { opacity: 0.85; }
.zone-content .placed-chip:active { cursor: grabbing; }
.zone-content .placed-chip.dragging { opacity: 0.4; }
.zone-content .placed-chip .option-letter {
  width: 24px; height: 24px; font-size: 0.85em;
}

.zone-empty-hint {
  color: var(--muted);
  font-style: italic;
  font-family: var(--font);
  font-size: 0.92em;
}

.options-list.drag-over {
  background: var(--accent-soft);
  border-radius: var(--radius);
  outline: 2px dashed var(--accent);
  outline-offset: 2px;
}

/* Custom drag system */
.option, .placed-chip { cursor: grab; }
.option:active, .placed-chip:active { cursor: grabbing; }
.source-dragging {
  opacity: 0.35;
  pointer-events: none;
}
.drag-ghost {
  /* Ghost inherits the visible look of whatever was picked up */
  background: var(--bg);
  border: 1.5px solid var(--accent);
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.18);
  cursor: grabbing;
  user-select: none;
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 12px;
  align-items: start;
}
.drag-ghost .option-letter {
  display: flex; justify-content: center; align-items: center;
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--accent-soft); color: var(--fg); font-weight: 700;
}
.drag-ghost .option-text { padding-top: 4px; }

/* ─── Action bar ─── */
.actionbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  border-top: 1px solid var(--border);
  padding: 12px 22px;
  z-index: 10;
}
.actionbar button { white-space: nowrap; }

/* ─── Review screen ─── */
.review-list {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin: 14px 0;
  background: var(--bg);
}
.review-row {
  display: grid;
  grid-template-columns: 56px 1fr 70px 36px 100px;
  align-items: center;
  gap: 12px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  transition: background 0.12s;
}
.review-row:last-child { border-bottom: 0; }
.review-row:hover { background: var(--accent-soft); }
.review-row .num {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: var(--muted);
}
.review-row .preview {
  font-family: var(--serif);
  line-height: 1.4;
  color: var(--fg);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}
.review-row .chosen {
  text-align: center;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--fg);
  letter-spacing: 0.04em;
}
.review-row .chosen .dash { color: var(--muted); font-weight: 400; }
.review-row .flag {
  text-align: center;
  color: var(--fg);
  font-weight: 700;
  font-size: 1.1em;
}
.review-row .review-btn {
  padding: 4px 12px;
  font-size: 0.88em;
}
.review-row.unanswered .preview { opacity: 0.75; }

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.55);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}
.modal {
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  max-width: 480px;
  text-align: center;
  box-shadow: 0 10px 40px rgba(0,0,0,0.3);
}
.modal h2 { margin-top: 0; }
.modal .count {
  font-size: 2.6em;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  margin: 14px 0;
  color: var(--flag);
}

/* ─── Break screen ─── */
.break-card {
  text-align: center;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  max-width: 540px;
  margin: 36px auto;
}
.break-clock {
  font-size: 3em;
  font-variant-numeric: tabular-nums;
  margin: 18px 0;
}

/* ─── Results ─── */
.result-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin: 16px 0;
}
.stat {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  text-align: center;
}
.stat-value { font-size: 1.8em; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-label { color: var(--muted); font-size: 0.85em; }

.competency-row {
  display: grid;
  grid-template-columns: 1fr 90px 1fr;
  align-items: center;
  gap: 12px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}
.bar-track { height: 10px; background: var(--accent-soft); border-radius: 5px; overflow: hidden; }
.bar-fill  { height: 100%; background: var(--accent); }

.result-item {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin: 10px 0;
}
.result-item.correct { border-left: 4px solid var(--accent); }
.result-item.partial { border-left: 4px solid var(--flag); }
.result-item.wrong   { border-left: 4px solid var(--border); }
.result-item summary { cursor: pointer; font-weight: 600; }
.result-item .option-line {
  display: flex; gap: 8px; padding: 4px 0; align-items: flex-start;
}
.result-item .option-line .tag {
  font-size: 0.75em; padding: 1px 6px; border-radius: 4px; white-space: nowrap;
  border: 1px solid var(--border);
}
.tag-best { background: var(--accent-soft); color: var(--fg); border-color: var(--accent); font-weight: 600; }
.tag-worst{ background: var(--panel); color: var(--fg); border-color: var(--muted); font-weight: 600; }
.tag-you  { background: var(--flag-soft); color: var(--flag); border-color: var(--flag); }

.rationale {
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 10px;
  border-radius: var(--radius);
  margin-top: 8px;
  font-family: var(--serif);
}
.rationale h4 { margin: 8px 0 4px 0; font-size: 0.95em; }
.rationale h4:first-child { margin-top: 0; }

/* ─── Results screen — walk-through entry ─── */
.results-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 14px 0 22px 0;
  padding: 14px 18px;
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
}
.results-actions .primary { font-weight: 700; }
.results-actions .muted { flex: 1; font-size: 0.9em; }
@media (max-width: 720px) {
  .results-actions { flex-direction: column; align-items: stretch; gap: 8px; }
}

/* ─── Study mode (walkthrough) ─── */
.walkthrough-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.walkthrough-header h1 { margin: 0; }
.walkthrough-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}
.walkthrough-controls label { display: flex; align-items: center; gap: 6px; }
.walkthrough-controls select { padding: 4px 8px; }

.walkthrough-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  padding: 8px 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 12px;
  font-size: 0.9em;
}
.walkthrough-meta .wt-id { font-weight: 700; font-family: ui-monospace, monospace; }
.walkthrough-meta .wt-result { font-weight: 600; }
.walkthrough-meta .wt-correct { color: var(--accent); }
.walkthrough-meta .wt-partial { color: var(--flag); }
.walkthrough-meta .wt-wrong { color: var(--fg); }
.walkthrough-meta .wt-flagged { color: var(--flag); font-weight: 600; }

.wt-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 14px 0 18px 0;
}
.wt-option {
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  background: var(--bg);
}
.wt-option.is-best { border-color: var(--accent); }
.wt-option.is-worst { border-color: var(--muted); }
.wt-option.is-you { background: var(--accent-soft); }
.wt-option-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.wt-option-tags:empty { display: none; }
.wt-option-body { font-family: var(--serif); line-height: 1.5; }

.walkthrough-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 0;
  margin-top: 14px;
  border-top: 1px solid var(--border);
}
.walkthrough-nav .muted { font-variant-numeric: tabular-nums; }

/* ─── Study panel ─── */
.study-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin: 10px 0;
}
.study-panel h3 { margin-top: 0; }
.study-panel table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92em;
}
.study-panel th, .study-panel td {
  text-align: left;
  padding: 5px 8px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.study-panel th { background: var(--accent-soft); font-weight: 600; }
