/* ============================================================================
   Exam Superstars — part of the SATs Superstars family
   Palette: warm cream canvas · ink · golden-amber accent · sage success
   Display: Boldonse · UI: General Sans · Data: Geist Mono
   The exam "sheet" stays deliberately plain (it must read as a real paper);
   everything around it is the designed product chrome.
   ========================================================================== */

:root {
  /* canvas + surfaces — warm cream, matching satsuperstars.com */
  --paper: #faf7f2;          /* warm cream app background */
  --surface: #ffffff;        /* raised panels */
  --surface-2: #fff7ea;      /* warm inset / hover */
  --sheet: #ffffff;          /* the exam paper */

  /* ink */
  --ink: #1a1612;            /* near-black, warm */
  --ink-2: #3a3428;          /* secondary text */
  --ink-3: #6a5f4c;          /* captions, placeholders — WCAG AA (≈5.4:1 on cream) */
  --qink: #1a1a1a;           /* exam paper ink (kept neutral) */

  /* lines */
  --line: #ece4d6;
  --line-2: #ddd2bf;

  /* accent — golden amber (SATs Superstars). --clay* names kept for reach;
     --clay/-deep are accent TEXT (AA on cream); --gold* are bright FILLS. */
  --clay: #b07514;           /* accent text/medium (AA-large on cream) */
  --clay-deep: #8a5a10;      /* darker accent text (AA-normal on cream) */
  --clay-tint: #fdeecb;      /* pale gold — chip / step backgrounds */
  --clay-ring: rgba(253, 176, 61, .45);
  --gold: #fdb03d;           /* signature bright gold — fills */
  --gold-2: #e89a28;         /* deeper gold — hover / borders */
  --gold-ink: #1f1a12;       /* dark text on gold fills */

  /* secondary — ink-blue for exam/board cues */
  --slate: #2f3d4f;

  /* status */
  --sage: #4f7a4a;
  --sage-tint: #e7f0e3;
  --crimson: #b4402f;
  --crimson-tint: #fbe9e5;
  --amber: #c98a2b;

  --radius: 13px;
  --radius-lg: 20px;
  --shadow-sm: 0 1px 2px rgba(33, 29, 24, .06), 0 1px 3px rgba(33, 29, 24, .05);
  --shadow-md: 0 4px 14px rgba(33, 29, 24, .09), 0 1px 3px rgba(33, 29, 24, .06);
  --shadow-lg: 0 16px 48px rgba(33, 29, 24, .16);
  --sans: "General Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --display: "Boldonse", "General Sans", -apple-system, "Segoe UI", sans-serif;
  --serif: var(--display); /* legacy alias */
  --mono: "Geist Mono", ui-monospace, "SF Mono", "Roboto Mono", Menlo, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
/* signature: a thin gold rule across the very top of the page */
body::before {
  content: ""; position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 50;
  background: linear-gradient(90deg, var(--gold) 0%, var(--gold-2) 55%, var(--clay) 100%);
}
::selection { background: var(--clay-ring); }

/* consistent keyboard focus ring across all interactive controls */
.pf-segbtn:focus-visible, .pf-chip:focus-visible, .pf-btn:focus-visible, .pf-tab:focus-visible,
.pf-mini:focus-visible, .pf-generate:focus-visible, .pf-markin:focus-visible,
.pf-showans:focus-within, .pf-predict:focus-within, summary:focus-visible {
  outline: 2px solid var(--clay); outline-offset: 2px; border-radius: 8px;
}

/* ── Header ─────────────────────────────────────────────────────────────── */
.pf-header {
  display: flex; align-items: center; gap: 14px;
  padding: 0 26px; height: 60px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 30;
}
.pf-logo { display: flex; align-items: center; gap: 11px; }
.pf-logo-mark { width: 30px; height: 30px; flex: none; }
.pf-logo h1 {
  margin: 0; font-family: var(--display); font-weight: 400;
  font-size: 15px; letter-spacing: -.01em; color: var(--ink); line-height: 1;
}
.pf-logo h1 .pf-forge { color: var(--clay); }
.pf-tag {
  font-size: 13px; color: var(--ink-3); border-left: 1px solid var(--line-2);
  padding-left: 14px; margin-left: 2px;
}
.pf-header-spacer { flex: 1; }
.pf-header-note {
  font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums;
}
.pf-header-note b { color: var(--ink-2); font-weight: 600; }

/* ── Layout ─────────────────────────────────────────────────────────────── */
.pf-layout { display: flex; align-items: flex-start; }
.pf-sidebar {
  width: 326px; flex: none;
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 22px 20px 48px;
  min-height: calc(100vh - 60px);
  position: sticky; top: 60px;
  max-height: calc(100vh - 60px); overflow-y: auto;
  scrollbar-width: thin;
}
.pf-sidebar::-webkit-scrollbar { width: 8px; }
.pf-sidebar::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 8px; }
.pf-main { flex: 1; padding: 26px 30px 90px; min-width: 0; }

