/* Free Reviewer — sized for iPad touch: 48px+ tap targets, 18px text, no hover-only UI. */

[hidden] {
  display: none !important;
}

:root {
  --bg: #f3f5f7;
  --card: #ffffff;
  --text: #17202b;
  --muted: #5a6573;
  --line: #d9dfe6;
  --accent: #0f766e;
  --accent-ink: #ffffff;
  --accent-soft: #e3f3f1;
  --good: #157a3b;
  --good-soft: #e5f5ea;
  --partial: #9a5b00;
  --partial-soft: #fff3dc;
  --bad: #b42318;
  --bad-soft: #fdecea;
  --radius: 14px;
  --shadow: 0 1px 2px rgb(16 24 40 / 0.06), 0 1px 3px rgb(16 24 40 / 0.08);
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1418;
    --card: #182027;
    --text: #e8edf2;
    --muted: #9aa6b2;
    --line: #2c3742;
    --accent: #2bb3a3;
    --accent-ink: #062320;
    --accent-soft: #123532;
    --good: #4ccb7a;
    --good-soft: #10301c;
    --partial: #f0b44c;
    --partial-soft: #36290f;
    --bad: #ff7b6e;
    --bad-soft: #3a1714;
    --shadow: none;
  }
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 18px/1.5 -apple-system, BlinkMacSystemFont, 'SF Pro Text', system-ui, 'Segoe UI', Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

button,
select,
input {
  font: inherit;
  color: inherit;
  touch-action: manipulation;
}

button {
  cursor: pointer;
}

h1,
h2,
h3,
h4 {
  line-height: 1.25;
  margin: 0 0 0.5em;
}

h1 {
  font-size: 1.6rem;
}

h2 {
  font-size: 1.25rem;
}

h3 {
  font-size: 1.05rem;
  margin-top: 1.25em;
}

h4 {
  font-size: 1rem;
  margin-top: 1em;
}

p {
  margin: 0 0 0.75em;
}

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

.muted {
  color: var(--muted);
}

.small {
  font-size: 0.88rem;
}

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- layout */

.screen {
  max-width: 820px;
  margin: 0 auto;
  padding: 20px 20px calc(120px + env(safe-area-inset-bottom));
}

.screen.center {
  text-align: center;
  padding-top: 30vh;
}

.home {
  padding-top: calc(24px + env(safe-area-inset-top));
}

.hero h1 {
  font-size: 2rem;
  margin-bottom: 0.1em;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
  padding: 20px 22px;
  margin: 18px 0;
}

.card > h3:first-of-type {
  margin-top: 1em;
}

.notice {
  background: var(--accent-soft);
  border-radius: 12px;
  padding: 12px 16px;
}

.notice.warn {
  background: var(--partial-soft);
  color: var(--text);
  border: 1px solid color-mix(in srgb, var(--partial) 35%, transparent);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 18px;
}

.footer {
  text-align: center;
  margin-top: 28px;
}

.footer .btn {
  margin-bottom: 12px;
}

/* ---------- buttons and choices */

.btn {
  min-height: 50px;
  padding: 0 22px;
  border-radius: 12px;
  border: 1px solid transparent;
  font-size: 1rem;
  font-weight: 600;
  background: none;
}

.btn.primary {
  background: var(--accent);
  color: var(--accent-ink);
}

.btn.secondary {
  background: var(--card);
  border-color: var(--line);
}

.btn.ghost {
  color: var(--accent);
  padding: 0 12px;
}

.btn.large {
  min-height: 58px;
  font-size: 1.1rem;
  width: 100%;
}

.btn.small {
  min-height: 44px;
  font-size: 0.9rem;
  margin-top: 8px;
}

.btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.segmented,
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.seg,
.chip {
  min-height: 48px;
  padding: 8px 18px;
  border-radius: 999px;
  border: 2px solid var(--line);
  background: var(--card);
  text-align: left;
}

