/* Sage Gate Academics. The drill screen follows the digital SAT's layout:
   header with timer, passage | question split, question bar, bottom navigation.
   Light theme only, like the real test. */
:root {
  --ink: #1e1e1e;
  --muted: #5b5b5b;
  --line: #c9c9c9;
  --soft: #f2f2f2;
  --page: #ffffff;
  --blue: #3050c8;
  --blue-dark: #233c9d;
  --blue-soft: #e8ecfa;
  --lilac: #b48fe0;
  --red: #c42f43;
  --warn: #7a4a00;
  --warn-soft: #fff4dc;
  --error: #b3261e;
  --header-h: 60px;
  --footer-h: 72px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 17px/1.6 "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  overflow-wrap: anywhere;
}
h1 { font-size: 1.6rem; line-height: 1.25; margin: 0.5rem 0 1rem; }
h2 { font-size: 1.1rem; margin: 0; }
a { color: var(--blue); }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.error { color: var(--error); }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
[hidden] { display: none !important; }

.icon { display: inline-flex; width: 18px; height: 18px; flex: none; }
.icon svg { width: 100%; height: 100%; }

/* ---------- buttons ---------- */
button { font: inherit; color: inherit; }
.button {
  font: inherit;
  font-weight: 600;
  min-height: 44px;
  padding: 0.45rem 1.2rem;
  border-radius: 8px;
  border: 1.5px solid var(--ink);
  background: var(--page);
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}
.button.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.button.primary:hover:not(:disabled) { background: var(--blue-dark); border-color: var(--blue-dark); }
.button.outline { border-color: var(--blue); color: var(--blue); border-radius: 999px; }
.button.round { border-radius: 999px; min-width: 6rem; }
.button.big { width: 100%; min-height: 52px; margin-top: 0.5rem; }
.button:disabled { opacity: 0.35; cursor: default; }
.text-button {
  border: 0;
  background: none;
  color: var(--blue);
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  min-height: 36px;
}
.icon-button {
  border: 0;
  background: none;
  cursor: pointer;
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}
.icon-button:hover { background: var(--soft); }

/* ---------- sign-in, my drills, start and finish pages ---------- */
.narrow { max-width: 34rem; margin: 0 auto; padding: 1.5rem 16px 3rem; }
.card { border: 1px solid var(--line); border-radius: 10px; padding: 1rem; background: var(--page); }
.form { display: grid; gap: 1rem; }
.form label { display: grid; gap: 0.35rem; font-weight: 600; }
.form input {
  font: inherit;
  font-weight: 400;
  padding: 0.65rem 0.75rem;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  width: 100%;
}
.form input:focus { border-color: var(--blue); outline: none; }
.site-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 16px;
  border-bottom: 1px solid var(--line);
}
.site-bar .title { font-weight: 700; }
.drill-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.75rem; }
.drill-link {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  color: var(--ink);
  text-decoration: none;
}
.drill-link:hover { border-color: var(--blue); }
.drill-name { font-weight: 600; display: block; }
.drill-link.overdue { border-color: var(--red); }
.due { display: block; font-size: 0.85rem; color: var(--muted); }
.due.soon { color: var(--warn); font-weight: 600; }
.due.bad { font-weight: 600; }
.status { color: var(--muted); font-size: 0.9rem; text-align: right; }
.parts { padding-left: 1.25rem; }
.results-link { display: inline-block; margin: 0.35rem 0 0 1rem; font-weight: 600; font-size: 0.9rem; }

