/* Study HQ: "exam answer booklet".
   One bold element: the margin, where the examiner marks go. Everything else stays quiet. */

:root {
  --paper: #F5F7FA;
  --surface: #FFFFFF;
  --ink: #1A2340;
  --ink-2: #3B4563;
  --quiet: #6B7280;
  --line: #D6DEE9;
  --margin: #D9475A;
  --green: #0E7A5C;
  --green-wash: #E3F2EC;
  --hl: #FFE35A;
  --hl-ink: #1A2340;
  --error: #B42335;
  --error-wash: #FCEBED;
  --focus: #1A2340;

  --ui: "Bricolage Grotesque", ui-sans-serif, system-ui, sans-serif;
  --read: "Literata", Georgia, "Times New Roman", serif;
  --hand: "Kalam", "Comic Sans MS", cursive;

  /* Type scale: 1.2 steps from a 17px reading size */
  --t-xs: 0.8125rem;  /* 13 */
  --t-sm: 0.9375rem;  /* 15 */
  --t-md: 1.0625rem;  /* 17 */
  --t-lg: 1.3125rem;  /* 21 */
  --t-xl: 1.625rem;   /* 26 */
  --t-2xl: 2.0625rem; /* 33 */

  --lh: 2rem;          /* ruled line pitch */
  --mw: 5rem;          /* booklet margin width (mobile) */
  --gutter: 16px;
  --measure: 68ch;
  --radius: 6px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #121826;
    --surface: #182033;
    --ink: #E7EBF3;
    --ink-2: #BAC3D6;
    --quiet: #8F98AB;
    --line: #27314A;
    --margin: #F07280;
    --green: #4CC9A0;
    --green-wash: #14322B;
    --hl: #FFE35A;
    --hl-ink: #1A2340;
    --error: #FF8F9B;
    --error-wash: #3A1820;
    --focus: #FFE35A;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #121826;
  --surface: #182033;
  --ink: #E7EBF3;
  --ink-2: #BAC3D6;
  --quiet: #8F98AB;
  --line: #27314A;
  --margin: #F07280;
  --green: #4CC9A0;
  --green-wash: #14322B;
  --hl: #FFE35A;
  --hl-ink: #1A2340;
  --error: #FF8F9B;
  --error-wash: #3A1820;
  --focus: #FFE35A;
  color-scheme: dark;
}

@media (min-width: 720px) {
  :root { --mw: 7.5rem; }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--ui);
  font-size: var(--t-md);
  line-height: 1.5;
  overflow-x: hidden;
  padding-bottom: calc(64px + env(safe-area-inset-bottom));
}
@media (min-width: 900px) { body { padding-bottom: 0; } }

h1, h2, h3 { font-family: var(--ui); line-height: 1.2; margin: 0; letter-spacing: -0.01em; }
h1 { font-size: var(--t-2xl); font-weight: 700; }
h2 { font-size: var(--t-lg); font-weight: 600; }
h3 { font-size: var(--t-md); font-weight: 600; }
p { margin: 0 0 0.75em; }
a { color: inherit; text-underline-offset: 3px; }
button, input, select, textarea { font: inherit; color: inherit; }

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

