:root {
  --ink: #101b35;
  --paper: #f6f8fc;
  --white: #ffffff;
  --teal: #007f83;
  --teal-dark: #005d61;
  --amber: #f1a62a;
  --blue-wash: #dfe9f7;
  --line: #c5d0e0;
  --muted: #58657b;
  --error: #a52c35;
  --focus: #ffbf47;
  --display: "Fraunces", Georgia, serif;
  --body: "DM Sans", Arial, sans-serif;
  --utility: "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { color-scheme: light; background: var(--paper); scroll-behavior: smooth; }
body { margin: 0; color: var(--ink); background: var(--paper); font-family: var(--body); line-height: 1.5; overflow-x: hidden; }
a { color: inherit; text-underline-offset: 0.22em; }
button, input { font: inherit; touch-action: manipulation; -webkit-tap-highlight-color: rgba(0, 127, 131, 0.18); }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: 0.68; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
.skip-link { position: fixed; z-index: 100; left: 1rem; top: 1rem; padding: 0.75rem 1rem; background: var(--ink); color: var(--white); transform: translateY(-180%); transition: transform 150ms ease; }
.skip-link:focus { transform: translateY(0); }
.report-shell { width: min(1180px, calc(100% - 2rem)); margin: 0 auto; min-height: 100vh; }
.topbar { min-height: 78px; display: flex; align-items: center; justify-content: space-between; gap: 2rem; border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; align-items: center; gap: 0.75rem; text-decoration: none; }
.brand img { display: block; }
.brand span { display: grid; }
.brand strong { font-family: var(--display); font-size: 1.08rem; }
.brand small { color: var(--muted); font-family: var(--utility); font-size: 0.69rem; letter-spacing: 0.05em; text-transform: uppercase; }
.topbar nav { display: flex; gap: 1.5rem; font-weight: 700; }
.topbar nav a:hover { color: var(--teal-dark); }
.topbar nav button { min-height: 44px; border: 1px solid rgba(16,27,53,.28); border-radius: 999px; padding: .55rem 1rem; color: inherit; background: transparent; font: inherit; font-weight: 700; cursor: pointer; }
.topbar nav button:hover, .topbar nav button:focus-visible { color: var(--teal-dark); border-color: currentColor; }

.hero { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: clamp(2rem, 7vw, 7rem); padding: clamp(3.5rem, 8vw, 7.5rem) 0 clamp(3rem, 6vw, 5.5rem); }
.eyebrow, .section-label { margin: 0 0 0.7rem; color: var(--teal-dark); font-family: var(--utility); font-size: 0.72rem; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; }
h1, h2, h3, p { text-wrap: pretty; }
h1 { max-width: 780px; margin: 0; font-family: var(--display); font-size: clamp(3.15rem, 8vw, 7.5rem); font-weight: 700; letter-spacing: -0.055em; line-height: 0.91; text-wrap: balance; }
h1 em { color: var(--teal); font-weight: 600; }
.lede { max-width: 680px; margin: 1.75rem 0 0; color: var(--muted); font-size: clamp(1rem, 1.6vw, 1.2rem); }
.privacy-stamp { width: 170px; aspect-ratio: 1; display: grid; place-items: center; align-content: center; border: 2px solid var(--teal); border-radius: 50%; color: var(--teal-dark); text-align: center; transform: rotate(4deg); }
.privacy-stamp span { display: grid; place-items: center; width: 2.2rem; height: 2.2rem; margin-bottom: 0.45rem; border: 1px solid currentColor; border-radius: 50%; font-family: var(--display); font-size: 1.35rem; }
.privacy-stamp strong { font-family: var(--utility); font-size: 0.78rem; letter-spacing: 0.08em; text-transform: uppercase; }
.privacy-stamp small { max-width: 110px; margin-top: 0.2rem; font-size: 0.72rem; }

.report-loader { display: grid; grid-template-columns: minmax(0, 0.8fr) minmax(360px, 1.2fr); gap: clamp(2rem, 6vw, 6rem); align-items: center; padding: clamp(1.5rem, 4vw, 3.2rem); border: 1px solid var(--line); border-left: 7px solid var(--amber); background: var(--white); box-shadow: 0 22px 55px rgba(16, 27, 53, 0.08); }
.recent-section { margin-bottom: 2rem; }
.recent-section h2 { margin: 0; font-family: var(--display); font-size: clamp(1.8rem, 3vw, 2.7rem); }
.recent-reports { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: .75rem; margin-top: 1rem; }
.recent-report { min-height: 120px; padding: 1rem; border: 1px solid var(--line); background: var(--white); color: var(--ink); text-align: left; }
.recent-report:hover { border-color: var(--teal); box-shadow: 0 8px 20px rgba(16,27,53,.08); }
.recent-report strong, .recent-report span, .recent-report small { display: block; }
.recent-report span, .recent-report small { margin-top: .25rem; color: var(--muted); }
.report-loader h2, .report-heading h2 { margin: 0; font-family: var(--display); font-size: clamp(1.8rem, 3vw, 2.7rem); line-height: 1.05; }
.report-loader p { margin-bottom: 0; color: var(--muted); }
.report-loader form { min-width: 0; }
.report-loader label { display: block; margin-bottom: 0.55rem; font-family: var(--utility); font-size: 0.78rem; font-weight: 600; text-transform: uppercase; }
.field-action { display: grid; grid-template-columns: minmax(0, 1fr) auto; }
.field-action input { min-width: 0; height: 52px; padding: 0 1rem; border: 1px solid var(--line); border-right: 0; border-radius: 0; background: #fbfcff; color: var(--ink); font-family: var(--utility); }
.field-action input::placeholder { color: #79869a; }
.field-action:focus-within { box-shadow: 0 0 0 3px rgba(255, 191, 71, 0.45); }
.field-action input:focus-visible, .field-action button:focus-visible { outline: 0; }
.field-action button, .secondary-button { min-height: 48px; border: 1px solid var(--ink); border-radius: 0; font-weight: 700; }
.field-action button { padding: 0 1.3rem; border-color: var(--ink); background: var(--ink); color: var(--white); }
.field-action button:hover { background: var(--teal-dark); border-color: var(--teal-dark); }
.report-loader small { display: block; margin-top: 0.55rem; color: var(--muted); }
.field-error { margin: 0.65rem 0 0; color: var(--error) !important; font-weight: 700; }
.status-line { margin: 1.5rem 0; padding: 0.8rem 1rem; border-left: 3px solid var(--teal); background: var(--blue-wash); color: #33435e; }

.report-heading { display: flex; align-items: end; justify-content: space-between; gap: 1.5rem; margin: clamp(3.5rem, 7vw, 6rem) 0 1.5rem; }
.secondary-button { min-width: 150px; padding: 0.7rem 1rem; background: transparent; color: var(--ink); }
.secondary-button:hover { background: var(--ink); color: var(--white); }
.summary-panel { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border-block: 1px solid var(--ink); }
.metric { min-width: 0; padding: 1.5rem clamp(1rem, 3vw, 2rem); border-right: 1px solid var(--line); }
.metric:last-child { border-right: 0; }
.metric span { display: block; color: var(--muted); font-family: var(--utility); font-size: 0.7rem; letter-spacing: 0.08em; text-transform: uppercase; }
.metric strong { display: block; margin-top: 0.2rem; font-family: var(--display); font-size: clamp(2rem, 5vw, 4rem); line-height: 1; font-variant-numeric: tabular-nums; }
.suppressed { grid-column: 1 / -1; padding: 1.5rem; background: var(--blue-wash); }
.suppressed strong { display: block; margin-bottom: 0.3rem; }
.suppressed p { margin: 0; color: var(--muted); }
.score-bands { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(5, minmax(0,1fr)); border-top: 1px solid var(--line); }
.score-bands div { padding: 1rem; border-right: 1px solid var(--line); }
.score-bands div:last-child { border-right: 0; }
.score-bands strong, .score-bands span { display: block; }
.score-bands span { color: var(--muted); font-size: .78rem; }
.question-summary { margin-top: 2.25rem; }
.question-performance { display: grid; gap: .65rem; }
.question-performance article { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: .25rem 1rem; padding: 1rem; border: 1px solid var(--line); background: var(--white); }
.question-performance h4 { margin: 0; }
.question-performance small { color: var(--muted); }
.question-performance strong { grid-column: 2; grid-row: 1 / 3; align-self: center; color: var(--teal-dark); }

.access-section { margin-top: 2.25rem; padding: 1.25rem; border: 1px solid var(--line); background: var(--white); }
.access-heading { display: flex; align-items: end; justify-content: space-between; gap: 2rem; }
.access-heading h3 { margin: 0; font-family: var(--display); font-size: 1.5rem; }
.access-heading > p { max-width: 580px; margin: 0; color: var(--muted); font-size: .9rem; }
.co-teacher-list { display: grid; gap: .65rem; margin-top: 1rem; }
.co-teacher-row { display: flex; min-width: 0; align-items: center; justify-content: space-between; gap: 1rem; padding: .8rem 0; border-top: 1px solid var(--line); }
.co-teacher-row strong, .co-teacher-row small { display: block; overflow-wrap: anywhere; }
.co-teacher-row small { color: var(--muted); }
.co-teacher-row button { min-width: 128px; min-height: 44px; border: 1px solid var(--ink); padding: .55rem .8rem; color: var(--ink); background: transparent; font-weight: 700; }
.co-teacher-row button:hover { color: var(--white); background: var(--ink); }
.co-teacher-empty { margin: 0; padding-top: .8rem; border-top: 1px solid var(--line); color: var(--muted); }

.attempt-section { margin-top: 3rem; }
.attempt-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: 0.8rem; }
.attempt-heading h3 { margin: 0; font-family: var(--display); font-size: 1.5rem; }
.attempt-heading span { color: var(--muted); font-family: var(--utility); font-size: 0.74rem; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); background: var(--white); }
table { width: 100%; min-width: 760px; border-collapse: collapse; }
caption { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
th, td { padding: 1rem 1.1rem; border-bottom: 1px solid var(--line); text-align: left; overflow-wrap: anywhere; }
th { background: var(--ink); color: var(--white); font-family: var(--utility); font-size: 0.7rem; letter-spacing: 0.06em; text-transform: uppercase; }
td { font-variant-numeric: tabular-nums; }
td:first-child { color: var(--teal-dark); font-family: var(--utility); font-weight: 600; }
tbody tr { content-visibility: auto; contain-intrinsic-size: auto 58px; }
tbody tr:hover { background: #f1f6fb; }
.score-mark { display: inline-flex; min-width: 4.5rem; justify-content: center; padding: 0.25rem 0.45rem; background: var(--blue-wash); font-weight: 700; }
.detail-button { min-width: 110px; min-height: 44px; border: 1px solid var(--ink); background: transparent; color: var(--ink); font-weight: 700; }
.detail-button:hover { background: var(--ink); color: var(--white); }
.empty-state { display: grid; gap: 0.25rem; padding: 2.5rem; text-align: center; }
.empty-state span { color: var(--muted); }
.attempt-actions { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 1rem; }
.attempt-actions .secondary-button { min-width: 170px; }
footer { display: flex; justify-content: space-between; gap: 1.5rem; margin-top: 5rem; padding: 1.5rem 0 calc(1.5rem + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); color: var(--muted); font-size: 0.83rem; }
.toast-region { position: fixed; z-index: 50; right: 1rem; bottom: calc(1rem + env(safe-area-inset-bottom)); display: grid; gap: 0.5rem; width: min(360px, calc(100vw - 2rem)); }
.toast { padding: 0.85rem 1rem; border-left: 4px solid var(--teal); background: var(--ink); color: var(--white); box-shadow: 0 12px 30px rgba(16, 27, 53, 0.24); }
dialog { width: min(820px, calc(100% - 2rem)); max-height: calc(100vh - 2rem); padding: clamp(1rem, 3vw, 2rem); border: 1px solid var(--line); color: var(--ink); background: var(--paper); overflow: auto; }
dialog::backdrop { background: rgba(8, 15, 31, .72); }
.dialog-heading { display: flex; align-items: start; justify-content: space-between; gap: 1rem; }
.dialog-heading h2 { margin: 0; font-family: var(--display); font-size: 2rem; }
.dialog-heading > button { width: 48px; height: 48px; border: 1px solid var(--ink); background: transparent; font-size: 1.7rem; }
.detail-overview { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); margin-top: 1.5rem; border-block: 1px solid var(--ink); }
.detail-overview .metric strong { font-size: clamp(1.2rem, 3vw, 2rem); overflow-wrap: anywhere; }
.awards, .attempt-questions { margin-top: 2rem; }
.awards h3, .attempt-questions h3 { font-family: var(--display); }
.badge-list { display: flex; flex-wrap: wrap; gap: .5rem; }
.badge-chip { padding: .45rem .7rem; border: 1px solid var(--amber); background: #fff7df; font-weight: 700; }
.attempt-questions { display: grid; gap: .7rem; }
.attempt-questions h3 { margin-bottom: 0; }
.attempt-questions article { padding: 1rem; border-left: 6px solid var(--teal); background: var(--white); }
.attempt-questions article.incorrect { border-left-color: var(--error); }
.attempt-questions p { margin: .25rem 0; }
.attempt-questions small { color: var(--muted); }
.certificate-button { margin-top: 1.5rem; }

@media (max-width: 760px) {
  .report-shell { width: min(100% - 1.2rem, 1180px); }
  .topbar { align-items: flex-start; padding: 0.8rem 0; }
  .topbar { flex-wrap: wrap; }
  .topbar nav { width: 100%; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.6rem; font-size: 0.82rem; }
  .topbar nav button { padding-inline: .75rem; }
  .brand small { display: none; }
  .hero { grid-template-columns: 1fr; }
  .privacy-stamp { width: 135px; }
  .report-loader { grid-template-columns: 1fr; }
  .recent-reports { grid-template-columns: 1fr; }
  .field-action { grid-template-columns: 1fr; gap: 0.55rem; }
  .field-action input { border-right: 1px solid var(--line); }
  .field-action button { min-height: 50px; }
  .report-heading { align-items: stretch; flex-direction: column; }
  .summary-panel { grid-template-columns: 1fr; }
  .score-bands { grid-template-columns: 1fr 1fr; }
  .score-bands div { border-bottom: 1px solid var(--line); }
  .question-performance article { grid-template-columns: 1fr; }
  .question-performance strong { grid-column: 1; grid-row: auto; }
  .detail-overview { grid-template-columns: 1fr; }
  .access-heading, .co-teacher-row { align-items: stretch; flex-direction: column; }
  .co-teacher-row button { width: 100%; }
  .metric { border-right: 0; border-bottom: 1px solid var(--line); }
  .metric:last-child { border-bottom: 0; }
  footer { flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .skip-link { transition-duration: 0.01ms; }
  .privacy-stamp { transform: none; }
}