/* Student dashboard */
.wide-home { max-width: 46rem; }
.drill-link { border-left-width: 6px; }
.drill-link.tone-overdue { border-left-color: var(--red); }
.drill-link.tone-soon { border-left-color: #e08a00; }
.drill-link.tone-later { border-left-color: #9a9a9a; }
.drill-link.tone-none { border-left-color: var(--line); }
.drill-link.tone-done { border-left-color: #2e8b57; }
.drill-main { min-width: 0; flex: 1; }
.drill-side { display: flex; flex-direction: column; align-items: flex-end; gap: 0.25rem; }
.countdown {
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  background: var(--soft);
  white-space: nowrap;
}
.tone-overdue .countdown { background: #fdecec; color: var(--red); }
.tone-soon .countdown { background: var(--warn-soft); color: var(--warn); }
.progress {
  display: block;
  height: 8px;
  margin-top: 0.45rem;
  max-width: 16rem;
  border-radius: 999px;
  background: var(--soft);
  overflow: hidden;
}
.progress-fill { display: block; height: 100%; background: #e0a800; border-radius: 999px; }

.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.6rem; margin-top: 1rem; }
.tile {
  display: flex;
  flex-direction: column;
  padding: 0.75rem 0.9rem;
  border-radius: 10px;
  border: 1px solid transparent;
}
.tile-number { font-size: 1.9rem; font-weight: 700; line-height: 1.1; }
.tile-label { font-size: 0.85rem; font-weight: 600; }
.tile-overdue { background: #fdecec; color: var(--red); }
.tile-overdue.zero { background: var(--soft); color: var(--muted); }
.tile-week { background: var(--blue-soft); color: var(--blue-dark); }
.tile-progress { background: var(--warn-soft); color: var(--warn); }
.tile-done { background: #e6f4ec; color: #1f6b41; }

.batches { display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); gap: 0.6rem; }
.batch {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0.7rem;
  border: 1px solid var(--line);
  border-left-width: 6px;
  border-radius: 10px;
  background: var(--page);
}
.batch.tone-soon { border-left-color: #e08a00; }
.batch.tone-later { border-left-color: #9a9a9a; }
.batch-head { display: flex; justify-content: space-between; align-items: center; gap: 0.4rem; font-size: 0.9rem; }
.batch-count { font-size: 0.8rem; color: var(--muted); }
.batch .progress { margin-top: 0; max-width: none; }
.batch-bar .progress-fill { background: #2e8b57; }
.overdue-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.6rem;
  margin-top: 1.2rem;
  padding: 0.55rem 0.7rem;
  border: 2px solid var(--red);
  border-radius: 10px;
  background: #fdecec;
}
.overdue-strip .day-name { color: var(--red); }
.day-name { font-weight: 700; }
.day-chip {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.3;
  padding: 0.3rem 0.45rem;
  border-radius: 6px;
  background: var(--blue-soft);
  color: var(--blue-dark);
  text-decoration: none;
  overflow-wrap: anywhere;
}
.day-chip:hover { background: var(--blue); color: #fff; }
.day-chip.late { background: var(--red); color: #fff; }
.day-chip.finished { background: #e6f4ec; color: #1f6b41; }

@media (max-width: 560px) {
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .drill-link { flex-wrap: wrap; gap: 0.5rem; }
  .drill-main { flex-basis: 100%; }
  .drill-side { flex-direction: row; flex-wrap: wrap; align-items: center; }
  .status { text-align: left; }
}

.preview-banner {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem;
  padding: 0.5rem 16px; background: var(--warn-soft); color: var(--warn); border-bottom: 2px solid #e0a84a;
}
.preview-banner form { margin: 0; }

/* ---------- results and retake ---------- */
.results-page { max-width: 48rem; margin: 0 auto; padding: 1.5rem 16px 3rem; }
.try-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); gap: 0 1rem; }
.retake-box { border: 1px solid var(--line); border-radius: 10px; padding: 1rem; margin: 0 0 1.25rem; }
.retake-box h2 { margin-bottom: 0.4rem; }
.retake-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.75rem; }

/* ---------- tutor pages ---------- */
.wide { max-width: 76rem; margin: 0 auto; padding: 1.25rem 16px 3rem; }
.bar-links { display: flex; align-items: center; gap: 0.75rem; }
.bar-links a { font-weight: 600; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.filter { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.filter label { font-weight: 600; }
.filter select {
  font: inherit;
  min-height: 44px;
  padding: 0.3rem 0.5rem;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  background: var(--page);
  max-width: 100%;
}
.section-title { font-size: 1.15rem; margin: 2rem 0 0.6rem; }
.plain-list { padding-left: 1.25rem; }
.badge {
  display: inline-block;
  padding: 0.05rem 0.5rem;
  border-radius: 999px;
  background: var(--warn-soft);
  color: var(--warn);
  font-size: 0.8rem;
  font-weight: 600;
}

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; }
table.data { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
table.data th, table.data td { padding: 0.55rem 0.75rem; text-align: left; vertical-align: top; }
table.data td { overflow-wrap: normal; }
.qtable td.skill { min-width: 9rem; }
table.data thead th {
  background: var(--soft);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
  white-space: nowrap;
}
table.data tbody tr + tr td { border-top: 1px solid #e6e6e6; }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.data .center { text-align: center; white-space: nowrap; }
table.data .over { color: var(--red); font-weight: 600; }
.qtable tr.wrong td:first-child { box-shadow: inset 4px 0 0 var(--red); }
.qtable tr.right td:first-child { box-shadow: inset 4px 0 0 #2e8b57; }
.qid { display: block; font-weight: 700; font-size: 0.8rem; }
.preview { display: block; color: var(--muted); min-width: 14rem; }
.ok { color: #22754a; font-weight: 700; }
.bad { color: var(--red); font-weight: 700; }
.flag { color: var(--red); }

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: 0.75rem;
  margin-top: 1rem;
}
.stat { border: 1px solid var(--line); border-top: 4px solid var(--lilac); border-radius: 10px; padding: 0.75rem 1rem; }
.stat-label { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); }
.stat-value { font-size: 1.7rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.stat-value.over { color: var(--red); }
.stat-sub { color: var(--muted); font-size: 0.85rem; }

.time-head { min-width: 14rem; }
.time-cell { display: flex; align-items: center; gap: 0.6rem; min-width: 14rem; }
.bar-track { position: relative; flex: 1; height: 14px; background: var(--soft); border-radius: 3px; }
.bar { height: 100%; background: var(--blue); border-radius: 3px; min-width: 2px; }
.bar.slow { background: #e0922b; }
.bar-target { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--ink); }
.time-value { font-variant-numeric: tabular-nums; font-weight: 700; min-width: 3.2rem; text-align: right; }
.key-line { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem 0.6rem; }
.key { display: inline-block; width: 18px; height: 10px; border-radius: 2px; background: var(--blue); }
.key.slow { background: #e0922b; }
.key-target { display: inline-block; width: 2px; height: 14px; background: var(--ink); }

.tag {
  display: inline-block;
  margin-left: 0.3rem;
  padding: 0 0.4rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
}
.bad-tag { background: #fdecec; color: var(--red); }
.ok-tag { background: #e7f5ec; color: #22754a; }
table.data td.changed { color: var(--warn); font-weight: 700; }
.activity summary { cursor: pointer; list-style: none; }
.activity summary::-webkit-details-marker { display: none; }
.activity summary h2::before { content: "▸ "; }
.activity[open] summary h2::before { content: "▾ "; }
.activity summary h2 { display: inline-block; }
tr.event-a td:last-child { font-weight: 600; }
tr.event-f td:last-child { color: var(--red); }
.head-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.head-actions form { margin: 0; }
.hint { color: var(--muted); font-size: 0.85rem; font-weight: 400; }
.admin-form { max-width: 34rem; }
.success, .error-box {
  border-radius: 8px;
  padding: 0.65rem 0.9rem;
  margin: 0.75rem 0;
}
.success { background: #e7f5ec; color: #1d5f3a; }
.success a { margin-left: 0.4rem; font-weight: 600; }
.error-box { background: #fdecec; color: var(--error); }
.password-box {
  border: 2px solid var(--lilac);
  border-radius: 10px;
  padding: 0.75rem 1rem;
  margin: 0.75rem 0;
  max-width: 34rem;
}
.password-box code {
  display: inline-block;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  margin: 0.25rem 0;
  user-select: all;
}
.row-actions { white-space: nowrap; }
.text-input.date-input { width: auto; min-height: 36px; padding: 0.15rem 0.4rem; font-size: 0.9rem; }
.due-form { display: flex; align-items: center; gap: 0.1rem; flex-wrap: nowrap; margin: 0; }
.due-cell { white-space: nowrap; }
.soon-text { color: var(--warn); font-weight: 600; }
.overdue-row td:first-child { box-shadow: inset 4px 0 0 var(--red); }
.row-actions form { display: inline; margin-left: 0.5rem; }
.text-button.danger { color: var(--error); }
tr.cancelled td { color: var(--muted); text-decoration: line-through; }
tr.cancelled td:last-child { text-decoration: none; }

.sheet-status p { margin: 0.25rem 0; }
.report {
  white-space: pre-wrap;
  background: var(--soft);
  border-radius: 8px;
  padding: 0.75rem;
  font-size: 0.8rem;
  max-height: 20rem;
  overflow: auto;
}
.assign-form { display: grid; gap: 1rem; margin-top: 1rem; }
.assign-form fieldset { margin: 0; }
.assign-form .card > h2, .card-head h2 { font-size: 1.05rem; margin-bottom: 0.6rem; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 0.5rem; }
.timing-cell { display: grid; gap: 0.35rem; min-width: 15rem; }
.timing-inputs { display: flex; flex-wrap: wrap; gap: 0.35rem 0.75rem; }
.part-list { margin: 0.25rem 0 0; padding-left: 1.1rem; }
.chosen-table tr.all-row td { background: var(--blue-soft); }
.chosen-table td { vertical-align: top; }
.assign-form legend { font-weight: 700; font-size: 1.05rem; padding: 0 0.35rem; }
.group-title { font-size: 0.95rem; margin: 0.5rem 0 0.4rem; }
.pick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); gap: 0.4rem; }
.pick-list { display: grid; gap: 0.4rem; }
.pick {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  line-height: 1.4;
}
.pick:hover { border-color: var(--blue); }
.pick:has(input:checked) { border-color: var(--blue); background: var(--blue-soft); }
.pick > input { margin-top: 0.2rem; width: 18px; height: 18px; flex: none; accent-color: var(--blue); }
.inline-input {
  font: inherit;
  width: 5rem;
  padding: 0.15rem 0.4rem;
  border: 1.5px solid var(--line);
  border-radius: 6px;
  margin: 0 0.25rem;
}
.blocked { margin: 0.5rem 0 0.75rem; }
.blocked summary { cursor: pointer; color: var(--muted); font-weight: 600; }
.blocked-item { margin: 0.5rem 0 0 1rem; font-size: 0.9rem; }
.blocked-item ul { margin: 0.2rem 0; color: var(--muted); }

/* ---------- drill builder ---------- */
.builder-head { display: grid; gap: 0.75rem; margin-bottom: 1rem; }
.field { display: grid; gap: 0.3rem; font-weight: 600; }
.text-input, .builder-select {
  font: inherit;
  font-weight: 400;
  padding: 0.45rem 0.6rem;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  background: var(--page);
  min-height: 42px;
  max-width: 100%;
}
.text-input:focus, .builder-select:focus { border-color: var(--blue); outline: none; }
.inline-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; font-weight: 400; }
.check { display: inline-flex; align-items: center; gap: 0.35rem; font-weight: 400; }
.check input { width: 18px; height: 18px; accent-color: var(--blue); }
.builder-grid { display: grid; gap: 1rem; }
@media (min-width: 1000px) {
  .builder-grid { grid-template-columns: 1fr 1fr; align-items: start; }
  .picker { position: sticky; top: 1rem; max-height: calc(100vh - 2rem); overflow-y: auto; }
}
.parts-list { display: grid; gap: 0.75rem; justify-items: start; }
.parts-list > .card { width: 100%; }
.part-card.target { border: 2px solid var(--blue); }
.part-top { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.5rem; }
.part-number { font-weight: 700; white-space: nowrap; }
.part-name { flex: 1; min-width: 0; }
.row-buttons { display: flex; gap: 0.25rem; flex: none; }
.icon-text {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--page);
  cursor: pointer;
  font-weight: 700;
}
.icon-text:disabled { opacity: 0.3; cursor: default; }
.icon-text.danger { color: var(--error); }
.built-list { margin: 0.5rem 0; padding-left: 1.5rem; display: grid; gap: 0.35rem; }
.built-q { display: flex; justify-content: space-between; align-items: flex-start; gap: 0.5rem; }
.built-q-text { min-width: 0; }
.built-q.not-ready { background: #fdecec; border-radius: 6px; padding: 0.25rem; }
.target-note { color: var(--blue); font-weight: 600; font-size: 0.85rem; margin: 0.5rem 0 0; }
.small-button { min-height: 34px; padding: 0.2rem 0.8rem; font-size: 0.85rem; }
.small-select { font-size: 0.9rem; }
.picker .section-title { margin-top: 0; }
.filter-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin: 0.5rem 0; }
.filter-row .search { flex: 1; min-width: 10rem; }
.skill-tag {
  display: inline-block;
  margin: 0.1rem 0 0.1rem 0.4rem;
  padding: 0 0.45rem;
  border: 1.5px solid;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
}
/* Skill tag levels: grey basic, blue critical, purple advanced (same as the sheet). */
.level-basic { background: #efefef; border-color: #9a9a9a; color: #4a4a4a; }
.level-critical { background: #e8eefc; border-color: #7f9be6; color: #1a3fa8; }
.level-advanced { background: #f1e9fb; border-color: #b48fe0; color: #5f2296; }
.level-none { background: #fff; border-color: #c9c9c9; color: #5b5b5b; border-style: dashed; }
.random-row { background: var(--soft); border-radius: 8px; padding: 0.4rem 0.6rem; font-size: 0.9rem; }
.results { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.4rem; }
.result { display: flex; gap: 0.6rem; align-items: flex-start; border-top: 1px solid #eee; padding-top: 0.4rem; }
.result.not-ready { opacity: 0.75; }
.save-bar {
  position: sticky;
  bottom: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  margin-top: 1rem;
  padding: 0.75rem 0;
  background: var(--page);
  border-top: 1px solid var(--line);
}
.save-bar #save-result { flex-basis: 100%; }
.save-bar #save-result:empty { display: none; }
.save-bar .success, .save-bar .error-box { margin: 0; }
.save-bar ul { margin: 0.3rem 0 0; }

/* ---------- drill: header ---------- */
.test-header {
  position: sticky;
  top: 0;
  z-index: 20;
  height: var(--header-h);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 0.75rem;
  padding: 0 16px;
  background: var(--page);
}
.test-header::after, .test-footer::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 3px;
  background: repeating-linear-gradient(90deg,
    #1e1e1e 0 22px, transparent 22px 28px,
    var(--lilac) 28px 50px, transparent 50px 56px);
}
.test-header::after { bottom: 0; }
.test-heading { min-width: 0; line-height: 1.25; }
.test-brand {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #7a55b8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.test-title {
  font-weight: 700;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.timer { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.clock { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 1.15rem; line-height: 1.1; }
.clock.over { color: var(--red); }
.pill-button {
  border: 1.5px solid var(--ink);
  background: var(--page);
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0 0.7rem;
  min-height: 22px;
  cursor: pointer;
}
.header-right { justify-self: end; display: flex; align-items: center; gap: 0.4rem; }
.exit-link { font-size: 0.85rem; font-weight: 600; white-space: nowrap; }

.save-status:not(:empty), .notice {
  margin: 0.6rem 16px 0;
  padding: 0.55rem 0.8rem;
  border-radius: 8px;
  background: var(--warn-soft);
  color: var(--warn);
  font-size: 0.95rem;
}
.notice { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; }

/* ---------- drill: body ---------- */
.test-body { padding-bottom: calc(var(--footer-h) + 1.5rem); }
.test-body.single { max-width: 46rem; margin: 0 auto; padding-left: 16px; padding-right: 16px; }
.test-body.split .passage-pane,
.test-body.split .question-pane { padding: 1.25rem 16px; }
.passage-pane { border-bottom: 3px solid var(--soft); }
.passage { white-space: pre-wrap; font-size: 1.02rem; line-height: 1.7; }
.question-image { display: block; max-width: 100%; height: auto; margin: 0 auto 1rem; }

@media (min-width: 900px) {
  .test-body.split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    height: calc(100vh - var(--header-h) - var(--footer-h));
    padding-bottom: 0;
  }
  .test-body.split .passage-pane,
  .test-body.split .question-pane {
    overflow-y: auto;
    padding: 2rem 2.5rem;
  }
  .test-body.split .passage-pane { border-bottom: 0; border-right: 4px solid var(--soft); }
  .test-body.single { padding-top: 1.5rem; }
}

.question-pane { padding-top: 1.25rem; }
.question-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--soft);
  border-bottom: 2px dashed #9a9a9a;
  padding: 0 0.5rem 0 0;
  margin-bottom: 1.1rem;
  min-height: 40px;
}
.question-number {
  background: var(--ink);
  color: #fff;
  font-weight: 700;
  min-width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 0.5rem;
}
.mark-button {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border: 0;
  background: none;
  cursor: pointer;
  font-size: 0.95rem;
  padding: 0.3rem 0.2rem;
  min-height: 40px;
}
.mark-button.on { font-weight: 600; }
.mark-button.on .icon { color: var(--red); }
.abc-button {
  margin-left: auto;
  border: 1.5px solid var(--ink);
  border-radius: 6px;
  background: var(--page);
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 0.1rem 0.45rem;
  min-height: 30px;
}
.abc-button span { text-decoration: line-through; text-decoration-thickness: 2px; }
.abc-button.on { background: var(--blue); border-color: var(--blue); color: #fff; }

.stem { white-space: pre-wrap; margin-bottom: 1.2rem; }
.math .katex { font-size: 1.08em; }

.choices { display: grid; gap: 0.75rem; }
.choice-row { display: flex; align-items: center; gap: 0.6rem; }
.choice {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 0.9rem;
  text-align: left;
  min-height: 52px;
  padding: 0.55rem 0.9rem;
  border: 1.5px solid var(--ink);
  border-radius: 10px;
  background: var(--page);
  cursor: pointer;
  position: relative;
}
.choice:hover { background: #fafbff; }
.choice .letter {
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1.5px solid var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
}
.choice-text { white-space: pre-wrap; min-width: 0; }
.choice.chosen { border: 3px solid var(--blue); padding: calc(0.55rem - 1.5px) calc(0.9rem - 1.5px); }
.choice.chosen .letter { background: var(--blue); border-color: var(--blue); color: #fff; }
.choice-row.crossed .choice { opacity: 0.55; }
.choice-row.crossed .choice::after {
  content: "";
  position: absolute;
  left: -6px;
  right: -6px;
  top: 50%;
  border-top: 2px solid var(--ink);
}
.strike-button {
  flex: none;
  position: relative;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1.5px solid var(--ink);
  background: var(--page);
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
}
.strike-button::after {
  content: "";
  position: absolute;
  left: -4px;
  right: -4px;
  top: 50%;
  border-top: 2px solid var(--ink);
}
.undo-button {
  flex: none;
  min-width: 44px;
  border: 0;
  background: none;
  font-weight: 700;
  font-size: 0.85rem;
  text-decoration: underline;
  cursor: pointer;
}

/* Highlighter */
.it { font-style: italic; }
mark, .hl { color: inherit; border-radius: 2px; padding: 0 1px; }
mark, .hl-yellow { background: #fbe58a; }
.hl-blue { background: #bfe3fa; }
.hl-pink { background: #f9c8e2; }
.hl-none { background: transparent; }
.u-solid { text-decoration: underline; text-decoration-thickness: 2px; }
.u-dashed { text-decoration: underline dashed; text-decoration-thickness: 2px; }
.u-dotted { text-decoration: underline dotted; text-decoration-thickness: 3px; }
.u-none { text-decoration: none; }
.passage mark.hl { cursor: pointer; }

/* The bar that appears when passage text is selected, or a mark is clicked. */
.hl-pop, .hl-menu {
  position: fixed;
  z-index: 35;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--page);
  box-shadow: 0 4px 14px rgb(0 0 0 / 0.25);
}
.hl-menu { flex-direction: column; border-radius: 10px; padding: 0.25rem; gap: 0.15rem; }
.hl-pop .swatch, .hl-pop .hl-tool, .hl-menu button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  min-height: 36px;
  border: 1.5px solid transparent;
  border-radius: 999px;
  background: none;
  color: var(--ink);
  font-weight: 700;
  cursor: pointer;
}
.hl-pop .swatch { border-color: var(--line); }
.hl-pop .swatch-yellow { background: #fbe58a; }
.hl-pop .swatch-blue { background: #bfe3fa; }
.hl-pop .swatch-pink { background: #f9c8e2; }
.hl-pop .swatch.on, .hl-pop .hl-tool.on { border-color: var(--ink); border-width: 2px; }
.hl-pop .hl-tool:hover, .hl-menu button:hover { background: var(--soft); }
.hl-pop .danger { color: var(--red); }
.hl-pop .icon.tiny { width: 12px; height: 12px; }
.hl-menu { border-radius: 10px; }
.hl-menu .menu-none { font-size: 0.85rem; font-weight: 600; }
.u-sample { font-size: 0.95rem; line-height: 1.1; }

.highlight-list { display: grid; gap: 0.75rem; }
.passage-copy { white-space: pre-wrap; margin: 0.4rem 0 0; line-height: 1.6; }

/* Grid-in answers */
.grid-answer { display: grid; gap: 0.6rem; justify-items: start; }
.grid-input {
  font: inherit;
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  width: 9ch;
  padding: 0.4rem 0.6rem;
  border: 1.5px solid var(--ink);
  border-radius: 8px;
  font-variant-numeric: tabular-nums;
}
.grid-input:focus { outline: 3px solid var(--blue); outline-offset: 1px; }
.preview-line { display: flex; align-items: center; gap: 0.4rem; min-height: 2.5rem; }
.preview-label { font-weight: 600; }
.grid-preview .katex { font-size: 1.2em; }
.grid-preview .incomplete { color: var(--muted); font-size: 0.9rem; white-space: pre; }
.directions { font-size: 0.95rem; }
.directions summary { font-weight: 700; cursor: pointer; margin-bottom: 0.5rem; }
.directions ul { padding-left: 1.2rem; margin: 0.5rem 0 1rem; }
.directions li { margin: 0.25rem 0; }
.examples { border-collapse: collapse; width: 100%; font-size: 0.88rem; }
.examples th, .examples td { border: 1px solid var(--line); padding: 0.35rem 0.5rem; text-align: left; vertical-align: top; }
.examples th { background: var(--soft); }

/* ---------- drill: footer ---------- */
.test-footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  min-height: var(--footer-h);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 16px calc(0.5rem + env(safe-area-inset-bottom));
  background: var(--page);
}
.test-footer::before { top: 0; }
.student-name {
  font-weight: 700;
  font-size: 0.9rem;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.question-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--ink);
  color: #fff;
  border: 0;
  border-radius: 8px;
  padding: 0.4rem 0.8rem;
  min-height: 40px;
  font-weight: 700;
  font-size: 0.9rem;
  white-space: nowrap;
  cursor: pointer;
}
.footer-buttons { justify-self: end; display: flex; gap: 0.5rem; }
.footer-buttons .button.round { min-width: 0; padding: 0.4rem 1.1rem; }

@media (max-width: 520px) {
  .test-footer { grid-template-columns: auto 1fr; }
  .student-name { display: none; }
  .question-pill { justify-self: start; }
  /* Room is tight: keep the math tools as icons, drop the Save & Exit link. */
  .test-header { grid-template-columns: minmax(0, 1fr) auto auto; gap: 0.3rem; }
  .test-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .header-right .exit-link { display: none; }
  .math-tools { margin-right: 0; }
  .tool-label { display: none; }           /* icons only; the icon is a span too */
  .tool-button { padding: 0.35rem 0.45rem; }
}

/* ---------- question map ---------- */
.legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.4rem 1.4rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.85rem;
}
.legend span { display: inline-flex; align-items: center; gap: 0.35rem; }
.legend-box { display: inline-block; width: 16px; height: 16px; border: 1.5px dashed var(--ink); }
.legend-flag, .cell-flag { color: var(--red); }
.nav-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(42px, 1fr));
  gap: 1.1rem 0.6rem;
  padding: 1.2rem 0.2rem 0.4rem;
}
.nav-cell {
  position: relative;
  height: 42px;
  border: 1.5px dashed var(--ink);
  background: var(--page);
  color: var(--blue);
  font-weight: 700;
  cursor: pointer;
  padding: 0;
}
.nav-cell:hover:not(:disabled) { background: var(--blue-soft); }
.nav-cell.answered { background: var(--blue); border: 1.5px solid var(--blue); color: #fff; }
.nav-cell:disabled { cursor: default; }
.nav-cell.small { width: 38px; height: 38px; }
.cell-pin {
  position: absolute;
  top: -15px;
  left: 50%;
  transform: translateX(-50%);
  width: 16px;
  height: 16px;
  color: var(--ink);
}
.cell-flag {
  position: absolute;
  top: -7px;
  right: -7px;
  width: 16px;
  height: 16px;
  filter: drop-shadow(0 0 1px #fff);
}

.popover {
  position: fixed;
  z-index: 30;
  bottom: calc(var(--footer-h) + 10px);
  left: 50%;
  transform: translateX(-50%);
  width: min(560px, calc(100vw - 24px));
  max-height: calc(100vh - var(--header-h) - var(--footer-h) - 30px);
  overflow-y: auto;
  background: var(--page);
  border-radius: 12px;
  padding: 1rem 1.25rem 1.25rem;
  box-shadow: 0 6px 30px rgb(0 0 0 / 0.25);
}
.popover-head { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; }
.popover-head h2 { flex: 1; text-align: center; }
.popover-foot { display: flex; justify-content: center; margin-top: 1rem; }

/* ---------- review page ---------- */
.test-body.review {
  max-width: 48rem;
  margin: 0 auto;
  padding: 1.5rem 16px calc(var(--footer-h) + 1.5rem);
  text-align: center;
}
.test-body.review > p { max-width: 36rem; margin: 0 auto 1.25rem; }
.review-card {
  text-align: left;
  border-radius: 12px;
  padding: 1rem 1.25rem 1.5rem;
  box-shadow: 0 2px 16px rgb(0 0 0 / 0.14);
}
.review-head h2 { text-align: center; }

/* ---------- after submitting ---------- */
.result-card {
  text-align: center;
  border-radius: 12px;
  padding: 1.5rem 1rem;
  margin: 1rem 0 1.25rem;
  box-shadow: 0 2px 16px rgb(0 0 0 / 0.14);
  border-top: 5px solid var(--lilac);
}
.result-percent { font-size: 3rem; font-weight: 800; line-height: 1.1; color: var(--blue); }
.result-score { font-size: 1.15rem; font-weight: 600; margin-top: 0.25rem; }
.result-time { color: var(--muted); margin-top: 0.5rem; font-variant-numeric: tabular-nums; }
.result-time.over { color: var(--red); }

/* ---------- math tools: calculator link and reference panel ---------- */
.math-tools { display: inline-flex; flex: none; gap: 0.4rem; margin-right: 0.8rem; }
.tool-button {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
  padding: 0.15rem 0.5rem;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--ink);
  font-size: 0.7rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
.tool-button:hover { background: var(--soft); }
.tool-button.on { background: var(--blue-soft); color: var(--blue-dark); }

.ref-panel {
  position: fixed;
  top: var(--header-h);
  right: 0;
  width: min(23rem, 100%);
  height: calc(100vh - var(--header-h) - var(--footer-h));
  z-index: 25;
  display: flex;
  flex-direction: column;
  background: var(--page);
  border-left: 1px solid var(--line);
  box-shadow: -6px 0 18px rgb(0 0 0 / 0.12);
}
.ref-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.6rem 0.9rem;
  border-bottom: 1px solid var(--line);
}
.ref-head h2 { font-size: 1.05rem; }
.ref-body { overflow-y: auto; padding: 0.9rem; }
.ref-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr)); gap: 0.9rem; }
.ref-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  text-align: center;
}
.ref-wide { grid-column: 1 / -1; }
.ref-card .figure { width: 100%; max-width: 7rem; height: 5rem; color: var(--ink); }
.figure-label { font-size: 13px; font-style: italic; fill: currentColor; }
.figure-small { font-size: 10px; fill: currentColor; }
.ref-facts { margin: 1.2rem 0 0; padding-left: 1.1rem; font-size: 0.85rem; line-height: 1.5; }
.ref-facts li + li { margin-top: 0.4rem; }

@media (max-width: 700px) {
  .ref-panel { width: 100%; }
}

/* ---------- dialogs ---------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgb(0 0 0 / 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.dialog {
  width: 100%;
  max-width: 30rem;
  max-height: 85vh;
  overflow-y: auto;
  background: var(--page);
  border-radius: 12px;
  padding: 1.25rem;
}
.dialog h2 { font-size: 1.25rem; margin-bottom: 0.5rem; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 0.5rem; flex-wrap: wrap; margin-top: 1rem; }
.jump { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin: 0.6rem 0; }
.jump-label { font-weight: 600; margin-right: 0.25rem; }
.jump-number { font-variant-numeric: tabular-nums; font-weight: 700; }

/* ---------- tutor area: backup status ---------- */
.backup-ok { font-size: 0.85rem; white-space: nowrap; }
.backup-alert {
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center;
  gap: 0.5rem 1rem;
  margin: 0.6rem 16px 0;
  padding: 0.6rem 0.9rem;
  border-radius: 8px;
  border: 1px solid var(--error);
  background: #fdecea;
  color: var(--error);
}
.backup-alert a { color: var(--error); font-weight: 700; white-space: nowrap; }
