:root {
  --desk-bg: #EFECE6;
  --sheet-bg: #FFFFFF;
  --sheet-border: #D8D2C7;
  --ink: #18181B;
  --ink-secondary: #3F3F46;
  --muted: #57534E;
  --line-subtle: #E5E0D8;

  --note-bg: #FFF8F3;
  --note-border: #EAB896;
  --note-accent: #B44912;
  --note-ink: #7C2D12;

  --ans-bg: #F9FBF9;
  --ans-border: #CBD5CE;
  --ans-focus: #166534;
  --ans-badge-bg: #DCFCE7;
  --ans-badge-ink: #14532D;

  --hl-yellow: #FEF08A;
  --hl-tag-bg: #F4F1EA;

  --font-sans: 'Be Vietnam Pro', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-serif: 'Newsreader', Georgia, 'Times New Roman', Times, serif;
}

*, *::before, *::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

section[id],
div[id] {
  scroll-margin-top: 96px;
}

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

body {
  margin: 0;
  padding: 0;
  background-color: var(--desk-bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
}

/* Skip link */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 8px;
  background: var(--ink);
  color: #FFFFFF;
  padding: 8px 14px;
  border-radius: 4px;
  z-index: 1000;
  text-decoration: none;
  font-weight: 600;
}
.skip-link:focus-visible {
  left: 12px;
}

/* Sticky Top Document Bar */
.doc-toolbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: #1C1917;
  color: #FAFAF9;
  border-bottom: 1px solid #292524;
  padding: 10px 16px;
}

.toolbar-inner {
  max-width: 980px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
}

.doc-brand {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.doc-brand-course {
  font-size: 12px;
  font-weight: 600;
  color: #FDBA74;
  letter-spacing: 0.02em;
}

.doc-brand-title {
  font-size: 15px;
  font-weight: 700;
  color: #FFFFFF;
}

.save-status {
  font-size: 12px;
  color: #A8A29E;
  font-variant-numeric: tabular-nums;
}

.toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.btn {
  appearance: none;
  border: 1px solid #44403C;
  background-color: #292524;
  color: #F5F5F4;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.2;
  padding: 8px 12px;
  min-height: 36px;
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.btn:hover {
  background-color: #3F3A36;
}

.btn:active {
  transform: translateY(1px);
}

.btn:focus-visible,
input:focus-visible,
textarea:focus-visible,
a:focus-visible,
summary:focus-visible {
  outline: 2px solid #16A34A;
  outline-offset: 2px;
}

.btn-primary {
  background-color: #166534;
  border-color: #15803D;
  color: #FFFFFF;
}

.btn-primary:hover {
  background-color: #15803D;
}

.btn-accent {
  background-color: #9A3412;
  border-color: #C2410C;
  color: #FFFFFF;
}

.btn-accent:hover {
  background-color: #B44912;
}

.btn-light {
  background-color: #FFFFFF;
  border-color: var(--sheet-border);
  color: var(--ink);
}

.btn-light:hover {
  background-color: #F5F5F4;
}

/* Secondary Strip: Mode Switcher + Quick Jump */
.mode-strip {
  background-color: #F7F5F0;
  border-bottom: 1px solid var(--sheet-border);
  padding: 10px 16px;
}

.mode-strip-inner {
  max-width: 980px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
}

.preset-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.preset-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin-right: 4px;
}

.preset-btn {
  appearance: none;
  border: 1px solid var(--sheet-border);
  background-color: #FFFFFF;
  color: var(--ink-secondary);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  padding: 6px 12px;
  min-height: 34px;
  border-radius: 5px;
  cursor: pointer;
}

.preset-btn[aria-pressed="true"] {
  background-color: var(--ink);
  border-color: var(--ink);
  color: #FFFFFF;
}

.toggle-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.toggle-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-secondary);
  cursor: pointer;
  min-height: 32px;
}

.toggle-check input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--note-accent);
  cursor: pointer;
}

