/* ==========================================================================
   UK Secondary Maths Teacher Worksheet Generator — Clean Minimalist Styles
   ========================================================================== */

:root {
  --bg-app: #f1f5f9;
  --bg-panel: #ffffff;
  --text-main: #0f172a;
  --text-muted: #475569;
  --border-color: #cbd5e1;
  --primary: #1e40af;
  --primary-hover: #1e3a8a;
  --primary-light: #eff6ff;
  --accent-emerald: #059669;
  --radius: 10px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg-app);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Top Bar */
.app-header {
  background: #0f172a;
  color: #ffffff;
  padding: 0.85rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.15);
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.brand-badge {
  background: #3b82f6;
  color: #ffffff;
  font-weight: 800;
  font-size: 0.78rem;
  padding: 0.32rem 0.65rem;
  border-radius: 6px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.brand-title h1 {
  font-size: 1.08rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.brand-title p {
  font-size: 0.76rem;
  color: #94a3b8;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
}

/* Main Workspace Layout */
.app-layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 1.5rem;
  max-width: 1480px;
  margin: 0 auto;
  padding: 1.4rem;
  align-items: start;
}

@media (max-width: 1024px) {
  .app-layout {
    grid-template-columns: 1fr;
  }
}

/* Sidebar Controls */
.controls-card {
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 1.2rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  position: sticky;
  top: 4.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.control-section-title {
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.42rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.year-pills {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.35rem;
}

.year-pill {
  border: 1px solid var(--border-color);
  background: #f8fafc;
  color: var(--text-main);
  padding: 0.48rem 0.2rem;
  border-radius: 7px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s ease;
}

.year-pill:hover {
  border-color: #94a3b8;
  background: #f1f5f9;
}

.year-pill.active {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
}

.year-pill .yr-num {
  display: block;
  font-size: 0.88rem;
  font-weight: 700;
}

.year-pill .yr-ks {
  display: block;
  font-size: 0.64rem;
  opacity: 0.85;
}

.form-select,
.form-input {
  width: 100%;
  padding: 0.52rem 0.7rem;
  border: 1px solid var(--border-color);
  border-radius: 7px;
  font-size: 0.86rem;
  font-family: inherit;
  color: var(--text-main);
  background-color: #ffffff;
}

.form-select:focus,
.form-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(30, 64, 175, 0.12);
}

.diff-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.42rem;
}

.diff-btn {
  border: 1px solid var(--border-color);
  background: #f8fafc;
  padding: 0.5rem 0.6rem;
  border-radius: 7px;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s ease;
}

.diff-btn .diff-title {
  font-size: 0.8rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.diff-btn .diff-desc {
  font-size: 0.68rem;
  color: var(--text-muted);
  margin-top: 0.1rem;
}

.diff-btn.active {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary);
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.dot-mixed { background: #3b82f6; }
.dot-bronze { background: #d97706; }
.dot-silver { background: #64748b; }
.dot-gold { background: #eab308; }

.two-col-inputs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.7rem;
}

.form-label {
  display: block;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.28rem;
}

.chip-row {
  display: flex;
  gap: 0.3rem;
  margin-top: 0.35rem;
  flex-wrap: wrap;
}

.chip {
  font-size: 0.7rem;
  padding: 0.2rem 0.48rem;
  border-radius: 5px;
  border: 1px solid var(--border-color);
  background: #f8fafc;
  cursor: pointer;
  font-weight: 600;
  color: var(--text-muted);
}

.chip:hover,
.chip.active {
  background: #e2e8f0;
  color: var(--text-main);
  border-color: #94a3b8;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.81rem;
  color: var(--text-main);
  cursor: pointer;
  user-select: none;
  padding: 0.18rem 0;
}

.checkbox-row input {
  width: 15px;
  height: 15px;
  accent-color: var(--primary);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.5rem 0.9rem;
  border-radius: 7px;
  font-size: 0.83rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease;
  font-family: inherit;
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
}
.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-emerald {
  background: var(--accent-emerald);
  color: #ffffff;
}
.btn-emerald:hover {
  background: #047857;
}

.btn-outline {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.24);
}
.btn-outline:hover {
  background: rgba(255, 255, 255, 0.18);
}

/* Preview Area */
.preview-column {
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

.preview-toolbar {
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 0.7rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.tab-group {
  display: flex;
  background: #f1f5f9;
  padding: 0.22rem;
  border-radius: 7px;
  gap: 0.22rem;
}

.tab-btn {
  border: none;
  background: transparent;
  padding: 0.38rem 0.8rem;
  border-radius: 5px;
  font-size: 0.81rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
}

.tab-btn.active {
  background: #ffffff;
  color: var(--text-main);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

/* Classroom Timer Banner */
.timer-banner {
  background: #0f172a;
  color: #ffffff;
  border-radius: var(--radius);
  padding: 0.8rem 1.2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.timer-banner.hidden {
  display: none;
}

.timer-display {
  font-size: 1.9rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
  color: #38bdf8;
}

.timer-display.warning { color: #fbbf24; }
.timer-display.expired { color: #f87171; }

/* ==========================================================================
   SIMPLE A4 PRINTABLE WORKSHEET STYLING
   - Starts with Title and Name
   - Question by question (1 per row)
   - Plenty of blank working space (2-3 per page, longer ones 1 per page)
   ========================================================================== */

.paper-sheet {
  background: #ffffff;
  color: #000000;
  width: 100%;
  max-width: 210mm;
  min-height: 297mm;
  margin: 0 auto;
  padding: 15mm 16mm;
  box-shadow: 0 6px 24px rgba(15, 23, 42, 0.08);
  border: 1px solid #cbd5e1;
  border-radius: 3px;
}

.paper-sheet.hidden-on-screen {
  display: none;
}

/* Ultra-Simple Top Header: Title + Name Only */
.ws-simple-header {
  border-bottom: 2px solid #000000;
  padding-bottom: 0.7rem;
  margin-bottom: 1.2rem;
}

.ws-title-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: 0.65rem;
}

.ws-title {
  font-size: 1.3rem;
  font-weight: 800;
  color: #000000;
  letter-spacing: -0.01em;
}

.ws-subtitle {
  font-size: 0.85rem;
  font-weight: 600;
  color: #334155;
  white-space: nowrap;
}

.ws-name-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1.5rem;
  font-size: 0.95rem;
}

.name-field {
  flex: 1;
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}

.name-line {
  flex: 1;
  border-bottom: 1.5px solid #000000;
  height: 1.1rem;
}

.date-field {
  width: 170px;
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}

/* Question-by-Question Single-Column List */
.ws-questions-list {
  display: flex;
  flex-direction: column;
}

.q-block {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border-bottom: 1px solid #e2e8f0;
  padding: 1rem 0 0.85rem 0;
  break-inside: avoid;
  page-break-inside: avoid;
}

/* Spacing modes for 2-3 questions per page vs 1 per page for longer questions */
.spacing-auto .q-block.q-standard,
.spacing-3per .q-block {
  min-height: 78mm;
}

.spacing-2per .q-block {
  min-height: 112mm;
}

.spacing-auto .q-block.q-long,
.spacing-1per .q-block {
  min-height: 220mm;
  page-break-before: always;
  break-before: page;
  page-break-after: always;
  break-after: page;
}

/* If the very first question on the sheet happens to be long, don't leave a blank page before Q1 */
.spacing-auto .ws-questions-list > .q-block.q-long:first-child,
.spacing-1per .ws-questions-list > .q-block:first-child {
  page-break-before: auto;
  break-before: auto;
}

.q-top-row {
  display: flex;
  align-items: baseline;
  gap: 0.65rem;
}

.q-num {
  font-weight: 800;
  font-size: 1.05rem;
  min-width: 1.8rem;
  color: #000000;
}

.q-prompt {
  flex: 1;
  font-size: 1.04rem;
  line-height: 1.65;
  color: #000000;
}

/* Crisp KaTeX sizing inside questions */
.q-prompt .katex {
  font-size: 1.12em;
}

.q-prompt .katex-display {
  margin: 0.55rem 0;
  text-align: left;
  padding-left: 0.5rem;
}

.q-regen-btn {
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 5px;
  font-size: 0.72rem;
  padding: 0.2rem 0.5rem;
  cursor: pointer;
  color: #475569;
  font-weight: 600;
  opacity: 0.6;
  transition: opacity 0.15s;
}

.q-block:hover .q-regen-btn {
  opacity: 1;
}

.q-regen-btn:hover {
  background: #e2e8f0;
  color: #0f172a;
}

/* Large Blank Working Space */
.q-blank-space {
  flex: 1;
  width: 100%;
  min-height: 45mm;
}

.q-long .q-blank-space,
.spacing-1per .q-blank-space {
  min-height: 165mm;
}

/* Bottom Answer Line */
.q-footer-row {
  display: flex;
  justify-content: flex-end;
  align-items: baseline;
  gap: 0.75rem;
  padding-top: 0.5rem;
  font-size: 0.9rem;
}

.ans-line {
  display: inline-block;
  width: 160px;
  border-bottom: 1.5px dotted #000000;
}

.marks-tag {
  font-weight: 700;
  font-size: 0.85rem;
  color: #1e293b;
}

/* Geometry SVG */
.q-with-diagram {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
  flex-wrap: wrap;
}

.geom-svg {
  display: block;
  max-width: 195px;
  height: auto;
  flex-shrink: 0;
}

/* Mark Scheme Styling */
.ms-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem 1rem;
  margin-top: 0.75rem;
}

.ms-item {
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 0.6rem 0.75rem;
  break-inside: avoid;
  page-break-inside: avoid;
  font-size: 0.88rem;
}

.ms-item-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.25rem;
  border-bottom: 1px solid #e2e8f0;
  padding-bottom: 0.2rem;
}

.ms-qnum {
  font-weight: 800;
  color: #0f172a;
}

.ms-final-ans {
  font-weight: 700;
  color: #047857;
}

.ms-working {
  font-size: 0.8rem;
  color: #334155;
  line-height: 1.45;
  margin-top: 0.25rem;
}

/* ==========================================================================
   PRINT & PDF EXPORT MEDIA QUERY
   ========================================================================== */
@media print {
  @page {
    size: A4 portrait;
    margin: 12mm 14mm;
  }

  body {
    background: #ffffff !important;
    color: #000000 !important;
  }

  .no-print,
  .app-header,
  .controls-card,
  .preview-toolbar,
  .timer-banner,
  .q-regen-btn {
    display: none !important;
  }

  .app-layout,
  .preview-column {
    display: block !important;
    padding: 0 !important;
    margin: 0 !important;
    max-width: none !important;
  }

  .paper-sheet {
    box-shadow: none !important;
    border: none !important;
    padding: 0 !important;
    margin: 0 !important;
    max-width: none !important;
    width: 100% !important;
    min-height: auto !important;
  }

  .paper-sheet.print-page-break {
    break-before: page;
    page-break-before: always;
  }

  .paper-sheet.do-not-print {
    display: none !important;
  }

  .ms-final-ans {
    color: #000000 !important;
  }
}
/* Exam-style bank and paper layout. */
[hidden] { display:none !important; }
.app-header { position:relative; align-items:flex-start; }
.brand-group { min-width:280px; }
.brand-title h1 { font-size:1.2rem; }
.brand-badge { background:#176f61; white-space:nowrap; }
.header-actions { justify-content:flex-end; }
.controls-card { top:1rem; position:relative; }
.control-note,.bank-notice { font-size:.78rem;color:#475569; }
.bank-notice { padding:0 .4rem; }
.paper-sheet { font-family:Arial,Helvetica,sans-serif; }
.ws-title { font-size:20px; margin:8px 0 18px; }
.exam-kicker { font-size:10px; font-weight:bold; letter-spacing:1.3px; }
.exam-meta { margin:15px 0 6px;font-size:13px;font-weight:bold; }
.exam-instructions,.exam-origin { font-size:11px;line-height:1.5;margin:6px 0; }
.exam-origin { color:#555; }
.q-block { border-bottom:0;position:relative;padding:5mm 0;display:block;min-height:0; }
.q-top-row { align-items:flex-start; }
.q-prompt { min-width:0;font-size:14px;line-height:1.6; }
.q-prompt:empty { display:none; }
.q-num { font-size:15px; }
.exam-part { margin:3mm 0 0 9mm; }
.part-prompt { font-size:14px;line-height:1.65; }
.part-working { min-height:var(--work-height,30mm); }
.part-answer { display:flex;justify-content:flex-end;gap:20px;align-items:baseline;font-size:13px; }
.answer-dots { width:48mm;border-bottom:1px dotted #111; }
.question-total { text-align:right;font-size:12px;font-weight:bold;margin-top:5mm; }
.question-ref { font-size:9px;color:#777; margin-left:9mm; }
.spacing-auto .q-block.q-standard,.spacing-3per .q-block { min-height:75mm; }
.spacing-auto .q-block.q-long,.spacing-2per .q-block { min-height:110mm;break-before:auto;break-after:auto;page-break-before:auto;page-break-after:auto; }
.spacing-1per .q-block { min-height:225mm;break-before:auto;break-after:page; }
.spacing-1per .q-block:last-child {break-after:auto;}
.exam-figure { margin:4mm auto;text-align:center;max-width:100%; }
.exam-figure svg { max-width:100%;height:auto;display:block;margin:auto; }
.exam-figure figcaption {font-size:10px;text-align:right;margin-top:2mm;}
.exam-table {border-collapse:collapse;margin:4mm 0;max-width:100%;width:auto;font-size:12px;}
.exam-table td,.exam-table th {border:1px solid #111;padding:6px 10px;min-width:30px;text-align:center;height:30px;}
.exam-table th {font-weight:600;background:#f9f9f9;}
.ms-grid {display:block;}
.ms-item {border-radius:0;margin:0 0 5mm;padding:4mm;font-size:12px;}
.ms-item-header {font-size:11px;}
.ms-final-ans {color:#111;font-size:13px;font-weight:normal;margin:3mm 0;}
.question-metadata {font-size:10px;color:#555;margin:3mm 0;}
.scheme-table {width:100%;border-collapse:collapse;font-size:11px;}
.scheme-table th {width:35px;vertical-align:top;text-align:left;padding:5px;border:1px solid #bbb;}
.scheme-table td {padding:5px;border:1px solid #bbb;}
.ms-part {margin:3mm 0;}
.ws-block + .ws-block {break-before:page;margin-top:10mm;}
.bank-browser {background:#fff;padding:1.5rem;border:1px solid #cbd5e1;border-radius:10px;}
.bank-heading,.bank-search-row,.bank-pagination {display:flex;gap:12px;align-items:center;justify-content:space-between;margin-bottom:15px;flex-wrap:wrap;}
.bank-heading h2 {font-size:20px;}
.bank-browser>p {font-size:13px;color:#475569;margin-bottom:16px;}
.bank-search-row input[type=search] {max-width:330px;}
.bank-search-row label,.bank-pagination {font-size:12px;}
.bank-pagination .btn {background:#f1f5f9;border:1px solid #cbd5e1;}
.btn:disabled {opacity:.4;cursor:default;}
.bank-result {border-top:1px solid #cbd5e1;padding:16px 0;font-size:14px;}
.bank-result .btn {margin-top:12px;font-size:12px;}
.bank-result details {margin-top:10px;}
.bank-result summary {cursor:pointer;color:#1e40af;}
.bank-answer {padding:12px;background:#f8fafc;}
.mark-step {margin:5px 0;font-size:13px;}
.question-part {margin:8px 0;}
.part-marks {float:right;margin-left:15px;font-weight:600;}
.standalone {background:white;padding:10mm;}
.standalone .q-regen-btn {display:none;}
@media(max-width:700px){.app-header {flex-direction:column;} .app-layout{padding:10px;gap:14px;} .paper-sheet{padding:8mm 5mm;} .header-actions{justify-content:flex-start;} .brand-group{flex-wrap:wrap;} .exam-part{margin-left:5mm;} .q-prompt,.part-prompt{font-size:13px;} .ws-name-row{flex-wrap:wrap;}.tab-group{flex-wrap:wrap;} .exam-table td,.exam-table th{padding:4px;} .date-field{width:120px;}}
@media print {
 body,.standalone {padding:0 !important;}
 .q-block,.ms-item {break-inside:avoid;page-break-inside:avoid;}
 .ws-questions-list {display:block;}
 .question-ref,.exam-origin {color:#555;}
 .ws-block + .ws-block {margin-top:0;}
 .exam-table th {background:white;}
 .paper-sheet.hidden-on-screen:not(.do-not-print) {display:block;}
}
.app-layout {grid-template-columns:340px minmax(0,1fr);}
.controls-card,.preview-column {min-width:0;}
.form-select,.form-input {min-width:0;}
@media(max-width:1024px){.app-layout {grid-template-columns:minmax(0,1fr);}}
@media(max-width:700px){.timer-banner{flex-wrap:wrap;}.timer-banner>div:last-child{flex-wrap:wrap;}.bank-browser{padding:1rem;}.exam-table{font-size:11px;}.paper-sheet{overflow-wrap:break-word;}}

/* Common GCSE-style question presentation, applied to every bank record. */
.q-prompt,.part-prompt {font-family:Arial,Helvetica,sans-serif;font-size:16px;line-height:1.5;color:#000;}
.q-top-row {gap:3mm;}
.q-num {font-size:16px;line-height:1.5;min-width:6mm;}
.part-prompt:empty {display:none;}
.exam-part {break-inside:avoid;page-break-inside:avoid;}
.exam-figure svg {filter:grayscale(1);}
.answer-dots {min-height:4mm;}
@media print {
 .q-prompt,.part-prompt {font-size:12pt;line-height:1.45;}
 .q-num {font-size:12pt;}
 .question-total {font-size:10pt;}
 .q-top-row {break-after:avoid;page-break-after:avoid;}
 .exam-figure,.exam-table {break-inside:avoid;page-break-inside:avoid;}
}
@media(max-width:700px){.q-prompt,.part-prompt{font-size:14px;}}

/* Multi-topic and exact-mark controls. */
[hidden] { display: none !important; }
.topic-checklist { max-height: 260px; overflow-y: auto; border: 1px solid var(--border-color); border-radius: 8px; padding: .4rem; }
.topic-choice { display: flex; align-items: flex-start; gap: .5rem; padding: .45rem .3rem; font-size: .82rem; line-height: 1.4; cursor: pointer; }
.topic-choice input { margin-top: .2rem; flex-shrink: 0; }
.topic-choice small { display: block; color: #8b3f16; }
.topic-actions { display: flex; gap: .4rem; margin-top: .6rem; }
.topic-breakdown { padding: .7rem 1rem; margin-bottom: 1rem; background: #fff; border: 1px solid var(--border-color); border-radius: 8px; font-size: .85rem; }
.topic-breakdown summary { cursor: pointer; font-weight: 600; }
.topic-breakdown li { margin: .4rem 0; }

.selected-topics { display: grid; gap: .45rem; margin: .5rem 0; }
.selected-topic { border: 1px solid #b8d2c9; border-radius: 7px; padding: .6rem; background: #f1f8f5; }
.selected-topic-heading { display: flex; gap: .35rem; justify-content: space-between; align-items: flex-start; font-size: .82rem; line-height: 1.4; }
.selected-topic small { display: block; color: #8b3f16; }
.topic-remove { flex-shrink: 0; width: 28px; height: 28px; border: 1px solid #a5bdb4; background: white; border-radius: 5px; font-size: 1.15rem; cursor: pointer; }
.topic-marks-label { display: flex; justify-content: space-between; align-items: center; gap: .6rem; margin-top: .4rem; font-size: .8rem; }
.topic-marks-label input { width: 90px; padding: .4rem; }
.allocation-summary { font-size: .82rem; line-height: 1.45; padding: .65rem; background: #edf1ff; border-radius: 6px; margin-top: .5rem; }
#topicSearchInput { margin-top: .15rem; }
#selectedTopicCount { margin-top: .75rem; }

/* ==========================================================================
   EXAMWIZARD MARK SCHEME & HIGHER METHODS BOOKLET MODEL SOLUTIONS
   ========================================================================== */
.examwizard-table { width: 100%; border-collapse: collapse; font-size: 11px; margin-top: 2mm; }
.examwizard-table thead th { background: #f1f5f9; color: #0f172a; font-weight: 700; text-align: left; padding: 5px 7px; border: 1px solid #94a3b8; }
.examwizard-table tbody td { padding: 5px 7px; border: 1px solid #cbd5e1; vertical-align: top; line-height: 1.45; }
.ew-col-part { width: 38px; text-align: center !important; }
.ew-col-work { width: 34%; }
.ew-col-ans { width: 18%; }
.ew-col-mark { width: 46px; text-align: center !important; }
.ew-col-notes { width: 34%; }
.ew-part-cell { text-align: center; font-weight: 700; color: #334155; }
.ew-ans-cell { color: #065f46; }
.ew-mark-cell { text-align: center; white-space: nowrap; }
.ew-notes-cell { color: #334155; font-size: 10.5px; }
.mark-code-pill { display: inline-block; padding: 1px 6px; border-radius: 4px; font-weight: 700; font-size: 10.5px; border: 1px solid #94a3b8; background: #f8fafc; color: #0f172a; }
.mark-M, .mark-P { background: #eff6ff; border-color: #93c5fd; color: #1e40af; }
.mark-A { background: #ecfdf5; border-color: #6ee7b7; color: #065f46; }
.mark-B { background: #fefce8; border-color: #fde047; color: #854d0e; }
.mark-C { background: #f5f3ff; border-color: #c4b5fd; color: #5b21b6; }

/* Model Solutions (Higher Methods Booklet 2023) */
.model-item { background: #ffffff; border: 1px solid #94a3b8; padding: 4.5mm; margin-bottom: 5mm; }
.model-part { border-top: 1px dashed #cbd5e1; padding-top: 3mm; margin-top: 3mm; }
.model-part:first-of-type { border-top: none; padding-top: 1mm; margin-top: 1mm; }
.model-part-header { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 2mm; }
.model-part-label { font-weight: 700; font-size: 12px; color: #0f172a; background: #e2e8f0; padding: 2px 7px; border-radius: 4px; }
.method-badge { display: inline-block; background: #0f172a; color: #ffffff; font-size: 10.5px; font-weight: 700; padding: 2px 8px; border-radius: 4px; letter-spacing: 0.01em; }
.method-rule { background: #f8fafc; border-left: 3px solid #0284c7; padding: 5px 9px; font-size: 11.5px; line-height: 1.45; color: #1e293b; margin-bottom: 2.5mm; }
.method-steps { display: flex; flex-direction: column; gap: 2mm; }
.method-step { font-size: 12px; line-height: 1.55; color: #0f172a; padding-left: 2mm; }
.model-ans-box { display: inline-block; border: 1.5px solid #047857; background: #ecfdf5; color: #065f46; font-weight: 700; padding: 1px 8px; border-radius: 4px; }

/* Booklet Grids & Structured Tables inside Model Solutions */
.method-grid, .method-table, .method-maths-reason { border-collapse: collapse; margin: 2mm 0; font-size: 11.5px; }
.method-grid th, .method-grid td { border: 1.5px solid #0f172a; padding: 4px 10px; text-align: center; min-width: 38px; }
.method-grid thead th, .method-grid tbody td:first-child { background: #f1f5f9; font-weight: 700; }
.method-table th, .method-table td, .method-maths-reason th, .method-maths-reason td { border: 1px solid #64748b; padding: 4px 8px; text-align: left; }
.method-table thead th, .method-maths-reason thead th { background: #e2e8f0; font-weight: 700; color: #0f172a; }

@media print {
  .method-badge { background: #f1f5f9 !important; color: #000 !important; border: 1px solid #000 !important; }
  .method-rule { background: #fff !important; border-left: 2.5px solid #000 !important; color: #000 !important; }
  .model-ans-box { background: #fff !important; color: #000 !important; border: 1.5px solid #000 !important; }
  .examwizard-table thead th, .method-grid thead th, .method-grid tbody td:first-child, .method-table thead th, .method-maths-reason thead th { background: #f8fafc !important; color: #000 !important; }
  .ew-ans-cell { color: #000 !important; }
  .shadow-toolbar { display: none !important; }
}

/* ==========================================================================
   SHADOW PAPER (PAPER A / PAPER B) & SAVED PAPERS / MEMORY
   ========================================================================== */
.btn-amber {
  background: #d97706;
  color: #ffffff;
}
.btn-amber:hover {
  background: #b45309;
}

.shadow-toolbar {
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 0.6rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.shadow-toolbar-left {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.65rem;
}

.shadow-toolbar-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.shadow-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.25rem 0.55rem;
  border-radius: 6px;
  background: #e2e8f0;
  color: #1e293b;
}

.shadow-badge.shadow-badge-active {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #f59e0b;
}

.save-paper-row {
  display: flex;
  gap: 0.45rem;
  margin-bottom: 0.3rem;
}

.save-paper-row .form-input {
  flex: 1;
}

.save-paper-row .btn {
  white-space: nowrap;
  padding: 0.48rem 0.75rem;
}

.saved-papers-list {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  max-height: 260px;
  overflow-y: auto;
  margin-top: 0.45rem;
}

.saved-paper-card {
  border: 1px solid var(--border-color);
  border-radius: 7px;
  padding: 0.55rem 0.65rem;
  background: #f8fafc;
}

.saved-paper-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.4rem;
}

.saved-paper-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.3;
}

.saved-paper-meta {
  font-size: 0.71rem;
  color: var(--text-muted);
  margin-top: 0.12rem;
}

.saved-ab-pill {
  display: inline-block;
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #f59e0b;
  font-weight: 700;
  font-size: 0.65rem;
  padding: 0 0.32rem;
  border-radius: 4px;
}

.saved-paper-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 0.45rem;
}

.chip-amber {
  background: #fffbeb;
  border-color: #f59e0b;
  color: #92400e;
}

.chip-amber:hover {
  background: #fef3c7;
  color: #78350f;
  border-color: #d97706;
}

.saved-papers-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.55rem;
}

.diff-btn-gcse {
  grid-column: 1 / -1;
}

.dot-gcse {
  background: #059669;
}

#generateAllSowBtn.active {
  background: #eff6ff;
  border-color: var(--primary);
  color: var(--primary);
}

.booklet-banner {
  background: #eff6ff;
  border: 1px solid #93c5fd;
  border-radius: var(--radius);
  padding: 0.65rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.booklet-banner[hidden] {
  display: none !important;
}

.booklet-banner-left {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.booklet-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.22rem 0.55rem;
  border-radius: 6px;
  background: var(--primary);
  color: #ffffff;
}

.booklet-banner-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: #1e3a8a;
}

.booklet-banner-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.booklet-jump-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: #1e3a8a;
}

.booklet-jump-select {
  width: auto;
  min-width: 240px;
  max-width: 340px;
  padding: 0.32rem 0.6rem;
  font-size: 0.8rem;
}



.booklet-jump-select {
  width: auto;
  min-width: 240px;
  max-width: 340px;
  padding: 0.32rem 0.6rem;
  font-size: 0.8rem;
}

/* ==========================================================================
   HIGHER METHODS BOOKLET 2023 — HANDWRITTEN MODEL SOLUTIONS
   ========================================================================== */
:root {
  --hw-font: 'Segoe Print', 'Bradley Hand', 'Chalkboard SE', 'Comic Sans MS', cursive, sans-serif;
  --hw-blue: #0f2cbd;
  --hw-red: #dc2626;
  --hw-green: #15803d;
  --hw-purple: #6d28d9;
}

.hw-question-stem {
  font-size: 13px;
  line-height: 1.5;
  color: #0f172a;
  background: #f8fafc;
  border-left: 3px solid #64748b;
  padding: 6px 10px;
  margin: 4px 0 8px 0;
}

.hw-booklet-card {
  border: 2px solid var(--hw-purple);
  border-radius: 6px;
  overflow: hidden;
  margin-top: 8px;
  padding: 0 !important;
  background: #ffffff;
  break-inside: avoid;
  page-break-inside: avoid;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

/* Top Purple-Bordered Method Header (Matches Higher Methods Booklet 2023) */
.hw-booklet-top {
  display: grid;
  grid-template-columns: 220px 1fr;
  border-bottom: 2px solid var(--hw-purple);
  background: #faf5ff;
}

.hw-booklet-title-col {
  padding: 8px 10px;
  border-right: 2px solid var(--hw-purple);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  background: #f3e8ff;
}

.hw-topic-title {
  font-weight: 800;
  font-size: 13px;
  color: #1e1b4b;
  line-height: 1.3;
}

.hw-page-pill {
  display: inline-block;
  align-self: flex-start;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--hw-purple);
  background: #ffffff;
  border: 1px solid #c4b5fd;
  padding: 1px 7px;
  border-radius: 999px;
}

.hw-booklet-rules-col {
  padding: 7px 12px;
  font-size: 12px;
  line-height: 1.45;
  color: #0f172a;
}

.hw-method-heading {
  font-weight: 800;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--hw-purple);
  margin-bottom: 2px;
}

.hw-rule-line {
  margin: 2px 0;
  font-weight: 600;
}

/* Lined / Squared Notebook Canvas for Handwritten Working */
.hw-notebook-canvas {
  padding: 10px 14px 12px 18px;
  background-color: #fffef9;
  background-image:
    linear-gradient(90deg, rgba(220, 38, 38, 0.14) 0, rgba(220, 38, 38, 0.14) 1.5px, transparent 1.5px),
    repeating-linear-gradient(0deg, transparent, transparent 27px, rgba(148, 163, 184, 0.22) 27px, rgba(148, 163, 184, 0.22) 28px);
  background-size: 100% 100%, 100% 28px;
  background-position: 10px 0, 0 4px;
}

.hw-examples-kicker {
  font-size: 10.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #475569;
  margin-bottom: 4px;
}

.hw-part-prompt {
  font-family: Arial, Helvetica, sans-serif;
  font-size: 12.5px;
  color: #0f172a;
  background: rgba(255, 255, 255, 0.85);
  border: 1px dashed #cbd5e1;
  border-radius: 4px;
  padding: 4px 8px;
  margin-bottom: 8px;
}

.hw-working-stage {
  font-family: var(--hw-font);
  font-size: 14px;
  line-height: 1.65;
  color: var(--hw-blue);
}

.hw-line {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 4px 0;
  color: var(--hw-blue);
}

.hw-step-num {
  font-weight: 800;
  color: var(--hw-red);
  flex-shrink: 0;
  min-width: 22px;
}

.hw-step-tag {
  font-weight: 800;
  color: var(--hw-red);
}

.hw-step-body {
  flex: 1;
  min-width: 0;
}

.hw-red, .hw-note-red {
  color: var(--hw-red) !important;
  font-weight: 700;
}

.hw-note-green {
  color: var(--hw-green) !important;
  font-weight: 700;
}

.hw-underline-red {
  text-decoration: underline wavy var(--hw-red);
  font-weight: 800;
  color: var(--hw-red);
}

.hw-mark-tag {
  font-family: Arial, sans-serif;
  font-size: 10px;
  font-weight: 700;
  color: #475569;
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  padding: 0 5px;
  margin-left: auto;
}

/* Stacked "Kill, kill" Equation Solver (Booklet p. 10–11) */
.hw-kill-wrap {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin: 4px 0;
}

.hw-kill-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 230px;
}

.hw-kill-row {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.hw-kill-eq {
  font-size: 15px;
  font-weight: 700;
  color: #0f172a;
  padding: 1px 6px;
}

.hw-kill-ops {
  display: flex;
  justify-content: space-around;
  max-width: 210px;
  color: var(--hw-red);
  font-weight: 800;
  font-size: 13.5px;
  border-bottom: 1.8px solid #94a3b8;
  padding-bottom: 2px;
  margin-bottom: 3px;
}

.hw-kill-op {
  color: var(--hw-red);
}

.hw-side-callout {
  border: 2px dashed var(--hw-red);
  background: #fef2f2;
  color: var(--hw-red);
  font-weight: 700;
  font-size: 12.5px;
  padding: 6px 10px;
  border-radius: 8px;
  max-width: 260px;
}

/* Hand-Drawn Double-Underlined / Red-Boxed Final Answer */
.hw-kill-final {
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.hw-final-label {
  font-weight: 800;
  color: var(--hw-red);
  font-size: 14px;
}

.hw-ans-box {
  display: inline-block;
  border: 2.4px solid var(--hw-red);
  border-radius: 6px 10px 7px 9px;
  background: #fff1f2;
  color: #0f2cbd;
  font-weight: 800;
  font-size: 15px;
  padding: 2px 12px;
  box-shadow: 2px 2px 0 rgba(220, 38, 38, 0.16);
}

/* Collecting Like Terms Shapes (Booklet p. 1) */
.hw-shapes-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: 6px 0;
}

.hw-shape-box {
  border: 2.2px solid var(--hw-blue);
  background: rgba(15, 44, 189, 0.06);
  color: var(--hw-blue);
  font-weight: 800;
  padding: 2px 9px;
  border-radius: 3px;
}

.hw-shape-oval {
  border: 2.2px solid var(--hw-red);
  background: rgba(220, 38, 38, 0.06);
  color: var(--hw-red);
  font-weight: 800;
  padding: 2px 11px;
  border-radius: 999px;
}

/* Handwritten Multiplication & Factorising Grids (Booklet p. 2, 3, 5, 6, 46) */
.hw-grid-layout {
  display: flex;
  align-items: flex-start;
  gap: 18px;
  flex-wrap: wrap;
  margin: 6px 0;
}

.hw-mini-label {
  font-size: 12.5px;
  font-weight: 700;
  color: #334155;
  margin-bottom: 4px;
}

.hw-mult-grid, .method-grid {
  border-collapse: collapse;
  margin: 4px 0;
  font-family: var(--hw-font);
  font-size: 14.5px;
  background: #ffffff;
}

.hw-mult-grid th, .hw-mult-grid td,
.method-grid th, .method-grid td {
  border: 2px solid #0f172a;
  padding: 5px 14px;
  text-align: center;
  min-width: 52px;
}

.hw-grid-corner {
  background: #f3e8ff;
  color: var(--hw-purple);
  font-weight: 800;
}

.hw-grid-hdr-top, .hw-grid-hdr-left {
  background: #fef9c3;
  color: #0f172a;
  font-weight: 800;
}

.hw-grid-cell {
  color: var(--hw-blue);
  font-weight: 700;
}

.hw-grid-diag {
  background: #fff1f2;
  outline: 2px dashed var(--hw-red);
  outline-offset: -3px;
}

/* a × c Factor Pair T-Table (Booklet p. 5–6) */
.hw-ac-card {
  border: 2px solid #cbd5e1;
  border-radius: 8px;
  padding: 6px 12px;
  background: #ffffff;
  text-align: center;
}

.hw-ac-title {
  font-weight: 800;
  color: #0f172a;
  border-bottom: 2px solid #0f172a;
  padding-bottom: 2px;
  margin-bottom: 4px;
}

.hw-ac-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.hw-ac-table td {
  padding: 2px 10px;
  color: #334155;
}

.hw-ac-table td:first-child {
  border-right: 2px solid #0f172a;
}

.hw-ac-chosen td {
  color: var(--hw-red);
  font-weight: 800;
  background: #fef2f2;
  border-top: 2px solid var(--hw-red);
  border-bottom: 2px solid var(--hw-red);
}

.hw-ac-check {
  margin-top: 4px;
  font-size: 12.5px;
  font-weight: 800;
  color: var(--hw-green);
}

.hw-tick {
  color: var(--hw-green);
  font-size: 14px;
}

/* Quadratic T-Split Branches (Booklet p. 12–13) */
.hw-quad-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 6px 0;
  border-top: 2px solid #0f172a;
  padding-top: 6px;
  max-width: 380px;
}

.hw-quad-branch {
  padding: 4px 8px;
  border-right: 2px solid #0f172a;
}

.hw-quad-branch:last-child {
  border-right: none;
}

/* Open-Frame Ratio / Proportion / L.A.V / DuSTy / MeDiVa / TiMoNe Tables */
.hw-ratio-wrap {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  margin: 4px 0;
}

.hw-ratio-arc {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.1;
}

.hw-arc-svg {
  width: 165px;
  height: 28px;
  display: block;
}

.hw-arc-label {
  font-size: 12.5px;
  font-weight: 800;
  color: var(--hw-red);
}

.hw-open-table, .method-table {
  border-collapse: collapse;
  margin: 4px 0;
  font-family: var(--hw-font);
  font-size: 13.5px;
  background: #ffffff;
}

.hw-open-table th, .hw-open-table td,
.method-table th, .method-table td {
  border: 1.8px solid #1e293b;
  padding: 4px 10px;
  text-align: center;
}

.hw-open-table thead th, .method-table thead th {
  background: #f1f5f9;
  color: #0f172a;
  font-weight: 800;
}

.hw-ratio-label-col {
  font-weight: 800;
  color: #0f172a;
  background: #f8fafc;
  text-align: left !important;
}

.hw-ratio-total-row td {
  border-top: 2.4px solid #0f172a;
  background: #fefce8;
  font-weight: 800;
}

/* Two-Column & Three-Column Booklet Layouts */
.hw-two-col {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.hw-two-col > div:first-child {
  flex: 1;
  min-width: 220px;
}

.hw-three-col {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
  margin: 6px 0;
}

.hw-col-card {
  border: 1.8px solid #94a3b8;
  border-radius: 6px;
  padding: 6px 9px;
  background: #ffffff;
  font-size: 13px;
}

.hw-col-hdr {
  font-weight: 800;
  color: var(--hw-purple);
  border-bottom: 1.5px solid #cbd5e1;
  padding-bottom: 2px;
  margin-bottom: 4px;
}

/* Formula Triangles & SVG Diagrams (SOH CAH TOA, DuSTy, MeDiVa, FiliPA, TiMoNe, cow food) */
.hw-tri-widget {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: #ffffff;
  border: 1.5px solid #cbd5e1;
  border-radius: 8px;
  padding: 6px 10px;
}

.hw-tri-mnemonic {
  font-size: 12px;
  font-weight: 800;
  color: var(--hw-red);
  margin-bottom: 2px;
}

.hw-tri-svg {
  width: 122px;
  height: auto;
  display: block;
}

.hw-parabola-svg {
  width: 165px;
  height: auto;
  background: #ffffff;
  border: 1.5px solid #cbd5e1;
  border-radius: 8px;
  padding: 4px;
}

.hw-warning-green {
  border: 2px dashed var(--hw-green);
  background: #f0fdf4;
  color: var(--hw-green);
  font-weight: 800;
  font-size: 12.5px;
  padding: 4px 10px;
  border-radius: 6px;
  margin-bottom: 6px;
}

.hw-formula-banner, .hw-kcf-banner {
  border: 2px solid var(--hw-red);
  background: #fff1f2;
  color: #0f172a;
  font-weight: 700;
  font-size: 13px;
  padding: 5px 10px;
  border-radius: 6px;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.hw-kcf-pill {
  background: #ffffff;
  border: 1.5px solid #0f172a;
  border-radius: 5px;
  padding: 2px 8px;
  font-weight: 800;
}

.hw-kcf-arrow {
  font-weight: 800;
  color: var(--hw-red);
}

/* Story of x Box (Booklet p. 28–31) */
.hw-story-card {
  border: 2px solid var(--hw-red);
  border-radius: 8px;
  background: #fff1f2;
  padding: 6px 10px;
  min-width: 175px;
}

.hw-story-title {
  font-weight: 800;
  color: var(--hw-red);
  text-align: center;
  border-bottom: 1.5px solid #fecdd3;
  padding-bottom: 2px;
  margin-bottom: 4px;
}

.hw-story-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  font-size: 12.5px;
}

.hw-story-sub {
  font-size: 11px;
  font-weight: 800;
  color: #475569;
}

.hw-story-item {
  font-weight: 700;
}

/* Bounds Fork & Sequence Arcs (Booklet p. 25, 63–65) */
.hw-bounds-fork, .hw-seq-diagram {
  margin: 4px 0;
}

.hw-bounds-svg, .hw-seq-svg {
  max-width: 340px;
  width: 100%;
  height: auto;
  display: block;
  background: #ffffff;
  border: 1.5px solid #cbd5e1;
  border-radius: 8px;
  padding: 4px;
}

.hw-bounds-ineq {
  margin-top: 6px;
  font-size: 14.5px;
  color: var(--hw-blue);
}

/* Coordinate Labels x₁ y₁ x₂ y₂ (Booklet p. 80–82) */
.hw-coord-pair {
  display: inline-flex;
  align-items: flex-end;
  gap: 14px;
  background: #ffffff;
  border: 1.5px dashed #94a3b8;
  border-radius: 8px;
  padding: 4px 12px;
  margin-bottom: 4px;
}

.hw-coord-item {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
}

.hw-coord-sup {
  font-size: 11.5px;
  font-weight: 800;
  color: var(--hw-red);
  line-height: 1.1;
}

.hw-coord-val {
  font-size: 14.5px;
  font-weight: 800;
  color: var(--hw-blue);
}

/* Circle Theorems Maths | Reason Table (Booklet p. 86, 92–94) */
.hw-mr-table, .method-maths-reason {
  width: 100%;
  border-collapse: collapse;
  margin: 6px 0;
  font-family: var(--hw-font);
  font-size: 13.5px;
  background: #ffffff;
}

.hw-mr-table th, .hw-mr-table td,
.method-maths-reason th, .method-maths-reason td {
  border: 2px solid #0f172a;
  padding: 5px 10px;
  vertical-align: top;
}

.hw-mr-table thead th, .method-maths-reason thead th {
  background: #f3e8ff;
  color: #1e1b4b;
  font-weight: 800;
}

.hw-mr-math {
  width: 42%;
  color: var(--hw-blue);
  font-weight: 700;
}

.hw-mr-reason {
  color: #0f172a;
}

@media (max-width: 700px) {
  .hw-booklet-top {
    grid-template-columns: 1fr;
  }
  .hw-booklet-title-col {
    border-right: none;
    border-bottom: 1.5px solid var(--hw-purple);
  }
}

/* Booklet review: concrete factor trees and region diagrams. */
.review-factor-tree { display:inline-flex; flex-direction:column; align-items:center; margin:6px 10px; color:#243eb8; }
.review-tree-branches { display:flex; gap:20px; padding-top:14px; }
.review-tree-branches>div { border-top:1px solid #243eb8; padding:8px 5px 0; text-align:center; }
.review-prime { border:2px solid #c22542; border-radius:50%; padding:3px 7px; display:inline-block; }
.review-venn { display:block; width:min(100%,360px); height:auto; margin:12px auto; font-family:Arial,sans-serif; font-size:13px; fill:#243eb8; }
.number-basics-trees { display:flex; flex-wrap:wrap; align-items:flex-start; justify-content:center; gap:12px 28px; }
.number-basics-trees>.review-factor-tree { break-inside:avoid; }
.review-bearing-diagram { display:block; width:min(100%,300px); height:auto; margin:8px auto; font:14px Arial,sans-serif; }
.hw-open-table td, .hw-open-table th { overflow-wrap:normal; }
.hw-question-stem .exam-figure { margin:10px auto; }

.review-plot {display:block;max-width:100%;width:500px;height:auto;margin:12px auto;font:12px Arial,sans-serif;fill:#334155;}

/* Keep step numbers beside the top of tables and diagrams. */
.hw-steps-list > .hw-line { align-items: flex-start; }

/* Per-question topic choices stay outside the printed paper. */
.q-swap-controls{display:flex;flex-wrap:wrap;align-items:center;justify-content:flex-end;gap:7px;margin:8px 0 10px;padding:8px;background:#f3f6f9;border:1px solid #dbe3ec;border-radius:6px;font:12px Arial,Helvetica,sans-serif;color:#405267}
.q-swap-controls label{font-weight:700;margin:0}.q-swap-controls select{max-width:min(340px,100%);min-width:180px;flex:1 1 220px;padding:6px 8px;border:1px solid #b9c7d5;border-radius:4px;background:white;font:12px Arial,Helvetica,sans-serif;color:#17212e}
.q-swap-controls .q-regen-btn{position:static;opacity:1;transform:none;margin:0;flex:none}.q-swap-controls small{flex-basis:100%;text-align:right;font-size:11px;color:#64758a}
@media print{.q-swap-controls{display:none!important}}.standalone .q-swap-controls{display:none}

/* ==========================================================================
   QUESTIONS PER PAGE — fixed A4 pages (1, 2 or 3 questions per page)
   Each .ws-page is one printed page. Its questions share the full height,
   and every answer line sits at the bottom of its question's space.
   ========================================================================== */
.ws-paged .ws-page { display:flex;flex-direction:column;min-height:270mm;position:relative; }
.ws-paged .ws-page + .ws-page { min-height:calc(270mm + 12mm);margin-top:12mm;padding-top:12mm;border-top:2px dashed #cbd5e1; }
.ws-paged .ws-page + .ws-page::before { content:'Page ' attr(data-page);position:absolute;top:-0.7em;left:50%;transform:translateX(-50%);background:#fff;padding:0 10px;font:600 10px/1.4 Arial,Helvetica,sans-serif;color:#94a3b8;letter-spacing:.08em;text-transform:uppercase; }
.ws-paged .ws-simple-header,.ws-paged .copyright-notice { flex:none; }
.ws-paged .copyright-notice { margin-top:3mm !important; }
.ws-paged .ws-page .ws-questions-list { flex:1 1 auto;display:flex;flex-direction:column; }
.ws-paged .ws-page .q-block { flex:1 1 0;min-height:auto;display:flex;flex-direction:column;padding:3mm 0 2mm;break-before:auto;break-after:auto;page-break-before:auto;page-break-after:auto; }
.ws-paged .ws-page .q-block + .q-block { border-top:1px solid #d5dbe3; }
.ws-paged .ws-page.overfull { outline:2px solid #f59e0b;outline-offset:4mm; }
@media print { .ws-paged .ws-page.overfull { outline:0; } }
.ws-paged .ws-page.overfull::after { content:'This question is longer than its space on one A4 page — choose fewer questions per page.';display:block;margin-top:2mm;font:600 11px Arial,Helvetica,sans-serif;color:#b45309;text-align:center; }

/* Working space grows to fill the question; the answer line stays at the bottom. */
.ws-paged .exam-part,
.spacing-auto .exam-part { display:flex;flex-direction:column;flex:var(--part-marks,1) 1 auto; }
.ws-paged .exam-part { flex-basis:0; }
.ws-paged .part-working,
.spacing-auto .part-working { flex:1 1 auto; }
.ws-paged .part-working { min-height:6mm; }
.ws-paged .part-answer,.spacing-auto .part-answer,
.ws-paged .question-total,.spacing-auto .question-total { flex:none; }
.spacing-auto .q-block { display:flex;flex-direction:column; }
.spacing-auto .q-top-row,.spacing-auto .question-ref,.ws-paged .q-top-row,.ws-paged .question-ref,.ws-paged .q-swap-controls { flex:none; }
.ws-paged .question-total { margin-top:2mm; }

@media print {
  .ws-paged .ws-page,
  .ws-paged .ws-page + .ws-page { min-height:270mm;margin:0;padding:0;border:0;outline:0;break-after:page;page-break-after:always; }
  .ws-paged .ws-page:last-child { break-after:auto;page-break-after:auto; }
  .ws-paged .ws-page + .ws-page::before,.ws-paged .ws-page.overfull::after { display:none; }
  .ws-paged .ws-page .q-block { break-inside:auto;page-break-inside:auto; }
}