.skip {
  position: absolute; left: 8px; top: -60px; z-index: 50;
  background: var(--ink); color: var(--paper); padding: 8px 12px; border-radius: var(--radius);
}
.skip:focus { top: 8px; }
.vh { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.boot { padding: 2rem var(--gutter); color: var(--quiet); }

/* ---------- top bar + tabs ---------- */
.top {
  display: flex; align-items: center; gap: 12px;
  padding: 10px var(--gutter);
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: var(--t-md); text-decoration: none; }
.brand-mark { width: 22px; height: 22px; }
.top-nav { display: none; gap: 4px; margin-left: 16px; }
.top-nav a, .tabs a {
  text-decoration: none; color: var(--ink-2); font-weight: 500;
}
.top-nav a { padding: 6px 10px; border-radius: var(--radius); }
.top-nav a[aria-current="page"] { color: var(--ink); box-shadow: inset 0 -2px 0 var(--margin); border-radius: 0; }
.top-tools { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.tool {
  background: none; border: 1px solid transparent; border-radius: var(--radius);
  padding: 6px 8px; color: var(--ink-2); font-size: var(--t-sm); cursor: pointer; min-height: 36px;
}
.tool:hover { border-color: var(--line); color: var(--ink); }
.brand, .tool { white-space: nowrap; }
.tool .glyph { font-size: 1.1rem; line-height: 1; }
.tool .wide { display: none; }
@media (min-width: 900px) { .tool .glyph { display: none; } .tool .wide { display: inline; } }
[tabindex="-1"]:focus { outline: none; }

.tabs {
  position: fixed; inset: auto 0 0 0; z-index: 20;
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr);
  background: var(--paper); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabs a {
  display: flex; align-items: center; justify-content: center; min-height: 56px;
  font-size: var(--t-sm);
}
.tabs a[aria-current="page"] { color: var(--ink); font-weight: 650; box-shadow: inset 0 3px 0 var(--margin); }
.tabs.single { grid-template-columns: 1fr; }
@media (min-width: 900px) {
  .top-nav { display: flex; }
  .tabs { display: none !important; }
}

/* ---------- page frame ---------- */
main { display: block; padding: 20px var(--gutter) 48px; max-width: 1120px; margin: 0 auto; }
main:focus { outline: none; }
.page-head { margin-bottom: 20px; max-width: var(--measure); }
.page-head p { color: var(--quiet); margin: 6px 0 0; }
.section { margin: 28px 0; max-width: var(--measure); }
.section > h2 { margin-bottom: 10px; }
.quiet { color: var(--quiet); }
.small { font-size: var(--t-sm); }
.read { font-family: var(--read); }

/* ---------- buttons, fields ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 18px;
  border-radius: var(--radius); border: 1.5px solid var(--ink);
  background: var(--ink); color: var(--paper);
  font-weight: 600; font-size: var(--t-md); cursor: pointer; text-decoration: none;
}
.btn:hover { filter: brightness(1.12); }
.btn.secondary { background: transparent; color: var(--ink); }
.btn.secondary:hover { background: var(--surface); filter: none; }
.btn.link { background: none; border-color: transparent; color: var(--ink-2); padding-inline: 6px; text-decoration: underline; text-underline-offset: 3px; }
.btn.danger { background: transparent; color: var(--error); border-color: var(--error); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; filter: none; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 14px; }
.why { flex-basis: 100%; font-size: var(--t-sm); color: var(--quiet); margin: 0; }

label.field { display: block; margin: 14px 0; }
.field > span { display: block; font-weight: 600; font-size: var(--t-sm); margin-bottom: 6px; }
.field > small { display: block; color: var(--quiet); font-size: var(--t-xs); margin-top: 4px; }
input[type="text"], input[type="date"], input[inputmode], select, textarea.plain {
  width: 100%; min-height: 44px; padding: 8px 12px;
  border: 1.5px solid var(--line); border-radius: var(--radius); background: var(--surface);
}
input:focus-visible, select:focus-visible, textarea:focus-visible { border-color: var(--ink); outline-offset: 1px; }
textarea.plain { font-family: var(--read); min-height: 120px; resize: vertical; line-height: 1.6; }
fieldset { border: 0; padding: 0; margin: 18px 0; min-width: 0; }
legend { font-weight: 600; font-size: var(--t-sm); margin-bottom: 8px; padding: 0; }
.choices { display: flex; flex-wrap: wrap; gap: 8px; }
.choice { position: relative; }
.choice input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.choice span {
  display: inline-flex; align-items: center; min-height: 44px; padding: 8px 16px;
  border: 1.5px solid var(--line); border-radius: var(--radius); background: var(--surface); font-weight: 500;
}
.choice input:checked + span { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); font-weight: 650; }
.choice input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }

/* status lines: every write says saving / saved / failed */
.status { font-size: var(--t-sm); margin: 10px 0 0; min-height: 1.5em; }
.status.saving { color: var(--quiet); }
.status.saved { color: var(--green); font-weight: 600; }
.status.failed {
  color: var(--error); background: var(--error-wash); padding: 10px 12px; border-radius: var(--radius);
}
.status.failed .btn { margin-top: 8px; }
.notice { border-left: 3px solid var(--line); padding: 4px 0 4px 12px; color: var(--ink-2); font-size: var(--t-sm); }

/* ---------- login ---------- */
.login { max-width: 26rem; margin: 8vh auto 0; }
.login h1 { font-size: var(--t-2xl); }
.login .lede { font-family: var(--read); color: var(--ink-2); margin: 10px 0 24px; }
.pin {
  font-size: 2rem; letter-spacing: 0.5em; text-align: center; font-weight: 600;
  font-variant-numeric: tabular-nums; padding: 10px 0 10px 0.5em !important; min-height: 64px !important;
}
.login .btn { width: 100%; margin-top: 8px; }

/* ---------- Today: the loop ---------- */
.loop-step { margin: 28px 0 0; }
.loop-step > header { display: flex; align-items: baseline; gap: 10px; margin-bottom: 12px; max-width: var(--measure); }
.loop-step > header .n {
  font-family: var(--ui); font-weight: 700; color: var(--quiet); font-size: var(--t-sm);
  width: 1.6rem; height: 1.6rem; border: 1.5px solid currentColor; border-radius: 50%;
  display: inline-grid; place-items: center; flex: none; transform: translateY(-2px);
}
.loop-step.is-done > header .n { color: var(--green); }
.loop-step.is-done > header h2 { color: var(--ink-2); font-weight: 500; }

/* recall */
.recall { max-width: var(--measure); border-top: 1px solid var(--line); padding-top: 14px; }
.recall .from { font-family: var(--read); color: var(--ink-2); margin-bottom: 12px; }
.recall .rule {
  font-family: var(--read); font-size: var(--t-lg); line-height: 1.45; margin: 12px 0;
  padding-left: 14px; border-left: 3px solid var(--green);
}
.recall .count { font-size: var(--t-sm); color: var(--quiet); }

/* question picker */
.qpick { max-width: var(--measure); }
.qtitle { font-family: var(--read); font-size: var(--t-lg); line-height: 1.4; font-weight: 500; margin: 6px 0 10px; }
.meta { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: var(--t-sm); color: var(--quiet); }
.tag { font-weight: 600; color: var(--ink-2); }
.tag.hl { color: var(--margin); }
.qlist { list-style: none; padding: 0; margin: 10px 0 0; border-top: 1px solid var(--line); }
.qlist li { border-bottom: 1px solid var(--line); }
.qlist button {
  display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; width: 100%; text-align: left;
  padding: 12px 4px; background: none; border: 0; cursor: pointer; min-height: 44px;
}
.qlist button:hover .read { text-decoration: underline; text-underline-offset: 3px; }
.qlist .read { font-size: var(--t-md); line-height: 1.4; }
.qlist .state { font-size: var(--t-xs); color: var(--quiet); white-space: nowrap; }
details.more > summary { cursor: pointer; color: var(--ink-2); font-weight: 500; min-height: 44px; display: flex; align-items: center; }

/* ---------- session layout: spine + booklet ---------- */
.session { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
@media (min-width: 900px) {
  .session { grid-template-columns: 11rem minmax(0, 1fr); gap: 28px; align-items: start; }
  .session > .spine-wrap { position: sticky; top: 20px; }
}

/* the spine: tutor stages as a real sequence */
.spine { margin: 0; padding: 0; list-style: none; counter-reset: st; }
.spine li { position: relative; }
.spine .dot {
  width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--line); background: var(--paper);
  display: block; position: relative; z-index: 1;
}
.spine li.done .dot { background: var(--green); border-color: var(--green); }
.spine li.skipped .dot { border-style: dashed; border-color: var(--quiet); }
.spine li.current .dot { border-color: var(--ink); background: var(--hl); }
.spine .label { font-size: var(--t-sm); color: var(--quiet); }
.spine li.done .label { color: var(--ink-2); }
.spine li.skipped .label { text-decoration: line-through; text-decoration-thickness: 1px; }
.spine li.current .label {
  color: var(--hl-ink); font-weight: 650;
  background: linear-gradient(100deg, transparent 0 2%, var(--hl) 3% 96%, transparent 97%);
  background-size: 100% 70%; background-position: 0 70%; background-repeat: no-repeat;
  padding: 0 4px; margin: 0 -4px;
}
.spine .who { display: block; font-size: var(--t-xs); color: var(--quiet); font-weight: 400; }
.spine-now { display: none; }

/* mobile: horizontal track, the current stage named under it */
@media (max-width: 899.98px) {
  .spine { display: grid; grid-template-columns: repeat(6, 1fr); align-items: center; padding: 4px 6px 0; }
  .spine li { display: flex; justify-content: center; }
  .spine li::before {
    content: ""; position: absolute; top: 50%; left: -50%; right: 50%; height: 2px; background: var(--line); transform: translateY(-50%);
  }
  .spine li:first-child::before { display: none; }
  .spine li.done::before, .spine li.current::before, .spine li.skipped::before { background: var(--green); }
  .spine .label, .spine .who { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .spine li.current .dot { width: 16px; height: 16px; }
  .spine-now { display: block; text-align: center; font-size: var(--t-sm); color: var(--ink-2); margin: 6px 0 0; }
  .spine-now b { color: var(--hl-ink); background: linear-gradient(transparent 35%, var(--hl) 35% 90%, transparent 90%); padding: 0 3px; font-weight: 650; }
}
@media (min-width: 900px) {
  .spine li { display: grid; grid-template-columns: 12px 1fr; gap: 12px; align-items: start; padding-bottom: 22px; }
  .spine li .dot { margin-top: 5px; }
  .spine li::before {
    content: ""; position: absolute; left: 5px; top: 14px; bottom: -2px; width: 2px; background: var(--line);
  }
  .spine li:last-child::before { display: none; }
  .spine li.done::before { background: var(--green); }
}

/* ---------- the booklet ---------- */
.booklet-head { max-width: calc(var(--measure) + var(--mw)); margin-bottom: 6px; }
.booklet-head .meta { margin-bottom: 4px; }
.booklet {
  position: relative; max-width: calc(var(--measure) + var(--mw));
  border-top: 1px solid var(--line);
}
/* the margin rule */
.booklet::before {
  content: ""; position: absolute; top: 0; bottom: 0; left: calc(var(--mw) - 1px);
  width: 2px; background: var(--margin); opacity: 0.85;
}
.entry { display: grid; grid-template-columns: var(--mw) minmax(0, 1fr); }
.entry > .m { padding: 12px 8px 12px 0; text-align: right; min-width: 0; }
.entry > .b { padding: 12px 0 12px 14px; min-width: 0; }
.entry + .entry { border-top: 1px solid var(--line); }
.m .lbl { font-size: var(--t-xs); color: var(--quiet); font-weight: 500; line-height: 1.3; display: block; hyphens: auto; -webkit-hyphens: auto; }

.question .b { font-family: var(--read); font-size: var(--t-lg); line-height: 1.45; font-weight: 500; }
.question .instr { font-family: var(--ui); font-size: var(--t-sm); color: var(--quiet); font-weight: 400; margin-top: 8px; }
.tutor .b { font-family: var(--read); font-size: var(--t-md); line-height: 1.65; color: var(--ink); }
.tutor .b p:last-child { margin-bottom: 0; }
.tutor.newq .b { font-size: var(--t-lg); line-height: 1.45; font-weight: 500; }
.tutor .lbl { color: var(--ink-2); font-weight: 600; }

/* her writing: ruled lines across the margin too, like real paper */
.answer {
  background-image: linear-gradient(to bottom, transparent calc(var(--lh) - 1px), var(--line) calc(var(--lh) - 1px));
  background-size: 100% var(--lh);
  background-position: 0 6px;
}
.answer > .m, .answer > .b { padding-top: 6px; padding-bottom: calc(var(--lh) - 6px); }
.answer .who { font-size: var(--t-xs); color: var(--quiet); line-height: var(--lh); display: block; }
.answer .text {
  font-family: var(--read); font-size: var(--t-md); line-height: var(--lh); white-space: pre-wrap; overflow-wrap: anywhere;
}
.answer.pending .text { color: var(--ink-2); }
.answer .skipped { color: var(--quiet); font-style: italic; }

/* margin marks: the examiner's hand */
.marks { list-style: none; margin: 0; padding: 0; line-height: var(--lh); }
.mark {
  font-family: var(--hand); color: var(--green); font-size: 1rem; line-height: 1.15;
  background: none; border: 0; padding: 4px 0; cursor: pointer; text-align: right; width: 100%;
  min-height: var(--lh); display: block;
}
.mark .nm { display: block; overflow-wrap: anywhere; }
.mark .sc { font-weight: 700; white-space: nowrap; }
.mark[aria-expanded="true"] .nm { text-decoration: underline; text-decoration-thickness: 1.5px; text-underline-offset: 3px; }
.mark.zero { color: var(--margin); }
.total {
  font-family: var(--hand); font-weight: 700; color: var(--green); font-size: 1.35rem; line-height: 1;
  display: inline-block; margin-top: 6px; padding: 8px 8px 6px;
  border: 2px solid var(--green); border-radius: 48% 52% 45% 55% / 55% 45% 55% 45%;
  transform: rotate(-4deg);
}
.skipmark { font-family: var(--hand); color: var(--quiet); font-size: 1rem; }
@media (min-width: 720px) {
  .mark { font-size: 1.125rem; line-height: var(--lh); padding: 0; }
  .mark .nm { display: inline; }
  .mark .nm::after { content: " "; }
}

/* the examiner's comment and evidence under her answer */
.examiner { font-family: var(--read); color: var(--green); font-style: italic; line-height: var(--lh); margin: 0; }
.evidence {
  font-family: var(--read); font-size: var(--t-sm); line-height: 1.5; color: var(--ink);
  background: var(--green-wash); border-left: 3px solid var(--green);
  padding: 8px 12px; margin: 6px 0; border-radius: 0 var(--radius) var(--radius) 0;
}
.evidence b { font-family: var(--ui); }
.not-official { font-family: var(--ui); font-size: var(--t-xs); color: var(--quiet); line-height: 1.4; margin: 6px 0 0; font-style: normal; }
.not-official.uncertain { color: var(--ink-2); }

/* the one orchestrated moment: marks write themselves into the margin */
@media (prefers-reduced-motion: no-preference) {
  .fresh .mark, .fresh .total, .fresh .examiner {
    animation: write-in 520ms cubic-bezier(.2,.7,.3,1) both;
    animation-delay: calc(var(--i, 0) * 170ms + 120ms);
  }
  .fresh .total { animation-duration: 420ms; }
  @keyframes write-in {
    from { clip-path: inset(0 0 0 100%); opacity: 0.2; }
    to { clip-path: inset(0 0 0 0); opacity: 1; }
  }
  .fresh .examiner { animation-name: ink-in; }
  @keyframes ink-in { from { opacity: 0; } to { opacity: 1; } }
}

/* writing area */
.write > .b { padding-bottom: 18px; }
.write label.who { font-size: var(--t-xs); color: var(--quiet); display: block; line-height: var(--lh); margin-top: 6px; }
textarea.ruled {
  display: block; width: 100%; min-height: calc(var(--lh) * 6); resize: vertical;
  font-family: var(--read); font-size: var(--t-md); line-height: var(--lh);
  border: 0; border-radius: 0; padding: 0 4px; margin: 0;
  background-color: transparent;
  background-image: linear-gradient(to bottom, transparent calc(var(--lh) - 1px), var(--line) calc(var(--lh) - 1px));
  background-size: 100% var(--lh); background-attachment: local;
  color: var(--ink); caret-color: var(--margin);
  box-shadow: inset 0 0 0 1.5px transparent;
}
textarea.ruled:focus-visible { outline: none; box-shadow: inset 0 0 0 1.5px var(--ink); border-radius: 2px; }
textarea.ruled::placeholder { color: var(--quiet); font-style: italic; }
.counter { font-size: var(--t-xs); color: var(--quiet); text-align: right; margin-top: 2px; }
.working { display: flex; gap: 10px; align-items: center; color: var(--ink-2); font-size: var(--t-sm); }
.working::before {
  content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--hl); border: 2px solid var(--ink); flex: none;
}
@media (prefers-reduced-motion: no-preference) {
  .working::before { animation: pulse 1.2s ease-in-out infinite; }
  @keyframes pulse { 50% { transform: scale(0.6); } }
}
.booklet-foot { max-width: calc(var(--measure) + var(--mw)); padding: 10px 0 0 calc(var(--mw) + 14px); font-size: var(--t-xs); color: var(--quiet); }

/* result */
.result { max-width: calc(var(--measure) + var(--mw)); margin-top: 24px; padding-top: 18px; border-top: 2px solid var(--ink); }
.result .verdict { display: flex; align-items: center; gap: 16px; margin-bottom: 12px; }
.result .verdict .total { font-size: 1.75rem; padding: 12px 12px 10px; }
.result .verdict h2 { font-size: var(--t-xl); }
.into-mistakes { margin: 16px 0; padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.into-mistakes h3 { margin-bottom: 6px; }
.into-mistakes .rule { font-family: var(--read); line-height: 1.55; }

/* ---------- ask ---------- */
.ask-form { max-width: var(--measure); }
.shot { display: flex; gap: 12px; align-items: center; margin-top: 10px; }
.shot img { width: 96px; height: 96px; object-fit: cover; border: 1px solid var(--line); border-radius: var(--radius); }
.file-btn { position: relative; overflow: hidden; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.file-btn:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }
.resume-list { list-style: none; padding: 0; margin: 0; border-top: 1px solid var(--line); }
.resume-list li { border-bottom: 1px solid var(--line); padding: 10px 0; display: flex; gap: 12px; justify-content: space-between; align-items: center; }
.resume-list .read { overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

/* ---------- mistakes ---------- */
.mlist { list-style: none; padding: 0; margin: 0; max-width: var(--measure); }
.mlist > li { padding: 14px 0; border-bottom: 1px solid var(--line); }
.mlist > li:first-child { border-top: 1px solid var(--line); }
.mlist .rule { font-family: var(--read); line-height: 1.55; margin: 4px 0 6px; }
.mlist .what { font-family: var(--read); color: var(--ink-2); font-size: var(--t-sm); margin: 0; }
.ladder { display: inline-flex; gap: 3px; vertical-align: middle; margin-right: 4px; }
.ladder i { width: 14px; height: 4px; border-radius: 2px; background: var(--line); }
.ladder i.on { background: var(--green); }
.history { font-size: var(--t-sm); color: var(--ink-2); margin-top: 6px; }
.history summary { cursor: pointer; color: var(--quiet); }
.history ol { margin: 6px 0 0; padding-left: 1.2em; }

/* ---------- profile ---------- */
.rows { display: grid; gap: 10px; }
.row { display: grid; grid-template-columns: 1fr; gap: 8px; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.row .pair { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.row label > span { display: block; font-size: var(--t-xs); color: var(--quiet); margin-bottom: 2px; }
@media (min-width: 720px) {
  .row { grid-template-columns: 2fr 1fr 1fr auto; align-items: end; }
  .row.test { grid-template-columns: 2fr 1.4fr auto; }
  .row .pair { display: contents; }
}

/* ---------- teacher ---------- */
.teacher { display: grid; gap: 24px; }
@media (min-width: 900px) { .teacher { grid-template-columns: 15rem minmax(0, 1fr); } }
.students { list-style: none; padding: 0; margin: 0; border-top: 1px solid var(--line); }
.students button {
  width: 100%; text-align: left; background: none; border: 0; border-bottom: 1px solid var(--line);
  padding: 10px 6px; cursor: pointer; min-height: 44px;
}
.students button[aria-current="true"] { box-shadow: inset 3px 0 0 var(--margin); background: var(--surface); font-weight: 650; }
.students .sub { display: block; font-size: var(--t-xs); color: var(--quiet); font-weight: 400; }
.subtabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 14px 0 16px; overflow-x: auto; }
.subtabs button { background: none; border: 0; padding: 10px 12px; min-height: 44px; cursor: pointer; color: var(--ink-2); font-weight: 500; white-space: nowrap; }
.subtabs button[aria-selected="true"] { color: var(--ink); box-shadow: inset 0 -2px 0 var(--margin); font-weight: 650; }
.att { padding: 16px 0; border-bottom: 1px solid var(--line); }
.att .q { font-family: var(--read); font-weight: 500; margin: 4px 0 8px; }
.att .ans { font-family: var(--read); white-space: pre-wrap; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; line-height: 1.6; overflow-wrap: anywhere; }
.crit { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: var(--t-sm); }
.crit th, .crit td { text-align: left; padding: 6px 8px 6px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.crit th { font-weight: 600; color: var(--quiet); font-size: var(--t-xs); }
.crit td.sc { font-family: var(--hand); color: var(--green); font-weight: 700; white-space: nowrap; font-size: 1rem; }
.crit td.ev { font-family: var(--read); }
.flag { display: inline-block; font-size: var(--t-xs); font-weight: 650; padding: 1px 8px; border-radius: 999px; border: 1px solid currentColor; }
.flag.warn { color: var(--margin); }
.flag.good { color: var(--green); }
.table-wrap { overflow-x: auto; max-width: 100%; }
table.usage { border-collapse: collapse; font-size: var(--t-sm); min-width: 100%; }
table.usage th, table.usage td { text-align: left; padding: 8px 12px 8px 0; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.usage th { font-size: var(--t-xs); color: var(--quiet); font-weight: 600; }
.meter { display: inline-block; width: 80px; height: 6px; background: var(--line); border-radius: 3px; vertical-align: middle; margin-left: 8px; overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--green); }
.meter.hot i { background: var(--margin); }
.once { border: 2px solid var(--ink); border-radius: var(--radius); padding: 14px 16px; margin: 12px 0; background: var(--surface); }
.once code { font-family: var(--ui); font-weight: 600; overflow-wrap: anywhere; display: block; margin: 4px 0 8px; font-size: var(--t-sm); }
.once .pinv { font-size: var(--t-xl); letter-spacing: 0.25em; font-variant-numeric: tabular-nums; }

/* ---------- upload: study packs ---------- */
.tabs a { padding: 0 2px; text-align: center; overflow-wrap: anywhere; line-height: 1.2; }
.crumb { margin: 0 0 8px; font-size: var(--t-sm); }
.crumb a { color: var(--ink-2); }
.section.wide { max-width: calc(var(--measure) + var(--mw)); }
.packlist { list-style: none; padding: 0; margin: 10px 0 0; border-top: 1px solid var(--line); }
.packlist a {
  display: grid; grid-template-columns: 4.6rem minmax(0, 1fr); gap: 4px 14px; align-items: center;
  padding: 12px 4px; border-bottom: 1px solid var(--line); text-decoration: none; min-height: 56px;
}
.packlist a:hover .read { text-decoration: underline; text-underline-offset: 3px; }
.pl-date { grid-row: span 2; display: flex; flex-direction: column; border-right: 2px solid var(--margin); padding-right: 10px; }
.pl-date b { font-family: var(--hand); font-size: 1.15rem; line-height: 1.1; }
.pl-date small { font-size: var(--t-xs); color: var(--quiet); line-height: 1.2; }
.pl-main { display: flex; flex-wrap: wrap; gap: 2px 10px; align-items: baseline; }
.pl-main .read { font-size: var(--t-md); }
.pl-st { font-size: var(--t-xs); color: var(--quiet); }
.pl-st.st-ready { color: var(--green); font-weight: 600; }
.pl-st.st-failed { color: var(--error); font-weight: 600; }
.upload-form { max-width: var(--measure); }
.flabel { display: block; font-weight: 600; font-size: var(--t-sm); margin-bottom: 6px; }
.field > .flabel + .dropzone { margin-bottom: 4px; }
.dropzone {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  border: 1.5px dashed var(--line); border-radius: var(--radius); padding: 14px; background: var(--surface);
}
.dropzone.over { border-color: var(--ink); background: var(--green-wash); }
.wide-only { display: none; }
@media (min-width: 720px) { .wide-only { display: inline; } }
.upfiles { list-style: none; padding: 0; margin: 10px 0 0; }
.upfiles li {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; align-items: center;
  padding: 10px 0 10px 12px; border-left: 3px solid var(--line); margin-bottom: 6px;
}
.upfiles .fn { min-width: 0; overflow-wrap: anywhere; }
.upfiles .fn small { color: var(--quiet); font-size: var(--t-xs); }
.upfiles .fs { grid-column: 1; font-size: var(--t-sm); color: var(--ink-2); }
.upfiles progress { grid-column: 1; width: 100%; height: 6px; accent-color: var(--green); }
.upfiles .btn.link { grid-column: 2; grid-row: 1 / span 2; min-height: 36px; }
.upfiles li.st-uploading { border-left-color: var(--hl); }
.upfiles li.st-ok { border-left-color: var(--green); }
.upfiles li.st-ok .fs { color: var(--green); }
.upfiles li.st-ok.warn { border-left-color: var(--margin); }
.upfiles li.st-ok.warn .fs { color: var(--ink-2); }
.upfiles li.st-failed, .upfiles li.st-invalid { border-left-color: var(--error); background: var(--error-wash); }
.upfiles li.st-failed .fs, .upfiles li.st-invalid .fs { color: var(--error); }

/* the pack page */
.countdown { color: var(--ink-2); font-family: var(--read); }
.countdown b { font-family: var(--ui); color: var(--hl-ink); background: var(--hl); padding: 0 4px; border-radius: 2px; }
.notice.warn { border-left-color: var(--margin); color: var(--ink); margin: 8px 0 0; }
.pq { list-style: none; padding: 0; margin: 12px 0 0; position: relative; border-top: 1px solid var(--line); }
.pq::before { content: ""; position: absolute; top: 0; bottom: 0; left: calc(var(--mw) - 1px); width: 2px; background: var(--margin); opacity: 0.85; }
.pq > li { display: grid; grid-template-columns: var(--mw) minmax(0, 1fr); border-bottom: 1px solid var(--line); }
.pq-m { padding: 14px 10px 14px 0; text-align: right; }
.pq-m .lbl { font-family: var(--hand); font-weight: 700; font-size: 1.25rem; color: var(--ink-2); }
.pq > li.flagged .pq-m .lbl { color: var(--margin); }
.pq-b { padding: 14px 0 16px 14px; min-width: 0; }
.pq .qtext { font-family: var(--read); font-size: var(--t-lg); line-height: 1.4; font-weight: 500; margin: 0 0 6px; }
.pq .actions { margin-top: 10px; }
.pq .status:empty { display: none; }
.pq > li.pq-split { display: block; padding: 18px 0 6px calc(var(--mw) + 14px); border-bottom: 0; }
.pq-split span { font-size: var(--t-xs); text-transform: uppercase; letter-spacing: 0.08em; color: var(--margin); font-weight: 700; }
.badge { display: inline-block; font-size: var(--t-xs); font-weight: 650; padding: 1px 8px; border-radius: 999px; border: 1px solid currentColor; }
.badge.confirmed { color: var(--green); }
.badge.provisional { color: var(--quiet); border-style: dashed; }
.src { font-size: var(--t-xs); color: var(--quiet); margin: 6px 0 0; overflow-wrap: anywhere; }
.thumbs { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.thumb { padding: 0; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; cursor: zoom-in; line-height: 0; }
.thumb img, .thumb-img { width: 132px; height: 88px; object-fit: contain; border-radius: var(--radius); background: #fff; }
.thumb-img { border: 1px solid var(--line); }
.imgdlg { border: 0; border-radius: var(--radius); padding: 14px; max-width: min(96vw, 900px); background: var(--surface); color: var(--ink); }
.imgdlg::backdrop { background: rgb(18 24 38 / 0.7); }
.imgdlg img { display: block; max-width: 100%; max-height: 70vh; margin: 0 auto 10px; background: #fff; }
.plan { list-style: none; padding: 0; margin: 10px 0 0; max-width: var(--measure); border-top: 1px solid var(--line); }
.plan > li { display: grid; grid-template-columns: 6.2rem minmax(0, 1fr); gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.plan .pd { font-size: var(--t-sm); color: var(--ink-2); font-weight: 600; align-self: start; justify-self: start; }
.plan ul { list-style: none; padding: 0; margin: 0; font-family: var(--read); font-size: var(--t-sm); line-height: 1.5; }
.plan ul li + li { margin-top: 4px; }
.plan li.test { font-family: var(--ui); font-weight: 700; color: var(--margin); }
.plan > li.today { background: var(--surface); box-shadow: inset 3px 0 0 var(--hl); padding-left: 8px; margin-left: -8px; }
.plan > li.today .pd { color: var(--hl-ink); }
.plan > li.today .pd { background: var(--hl); padding: 0 4px; border-radius: 2px; }
.plan > li.past { opacity: 0.55; }
.asks { list-style: none; padding: 0; margin: 14px 0 0; }
.asks > li { padding: 12px 0; border-top: 1px solid var(--line); }
.asks .q { font-weight: 600; margin: 0 0 6px; }
.asks .ans { font-family: var(--read); line-height: 1.6; padding-left: 12px; border-left: 3px solid var(--green); white-space: pre-wrap; }
.asks .ans.miss { border-left-color: var(--quiet); color: var(--ink-2); }
.defs { margin: 8px 0 0; }
.defs dt { font-weight: 600; margin-top: 10px; }
.defs dd { margin: 2px 0 0; font-family: var(--read); line-height: 1.55; }
.diaglist { padding-left: 1.1em; }
.diaglist li { margin: 6px 0; }
.diaglist ul { font-size: var(--t-sm); color: var(--ink-2); }
details.more.section { max-width: var(--measure); }

/* Today: persistent tutor + marking status (server-derived) */
.today-status { border-left: 3px solid var(--line); padding: 4px 0 4px 12px; margin-bottom: 8px; }
.today-status p, .today-status ul { margin: 2px 0; color: var(--ink-2); }
.today-status ul { padding-left: 18px; }
