:root {
  --teal: #0d5c63;
  --teal-deep: #173f43;
  --teal-soft: #e7f2f1;
  --coral: #d9654b;
  --coral-soft: #fbe9e4;
  --ochre: #d89a2b;
  --ochre-soft: #fbf3df;
  --ink: #203034;
  --muted: #657478;
  --paper: #fffdf8;
  --canvas: #f3f0e8;
  --line: #c8d4d2;
  --white: #fff;
  --success: #1f6b4f;
  --danger: #a63f32;
  --reading-scale: 1;
  --shadow: 0 18px 50px rgba(23, 63, 67, .11);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: Aptos, "Segoe UI", Calibri, Arial, sans-serif;
  line-height: 1.55;
}
button, input, textarea, select { font: inherit; }
button, .file-action { min-height: 44px; }
button { cursor: pointer; }
a { color: var(--teal); text-underline-offset: 3px; }
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--ochre); outline-offset: 3px; }

.skip-link { position: fixed; left: 1rem; top: -5rem; z-index: 100; padding: .75rem 1rem; background: var(--ink); color: white; border-radius: 0 0 8px 8px; }
.skip-link:focus { top: 0; }
.storage-warning { padding: .7rem 1rem; background: #fff0c9; border-bottom: 2px solid var(--ochre); text-align: center; font-weight: 700; }
.eyebrow { margin: 0 0 .25rem; color: var(--ochre); font-size: .75rem; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }

.site-header { min-height: 78px; display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .8rem clamp(1rem, 4vw, 4rem); background: var(--teal-deep); color: white; }
.brand-lockup { display: flex; align-items: center; gap: .8rem; }
.brand-lockup h1 { margin: 0; font-family: Georgia, serif; font-size: clamp(1.25rem, 2.3vw, 1.8rem); line-height: 1.05; }
.brand-mark { width: 46px; height: 46px; display: grid; place-items: center; border: 2px solid rgba(255,255,255,.5); border-radius: 50%; color: var(--ochre); font: 800 1.6rem Georgia, serif; }
.header-tools { display: flex; align-items: center; gap: 1rem; }
.save-status { font-size: .85rem; color: #d7e7e5; }
.font-controls { display: flex; border: 1px solid rgba(255,255,255,.35); border-radius: 10px; overflow: hidden; }
.font-controls button { min-width: 44px; border: 0; border-right: 1px solid rgba(255,255,255,.25); background: transparent; color: white; font-weight: 800; }
.font-controls button:last-child { border-right: 0; }
.font-controls button:hover { background: rgba(255,255,255,.12); }

.stage-nav { position: sticky; top: 0; z-index: 20; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); max-width: 1180px; margin: 0 auto; background: white; box-shadow: 0 10px 28px rgba(23,63,67,.12); }
.stage-tab { position: relative; display: flex; align-items: center; gap: .7rem; min-height: 70px; padding: .7rem clamp(.65rem, 2vw, 1.5rem); border: 0; border-bottom: 4px solid transparent; background: white; color: var(--muted); text-align: left; }
.stage-tab + .stage-tab { border-left: 1px solid #e1e8e6; }
.stage-tab strong, .stage-tab small { display: block; }
.stage-tab strong { color: var(--teal-deep); }
.stage-tab small { font-size: .75rem; }
.stage-tab.is-active { background: var(--teal-soft); border-bottom-color: var(--coral); }
.stage-tab[data-locked="true"] { opacity: .62; cursor: not-allowed; }
.stage-tab[data-locked="false"] .stage-lock { display: none; }
.step-number { width: 32px; height: 32px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 50%; background: var(--canvas); color: var(--teal); font-weight: 900; }
.is-active .step-number { background: var(--teal); color: white; }
.stage-tick { display: none; margin-left: auto; color: var(--success); font-size: 1.2rem; font-weight: 900; }
.stage-tab.is-complete .stage-tick { display: block; }
.stage-tab.is-complete .stage-lock { display: none; }
.stage-lock { margin-left: auto; }

main { max-width: 1440px; margin: 0 auto; }
.stage { padding: clamp(1.2rem, 3vw, 2.5rem) clamp(1rem, 3vw, 2.4rem) 4rem; }
.stage-intro { max-width: 1180px; margin: 0 auto 1.4rem; display: grid; grid-template-columns: minmax(280px,.8fr) minmax(320px,1.2fr); align-items: end; gap: 2rem; }
.stage-intro h2 { margin: 0; font: 800 clamp(1.9rem,4vw,3.3rem)/1 Georgia, serif; color: var(--teal-deep); }
.stage-intro > p { margin: 0; max-width: 690px; color: var(--muted); font-size: 1.02rem; }
.learning-grid, .assessment-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(330px, .82fr); gap: 1.5rem; align-items: start; }

.reading-card, .analysis-panel, .question-panel, .practice-overview, .practice-list, .export-card { background: var(--white); box-shadow: var(--shadow); }
.reading-card { overflow: hidden; border-radius: 5px; background: var(--paper); font-family: Georgia, "Times New Roman", serif; font-size: calc(1.03rem * var(--reading-scale)); }
.hero-figure { margin: 0; position: relative; }
.hero-figure img { width: 100%; aspect-ratio: 2.3 / 1; object-fit: cover; }
.hero-figure figcaption { position: absolute; right: 0; bottom: 0; max-width: 72%; padding: .5rem .8rem; background: rgba(23,63,67,.92); color: white; font: .78rem/1.35 Aptos, "Segoe UI", sans-serif; }
.article-masthead { padding: clamp(1.4rem,4vw,3rem) clamp(1.2rem,6vw,4.8rem) .8rem; text-align: center; }
.article-kicker { margin: 0 0 .7rem; color: var(--coral); font: 800 .75rem/1.2 Aptos, "Segoe UI", sans-serif; letter-spacing: .13em; text-transform: uppercase; }
.article-masthead h2 { max-width: 720px; margin: 0 auto .4rem; color: var(--teal-deep); font-size: clamp(2.25rem, 5vw, 4.7rem); line-height: .98; letter-spacing: -.035em; }
.article-subtitle { margin: .7rem 0 .9rem; color: var(--coral); font: 700 clamp(1rem,2.2vw,1.35rem)/1.25 Aptos, "Segoe UI", sans-serif; }
.article-meta { margin: 0; color: var(--muted); font: .78rem/1.4 Aptos, "Segoe UI", sans-serif; }
.standfirst { margin: .5rem clamp(1.2rem,6vw,4.8rem) 1.5rem; padding: 1rem 1.1rem; border-left: 5px solid var(--ochre); background: var(--ochre-soft); color: var(--teal-deep); font-size: calc(1.2rem * var(--reading-scale)); font-weight: 700; line-height: 1.45; }
.article-body { padding: 0 clamp(1.2rem,6vw,4.8rem) 1rem; }
.article-body p { margin: 0 0 1.1em; }
.article-body h3 { margin: 1.55em 0 .5em; color: var(--teal); font: 800 calc(1.42rem * var(--reading-scale))/1.15 Aptos, "Segoe UI", sans-serif; }
.article-body sup { font-family: Aptos, sans-serif; }
.inline-figure { margin: 1.7rem 0 1.5rem; }
.inline-figure img { width: 100%; max-height: 420px; object-fit: cover; }
.inline-figure figcaption { padding: .55rem .7rem; border-bottom: 1px solid var(--line); color: var(--muted); font: italic .82rem/1.35 Aptos, sans-serif; }
.proposal-box { display: flex; gap: 1rem; margin: 1rem clamp(1.2rem,6vw,4.8rem) 1.8rem; padding: 1rem 1.1rem; border: 1px solid #e7c678; background: var(--ochre-soft); font: .9rem/1.45 Aptos, sans-serif; }
.proposal-box strong { flex: 0 0 auto; color: var(--coral); text-transform: uppercase; letter-spacing: .06em; }
.source-notes { padding: 1.2rem clamp(1.2rem,6vw,4.8rem) 2rem; border-top: 1px solid var(--line); background: #f7f5ef; font: .75rem/1.45 Aptos, sans-serif; color: var(--muted); }
.source-notes h3 { margin: 0 0 .4rem; color: var(--teal-deep); font-size: .85rem; }
.source-notes ol { margin: 0; padding-left: 1.3rem; }
.source-notes li { margin: .35rem 0; }

.annotation { display: inline; min-height: 0; margin: 0; padding: .08em .15em; border: 0; border-bottom: 3px solid currentColor; border-radius: 3px; color: inherit; font: inherit; text-align: left; line-height: inherit; box-decoration-break: clone; -webkit-box-decoration-break: clone; }
.annotation::before { display: inline-block; margin-right: .22em; width: 1.3em; height: 1.3em; border-radius: 50%; color: white; font: 800 .64em/1.3em Aptos, sans-serif; text-align: center; vertical-align: .18em; }
.annotation.structure { background: #e1f0ef; border-color: var(--teal); }
.annotation.structure::before { content: "S"; background: var(--teal); }
.annotation.language { background: #fbe8e3; border-color: var(--coral); }
.annotation.language::before { content: "L"; background: var(--coral); }
.annotation.evidence { background: #fbf0cf; border-color: #9b6b0b; }
.annotation.evidence::before { content: "E"; background: #9b6b0b; }
.annotation.cohesion { background: #eee8f6; border-color: #684c88; }
.annotation.cohesion::before { content: "C"; background: #684c88; }
.annotation:hover, .annotation.is-selected { box-shadow: 0 0 0 3px rgba(216,154,43,.35); }
.annotation.is-visited::after { content: " ✓"; color: var(--success); font: 800 .72em Aptos, sans-serif; }

.analysis-panel { border-radius: 5px; overflow: clip; }
.panel-sticky { position: sticky; top: 92px; }
.panel-heading, .question-panel-header { display: flex; align-items: start; justify-content: space-between; gap: 1rem; padding: 1.2rem; border-bottom: 1px solid var(--line); background: var(--teal-deep); color: white; }
.panel-heading h2, .question-panel-header h2 { margin: 0; font: 800 1.45rem Georgia, serif; }
.progress-chip { flex: 0 0 auto; padding: .35rem .55rem; border-radius: 100px; background: white; color: var(--teal-deep); font-size: .76rem; font-weight: 900; }
.annotation-legend { display: grid; grid-template-columns: 1fr 1fr; gap: .55rem; padding: .9rem 1rem; border-bottom: 1px solid var(--line); color: var(--muted); font-size: .72rem; }
.legend-mark { display: inline-grid; place-items: center; width: 22px; height: 22px; margin-right: .25rem; border-radius: 50%; color: white; font-style: normal; font-weight: 900; }
.structure-mark { background: var(--teal); } .language-mark { background: var(--coral); } .evidence-mark { background: #9b6b0b; } .cohesion-mark { background: #684c88; }
.analysis-content { min-height: 390px; max-height: calc(100vh - 360px); overflow: auto; padding: 1.25rem; }
.analysis-empty { min-height: 320px; display: grid; place-content: center; text-align: center; color: var(--muted); }
.analysis-empty h3 { margin: .6rem 0 .2rem; color: var(--teal-deep); }
.analysis-empty p { margin: 0; }
.magnifier { font-size: 3rem; color: var(--ochre); }
.analysis-card .technique-label { display: inline-block; margin-bottom: .7rem; padding: .3rem .5rem; border-radius: 4px; background: var(--coral-soft); color: var(--coral); font-size: .72rem; font-weight: 900; letter-spacing: .07em; text-transform: uppercase; }
.analysis-card h3 { margin: 0 0 .6rem; color: var(--teal-deep); font: 800 1.5rem/1.15 Georgia, serif; }
.analysis-quote { margin: 0 0 1rem; padding: .8rem .9rem; border-left: 4px solid var(--ochre); background: var(--ochre-soft); font: italic 1.05rem/1.45 Georgia, serif; }
.analysis-card h4 { margin: 1rem 0 .25rem; color: var(--teal); font-size: .85rem; text-transform: uppercase; letter-spacing: .05em; }
.analysis-card p { margin: 0; }
.try-box { margin-top: 1.1rem; padding: .9rem; border: 1px dashed var(--coral); background: #fff8f4; }
.panel-sticky > .primary-action { width: calc(100% - 2rem); margin: 0 1rem 1rem; }

.primary-action, .secondary-action, .danger-action { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; padding: .72rem 1rem; border-radius: 5px; font-weight: 850; text-decoration: none; }
.primary-action { border: 2px solid var(--teal); background: var(--teal); color: white; }
.primary-action:hover:not(:disabled) { background: var(--teal-deep); border-color: var(--teal-deep); }
.primary-action:disabled { opacity: .48; cursor: not-allowed; }
.secondary-action { border: 2px solid var(--teal); background: white; color: var(--teal); }
.secondary-action:hover { background: var(--teal-soft); }
.danger-action { border: 2px solid #bd7b72; background: white; color: var(--danger); }

.practice-shell { display: grid; grid-template-columns: 260px minmax(0, 760px); justify-content: center; gap: 1.5rem; align-items: start; }
.practice-overview { position: sticky; top: 92px; padding: 1.3rem; text-align: center; }
.ring-progress { --value: 0; width: 130px; height: 130px; margin: 1.2rem auto; display: grid; place-items: center; border-radius: 50%; background: conic-gradient(var(--coral) calc(var(--value) * 1%), #dbe5e3 0); position: relative; }
.ring-progress::before { content: ""; position: absolute; inset: 10px; border-radius: 50%; background: white; }
.ring-progress span { position: relative; font-size: 1.1rem; }
.ring-progress strong { color: var(--teal-deep); font-size: 2.1rem; }
.lock-note { padding: .7rem; border-radius: 5px; background: var(--ochre-soft); color: #6f4d0e; font-size: .83rem; }
.practice-list { padding: clamp(1rem,3vw,2rem); }
.practice-item { padding: 1rem 0 1.35rem; border-bottom: 1px solid var(--line); }
.practice-item:last-child { border-bottom: 0; }
.question-number { color: var(--coral); font-size: .76rem; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
.practice-item h3 { margin: .25rem 0 .8rem; color: var(--teal-deep); }
.option-grid { display: grid; gap: .55rem; }
.choice-label { display: flex; align-items: flex-start; gap: .65rem; min-height: 44px; padding: .65rem .75rem; border: 1px solid var(--line); border-radius: 5px; background: white; }
.choice-label:hover { border-color: var(--teal); background: var(--teal-soft); }
.choice-label input { width: 20px; height: 20px; flex: 0 0 auto; margin-top: .1rem; accent-color: var(--teal); }
.check-row { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: .8rem; }
.hint-button { min-height: 44px; padding: .55rem .8rem; border: 0; background: transparent; color: var(--teal); text-decoration: underline; }
.feedback { margin: .8rem 0 0; padding: .7rem .8rem; border-left: 4px solid; font-size: .9rem; }
.feedback.correct { border-color: var(--success); background: #e7f4ed; color: #194d3b; }
.feedback.incorrect { border-color: var(--danger); background: #fbebe8; color: #762e25; }
.feedback.hint { border-color: var(--ochre); background: var(--ochre-soft); color: #67470d; }
.stage-footer-actions { max-width: 1035px; margin: 1.2rem auto 0; display: flex; justify-content: space-between; gap: 1rem; }

.question-panel { border-radius: 5px; overflow: hidden; }
.question-panel-header { position: sticky; top: 74px; z-index: 4; }
.identity-card { padding: 1rem 1.1rem; border-bottom: 1px solid var(--line); background: var(--ochre-soft); }
.identity-card h3 { margin: 0 0 .7rem; color: var(--teal-deep); }
.identity-fields { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; }
.identity-fields label:first-child { grid-column: 1 / -1; }
label { color: var(--teal-deep); font-size: .8rem; font-weight: 800; }
input[type="text"], input:not([type]), input[type="date"], textarea, select { width: 100%; min-height: 44px; margin-top: .25rem; padding: .65rem .7rem; border: 1px solid #9eb2af; border-radius: 4px; background: white; color: var(--ink); }
textarea { min-height: 105px; resize: vertical; line-height: 1.45; }
.field-note { margin: .45rem 0 0; color: var(--muted); font-size: .75rem; }
.question-section { border-bottom: 1px solid var(--line); }
.section-toggle { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: .7rem; padding: 1rem 1.1rem; border: 0; background: #f4f8f7; color: var(--teal-deep); text-align: left; }
.section-toggle strong, .section-toggle small { display: block; }
.section-toggle small { color: var(--muted); font-weight: 500; }
.section-toggle[aria-expanded="true"] .chevron { transform: rotate(180deg); }
.section-body { padding: 0 1.1rem; }
.assessment-question { padding: 1.2rem 0; border-bottom: 1px dashed var(--line); }
.assessment-question:last-child { border-bottom: 0; }
.assessment-question h4 { margin: .3rem 0 .75rem; color: var(--ink); font-size: .98rem; line-height: 1.4; }
.stretch-tag { display: inline-block; margin-left: .35rem; padding: .1rem .35rem; border-radius: 3px; background: var(--ochre-soft); color: #78520a; font-size: .68rem; }
.response-group { display: grid; gap: .65rem; }
.response-group label { display: block; }
.structured-check { margin-top: .7rem; }
.structured-feedback { margin: .6rem 0 0; font-size: .82rem; font-weight: 700; }
.structured-feedback.correct { color: var(--success); }
.structured-feedback.incorrect { color: var(--danger); }
.match-grid { display: grid; gap: .6rem; }
.match-row { display: grid; grid-template-columns: minmax(100px,.8fr) minmax(150px,1.2fr); align-items: center; gap: .7rem; }
.match-row span { font-size: .84rem; }
.match-row select { margin: 0; }
.question-hint { margin: .55rem 0 0; padding: .55rem .65rem; background: var(--ochre-soft); color: #63450d; font-size: .8rem; }
.completion-mark { float: right; color: var(--success); font-weight: 900; }

.export-card { max-width: 1180px; margin: 1.5rem auto 0; padding: clamp(1rem,3vw,1.6rem); display: grid; grid-template-columns: minmax(280px,1fr) minmax(360px,1.2fr); gap: 1.5rem; align-items: center; border-top: 5px solid var(--coral); }
.export-card h2 { margin: 0; color: var(--teal-deep); font: 800 1.6rem Georgia, serif; }
.export-card p { margin: .35rem 0 0; color: var(--muted); }
.export-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .6rem; }
.file-action { position: relative; cursor: pointer; }
.file-action input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.export-message { grid-column: 1 / -1; min-height: 1.4em; text-align: right; font-weight: 700; }
.site-footer { padding: 2rem 1rem; background: var(--teal-deep); color: #d3e2e0; text-align: center; font-size: .82rem; }

@media (max-width: 900px) {
  .learning-grid, .assessment-grid { grid-template-columns: 1fr; }
  .panel-sticky, .practice-overview { position: static; }
  .analysis-content { min-height: 250px; max-height: none; }
  .analysis-panel { order: -1; }
  .assessment-grid .question-panel { order: 2; }
  .practice-shell { grid-template-columns: 1fr; }
  .practice-overview { display: grid; grid-template-columns: 1fr 120px 1.2fr; align-items: center; gap: 1rem; text-align: left; }
  .practice-overview .ring-progress { grid-column: 2; grid-row: 1 / span 3; width: 100px; height: 100px; margin: 0; }
  .practice-overview .lock-note { grid-column: 3; grid-row: 1 / span 3; }
  .export-card { grid-template-columns: 1fr; }
  .export-actions { justify-content: flex-start; }
}

@media (max-width: 620px) {
  .site-header { align-items: flex-start; }
  .brand-mark, .save-status { display: none; }
  .header-tools { margin-left: auto; }
  .stage-nav { top: 0; }
  .stage-tab { min-height: 60px; justify-content: center; padding: .45rem; }
  .stage-tab small, .stage-tab .stage-tick, .stage-tab .stage-lock { display: none; }
  .step-number { width: 27px; height: 27px; }
  .stage { padding-inline: .7rem; }
  .stage-intro { grid-template-columns: 1fr; gap: .7rem; }
  .stage-intro h2 { font-size: 2rem; }
  .article-masthead { padding-inline: 1.1rem; }
  .article-masthead h2 { font-size: 2.45rem; }
  .standfirst, .proposal-box { margin-inline: .8rem; }
  .article-body, .source-notes { padding-inline: 1rem; }
  .proposal-box { display: block; }
  .proposal-box strong { display: block; margin-bottom: .3rem; }
  .hero-figure img { aspect-ratio: 1.55 / 1; }
  .hero-figure figcaption { position: static; max-width: none; }
  .annotation-legend { grid-template-columns: 1fr; }
  .practice-overview { display: block; text-align: center; }
  .practice-overview .ring-progress { margin: 1rem auto; }
  .identity-fields { grid-template-columns: 1fr; }
  .identity-fields label:first-child { grid-column: auto; }
  .match-row { grid-template-columns: 1fr; gap: .2rem; }
  .stage-footer-actions { flex-direction: column; }
  .stage-footer-actions button { width: 100%; }
  .export-actions { display: grid; }
  .question-panel-header { top: 60px; }
}

@media print {
  .site-header, .stage-nav, .analysis-panel, .practice-shell, .stage-footer-actions, .export-card, .site-footer { display: none !important; }
  body { background: white; }
  .stage { padding: 0; }
  .reading-card { box-shadow: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .001ms !important; animation-duration: .001ms !important; }
}