/* Quick Jump Nav */
.quick-nav {
  max-width: 900px;
  margin: 18px auto 0;
  padding: 0 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  padding: 5px 10px;
  background-color: #FFFFFF;
  border: 1px solid var(--sheet-border);
  border-radius: 4px;
  color: var(--ink-secondary);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.nav-link:hover {
  border-color: var(--ink);
  color: var(--ink);
}

/* Main A4 Paper Sheet */
.desk-wrap {
  max-width: 900px;
  margin: 14px auto 56px;
  padding: 0 16px;
}

.doc-sheet {
  background-color: var(--sheet-bg);
  border: 1px solid var(--sheet-border);
  border-radius: 4px;
  padding: 48px 56px;
}

/* Hide teacher notes cleanly when toggled off */
body.hide-teacher-notes .teacher-note,
body.hide-teacher-notes .para-tag,
body.hide-teacher-notes .opt-explain,
body.hide-teacher-notes .byline-tip {
  display: none !important;
}

/* Pre-reading box matching top of OneDrive doc */
.doc-header-block {
  border-bottom: 2px solid var(--ink);
  padding-bottom: 18px;
  margin-bottom: 28px;
}

.doc-kicker {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  margin: 0 0 4px;
  font-variant-numeric: tabular-nums;
}

.doc-main-heading {
  font-family: var(--font-serif);
  font-size: 28px;
  line-height: 1.2;
  font-weight: 700;
  margin: 0 0 12px;
  color: var(--ink);
  text-wrap: balance;
}

.teacher-note {
  background-color: var(--note-bg);
  border: 1px solid var(--note-border);
  border-left: 4px solid var(--note-accent);
  border-radius: 4px;
  padding: 12px 16px;
  margin: 12px 0 16px;
  color: var(--note-ink);
  font-size: 14.5px;
  line-height: 1.6;
}

.teacher-note-title {
  font-weight: 700;
  color: var(--note-accent);
  margin: 0 0 6px;
  font-size: 14.5px;
}

.teacher-note ul {
  margin: 0;
  padding-left: 20px;
}

.teacher-note li {
  margin-bottom: 5px;
}
.teacher-note li:last-child {
  margin-bottom: 0;
}

/* Whiteboard expandable figure */
.whiteboard-details {
  margin-top: 10px;
  background-color: #FFFFFF;
  border: 1px solid var(--note-border);
  border-radius: 4px;
  padding: 8px 12px;
}

.whiteboard-details summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--note-accent);
  font-size: 13.5px;
}

.whiteboard-fig {
  margin: 10px 0 4px;
}

.whiteboard-fig img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 4px;
  border: 1px solid var(--line-subtle);
}

.whiteboard-fig figcaption {
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 6px;
}

/* Reading Passage Section */
.passage-box {
  border: 1px solid var(--line-subtle);
  background-color: #FCFBF9;
  border-radius: 4px;
  padding: 28px 32px;
  margin-bottom: 36px;
}

.passage-title {
  font-family: var(--font-serif);
  font-size: 24px;
  font-weight: 700;
  margin: 0 0 4px;
  color: var(--ink);
  text-wrap: balance;
}

.passage-byline {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 16.5px;
  color: var(--note-accent);
  margin: 0 0 8px;
}

.hl-mark {
  background-color: var(--hl-yellow);
  color: var(--ink);
  padding: 1px 5px;
  border-radius: 2px;
  font-weight: 700;
}

.byline-tip {
  font-size: 13.5px;
  color: var(--note-ink);
  background-color: var(--note-bg);
  border-left: 3px solid var(--note-accent);
  padding: 6px 10px;
  margin: 0 0 18px;
}

.passage-para-wrap {
  margin-bottom: 16px;
}
.passage-para-wrap:last-child {
  margin-bottom: 0;
}

.para-tag {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  background-color: var(--hl-tag-bg);
  border: 1px solid var(--line-subtle);
  border-radius: 3px;
  padding: 2px 8px;
  margin-bottom: 4px;
}

.passage-para {
  font-family: var(--font-serif);
  font-size: 17.5px;
  line-height: 1.72;
  color: var(--ink);
  margin: 0;
}

