:root {
  color-scheme: light;
  --ink: #1f2633;
  --muted: #546172;
  --accent: #0064d2;
  --accent-dark: #004caa;
  --paper: #ffffff;
  --ground: #f0f2f6;
  --line: #d5dbe5;
  --soft: #e8f1ff;
  --highlight: #d8e9ff;
  --toolbar: #f8f9fc;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--ground); color: var(--ink); line-height: 1.55; }
a { color: var(--accent); text-underline-offset: 3px; }
a:hover { color: var(--accent-dark); }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .65; cursor: wait; }
:focus-visible { outline: 3px solid #007aff; outline-offset: 3px; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 20px; font: 500 clamp(2.2rem, 5vw, 3.15rem)/1.08 Georgia, serif; letter-spacing: -.055em; }
h2 { margin-bottom: 14px; font-size: 1.15rem; line-height: 1.3; letter-spacing: -.02em; }
h3 { font-size: .95rem; }
p { margin-bottom: 12px; }

.site-header { background: var(--toolbar); color: var(--ink); border-bottom: 1px solid var(--line); }
.header-inner { max-width: 1056px; margin: auto; min-height: 65px; padding: 0 28px; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.site-header a { color: inherit; text-decoration: none; }
.site-header nav a { font-size: .9rem; color: var(--accent); }
.site-header nav { display: flex; align-items: center; gap: 10px; }
.admin-member { margin-bottom: 16px; }
.chapter-grants { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 7px; }
#sign-in-status { margin-top: 12px; }
.site-header a:hover { text-decoration: underline; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 680; letter-spacing: -.02em; }
.brand-icon { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; background: linear-gradient(160deg, #187cfa, var(--accent)); color: white; font: bold 1.18rem Georgia, serif; }
.page { max-width: 1000px; padding: 40px 28px 65px; margin: auto; }
.page.narrow { max-width: 760px; }
.lesson-page, .print-view { max-width: 850px; }
.card { background: var(--paper); border: 1px solid var(--line); border-radius: 16px; padding: 26px; box-shadow: 0 2px 6px #192e5010; }
.grid { display: grid; grid-template-columns: 1.5fr 1fr; gap: 18px; }
.landing { margin: 16px 0 38px; }
.start-card { padding: 32px; }
.bank-card { padding: 30px; background: var(--soft); }
.bank-card form { margin-bottom: 12px; }
.count { font: 500 3.15rem/1 Georgia, serif; letter-spacing: -.07em; margin: 24px 0; }
.count span { font: 500 .95rem -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; letter-spacing: 0; color: var(--muted); }
.eyebrow { color: var(--accent); font-weight: 720; font-size: .74rem; text-transform: uppercase; letter-spacing: .105em; margin-bottom: 8px; }
.subtle, .reference { color: var(--muted); font-size: .875rem; }
.small-link { font-size: .88rem; font-weight: 650; }
.breadcrumb { display: inline-block; margin-bottom: 16px; }
.stack { display: grid; gap: 8px; justify-items: start; }
.stack label, legend { font-weight: 650; font-size: .9rem; }
.stack input, .stack textarea, .stack select { width: 100%; }
.stack > .primary { margin-top: 8px; }
input:not([type="checkbox"]), textarea, select { min-width: 0; padding: 9px 12px; color: var(--ink); border-radius: 8px; border: 1px solid #aeb8c8; background: var(--paper); }
textarea { resize: vertical; }
textarea::placeholder, input::placeholder { color: var(--muted); }
.primary, .secondary, .quiet {
  display: inline-flex; align-items: center; gap: 7px; justify-content: center;
  min-height: 41px; padding: 7px 14px; border: 1px solid transparent; border-radius: 8px;
  font-size: .87rem; font-weight: 680; line-height: 1.4; text-decoration: none;
}
.primary { background: var(--accent); color: white; }
.primary:hover { background: var(--accent-dark); color: white; }
.secondary { background: var(--paper); color: var(--accent); border-color: var(--line); }
.secondary:hover, .quiet:hover { background: var(--soft); }
.quiet { background: transparent; color: var(--accent); }
.actions { display: flex; flex-wrap: wrap; justify-content: end; gap: 8px; width: 100%; margin-top: 4px; }
.notice { background: var(--soft); color: var(--accent-dark); padding: 11px 14px; border-radius: 8px; margin-bottom: 16px; }
.notice.error { background: #fceae6; color: #742e23; }
.empty { padding: 18px 0; color: var(--muted); border-top: 1px solid var(--line); }
.history summary { padding: 7px 0 12px; cursor: pointer; font-size: 1.15rem; font-weight: 680; }
.history summary::marker { color: var(--accent); }
.lesson-list { margin: 0; padding: 0; list-style: none; border-top: 1px solid var(--line); }
.lesson-list li { display: flex; align-items: center; gap: 12px; padding: 0 2px; border-bottom: 1px solid var(--line); }
.lesson-link { flex: 1; min-width: 0; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 4px; text-decoration: none; font-weight: 650; overflow-wrap: anywhere; }
.lesson-link:hover { background: var(--soft); }
.delete-link { color: #742e23; }
.primary.danger { background: #8b3629; }
.primary.danger:hover { background: #742e23; }
.chapter-picker { display: grid; gap: 10px; }
.chapter-choice { text-align: left; justify-content: space-between; flex-wrap: wrap; gap: 4px 12px; padding: 12px 14px; }
.lesson-list small, .check-row small { display: block; font-weight: 400; font-size: .8rem; color: var(--muted); }

.lesson-top, .lesson-title { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px; }
.lesson-top { align-items: center; margin-bottom: 18px; }
.lesson-title h1 { margin: 0; overflow-wrap: anywhere; }
.lesson-title { margin-bottom: 18px; }
.progress-line { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; color: var(--muted); font-size: .84rem; font-weight: 660; }
.progress-line progress { width: 100%; height: 8px; accent-color: var(--accent); }
.progress-line span, .progress-line form { flex-shrink: 0; }
.lesson-page .card + .card { margin-top: 14px; }
.question-header, .result-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.result-heading { align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.result-heading h2 { margin-bottom: 0; }
.reference { margin-bottom: 0; }
.marks { background: var(--highlight); color: var(--accent-dark); padding: 5px 10px; border-radius: 7px; font-size: .8rem; font-weight: 730; white-space: nowrap; }
.question-body { font: 1.12rem/1.55 Georgia, serif; padding: 20px 0 15px; margin-bottom: 12px; border-bottom: 1px solid var(--line); }
.blocks p, .submitted-answer, .tutor-comment, .ai-breakdown { white-space: pre-wrap; overflow-wrap: anywhere; }
.blocks p:last-child { margin-bottom: 0; }
.block-heading { font-weight: 720; }
pre { max-width: 100%; margin: 8px 0 12px; padding: 11px; overflow-x: auto; border-radius: 6px; background: var(--ground); font: .84rem/1.5 ui-monospace, monospace; }
.source-table { border-collapse: collapse; margin: 8px 0 12px; font-size: .9rem; }
.source-table th, .source-table td { border: 1px solid var(--line); padding: 5px 9px; }
.source-table th { background: var(--soft); text-align: left; }
.source-figure { margin: 14px 0 0; break-inside: avoid; }
.source-figure img { display: block; max-width: 100%; height: auto; border: 1px solid var(--line); }
.marking-notice { margin: 14px 0; }
.ai-card { background: var(--soft); }
.ai-breakdown { margin: 0; }
.scheme-card { background: #f7faff; }
.scheme-card .result-heading:last-child { margin-bottom: 0; }
.score { display: grid; justify-items: end; gap: 1px; color: var(--accent-dark); }
.score strong { font-size: 1.35rem; white-space: nowrap; line-height: 1.15; }
.score span { font-size: .72rem; }
.student-mark-feedback { display: flex; align-items: center; gap: 10px; }
.student-reaction { display: inline-flex; align-items: center; gap: 5px; color: var(--accent-dark); font-size: .82rem; font-weight: 700; white-space: nowrap; }
.student-reaction-mascot { display: block; width: 46px; height: 52px; flex: 0 0 46px; background-image: url("mascot-feedback.png"); background-repeat: no-repeat; background-size: 92px 92px; background-position: left center; transform-origin: 50% 52%; }
.reaction-improve .student-reaction-mascot { background-position: right center; }
.reaction-full .student-reaction-mascot { animation: turtle-twirl .58s cubic-bezier(.2,.7,.2,1) 1 both; }
.reaction-improve .student-reaction-mascot { animation: turtle-nod .62s ease-in-out 1 both; }
@keyframes turtle-twirl {
  0% { transform: rotate(0deg) scale(.86); }
  55% { transform: rotate(370deg) scale(1.12); }
  78% { transform: rotate(350deg) scale(.98); }
  100% { transform: rotate(360deg) scale(1); }
}
@keyframes turtle-nod {
  0%, 100% { transform: translateY(0) rotate(0); }
  28% { transform: translateY(2px) rotate(5deg); }
  58% { transform: translateY(-1px) rotate(-3deg); }
}
.comment-confirmation { margin: 0; color: var(--accent-dark); font-size: .88rem; font-weight: 650; }
.comment-confirmation:empty { display: none; }
.mark-form { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.mark-form input { width: 65px; }
.lesson-nav { display: flex; margin-top: 16px; gap: 8px; }
.lesson-nav .next { margin-left: auto; }
.answer-heading { margin: 0; font-weight: 700; }
.answer-choice { margin: 0 0 4px; }
.answer-choice label { display: inline-flex; align-items: center; gap: 6px; margin-right: 12px; }
.answer-choice input { width: auto; accent-color: var(--accent); }
.result-totals { display: flex; flex-wrap: wrap; gap: 12px; margin: 20px 0; }
.result-totals div { flex: 1; min-width: 135px; padding: 14px; background: var(--soft); border-radius: 8px; }
.result-totals dt { color: var(--muted); font-size: .84rem; }
.result-totals dd { margin: 0; color: var(--accent-dark); font-size: 1.6rem; font-weight: 700; }

fieldset { border: 0; margin: 20px 0; padding: 0; }
legend { padding: 0 0 7px; }
.export-row { border-bottom: 1px solid var(--line); padding: 9px 0; }
.check-row { display: flex; align-items: flex-start; gap: 10px; line-height: 1.3; cursor: pointer; }
.check-row input { accent-color: var(--accent); margin-top: 4px; width: 16px; height: 16px; flex: 0 0 16px; }
.check-row small { margin-top: 3px; }
.export-question-title { flex: 1; }
.submission-status { border-radius: 7px; padding: 4px 8px; background: var(--ground); color: var(--muted); font-size: .72rem; font-weight: 650; white-space: nowrap; }
.submission-status.submitted { background: var(--highlight); color: var(--accent-dark); }
.question-preview { margin: 5px 0 0 26px; }
.question-preview summary { cursor: pointer; color: var(--accent); font-size: .8rem; }
.question-preview .blocks { margin: 8px 0 3px; }
.report-heading { padding-bottom: 10px; border-bottom: 2px solid var(--accent); margin-bottom: 18px; }
.report-heading h1 { margin-bottom: 3px; }
.report-question { padding-bottom: 16px; margin-bottom: 16px; border-bottom: 1px solid var(--line); }
.report-question h2 span { display: inline-block; color: var(--muted); font-size: .8rem; font-weight: 500; margin-left: 5px; }
.report-question h3 { margin: 12px 0 5px; }
.report-marks { font-size: .85rem; }
.report-response { margin: 14px 0; }
.report-response h3 { color: var(--accent-dark); font-size: 1.13rem; }
.report-response h4 { margin: 8px 0 2px; font-size: .9rem; }
.submitted-answer { padding: 8px 12px; border: 1px solid var(--line); border-radius: 6px; }
.tutor-comment { margin: 0; padding: 7px 12px; border-left: 3px solid var(--accent); background: var(--soft); }
.report-reference { margin-top: 12px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

@media (max-width: 600px) {
  .header-inner, .page { padding-left: 16px; padding-right: 16px; }
  .page { padding-top: 24px; }
  .grid { grid-template-columns: 1fr; }
  .card { padding: 19px; }
  .progress-line { gap: 6px; }
  .progress-line button { padding-inline: 6px; }
}
@media (prefers-reduced-motion: reduce) {
  .student-reaction-mascot { animation: none !important; }
}
@page { size: A4; margin: 15mm 17mm; }
@media print {
  body { background: white; color: var(--ink); font-size: 10.5pt; }
  .site-header, .print-controls, .notice { display: none; }
  .print-view { padding: 0; max-width: none; }
  .report-heading h1 { font-size: 23pt; }
  .report-question + .report-question { break-before: page; }
  .report-response h3 { font-size: 13pt; }
  .report-reference { font-size: 9.5pt; line-height: 1.4; }
  .report-reference .blocks p { margin-bottom: 5px; }
  .report-reference .block-heading { break-after: avoid; }
  h2, h3, h4 { break-after: avoid; }
  pre { overflow: visible; white-space: pre-wrap; overflow-wrap: anywhere; padding-left: 0; }
}