.seg[aria-pressed='true'],
.chip[aria-pressed='true'] {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.mode-choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.mode-choice {
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: left;
  padding: 14px 16px;
  min-height: 88px;
  border-radius: var(--radius);
  border: 2px solid var(--line);
  background: var(--card);
}

.mode-choice span {
  color: var(--muted);
  font-size: 0.92rem;
}

.mode-choice[aria-pressed='true'] {
  border-color: var(--accent);
  background: var(--accent-soft);
}

/* ---------- lists */

.list {
  list-style: none;
  margin: 0;
  padding: 0;
}

/* A divider above every visible row that has a visible row before it (search hides rows). */
.list li:not([hidden]) ~ li:not([hidden]) {
  border-top: 1px solid var(--line);
}

.list-row {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 64px;
  padding: 10px 4px;
  border: 0;
  background: none;
  text-align: left;
}

.list-main {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.score-pill,
.status-chip {
  border-radius: 999px;
  padding: 4px 12px;
  font-weight: 700;
  font-size: 0.9rem;
  background: var(--accent-soft);
  color: var(--accent);
  white-space: nowrap;
}

.status-chip {
  font-weight: 600;
  font-size: 0.8rem;
}

.status-chip.status-draft,
.status-chip.status-ai-checked {
  background: var(--partial-soft);
  color: var(--partial);
}

.status-chip.status-nurse-reviewed {
  background: var(--good-soft);
  color: var(--good);
}

/* ---------- top and bottom bars */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
}

.topbar-inner {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  max-width: 1180px;
  margin: 0 auto;
  min-height: 60px;
  padding: 0 8px;
}

.topbar-inner > :last-child {
  justify-self: end;
}

.topbar-inner > :first-child {
  justify-self: start;
}

.topbar h1 {
  font-size: 1.05rem;
  margin: 0;
  text-align: center;
}

.progress {
  height: 4px;
  background: var(--line);
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  transition: width 0.2s;
}

.bottombar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--card) 92%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  padding: 12px max(16px, env(safe-area-inset-right)) calc(12px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}

.bottombar-inner {
  display: flex;
  gap: 12px;
  max-width: 1180px;
  margin: 0 auto;
}

.spacer {
  flex: 1;
}

/* ---------- question */

.screen.question.with-exhibit {
  max-width: 1180px;
}

@media (min-width: 1000px) {
  .question.with-exhibit {
    display: grid;
    grid-template-columns: minmax(300px, 0.85fr) 1.15fr;
    gap: 28px;
    align-items: start;
  }

  .question.with-exhibit .exhibit {
    position: sticky;
    top: 84px;
    margin-top: 0;
  }
}