.para-num {
  display: inline-block;
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  margin-right: 6px;
  font-variant-numeric: tabular-nums;
  user-select: none;
}

/* Part Headings */
.part-banner {
  border-top: 2px solid var(--ink);
  border-bottom: 1px solid var(--line-subtle);
  padding: 14px 0 10px;
  margin: 36px 0 24px;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.part-title {
  font-family: var(--font-serif);
  font-size: 21px;
  font-weight: 700;
  margin: 0;
  color: var(--ink);
}

.part-pts {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* Question Block */
.question-block {
  margin-bottom: 34px;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--line-subtle);
}

.question-block:last-of-type {
  border-bottom: none;
}

.q-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px 12px;
  margin-bottom: 8px;
}

.q-title {
  font-size: 16.5px;
  font-weight: 700;
  color: var(--ink);
  margin: 0;
  flex: 1 1 260px;
  min-width: 0;
  overflow-wrap: break-word;
}

.q-points {
  font-weight: 600;
  color: var(--note-accent);
  font-variant-numeric: tabular-nums;
}

.q-sublist {
  margin: 6px 0 12px;
  padding-left: 22px;
  color: var(--ink-secondary);
  font-size: 15px;
}

.q-mini-tools {
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-mini {
  appearance: none;
  background-color: #FFFFFF;
  border: 1px solid var(--sheet-border);
  color: var(--muted);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  padding: 4px 9px;
  min-height: 28px;
  border-radius: 4px;
  cursor: pointer;
}

.btn-mini:hover {
  color: var(--ink);
  border-color: var(--ink);
}

/* Q1 Checkboxes */
.checkbox-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
}

.check-card {
  border: 1px solid var(--ans-border);
  background-color: #FFFFFF;
  border-radius: 5px;
  padding: 12px 14px;
}

.check-card.is-checked {
  background-color: var(--ans-bg);
  border-color: var(--ans-focus);
}

.check-label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  font-weight: 500;
}

.check-label input[type="checkbox"] {
  width: 19px;
  height: 19px;
  margin-top: 3px;
  flex-shrink: 0;
  accent-color: var(--ans-focus);
  cursor: pointer;
}

.opt-explain {
  margin: 6px 0 0 29px;
  font-size: 13.5px;
  color: var(--muted);
}

/* Editable Document Fields */
.evidence-group {
  border: 1px solid var(--line-subtle);
  border-radius: 6px;
  padding: 16px 18px;
  margin-top: 16px;
  background-color: #FFFFFF;
}

.evidence-heading {
  font-size: 15.5px;
  font-weight: 700;
  color: var(--ink);
  margin: 0 0 12px;
  padding-bottom: 6px;
  border-bottom: 1px dashed var(--line-subtle);
}

.field-wrap {
  margin-bottom: 14px;
}
.field-wrap:last-child {
  margin-bottom: 0;
}

.field-label-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 5px;
}

.field-label {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-secondary);
}

.word-count {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.doc-input {
  display: block;
  width: 100%;
  font-family: var(--font-serif);
  font-size: 16.5px;
  line-height: 1.65;
  color: var(--ink);
  background-color: var(--ans-bg);
  border: 1px solid var(--ans-border);
  border-left: 3px solid var(--ans-focus);
  border-radius: 4px;
  padding: 10px 14px;
  resize: vertical;
  overflow-y: hidden;
}

.doc-input::placeholder {
  color: #78716C;
  font-style: italic;
}

.doc-input:focus-visible {
  background-color: #FFFFFF;
  border-color: var(--ans-focus);
}

/* Print mirror hidden on screen, shown on print so multi-line answers never clip */
.print-mirror {
  display: none;
  font-family: var(--font-serif);
  font-size: 12pt;
  line-height: 1.6;
  color: #000000;
  white-space: pre-wrap;
  word-break: break-word;
  border-left: 2px solid #333333;
  padding: 4px 0 4px 12px;
  margin-top: 4px;
}

/* Combined Part 2 Essay Preview */
.combined-essay-box {
  margin-top: 18px;
  padding: 16px 18px;
  background-color: #F8FAF8;
  border: 1px solid var(--ans-border);
  border-radius: 5px;
}

.combined-essay-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.combined-essay-title {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--ans-badge-ink);
}