/* ── Sidebar sections ───────────────────────────────────────────────────── */
.pf-section-head {
  font-family: var(--mono); font-size: 10.5px; font-weight: 600;
  letter-spacing: .14em; text-transform: uppercase; color: var(--ink-3);
  margin: 22px 0 12px; padding-bottom: 7px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 8px;
}
.pf-section-head:first-child { margin-top: 0; }
.pf-section-head .pf-step {
  width: 18px; height: 18px; border-radius: 50%; background: var(--clay-tint);
  color: var(--clay-deep); font-size: 10px; display: grid; place-items: center;
  letter-spacing: 0;
}

.pf-ctl { margin-bottom: 15px; }
.pf-ctl-label {
  font-size: 12px; font-weight: 600; color: var(--ink-2);
  margin-bottom: 7px; display: flex; justify-content: space-between; align-items: baseline;
}
.pf-hint { font-weight: 400; color: var(--ink-3); font-size: 11px; }

/* segmented controls */
.pf-seg { display: flex; flex-wrap: wrap; gap: 6px; }
.pf-segbtn {
  flex: 1 1 auto; min-width: fit-content;
  border: 1px solid var(--line-2); background: var(--surface);
  border-radius: 9px; padding: 8px 11px;
  font-family: var(--sans); font-size: 13px; font-weight: 500; color: var(--ink-2);
  cursor: pointer; transition: border-color .12s, background .12s, color .12s, box-shadow .12s;
}
.pf-segbtn:hover { border-color: var(--clay); color: var(--ink); }
.pf-segbtn.on {
  background: var(--ink); border-color: var(--ink); color: var(--surface);
  box-shadow: var(--shadow-sm);
}
.pf-badge {
  font-family: var(--mono); font-size: 8.5px; font-weight: 600;
  background: var(--gold-2); color: var(--gold-ink); border-radius: 4px;
  padding: 1px 4px; vertical-align: 1.5px; letter-spacing: .04em;
}
.pf-segbtn.on .pf-badge { background: var(--gold); color: var(--gold-ink); }

/* topic chips */
.pf-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.pf-chip {
  border: 1px solid var(--line-2); background: var(--surface);
  border-radius: 7px; padding: 5px 10px;
  font-size: 12px; color: var(--ink-2); cursor: pointer;
  transition: all .12s;
}
.pf-chip:hover { border-color: var(--clay); }
.pf-chip.on { background: var(--clay-tint); border-color: var(--clay); color: var(--clay-deep); font-weight: 600; }
.pf-topic-group {
  font-family: var(--mono); font-size: 9.5px; letter-spacing: .1em;
  text-transform: uppercase; color: var(--ink-3);
  margin: 11px 0 6px; width: 100%;
}
.pf-topic-group:first-child { margin-top: 2px; }
.pf-topic-count {
  font-family: var(--mono); font-size: 10px; font-weight: 600;
  color: var(--clay-deep); background: var(--clay-tint);
  padding: 1px 7px; border-radius: 999px; vertical-align: middle;
}
.pf-topic-hint { margin: 0 0 9px; }
.pf-topic-tools { display: inline-flex; gap: 5px; }
.pf-mini {
  border: 1px solid var(--line-2); background: var(--surface); border-radius: 6px;
  font-family: var(--sans); font-size: 11px; padding: 2px 9px; cursor: pointer; color: var(--ink-2);
  transition: all .12s;
}
.pf-mini:hover { border-color: var(--clay); color: var(--clay-deep); }

/* inputs */
.pf-input {
  width: 100%; border: 1px solid var(--line-2); border-radius: 9px;
  padding: 9px 11px; font-family: var(--sans); font-size: 13px; margin-bottom: 6px;
  background: var(--surface); color: var(--ink); transition: border-color .12s, box-shadow .12s;
}
.pf-input::placeholder { color: var(--ink-3); }
.pf-input:focus { outline: none; border-color: var(--clay); box-shadow: 0 0 0 3px var(--clay-ring); }

/* custom paper length: marks + minutes */
.pf-custom { margin-top: -6px; padding: 11px; border: 1px dashed var(--line-2); border-radius: 10px; background: var(--surface-2, rgba(0,0,0,.015)); }
.pf-custom-row { display: flex; gap: 10px; }
.pf-custom-f { flex: 1; display: flex; flex-direction: column; gap: 4px; font-size: 11px; font-weight: 500; color: var(--ink-2); text-transform: uppercase; letter-spacing: .04em; }
.pf-custom-f .pf-num { width: 100%; margin-bottom: 0; font-family: var(--mono); font-size: 15px; font-weight: 500; text-align: center; }
.pf-num::-webkit-inner-spin-button { opacity: .5; }
.pf-custom-hint { margin-top: 8px; line-height: 1.45; }