.meta {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.stem {
  font-size: 1.12rem;
  margin-bottom: 18px;
}

.stem .prompt {
  margin-top: 12px;
}

.hint {
  color: var(--muted);
  font-size: 0.92rem;
}

.exhibit {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 18px;
}

.exhibit h3 {
  margin-top: 0;
}

.exhibit table {
  width: 100%;
  border-collapse: collapse;
}

.exhibit th,
.exhibit td {
  text-align: left;
  padding: 8px 6px;
  border-top: 1px solid var(--line);
  vertical-align: top;
}

.exhibit th {
  font-weight: 600;
  width: 42%;
}

/* multiple choice and select all */

.option {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  width: 100%;
  min-height: 62px;
  padding: 14px 16px;
  margin-bottom: 12px;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  text-align: left;
  -webkit-user-select: none;
  user-select: none;
}

.option .marker {
  flex: 0 0 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 2px solid var(--line);
  border-radius: 50%;
  font-weight: 700;
  font-size: 0.95rem;
}

.option.checkbox .marker {
  border-radius: 9px;
}

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

.option[aria-checked='true'] {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.option[aria-checked='true'] .marker {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

/* calculation */

.calc {
  display: block;
  margin: 8px 0 16px;
}

.calc-label {
  display: block;
  font-weight: 600;
  margin-bottom: 8px;
}

.calc-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.calc input {
  width: 200px;
  min-height: 56px;
  padding: 0 16px;
  font-size: 1.3rem;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: var(--card);
}

.calc input:focus {
  border-color: var(--accent);
  outline: none;
}

.unit {
  font-size: 1.15rem;
  font-weight: 600;
}

/* drop-down */

.cloze {
  font-size: 1.15rem;
  line-height: 2.6;
}

.cloze select {
  min-height: 48px;
  max-width: 100%;
  padding: 6px 12px;
  margin: 0 4px;
  border: 2px solid var(--accent);
  border-radius: 10px;
  background: var(--accent-soft);
  font-size: 1rem;
  font-weight: 600;
}

.cloze select:not(.filled) {
  color: var(--muted);
  border-style: dashed;
  background: var(--card);
}

/* matrix */

.matrix {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.matrix th,
.matrix td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.matrix thead th {
  font-size: 0.9rem;
  color: var(--muted);
  background: color-mix(in srgb, var(--line) 30%, var(--card));
}

.matrix tbody tr:last-child > * {
  border-bottom: 0;
}

.matrix tbody th {
  font-weight: 400;
}

.row-number {
  font-weight: 700;
  color: var(--muted);
}

.matrix td {
  width: 1%;
  text-align: center;
}

.cell-choice {
  display: inline-grid;
  place-items: center;
  width: 64px;
  height: 56px;
  border: 0;
  background: none;
}

.cell-choice .dot {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2px solid var(--line);
}

.cell-choice[aria-checked='true'] .dot {
  border: 9px solid var(--accent);
}

.cell-label {
  display: none;
}

/* Narrow screens: one card per finding with labelled buttons. */
@media (max-width: 640px) {
  .matrix thead {
    display: none;
  }

  .matrix tr,
  .matrix th,
  .matrix td {
    display: block;
    width: auto;
    border: 0;
  }

  .matrix tr {
    border-bottom: 1px solid var(--line);
    padding: 8px 0;
  }

  .matrix td {
    display: inline-block;
    padding: 4px 8px;
  }

  .cell-choice {
    width: auto;
    display: inline-flex;
    gap: 8px;
    padding: 0 10px;
  }

  .cell-label {
    display: inline;
  }
}

/* bow-tie */

.bowtie-diagram {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1.15fr 1fr;
  gap: 18px 26px;
  margin: 8px 0 14px;
  padding: 6px 0;
}

.bowtie-lines {
  position: absolute;
  inset: 0;
  z-index: 0;
}

.bowtie-lines svg {
  width: 100%;
  height: 100%;
}

.bowtie-lines line {
  stroke: var(--line);
  stroke-width: 3;
  vector-effect: non-scaling-stroke;
}

.bowtie-col {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 18px;
}

.bowtie-col.center {
  justify-content: center;
}

.slot {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 76px;
  padding: 10px 12px;
  border: 2px dashed var(--line);
  border-radius: 12px;
  background: var(--card);
  color: var(--muted);
  font-size: 0.95rem;
}

.slot.filled {
  border-style: solid;
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--text);
  font-weight: 600;
}

.slot-condition {
  min-height: 110px;
}

.slot.is-correct {
  border-color: var(--good);
  background: var(--good-soft);
}

.bowtie-options {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}

.bowtie-group h3 {
  font-size: 0.95rem;
  margin-top: 0.5em;
}

.bowtie-group .pick {
  color: var(--muted);
  font-weight: 400;
}

.bowtie-group .chip {
  display: block;
  width: 100%;
  border-radius: 12px;
  margin-bottom: 10px;
  font-size: 0.95rem;
}

@media (max-width: 900px) {
  .bowtie-options {
    grid-template-columns: 1fr;
  }

  .bowtie-group .chip {
    display: inline-block;
    width: auto;
    margin-right: 8px;
  }
}

/* ---------- review */

.score-banner {
  border-radius: 12px;
  padding: 12px 16px;
  margin: 4px 0 16px;
  font-size: 1.05rem;
}

.score-banner.good {
  background: var(--good-soft);
  color: var(--good);
}

.score-banner.partial {
  background: var(--partial-soft);
  color: var(--partial);
}

.score-banner.bad {
  background: var(--bad-soft);
  color: var(--bad);
}

.score-banner.blank {
  border: 1px dashed var(--line);
  color: var(--muted);
}

.option.review {
  -webkit-user-select: text;
  user-select: text;
}

.option.review .option-body {
  flex: 1;
}

.option.review.compact {
  min-height: 0;
  padding: 12px 14px;
}

.option.is-correct {
  border-color: var(--good);
  background: var(--good-soft);
}

.option.is-correct .marker {
  border-color: var(--good);
  background: var(--good);
  color: #fff;
}

.option.is-missed {
  border-color: var(--good);
  border-style: dashed;
}

.option.is-wrong {
  border-color: var(--bad);
  background: var(--bad-soft);
}

.option.is-wrong .marker {
  border-color: var(--bad);
  background: var(--bad);
  color: #fff;
}

.tags {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-left: 8px;
  vertical-align: 2px;
}

.tag {
  display: inline-block;
  border-radius: 999px;
  padding: 1px 10px;
  margin-left: 6px;
  font-size: 0.78rem;
  font-weight: 700;
  vertical-align: 1px;
}

td > .tag:first-child {
  margin-left: 0;
}

.tag.good {
  background: var(--good);
  color: #fff;
}

.tag.bad {
  background: var(--bad);
  color: #fff;
}

.tag.missed {
  background: var(--partial-soft);
  color: var(--partial);
}

.rationale {
  color: var(--muted);
  font-size: 0.95rem;
  margin: 6px 0 0;
}

.answer-line {
  font-size: 1.1rem;
}

.answer-line.good strong {
  color: var(--good);
}

.answer-line.bad strong {
  color: var(--bad);
  text-decoration: line-through;
}

.working li,
.common-errors li {
  margin-bottom: 4px;
}

.common-errors li.matched {
  color: var(--bad);
}

.blank .right {
  display: inline-block;
  padding: 0 8px;
  border-radius: 8px;
  background: var(--good-soft);
  color: var(--good);
  font-weight: 700;
  line-height: 1.6;
}

.blank .wrong {
  color: var(--bad);
  margin-right: 6px;
}

.cloze-review .cloze {
  line-height: 2;
}

.list-rationales {
  padding-left: 1.2em;
}

.list-rationales li {
  margin-bottom: 10px;
}

.matrix.review tr.is-wrong > th {
  box-shadow: inset 4px 0 0 var(--bad);
}

.matrix.review tr.is-correct > th {
  box-shadow: inset 4px 0 0 var(--good);
}

.matrix.review td {
  width: auto;
  text-align: left;
}

.explanation {
  margin-top: 22px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.references {
  padding-left: 1.3em;
}

.references li {
  margin-bottom: 8px;
  overflow-wrap: anywhere;
}

.ref-note {
  color: var(--muted);
  font-size: 0.9rem;
}

.review-status {
  margin-top: 18px;
  font-size: 0.85rem;
  color: var(--muted);
}

/* ---------- results */

.score-hero {
  text-align: center;
}

.score-hero .big {
  font-size: 3.4rem;
  font-weight: 800;
  line-height: 1.1;
  margin: 6px 0;
  color: var(--accent);
}

.score-hero .points {
  font-size: 1.2rem;
  font-weight: 600;
}

.score-hero .actions {
  justify-content: center;
}

.categories {
  width: 100%;
  border-collapse: collapse;
}

.categories th,
.categories td {
  padding: 10px 6px;
  border-top: 1px solid var(--line);
  text-align: left;
}

.categories th {
  font-weight: 500;
}

.categories .num {
  white-space: nowrap;
  font-weight: 700;
  width: 1%;
}

.bar-cell {
  width: 32%;
}

.bar {
  height: 10px;
  border-radius: 999px;
  background: var(--line);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: var(--accent);
}

.review-item {
  border-top: 1px solid var(--line);
}

.review-item summary {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 66px;
  padding: 8px 4px;
  cursor: pointer;
  list-style: none;
}

.review-item summary::-webkit-details-marker {
  display: none;
}

.summary-main {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.status-dot {
  flex: 0 0 14px;
  height: 14px;
  border-radius: 50%;
}

.status-dot.good {
  background: var(--good);
}

.status-dot.partial {
  background: var(--partial);
}

.status-dot.bad {
  background: var(--bad);
}

.status-dot.blank {
  border: 2px solid var(--muted);
}

.review-body {
  padding: 8px 0 24px;
}

/* ---------- answer review after an exam or a timed exam */

.review-sets {
  margin: 12px 0 8px;
}

.answer-list {
  margin-top: 8px;
}

.answer-result {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin-bottom: 12px;
}

/* ---------- question navigator */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgb(0 0 0 / 0.35);
  display: grid;
  place-items: center;
  padding: 20px;
}

.sheet {
  width: min(560px, 100%);
  max-height: 85vh;
  overflow: auto;
  background: var(--card);
  border-radius: 18px;
  padding: 22px;
}

.nav-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(58px, 1fr));
  gap: 10px;
  margin: 12px 0;
}

.nav-cell {
  height: 58px;
  border-radius: 12px;
  border: 2px solid var(--line);
  background: var(--card);
  font-weight: 700;
}

.nav-cell.answered {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.nav-cell.good {
  background: var(--good-soft);
  border-color: var(--good);
}

.nav-cell.partial {
  background: var(--partial-soft);
  border-color: var(--partial);
}

.nav-cell.bad {
  background: var(--bad-soft);
  border-color: var(--bad);
}

.nav-cell.current {
  outline: 3px solid var(--text);
  outline-offset: 2px;
}

@media (max-width: 600px) {
  .mode-choices {
    grid-template-columns: 1fr;
  }
}

.search {
  display: block;
  width: 100%;
  min-height: 52px;
  margin: 0 0 12px;
  padding: 10px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  font-size: 1rem;
}

.search:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.list-main .small:not(.muted) {
  display: block;
  margin: 2px 0;
}

/* ---------- question tools: calculator, flag, clock */

.quiz-tools {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.quiz-tools:empty {
  display: none;
}

.btn.tool {
  margin-top: 0;
  padding: 0 16px;
}

.btn.tool[aria-pressed='true'] {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.calculator {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: calc(92px + env(safe-area-inset-bottom));
  z-index: 15;
  width: 300px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 10px 30px rgb(16 24 40 / 0.22);
  padding: 10px 12px 12px;
}

.calculator.left {
  right: auto;
  left: max(16px, env(safe-area-inset-left));
}

.calc-head {
  display: flex;
  align-items: center;
  gap: 4px;
}

.calc-head strong {
  flex: 1;
}

.calc-head .btn {
  min-height: 40px;
  font-size: 0.9rem;
}

.calc-screen {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 6px 12px;
  margin: 4px 0 10px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.calc-pending {
  color: var(--muted);
  font-size: 0.85rem;
  min-height: 1.3em;
}

.calc-display {
  display: block;
  font-size: 1.8rem;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.calc-keys {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.calc-key {
  min-height: 52px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--card);
  font-size: 1.25rem;
  font-weight: 600;
  user-select: none;
  -webkit-user-select: none;
}

.calc-key.fn {
  background: var(--bg);
  font-size: 1.05rem;
}

.calc-key.op {
  color: var(--accent);
  background: var(--accent-soft);
}

.calc-key.eq {
  background: var(--accent);
  color: var(--accent-ink);
}

.calc-key.wide {
  grid-column: 1 / -1;
}

@media (max-width: 520px) {
  .calculator,
  .calculator.left {
    left: 12px;
    right: 12px;
    width: auto;
  }

  .calc-key {
    min-height: 46px;
  }
}

/* ---------- strike-out and flags */

.option-row {
  display: flex;
  align-items: stretch;
  gap: 8px;
  margin-bottom: 12px;
}

.option-row .option {
  flex: 1;
  min-width: 0;
  margin-bottom: 0;
}

.option {
  -webkit-touch-callout: none;
}

.strike-btn {
  flex: 0 0 52px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--muted);
  font-weight: 700;
  font-size: 1.1rem;
  text-decoration: line-through;
}

.strike-btn[aria-pressed='true'] {
  background: var(--bg);
  color: var(--text);
  border-color: var(--muted);
}

.option.struck .option-text {
  text-decoration: line-through;
  text-decoration-thickness: 2px;
}

.option.struck {
  opacity: 0.55;
}

.btn.tool.flag-btn[aria-pressed='true'] {
  border-color: var(--partial);
  background: var(--partial-soft);
  color: var(--partial);
}

.flag-mark {
  color: var(--partial);
  font-weight: 700;
}

.nav-cell.flagged {
  position: relative;
}

.nav-cell.flagged::after {
  content: '⚑';
  position: absolute;
  top: 2px;
  right: 6px;
  font-size: 0.8rem;
  color: var(--partial);
}

.flagged h3 {
  margin-top: 0.5em;
}

/* ---------- timed exam */

.mode-choices {
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}

.exam-clock {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  padding: 0 12px;
  white-space: nowrap;
}

.overlay.solid {
  background: var(--bg);
}

.break-sheet {
  text-align: center;
  border: 1px solid var(--line);
}

.break-clock {
  font-size: 3rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  margin: 0.2em 0 0;
  color: var(--accent);
}

.timed-note {
  align-self: center;
  max-width: 22em;
}

.time-summary {
  font-size: 0.95rem;
}

.time-summary.timed-out strong {
  color: var(--bad);
}

/* ---------- highlight */

:root {
  --hl: #fde68a;
  --hl-ink: #17202b;
}

@media (prefers-color-scheme: dark) {
  :root {
    --hl: #8a6d0b;
    --hl-ink: #fff8e1;
  }
}

.passage {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 18px;
  line-height: 2.1;
}

.passage p:last-child {
  margin-bottom: 0;
}

.hl-span {
  padding: 5px 3px;
  border-radius: 6px;
  border-bottom: 2px dotted var(--muted);
  cursor: pointer;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
  -webkit-user-select: none;
  user-select: none;
}

.hl-span[aria-pressed='true'] {
  background: var(--hl);
  color: var(--hl-ink);
  border-bottom-color: transparent;
}

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.hl-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.hl-table caption {
  text-align: left;
  font-weight: 700;
  padding: 0 0 8px;
}

.hl-table th,
.hl-table td {
  text-align: left;
  vertical-align: top;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}

.hl-table thead th {
  font-size: 0.85rem;
  color: var(--muted);
}

.hl-table tbody tr {
  cursor: pointer;
}

.hl-row-btn {
  border: 0;
  background: none;
  padding: 0;
  font-weight: 600;
  text-align: left;
  min-height: 32px;
}

.hl-table tr.hl-on > * {
  background: var(--hl);
  color: var(--hl-ink);
}

mark.hl-review,
.hl-table tr.hl-review > * {
  background: none;
  color: inherit;
}

mark.hl-review {
  padding: 3px 2px;
  border-radius: 5px;
  border-bottom: 2px dotted var(--line);
}

mark.hl-review.is-correct,
.hl-table tr.hl-review.is-correct > * {
  background: var(--good-soft);
  box-shadow: inset 0 -2px 0 var(--good);
}

mark.hl-review.is-wrong,
.hl-table tr.hl-review.is-wrong > * {
  background: var(--bad-soft);
  text-decoration: line-through;
}

mark.hl-review.is-missed,
.hl-table tr.hl-review.is-missed > * {
  outline: 2px dashed var(--good);
  outline-offset: -2px;
}

.hl-table tr.hl-review {
  cursor: default;
}

/* ---------- cause and effect */

.ce-sentence {
  font-size: 1.1rem;
  line-height: 2.4;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 18px;
}

.ce-slot {
  display: inline-block;
  min-width: 9em;
  min-height: 44px;
  line-height: 1.35;
  padding: 9px 14px;
  margin: 2px 2px;
  border: 2px dashed var(--line);
  border-radius: 10px;
  color: var(--muted);
  text-align: center;
  vertical-align: middle;
  background: var(--bg);
}

.ce-slot.filled {
  border: 2px solid var(--accent);
  background: var(--accent-soft);
  color: var(--text);
  font-weight: 600;
}

.ce-group h3 {
  margin-top: 1em;
}

.ce-group .pick {
  font-weight: 400;
  color: var(--muted);
}

.ce-group .chip {
  margin: 0 8px 8px 0;
}

/* ---------- trend */

.trend-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
  font-variant-numeric: tabular-nums;
}

.trend-table th,
.trend-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.exhibit .trend-table th,
.exhibit .trend-table td {
  width: auto;
  border-top: 0;
}

.trend-table thead th {
  color: var(--muted);
  font-size: 0.8rem;
  white-space: nowrap;
}

.trend-table tbody th {
  font-weight: 600;
  min-width: 7em;
}

.exhibit .table-scroll + h3 {
  margin-top: 1.2em;
}

/* ---------- case studies: the client record */

.case-record .case-label {
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}

.case-intro {
  font-size: 0.95rem;
}

.record-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0 10px;
}

.record-tab {
  position: relative;
  min-height: 44px;
  padding: 6px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg);
  font-size: 0.9rem;
  font-weight: 600;
}

.record-tab[aria-selected='true'] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.new-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  margin-left: 6px;
  border-radius: 50%;
  background: var(--partial);
  vertical-align: middle;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.record-panel {
  font-size: 0.92rem;
}

.record-entries {
  list-style: none;
  margin: 0;
  padding: 0;
}

.record-entries li {
  padding: 8px 0;
  border-top: 1px solid var(--line);
}

.record-entries li:first-child {
  border-top: 0;
}

.record-time {
  margin-right: 8px;
}

.record-entries li.is-new,
.record-table tr.is-new > *,
.record-table td.is-new,
.record-table th.is-new {
  background: var(--partial-soft);
}

.tag.new {
  margin-left: 6px;
  background: var(--partial-soft);
  color: var(--partial);
  border: 1px solid color-mix(in srgb, var(--partial) 40%, transparent);
}

.exhibit .record-table th {
  width: auto;
}

@media (min-width: 1000px) {
  .question.with-exhibit .case-record {
    max-height: calc(100vh - 110px);
    overflow: auto;
  }
}

@media (max-width: 999px) {
  .case-record .record-panel {
    max-height: 42vh;
    overflow: auto;
  }
}

/* ---------- results by category, item type and judgment step */

.breakdown-card .segmented {
  margin: 4px 0 6px;
}

.breakdown-count {
  display: block;
  font-weight: 400;
}

.breakdown th {
  width: 60%;
}

/* ---------- practice mastery */

.mastery .level-strong .bar-fill {
  background: var(--good);
}

.mastery .level-fair .bar-fill {
  background: var(--partial);
}

.mastery .level-weak .bar-fill {
  background: var(--bad);
}

.mastery .level-too-few .bar-fill {
  background: var(--muted);
}

/* ---------- study plan */

.exam-date {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}

.exam-date label {
  font-weight: 600;
}

.exam-date input {
  min-height: 44px;
  padding: 6px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

.study-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin: 12px 0 8px;
}

.study-stat {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.study-stat strong {
  font-size: 1.4rem;
}

.qotd {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.qotd h3 {
  margin-top: 0;
}

.qotd-done.good {
  color: var(--good);
}

.qotd-done.bad {
  color: var(--bad);
}

/* ---------- report a problem, my reports (app/js/report.js) */

.report-link {
  margin: 18px 0 0;
}

.report-sheet {
  width: min(720px, 100%);
  max-height: 90vh;
}

.report-sheet h2 {
  margin-bottom: 2px;
}

.report-kinds {
  border: 0;
  padding: 0;
  margin: 14px 0;
}

.report-kinds legend {
  font-weight: 700;
  margin-bottom: 6px;
}

.report-kind {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 4px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  margin: 6px 0;
}

.report-kind input {
  width: 20px;
  height: 20px;
  accent-color: var(--accent);
}

.report-kind:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.report-dispute,
.report-details {
  margin: 10px 0;
}

.report-dispute h3 {
  margin: 10px 0 2px;
}

.report-answer {
  margin: 8px 0 14px;
  padding: 12px;
  border: 1px dashed var(--line);
  border-radius: 12px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 12px 0;
}

.field-label {
  font-weight: 600;
}

.field input,
.field textarea,
.insist textarea,
.insist input {
  width: 100%;
  min-height: 44px;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

.field textarea {
  resize: vertical;
}

.report-status {
  min-height: 1.4em;
  margin: 8px 0 0;
}

.report-status.bad {
  color: var(--bad);
  font-weight: 600;
}

.turnstile-box:empty {
  display: none;
}

.report-card .report-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.report-card h2 {
  margin: 0;
  font-size: 1.1rem;
}

.status-chip.report-open {
  background: var(--partial-soft);
  color: var(--partial);
}

.status-chip.report-closed {
  background: var(--good-soft);
  color: var(--good);
}

.report-reason {
  white-space: pre-wrap;
}

.report-message {
  border-left: 3px solid var(--line);
  padding: 2px 0 2px 12px;
  margin: 10px 0;
  white-space: pre-wrap;
}

.report-message.admin {
  border-left-color: var(--accent);
}

.report-message p {
  margin: 2px 0;
}

.actions.compact {
  margin-top: 8px;
  padding-bottom: 0;
}

.linkish {
  background: none;
  border: 0;
  padding: 0;
  color: var(--accent);
  text-decoration: underline;
  font: inherit;
}

.held-note {
  margin: 0 0 14px;
}

.status-chip.status-held {
  background: var(--partial-soft);
  color: var(--partial);
}

/* RN or PN, chosen on the home screen */
.exam-switch {
  margin-top: 12px;
}

/* ---------- quick-reference cards (#/cards) */

.list-chevron {
  color: var(--muted);
  font-size: 1.6rem;
  line-height: 1;
}

.cards-link {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 10px 18px;
  margin-bottom: 18px;
}

.ref-section h2 {
  margin-bottom: 0.6em;
}

.ref-text p:last-child,
.ref-list:last-child {
  margin-bottom: 0;
}

.ref-list {
  padding-left: 1.3em;
  margin: 0.5em 0 0.75em;
}

.ref-list li {
  margin-bottom: 6px;
}

.ref-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
  margin: 0.25em 0 0.75em;
}

.ref-table caption {
  text-align: left;
  color: var(--muted);
  font-size: 0.88rem;
  padding: 0 0 8px;
}

.ref-table th,
.ref-table td {
  text-align: left;
  vertical-align: top;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
}

.ref-table thead th {
  color: var(--muted);
  font-size: 0.82rem;
}

.ref-table tbody th {
  font-weight: 600;
  min-width: 6.5em;
}

.ref-card-note {
  color: var(--muted);
  border-left: 3px solid var(--line);
  padding-left: 10px;
  margin: 0.5em 0 0;
}

/* ---------- account and data (#/account) */

.account-form label {
  display: block;
  font-weight: 600;
  margin: 12px 0 6px;
}

.text-input {
  width: 100%;
  max-width: 420px;
  min-height: 50px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
}

.code-input {
  max-width: 220px;
  font-size: 1.4rem;
  letter-spacing: 0.25em;
  font-variant-numeric: tabular-nums;
}

.btn.danger {
  background: var(--bad);
  color: #fff;
}