.combined-essay-text {
  font-family: var(--font-serif);
  font-size: 16.5px;
  line-height: 1.7;
  color: var(--ink);
  white-space: pre-wrap;
  margin: 0;
}

/* Teacher Handbook & ASR Glossary Section (Reference Appendix) */
.appendix-section {
  margin-top: 44px;
  padding-top: 32px;
  border-top: 2px solid var(--ink);
}

.appendix-heading {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 700;
  margin: 0 0 8px;
  color: var(--ink);
  text-wrap: balance;
}

.appendix-lead {
  font-size: 14.5px;
  color: var(--muted);
  margin: 0 0 20px;
}

.parts-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-bottom: 28px;
}

.part-card {
  border: 1px solid var(--line-subtle);
  border-left: 4px solid var(--note-accent);
  border-radius: 4px;
  padding: 12px 16px;
  background-color: #FCFBF9;
}

.part-card h4 {
  margin: 0 0 4px;
  font-size: 15px;
  color: var(--ink);
}

.part-card p {
  margin: 0;
  font-size: 14.5px;
  color: var(--ink-secondary);
}

.glossary-table-wrap {
  overflow-x: auto;
  margin-bottom: 28px;
}

.glossary-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

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

.glossary-table th {
  background-color: #F5F2EB;
  font-weight: 700;
  color: var(--ink);
}

.glossary-raw {
  color: var(--muted);
  font-style: italic;
}

.glossary-decoded {
  font-weight: 600;
  color: var(--ink);
}

/* 10-point Checklist */
.checklist-box {
  border: 1px solid var(--ans-border);
  border-radius: 6px;
  padding: 16px 20px;
  background-color: var(--ans-bg);
}

.checklist-box h3 {
  margin: 0 0 12px;
  font-size: 16.5px;
  color: var(--ans-badge-ink);
}

.checklist-items {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.checklist-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 14.5px;
  color: var(--ink);
  cursor: pointer;
}

.checklist-row input[type="checkbox"] {
  width: 17px;
  height: 17px;
  margin-top: 3px;
  flex-shrink: 0;
  accent-color: var(--ans-focus);
}

/* Toast feedback */
.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background-color: #18181B;
  color: #FFFFFF;
  padding: 10px 16px;
  border-radius: 6px;
  font-size: 13.5px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 0.18s ease, transform 0.18s ease;
  z-index: 500;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* Mobile Responsive (390px+) */
@media (max-width: 640px) {
  .doc-sheet {
    padding: 22px 16px;
  }
  .passage-box {
    padding: 18px 16px;
  }
  .doc-main-heading {
    font-size: 22px;
  }
  .passage-title {
    font-size: 20px;
  }
  .passage-para {
    font-size: 16.5px;
  }
  .btn,
  .preset-btn {
    min-height: 44px;
    padding: 10px 12px;
    font-size: 14px;
  }
  .btn-mini {
    min-height: 38px;
    padding: 6px 10px;
  }
  .doc-input {
    font-size: 16px;
  }
  .toolbar-actions {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  .btn,
  .toast {
    transition: none;
  }
}

/* Clean A4 Print Layout */
@page {
  size: A4;
  margin: 16mm 16mm;
}

@media print {
  body {
    background: #FFFFFF !important;
    color: #000000 !important;
    font-size: 11pt;
  }
  .doc-toolbar,
  .mode-strip,
  .quick-nav,
  .q-mini-tools,
  .combined-essay-head button,
  .appendix-no-print,
  .toast {
    display: none !important;
  }
  .desk-wrap {
    max-width: 100%;
    margin: 0;
    padding: 0;
  }
  .doc-sheet {
    border: none;
    padding: 0;
  }
  .doc-input {
    display: none !important;
  }
  .print-mirror {
    display: block !important;
  }
  .question-block,
  .evidence-group {
    break-inside: avoid-page;
  }
}