/* primary CTA — signature gold button with dark ink (SATs Superstars) */
.pf-generate {
  width: 100%; padding: 14px; margin-top: 8px;
  background: var(--gold); border: 1px solid var(--gold-2); border-radius: 12px;
  color: var(--gold-ink); font-family: var(--sans); font-size: 15px; font-weight: 600; cursor: pointer;
  box-shadow: 0 2px 0 var(--gold-2), var(--shadow-sm); transition: background .12s, transform .04s, box-shadow .12s;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.pf-generate:hover { background: var(--gold-2); box-shadow: 0 2px 0 var(--clay), var(--shadow-md); }
.pf-generate:active { transform: translateY(1px); box-shadow: var(--shadow-sm); }
.pf-generate kbd {
  font-family: var(--mono); font-size: 10px; background: rgba(31,26,18,.14);
  border-radius: 4px; padding: 1px 5px; font-weight: 500;
}

.pf-predict {
  display: flex; align-items: flex-start; gap: 8px; margin-top: 10px;
  font-size: 12px; color: var(--ink-2); cursor: pointer; user-select: none;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 9px; padding: 9px 11px;
}
.pf-predict input { accent-color: var(--clay); margin-top: 2px; flex: none; }
.pf-predict b { color: var(--clay-deep); }

.pf-bpnote {
  font-size: 11px; color: var(--ink-3); margin-top: 10px; line-height: 1.55;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 9px;
  padding: 9px 11px;
}
.pf-bpnote b { color: var(--clay-deep); font-weight: 600; }

.pf-ai {
  margin-top: 20px; font-size: 13px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px;
}
.pf-ai summary { cursor: pointer; font-weight: 600; color: var(--ink-2); list-style: none; }
.pf-ai summary::-webkit-details-marker { display: none; }
.pf-ai summary::before { content: "›"; display: inline-block; margin-right: 7px; transition: transform .15s; color: var(--ink-3); }
.pf-ai[open] summary::before { transform: rotate(90deg); }
.pf-ai-note { font-size: 11.5px; color: var(--ink-3); line-height: 1.5; }
.pf-ai-note code { font-family: var(--mono); font-size: 10.5px; background: var(--surface); padding: 1px 4px; border-radius: 3px; }
.pf-ai-save { margin-right: 8px; }
.pf-ai-status { font-size: 11px; color: var(--sage); font-weight: 600; }

.pf-log { margin-top: 14px; }
.pf-logta { font-family: var(--mono); font-size: 12px; resize: vertical; line-height: 1.5; }
.pf-log-fb { font-size: 11.5px; color: var(--sage); margin: 8px 0 4px; line-height: 1.45; }
.pf-logbars { margin-top: 10px; display: flex; flex-direction: column; gap: 5px; }
.pf-logbar { display: flex; align-items: center; gap: 8px; font-size: 11px; }
.pf-logbar-l { flex: 0 0 88px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pf-logbar-t { flex: 1; height: 7px; background: var(--surface); border: 1px solid var(--line); border-radius: 5px; overflow: hidden; }
.pf-logbar-t > span { display: block; height: 100%; background: var(--clay); }
.pf-logbar-n { flex: 0 0 22px; text-align: right; font-family: var(--mono); color: var(--ink-3); }

.pf-error {
  background: var(--crimson-tint); border: 1px solid #e7b9b0; color: var(--crimson);
  padding: 11px 14px; border-radius: var(--radius); font-size: 13px; margin-top: 10px;
}
.pf-shortnote {
  background: #fbf3e2; border: 1px solid #e6d3a8; color: #6b5418;
  padding: 11px 14px; border-radius: var(--radius); font-size: 13px;
  margin: 0 0 16px; line-height: 1.5;
}

.pf-foot {
  margin-top: 22px; padding-top: 14px; border-top: 1px solid var(--line);
  font-size: 10.5px; color: var(--ink-3); line-height: 1.5;
}
.pf-foot span { font-family: var(--display); color: var(--clay-deep); font-size: 10px; letter-spacing: .01em; }

/* ── Toolbar ────────────────────────────────────────────────────────────── */
.pf-toolbar {
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px;
  margin-bottom: 18px; position: sticky; top: 60px; z-index: 20;
  background: var(--paper); padding: 8px 0;
}
.pf-tabs { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.pf-tab {
  border: none; background: transparent; border-radius: 7px;
  padding: 7px 17px; font-family: var(--sans); font-size: 13.5px; font-weight: 500;
  color: var(--ink-2); cursor: pointer; transition: all .12s;
}
.pf-tab.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); font-weight: 600; }
.pf-tools { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.pf-btn {
  border: 1px solid var(--line-2); background: var(--surface); border-radius: 9px;
  padding: 8px 14px; font-family: var(--sans); font-size: 13px; font-weight: 500; color: var(--ink); cursor: pointer;
  transition: all .12s; display: inline-flex; align-items: center; gap: 6px;
}
.pf-btn:hover { border-color: var(--clay); }
.pf-btn-primary { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.pf-btn-primary:hover { background: #000; border-color: #000; }
.pf-seedchip {
  font-family: var(--mono); font-size: 11.5px; color: var(--ink-2);
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 5px 10px;
}
.pf-seedchip b { color: var(--clay-deep); }
.pf-showans { font-size: 12.5px; color: var(--ink-2); display: flex; align-items: center; gap: 6px; cursor: pointer; user-select: none; }
.pf-showans input { accent-color: var(--clay); }

/* ── Empty state (hero + live preview) ──────────────────────────────────── */
.pf-empty {
  max-width: 760px; margin: 30px auto 0; text-align: center;
}
.pf-empty-eyebrow {
  font-family: var(--mono); font-size: 11px; letter-spacing: .16em; text-transform: uppercase;
  color: var(--clay-deep); margin-bottom: 16px;
}
.pf-empty h2 {
  font-family: var(--sans); font-weight: 700; font-size: 40px; line-height: 1.1;
  letter-spacing: -.025em; color: var(--ink); margin: 0 0 16px;
}
.pf-empty h2 em { font-style: normal; color: var(--clay); }
.pf-empty p { font-size: 16px; color: var(--ink-2); line-height: 1.6; max-width: 560px; margin: 0 auto 10px; }
.pf-empty-steps {
  display: flex; gap: 14px; justify-content: center; margin: 28px auto 4px; flex-wrap: wrap;
}
.pf-empty-step {
  flex: 1 1 150px; max-width: 200px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px 14px; text-align: left;
  transition: transform .15s, box-shadow .15s, border-color .15s;
}
.pf-empty-step:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--line-2); }
.pf-empty-step .pf-step-n { font-family: var(--mono); font-size: 11px; color: var(--clay); font-weight: 600; }
.pf-empty-step h4 { margin: 6px 0 4px; font-size: 14px; font-weight: 600; color: var(--ink); }
.pf-empty-step p { font-size: 12.5px; color: var(--ink-3); margin: 0; text-align: left; }
.pf-empty-cta { margin-top: 30px; }
.pf-empty-cta .pf-generate { display: inline-flex; width: auto; padding: 13px 34px; }
.pf-empty-stats {
  display: flex; gap: 30px; justify-content: center; margin-top: 38px;
  padding-top: 26px; border-top: 1px solid var(--line);
}
.pf-stat { text-align: center; }
.pf-stat-n { font-family: var(--mono); font-size: 26px; font-weight: 600; color: var(--ink); letter-spacing: -.02em; }
.pf-stat-l { font-size: 11.5px; color: var(--ink-3); margin-top: 3px; }

.pf-loading { text-align: center; padding: 90px 20px; }
.pf-loading h2 { font-family: var(--sans); font-weight: 700; color: var(--ink); font-size: 26px; letter-spacing: -.02em; }
.pf-loading p { color: var(--ink-2); }
.pf-spinner {
  width: 34px; height: 34px; margin: 0 auto 22px; border-radius: 50%;
  border: 3px solid var(--line-2); border-top-color: var(--clay);
  animation: pf-spin .8s linear infinite;
}
@keyframes pf-spin { to { transform: rotate(360deg); } }

/* ── The paper sheet — a real sheet of A4 on the desk ───────────────────── */
.pf-sheet {
  display: none;
  position: relative;
  background-color: #fffefb;
  /* faint paper grain so it doesn't read as a flat panel */
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 220 220' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.7' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.028'/%3E%3C/svg%3E");
  max-width: 820px; margin: 0 auto;
  padding: 54px 60px 72px;
  border: 1px solid rgba(46, 38, 24, .08);
  border-radius: 2px;
  box-shadow: 0 1px 2px rgba(33, 29, 24, .05), 0 14px 34px rgba(33, 29, 24, .14);
  color: var(--qink);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 15px; line-height: 1.5;
}
.pf-sheet.active { display: block; }
/* two more sheets peeking out beneath — the "ream of paper" depth */
.pf-sheet::before, .pf-sheet::after {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: #fff; border: 1px solid rgba(46, 38, 24, .06); border-radius: 2px;
}
.pf-sheet::before { transform: translateY(5px) scaleX(.986); box-shadow: 0 9px 20px rgba(33, 29, 24, .08); }
.pf-sheet::after  { transform: translateY(10px) scaleX(.968); box-shadow: 0 11px 24px rgba(33, 29, 24, .07); }

.pf-cover-band { display: flex; justify-content: space-between; align-items: baseline; border-bottom: 4px solid var(--qink); padding-bottom: 6px; margin-bottom: 16px; }
.pf-cover-pub { font-size: 22px; font-weight: 800; }
.pf-cover-brand { font-size: 15px; font-weight: 600; }
.pf-cover-idrow { display: flex; gap: 26px; margin-bottom: 10px; }
.pf-idbox label, .pf-cover-namebox label { display: block; font-size: 11px; margin-bottom: 3px; }
.pf-cells { display: flex; }
.pf-cells span { width: 26px; height: 30px; border: 1px solid var(--qink); margin-right: -1px; display: inline-block; }
.pf-cover-namebox { margin-bottom: 18px; }
.pf-nameline { border-bottom: 1px solid var(--qink); height: 26px; max-width: 420px; }
.pf-cover-title h1 { margin: 4px 0 2px; font-size: 30px; }
.pf-cover-paper { font-size: 17px; margin-bottom: 6px; }
.pf-cover-meta { display: flex; justify-content: space-between; font-size: 14px; border-top: 2px solid var(--qink); border-bottom: 2px solid var(--qink); padding: 7px 0; margin: 10px 0 16px; }
.pf-cover-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 0 28px; font-size: 12.5px; }
.pf-cover-cols h3 { font-size: 13px; margin: 8px 0 4px; }
.pf-cover-cols ul { margin: 0 0 8px; padding-left: 18px; }
.pf-cover-cols li { margin-bottom: 3px; }
.pf-cover-foot { display: flex; justify-content: space-between; align-items: flex-end; margin-top: 22px; gap: 18px; }
.pf-totalbox { border: 2px solid var(--qink); padding: 8px 16px; font-size: 15px; }
.pf-disclaimer { font-size: 10.5px; color: #777; max-width: 420px; }
.pf-answerall { text-align: center; font-weight: 700; margin: 26px 0 10px; font-size: 14px; }

.pf-mini-cover { border: 2px solid var(--qink); padding: 12px 16px; margin-bottom: 22px; }
.pf-mini-title { font-weight: 800; font-size: 16px; }
.pf-mini-sub { font-size: 12.5px; margin-top: 4px; }
.pf-mini-id { font-size: 12px; margin-top: 10px; color: #333; }

.pf-q { position: relative; margin-bottom: 6px; }
.pf-qtools { position: absolute; right: -10px; top: -2px; display: flex; gap: 6px; align-items: center; opacity: 0; transition: opacity .15s; }
.pf-q:hover .pf-qtools { opacity: 1; }
.pf-qtopic { font-family: var(--mono); font-size: 9.5px; color: #b9b1a4; }
.pf-qrow { display: flex; gap: 14px; margin-top: 16px; }
.pf-qnum { font-weight: 800; min-width: 22px; }
.pf-qcontent { flex: 1; min-width: 0; }
.pf-rubric { font-style: italic; font-size: 13px; margin: 0 0 8px; }
.pf-stem { margin-bottom: 10px; }
.pf-part { margin-bottom: 8px; position: relative; }
.pf-plabel { font-weight: 700; float: left; margin-right: 10px; }
.pf-ptext { overflow: hidden; }
.pf-marks { text-align: right; font-weight: 700; font-size: 13.5px; margin: 2px 2px 0 0; }
.pf-qtotal { text-align: right; font-size: 12.5px; margin-top: 2px; font-weight: 600; }
.pf-qsep { border: none; border-top: 1px solid #d8d2c7; margin: 14px 0 0; }
.pf-endline { text-align: center; font-weight: 800; margin: 30px 0 8px; letter-spacing: .5px; }
.pf-footnote { margin: 8px auto 0; text-align: center; }

.pf-ans {
  margin-top: 8px;
  background: repeating-linear-gradient(to bottom, transparent 0, transparent calc(2.1em - 1px), rgba(0,0,0,.2) calc(2.1em - 1px), rgba(0,0,0,.2) 2.1em);
  background-size: 100% 2.1em;
}
.pf-ansline { display: flex; align-items: flex-end; gap: 8px; margin: 6px 0 2px; }
.pf-dots { flex: 1; border-bottom: 2px dotted #555; height: 1.4em; max-width: 380px; margin-left: auto; }
.pf-unit { font-size: 14px; }

.pf-inline-ans { background: var(--sage-tint); border: 1px solid #bcd6b4; border-radius: 8px; padding: 8px 12px; font-size: 13.5px; margin-top: 8px; }

.pf-markrow { margin-top: 8px; font-size: 12.5px; color: var(--ink-2); display: flex; align-items: center; gap: 7px; font-family: var(--sans); }
.pf-markin { width: 56px; border: 1px solid var(--line-2); border-radius: 7px; padding: 4px 7px; font-family: var(--mono); font-size: 13px; text-align: center; }
.pf-markin:focus { outline: none; border-color: var(--clay); box-shadow: 0 0 0 3px var(--clay-ring); }
.pf-markmax { color: var(--ink-3); font-family: var(--mono); }
.pf-score { font-family: var(--mono); font-size: 12.5px; color: var(--ink); background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 5px 11px; display: inline-flex; align-items: center; gap: 6px; }
.pf-grade { font-family: var(--sans); font-weight: 700; font-size: 17px; color: var(--gold-ink); background: var(--gold); border-radius: 6px; padding: 1px 9px; line-height: 1.4; }
.pf-grade-note { font-family: var(--sans); font-size: 9.5px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .05em; }

/* maths typography */
.pf-sheet i { font-family: "Times New Roman", Times, serif; font-size: 1.08em; }
.frac { display: inline-flex; flex-direction: column; align-items: center; vertical-align: -0.55em; line-height: 1.15; margin: 0 2px; font-size: .95em; }
.frac > span:first-child { border-bottom: 1.4px solid currentColor; padding: 0 4px 0; }
.frac > span:last-child { padding: 0 4px; }
.rt { border-top: 1.4px solid currentColor; padding: 0 2px; }
.pf-int { font-size: 1.7em; vertical-align: -0.25em; }
.pf-lims { display: inline-flex; flex-direction: column; font-size: .72em; vertical-align: 0.45em; line-height: 1.25; margin-right: 3px; }
.pf-vec { text-decoration: overline; font-style: italic; font-family: "Times New Roman", serif; }
.cvec { display: inline-flex; flex-direction: column; align-items: center; line-height: 1.05; vertical-align: middle; border-left: 1.6px solid currentColor; border-right: 1.6px solid currentColor; border-radius: 9px / 16px; padding: 2px 6px; margin: 0 2px; }
.cvec3 { display: inline-flex; flex-direction: column; align-items: center; line-height: 1.15; vertical-align: middle; border-left: 1.6px solid currentColor; border-right: 1.6px solid currentColor; border-radius: 9px / 22px; padding: 2px 7px; margin: 0 2px; }
.pf-stemleaf td:first-child { border-right: 2px solid var(--qink); font-weight: 700; }
.pf-formula { font-size: 13.5px; border: 1px solid #999; padding: 3px 10px; display: inline-block; }
.pf-datalist { letter-spacing: .5px; }
.pf-code { font-family: "Geist Mono", ui-monospace, monospace; font-size: .92em; background: #f0eee9; border: 1px solid #ddd8ce; border-radius: 4px; padding: 1px 6px; letter-spacing: .5px; }
.pf-extract { display: block; border-left: 3px solid #b9b1a4; padding: 8px 14px; margin: 8px 0; font-style: italic; color: #2a2a2a; line-height: 1.6; background: #faf9f6; }

.pf-diawrap { margin: 10px 0; }
.pf-dianote { text-align: right; font-size: 11.5px; font-style: italic; margin-bottom: 2px; color: #333; }
.pf-diagram { max-width: 100%; height: auto; display: block; margin: 0 auto; }
.pf-treep { font-family: Arial, sans-serif; font-size: 12px; text-align: center; color: #1a1a1a; }
.pf-treep .frac { vertical-align: middle; }

.pf-table { border-collapse: collapse; margin: 6px 0; font-size: 14px; }
.pf-table th, .pf-table td { border: 1px solid var(--qink); padding: 5px 12px; text-align: center; }
.pf-table th { background: #f0eee9; font-weight: 700; }
.pf-blank { display: inline-block; min-width: 36px; min-height: 1em; }

/* mark scheme */
.pf-ms-head h2 { margin: 0 0 4px; font-family: Arial, sans-serif; }
.pf-ms-head { margin-bottom: 16px; font-size: 13px; color: #444; }
.pf-mstable { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.pf-mstable th, .pf-mstable td { border: 1px solid #b3ada2; padding: 6px 10px; vertical-align: top; text-align: left; }
.pf-mstable th { background: #efece6; }
.pf-ms-q { font-weight: 700; white-space: nowrap; }
.pf-ms-code { font-family: var(--mono); font-weight: 600; white-space: nowrap; text-align: center; }
.pf-ms-ansrow td { background: #f7f4ee; border-bottom: 2px solid #8a8175; }
/* Restated question rows — the wording of each question sits above its scheme so
   the mark scheme is self-contained and reads 1:1 with the question paper. */
.pf-ms-qtext td { background: #fbf9f4; border-top: 2px solid #8a8175; }
.pf-ms-stemrow td { background: #f4efe4; }
.pf-ms-question { font-weight: 500; color: #2a2620; }
.pf-ms-question::before { content: "Q "; font-weight: 700; color: var(--clay-deep); }
.pf-ms-stemrow .pf-ms-question::before { content: ""; }
.pf-ms-diagram { margin-top: 8px; }
.pf-ms-diagram svg, .pf-ms-diagram img { max-width: 240px; height: auto; }
.pf-mscodes { font-size: 11.5px; color: #666; margin-top: 14px; }

/* ── Responsive ─────────────────────────────────────────────────────────── */
/* Floating "edit settings" button — desktop-hidden; revealed on mobile once a
   paper exists so the controls are one tap away without a long scroll up. */
.pf-edit-fab { display: none; }

@media (max-width: 920px) {
  .pf-layout { flex-direction: column; }
  .pf-sidebar { width: 100%; position: static; max-height: none; min-height: 0; border-right: none; border-bottom: 1px solid var(--line); }
  .pf-main { padding: 16px 12px 84px; }
  /* On mobile let the branding header scroll away and pin the toolbar instead,
     so Paper / Mark scheme / Print stay reachable while reading a long paper. */
  .pf-header { position: static; }
  .pf-toolbar {
    position: sticky; top: 0; z-index: 25;
    margin: 0 -12px 14px; padding: 10px 12px;
    background: var(--surface); border-bottom: 1px solid var(--line);
    box-shadow: 0 5px 16px rgba(0, 0, 0, 0.06);
  }
  .pf-sheet { padding: 26px 18px 40px; }
  .pf-empty h2 { font-size: 32px; }
  .pf-header .pf-tag { display: none; }
  html.pf-has-paper .pf-edit-fab {
    display: inline-flex; align-items: center; gap: 6px;
    position: fixed; left: 14px; bottom: 16px; z-index: 40;
    padding: 11px 17px; border: none; cursor: pointer;
    background: #1f1a12; color: #fff; font-weight: 600; font-size: 13.5px;
    border-radius: 999px; box-shadow: 0 8px 22px rgba(0, 0, 0, 0.22);
  }
  html.pf-has-paper .pf-edit-fab:active { transform: translateY(1px); }
}

/* ── Print ──────────────────────────────────────────────────────────────── */
@media print {
  @page { size: A4; margin: 13mm 14mm; }
  body { background: #fff; }
  .pf-header, .pf-sidebar, .pf-toolbar, .no-print { display: none !important; }
  .pf-main { padding: 0; }
  .pf-layout { display: block; }
  .pf-sheet { display: none; box-shadow: none; border: none; border-radius: 0; max-width: none; padding: 0; font-size: 13.5px; background-image: none; }
  .pf-sheet.active { display: block; }
  .pf-sheet::before, .pf-sheet::after { display: none !important; }
  .pf-inline-ans { display: none !important; }
  .pf-q { break-inside: avoid; }
  .pf-cover { break-after: page; }
  .pf-mstable tr { break-inside: avoid; }
  /* keep the faint answer-writing lines when printing (they're light, so minimal ink) */
  .pf-ans { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .pf-markrow { display: none !important; }
}

/* ── Motion / animation layer (screen-only, print-safe, reduced-motion aware) ─ */
@keyframes pf-reveal { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes pf-fade   { from { opacity: 0; } to { opacity: 1; } }
@keyframes pf-pop    { 0% { transform: scale(.6); opacity: 0; } 60% { transform: scale(1.12); } 100% { transform: scale(1); opacity: 1; } }
@keyframes pf-shimmer{ 0% { background-position: -340px 0; } 100% { background-position: 340px 0; } }
@keyframes pf-spin   { to { transform: rotate(360deg); } }
@keyframes pf-pulse  { 0%,100% { box-shadow: 0 0 0 0 var(--clay-ring); } 50% { box-shadow: 0 0 0 6px transparent; } }

/* staggered question reveal when a fresh paper renders */
.pf-animate .pf-q { animation: pf-reveal .5s cubic-bezier(.16,.84,.44,1) both; animation-delay: calc(min(var(--qi, 0), 16) * 0.045s); }
.pf-animate .pf-cover, .pf-animate .pf-mini-cover { animation: pf-reveal .5s cubic-bezier(.16,.84,.44,1) both; }
.pf-sheet.active { animation: pf-fade .35s ease both; }
#toolbar { animation: pf-fade .3s ease both; }

/* grade badge pops in; the score chip pulses on update */
.pf-grade { animation: pf-pop .42s cubic-bezier(.16,.9,.3,1.2) both; }
.pf-score.pf-bump { animation: pf-fade .25s ease; }

/* empty-state hero gentle entrance */
.pf-empty-eyebrow { animation: pf-fade .5s ease both; }
.pf-empty h2 { animation: pf-reveal .6s cubic-bezier(.16,.84,.44,1) both; animation-delay: .05s; }
.pf-empty p { animation: pf-reveal .6s cubic-bezier(.16,.84,.44,1) both; animation-delay: .12s; }
.pf-empty-step { animation: pf-reveal .55s cubic-bezier(.16,.84,.44,1) both; }
.pf-empty-steps .pf-empty-step:nth-child(1) { animation-delay: .18s; }
.pf-empty-steps .pf-empty-step:nth-child(2) { animation-delay: .26s; }
.pf-empty-steps .pf-empty-step:nth-child(3) { animation-delay: .34s; }
.pf-empty-cta { animation: pf-reveal .55s cubic-bezier(.16,.84,.44,1) both; animation-delay: .42s; }
.pf-empty-stats { animation: pf-fade .8s ease both; animation-delay: .5s; }

/* button press + active feedback */
.pf-generate:active, .pf-btn:active, .pf-segbtn:active, .pf-chip:active { transform: translateY(1px) scale(.99); }
.pf-generate, .pf-btn, .pf-segbtn, .pf-chip, .pf-tab, .pf-mini { transition: transform .08s ease, background .14s ease, border-color .14s ease, color .14s ease, box-shadow .14s ease; }
.pf-chip.on { animation: pf-pop .28s cubic-bezier(.16,.9,.3,1.2); }

/* "forging" shimmer overlay shown briefly while a paper is built */
.pf-forging { position: relative; min-height: 220px; }
.pf-forging::after {
  content: "Building your paper…"; position: absolute; inset: 0; display: grid; place-items: center;
  font-family: var(--sans); font-weight: 600; font-size: 19px; color: var(--ink-3);
  background: linear-gradient(100deg, transparent 30%, rgba(253,176,61,.16) 50%, transparent 70%);
  background-size: 680px 100%; animation: pf-shimmer 1.1s linear infinite;
}

/* generate button gets a subtle pulse on hover to invite the click */
.pf-generate:hover { animation: pf-pulse 1.6s ease-in-out infinite; }

@media (prefers-reduced-motion: reduce) {
  .pf-animate .pf-q, .pf-animate .pf-cover, .pf-animate .pf-mini-cover, .pf-sheet.active, #toolbar,
  .pf-grade, .pf-empty-eyebrow, .pf-empty h2, .pf-empty p, .pf-empty-step, .pf-empty-cta, .pf-empty-stats,
  .pf-chip.on { animation: none !important; }
  .pf-generate:hover { animation: none !important; }
  .pf-forging::after { animation: none !important; }
  * { transition-duration: .01ms !important; }
}

/* ── Reference inserts (periodic table / equation & formula sheets) ──────── */
.pf-insert { margin: 8px 0 26px; padding-bottom: 22px; border-bottom: 2px solid var(--qink); }
.pf-insert-h { font-family: Arial, Helvetica, sans-serif; font-size: 19px; font-weight: 800; margin: 0 0 4px; color: var(--qink); }
.pf-insert-note { font-size: 11px; color: #555; margin-top: 12px; line-height: 1.5; }
.pf-pt-key { font-size: 11.5px; color: #333; margin-bottom: 10px; }

/* periodic table: 18-column grid */
.pf-pt {
  display: grid; grid-template-columns: repeat(18, 1fr); gap: 2px;
  font-family: Arial, Helvetica, sans-serif;
}
.pf-pt-cell {
  border: 1px solid #999; border-radius: 2px; padding: 2px 1px 1px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 30px; background: #fff; line-height: 1.05;
}
.pf-pt-ar { font-size: 6.5px; color: #444; }
.pf-pt-sym { font-size: 11px; font-weight: 700; color: var(--qink); }
.pf-pt-z { font-size: 6.5px; color: #444; }
.pf-pt-gl { font-size: 8px; color: #777; text-align: center; align-self: end; }

/* equation / formula sheets: tidy two-column reference card */
.pf-eqcols { columns: 2; column-gap: 26px; font-family: Arial, Helvetica, sans-serif; }
.pf-eqgroup { break-inside: avoid; margin-bottom: 12px; }
.pf-eqgroup h3 { font-size: 12.5px; font-weight: 800; margin: 0 0 5px; color: var(--slate); text-transform: uppercase; letter-spacing: .03em; }
.pf-eqgroup ul { margin: 0; padding-left: 16px; }
.pf-eqgroup li { font-size: 12.5px; margin-bottom: 5px; line-height: 1.45; color: var(--qink); }

@media (max-width: 620px) { .pf-eqcols { columns: 1; } .pf-pt-sym { font-size: 9px; } .pf-pt-cell { min-height: 24px; } }
@media print {
  .pf-insert { break-after: page; }
  .pf-pt-cell { background: #fff !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
