/* Sample-course palette. */
:root {
  --primary: #1f3a5f;
  --primary-dark: #142840;
  --accent: #2e6f6a;
  --accent-soft: #e8f2f1;
  --soft: #f2f5f8;
  --success: #24703a;
  --warning-ink: #5f4307;
  --warning-bg: #fff7e2;
  --warning-line: #d9b75c;
  --danger: #a12a2a;
  --ink: #26323e;
  --muted: #59646f;
  --line: #d6dde4;
  --surface: #ffffff;
  --background: #f8f9fb;
  --focus: #0b5cad;
  --shadow: 0 10px 28px rgba(31, 58, 95, 0.08);
  --font: "Segoe UI", Arial, Helvetica, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { font-size: 16px; color: var(--ink); background: var(--background); }
body { margin: 0; min-width: 320px; min-height: 100vh; font-family: var(--font); line-height: 1.6; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.5; }
a { color: var(--primary); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
h1:focus { outline: none; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: fixed; top: 8px; left: 8px; z-index: 1000; transform: translateY(-160%); padding: 12px 18px; background: white; border: 2px solid var(--primary); border-radius: 8px; font-weight: 700; }
.skip-link:focus { transform: translateY(0); }

.diagnostic-banner { padding: 8px 20px; background: var(--warning-bg); color: var(--warning-ink); border-bottom: 1px solid var(--warning-line); font-size: 0.92rem; font-weight: 700; text-align: center; }
.topbar { min-height: 76px; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 24px; padding: 10px 28px; background: var(--surface); border-bottom: 3px solid var(--accent); position: sticky; top: 0; z-index: 40; }
.brand-block { display: flex; align-items: center; gap: 12px; }
.brand-mark img { display: block; height: 52px; width: auto; }
.wordmark { display: flex; align-items: center; gap: 10px; color: var(--primary); }
.wordmark strong { display: grid; place-items: center; width: 50px; height: 50px; border: 2px solid var(--primary); border-radius: 10px; font-size: 1.05rem; letter-spacing: 0.04em; }
.wordmark span { font-size: 0.82rem; font-weight: 700; line-height: 1.2; }
.course-name { display: flex; flex-direction: column; min-width: 0; }
.course-name strong { color: var(--primary-dark); font-size: 1.05rem; }
.course-name span { color: var(--muted); font-size: 0.86rem; }
.top-actions { display: flex; align-items: center; gap: 6px; }
.text-button, .icon-button { min-height: 44px; border: 0; background: transparent; color: var(--primary); font-weight: 700; border-radius: 8px; padding: 8px 12px; }
.text-button:hover, .icon-button:hover { background: var(--soft); }
.icon-button { min-width: 44px; display: grid; place-items: center; padding: 10px; }
.icon-button svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.menu-button { display: none; }

.progress-shell { display: flex; align-items: center; gap: 16px; min-height: 42px; padding: 8px 28px; background: var(--surface); border-bottom: 1px solid var(--line); font-size: 0.85rem; font-weight: 700; color: var(--muted); }
.progress-track { height: 8px; max-width: 480px; flex: 1; background: #e1e7ee; border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: var(--accent); border-radius: inherit; transition: width 200ms ease-out; }

.course-layout { display: grid; grid-template-columns: 270px minmax(0, 1fr); min-height: calc(100vh - 118px); }
.sidebar { background: var(--surface); border-right: 1px solid var(--line); padding: 18px 12px 120px; }
.sidebar-heading { display: flex; flex-direction: column; padding: 0 10px 14px; color: var(--muted); }
.sidebar-heading span { color: var(--ink); font-weight: 700; }
.sidebar-heading small { font-size: 0.78rem; }
#module-nav { display: grid; gap: 3px; }
.module-link { min-height: 58px; width: 100%; display: grid; grid-template-columns: 34px 1fr; align-items: center; gap: 8px; padding: 8px 10px; text-align: left; background: transparent; color: var(--ink); border: 1px solid transparent; border-radius: 10px; }
.module-link:hover:not(:disabled) { background: var(--soft); border-color: var(--line); }
.module-link.active { background: var(--accent-soft); border-color: #bcd8d5; box-shadow: inset 4px 0 0 var(--accent); }
.module-code { color: var(--accent); font-weight: 800; font-size: 0.82rem; }
.module-copy { display: flex; flex-direction: column; min-width: 0; }
.module-copy strong { font-size: 0.86rem; line-height: 1.3; }
.module-copy small { margin-top: 2px; color: var(--muted); font-size: 0.74rem; }
.module-link.done .module-copy small { color: var(--success); font-weight: 700; }

.main-content { min-width: 0; outline: none; }
.content-wrap { width: min(920px, calc(100% - 48px)); margin: 0 auto; padding: 44px 0 140px; }
h1 { margin: 0 0 24px; color: var(--primary-dark); font-size: clamp(1.8rem, 3.6vw, 2.6rem); line-height: 1.15; letter-spacing: -0.02em; }
h2, h3 { color: var(--primary-dark); line-height: 1.25; }
.section-title { margin: 32px 0 10px; font-size: 1.2rem; }
p, li { font-size: 1.04rem; max-width: 780px; }
.lead { font-size: 1.18rem; color: #22303f; }
.scenario { font-size: 1.1rem; padding-left: 16px; border-left: 4px solid var(--line); }
.eyebrow { margin: 0 0 8px; color: var(--accent); font-size: 0.8rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; }
.statement { margin: 24px 0; padding: 20px 24px; border-left: 5px solid var(--accent); background: var(--accent-soft); color: var(--primary-dark); font-size: clamp(1.15rem, 2.2vw, 1.45rem); font-weight: 700; border-radius: 0 12px 12px 0; }
.notice { margin: 20px 0; padding: 16px 18px; color: var(--warning-ink); background: var(--warning-bg); border: 1px solid var(--warning-line); border-radius: 10px; }
.instruction { color: var(--muted); font-weight: 700; }
.privacy-note, .small-print, .hint { color: var(--muted); font-size: 0.9rem; }
.check-list { padding-left: 0; list-style: none; display: grid; gap: 8px; }
.check-list li { position: relative; padding: 10px 14px 10px 40px; background: var(--surface); border: 1px solid var(--line); border-radius: 9px; }
.check-list li::before { content: "•"; position: absolute; left: 18px; color: var(--accent); font-weight: 800; }
.narration { margin: 24px 0; padding: 18px 22px; background: var(--soft); border-radius: 12px; border: 1px solid var(--line); }
.narration p:last-child { margin-bottom: 0; }

.hero { padding: clamp(28px, 5vw, 52px); color: white; background: linear-gradient(140deg, var(--primary-dark) 0%, var(--primary) 60%, #285a72 120%); border-radius: 16px; box-shadow: var(--shadow); }
.hero .eyebrow { color: #cfe7e4; }
.hero-title { margin: 0 0 12px; font-size: clamp(1.7rem, 4vw, 2.9rem); font-weight: 800; letter-spacing: 0.02em; line-height: 1.1; max-width: none; }
.hero-subtitle { margin: 0 0 18px; font-size: 1.2rem; max-width: 640px; }
.hero-theme { margin: 0; font-style: italic; color: #dce8f3; font-size: 1.1rem; }
.hero-facts { display: flex; flex-wrap: wrap; gap: 12px; margin: 28px 0; }
.hero-facts div { padding: 8px 14px; border: 1px solid rgba(255,255,255,.4); border-radius: 10px; }
.hero-facts dt { font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; color: #cfe7e4; }
.hero-facts dd { margin: 0; font-weight: 700; }
.hero-start { background: white !important; color: var(--primary-dark) !important; }

.button { min-height: 48px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; border-radius: 9px; padding: 10px 20px; border: 2px solid transparent; font-weight: 800; text-decoration: none; }
.button.primary { background: var(--primary); color: white; }
.button.primary:hover:not(:disabled) { background: var(--primary-dark); }
.button.secondary { background: white; color: var(--primary); border-color: var(--primary); }
.button.secondary:hover:not(:disabled) { background: var(--soft); }
.button.danger { background: white; color: var(--danger); border-color: var(--danger); }
.text-link { min-height: 44px; display: inline-flex; align-items: center; padding: 8px 0; color: var(--primary); background: transparent; border: 0; text-decoration: underline; font-weight: 700; }
.action-row, .quiz-actions, .modal-actions, .video-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 20px; }

.bottom-nav { position: fixed; z-index: 20; left: 270px; right: 0; bottom: 0; min-height: 76px; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 20px; padding: 12px max(24px, calc((100vw - 270px - 920px) / 2)); background: rgba(255,255,255,.98); border-top: 1px solid var(--line); box-shadow: 0 -8px 24px rgba(31,58,95,.06); }
#screen-position { color: var(--muted); font-size: .88rem; text-align: center; }

.video-lesson { margin: 20px 0; }
.video-frame { overflow: hidden; background: #0b1320; border-radius: 12px; box-shadow: var(--shadow); aspect-ratio: 16 / 9; }
.video-frame video { display: block; width: 100%; height: 100%; object-fit: contain; }
.watch-status { color: var(--muted); font-size: .92rem; font-weight: 700; }
.transcript-panel { margin-top: 14px; padding: 18px 20px; background: white; border: 1px solid var(--line); border-radius: 12px; }
.transcript-copy { max-height: 340px; overflow: auto; padding-right: 10px; }
.transcript-label { margin: 14px 0 4px; font-size: .78rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.optional-video { margin: 20px 0; padding: 0 16px 12px; background: white; border: 1px solid var(--line); border-radius: 12px; }
.optional-video summary { min-height: 48px; display: flex; align-items: center; font-weight: 800; color: var(--primary); cursor: pointer; }

.question-card, .activity-form, .local-form { max-width: 820px; margin: 20px 0; padding: clamp(18px, 3.5vw, 30px); background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); }
fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
legend { width: 100%; margin-bottom: 14px; color: var(--ink); font-size: 1.12rem; font-weight: 800; line-height: 1.4; }
.option { min-height: 48px; display: flex; align-items: flex-start; flex-wrap: wrap; gap: 10px; margin: 8px 0; padding: 11px 14px; background: #fafbfc; border: 1px solid var(--line); border-radius: 9px; cursor: pointer; }
.option:hover { border-color: #8aa3c0; background: var(--soft); }
.option.compact { min-height: 44px; padding: 8px 12px; }
.option input, .review-item input, .check-row input { width: 20px; height: 20px; margin-top: 3px; flex: none; accent-color: var(--primary); }
.option span:first-of-type { flex: 1; }
.feedback, .feedback-panel { min-height: 26px; margin-top: 14px; color: var(--primary-dark); font-weight: 700; }
.feedback-panel:not(:empty) { padding: 14px 16px; background: var(--accent-soft); border-radius: 10px; }
.tag { flex-basis: 100%; padding-left: 30px; font-size: .9rem; font-weight: 700; }
.tag-yes { color: var(--success); }
.tag-no { color: var(--muted); }
.guided-step { padding: 16px 0; border-bottom: 1px solid var(--line); }
.step-name { color: var(--accent); font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.step-feedback { margin-top: 6px; color: var(--primary-dark); font-weight: 600; }
.choice-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 12px; }
.inline-choice { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; margin-right: 20px; }
.small-label { display: block; margin-top: 8px; font-size: .9rem; }
.assessment-card { margin-bottom: 18px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }

.reveal-list, .checklist-grid { display: grid; gap: 8px; margin: 18px 0; }
.checklist-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.reveal-item, .evidence, .answer-review details { background: var(--surface); border: 1px solid var(--line); border-radius: 11px; }
.reveal-item summary, .evidence summary, .answer-review summary { min-height: 52px; display: flex; align-items: center; gap: 12px; padding: 12px 16px; cursor: pointer; color: var(--primary-dark); font-weight: 800; }
.reveal-item summary::-webkit-details-marker, .evidence summary::-webkit-details-marker, .answer-review summary::-webkit-details-marker, .optional-video summary::-webkit-details-marker { display: none; }
.reveal-item summary::after, .evidence summary::after, .answer-review summary::after, .optional-video summary::after { content: "+"; margin-left: auto; padding-left: 12px; color: var(--accent); font-size: 1.3rem; line-height: 1; }
.reveal-item[open] summary::after, .evidence[open] summary::after, .answer-review details[open] summary::after, .optional-video[open] summary::after { content: "−"; }
.reveal-item summary .seen { margin-left: auto; }
.reveal-item summary .seen + ::after { margin-left: 0; }
.reveal-item p { margin: 0; padding: 0 18px 16px; }
.numbered .reveal-item p { padding-left: 62px; }
.item-number { min-width: 32px; height: 32px; display: grid; place-items: center; background: var(--primary); color: white; border-radius: 8px; }
.seen { margin-left: auto; color: var(--success); font-size: .85rem; white-space: nowrap; }
.review-item { min-height: 50px; display: flex; align-items: flex-start; gap: 12px; padding: 12px 14px; background: white; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; font-weight: 600; }
.review-item:has(input:checked) { border-color: #9cc6c1; background: var(--accent-soft); }
.evidence { margin: 22px 0; }
.evidence-body { padding: 0 18px 12px; }
.evidence ul { padding-left: 20px; }

.order-row, .field { display: grid; gap: 6px; margin: 0 0 16px; }
.order-row { grid-template-columns: minmax(0, 1fr) 120px; align-items: center; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.order-result ol { padding-left: 24px; }
label { font-weight: 700; color: var(--ink); }
select, input[type="text"], textarea { width: 100%; min-height: 46px; padding: 10px 12px; color: var(--ink); background: white; border: 1px solid #8e9bab; border-radius: 8px; font-size: 1rem; }
textarea { resize: vertical; }
.check-row { min-height: 48px; display: flex; align-items: flex-start; gap: 12px; margin: 18px 0; padding: 14px; background: white; border: 1px solid var(--line); border-radius: 9px; }

.download-note { color: var(--muted); font-weight: 700; margin-top: 24px; }
.download-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 12px 0 24px; }
.download-card { min-height: 80px; display: grid; grid-template-columns: 44px 1fr; align-items: center; gap: 2px 14px; padding: 14px 16px; color: var(--ink); background: white; border: 1px solid var(--line); border-radius: 11px; text-decoration: none; }
.download-card:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.download-icon { grid-row: 1 / 3; width: 44px; height: 44px; display: grid; place-items: center; border-radius: 8px; background: var(--accent-soft); color: var(--accent); font-size: .78rem; font-weight: 800; }
.download-card small { color: var(--muted); }
.reference-list { padding-left: 0; list-style: none; display: grid; gap: 10px; }
.reference-list li { padding: 12px 14px; background: white; border: 1px solid var(--line); border-radius: 10px; }
.relevance { display: block; margin-top: 4px; color: var(--muted); font-size: .9rem; }

.result-panel, .completion-panel { padding: 30px; background: white; border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); text-align: center; }
.result-panel p, .completion-panel p { margin-left: auto; margin-right: auto; }
.result-panel.passed, .completion-panel { border-top: 6px solid var(--success); }
.result-panel.not-passed { border-top: 6px solid var(--warning-line); }
.result-status { margin: 0; font-weight: 800; font-size: 1.1rem; color: var(--primary-dark); }
.score { margin: 8px 0; color: var(--primary-dark); font-size: clamp(3rem, 8vw, 4.6rem); font-weight: 800; line-height: 1; }
.answer-review { display: grid; gap: 8px; }
.answer-review details > *:not(summary) { margin: 0; padding: 0 18px 10px; }
.completion-mark { width: 66px; height: 66px; display: grid; place-items: center; margin: 0 auto 16px; color: var(--success); border: 4px solid var(--success); border-radius: 50%; font-size: 2rem; font-weight: 900; }
.production-credit { margin-top: 28px; color: var(--muted); font-size: .86rem; text-align: center; max-width: none; }

.modal { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; padding: 20px; background: rgba(10, 18, 30, .6); }
.modal[hidden] { display: none; }
.modal-card { width: min(540px, 100%); max-height: 90vh; overflow: auto; padding: 26px; background: white; border-radius: 14px; box-shadow: 0 24px 70px rgba(0,0,0,.26); }
.modal-card.wide { width: min(820px, 100%); }
.modal-card h2 { margin-top: 0; }
.modal-actions { justify-content: flex-end; }
.toast { position: fixed; z-index: 300; right: 24px; bottom: 96px; max-width: min(420px, calc(100% - 48px)); padding: 14px 18px; color: white; background: var(--primary-dark); border-radius: 10px; box-shadow: var(--shadow); }
.toast.warning { background: #6b4a0e; }
.toast.success { background: var(--success); }
.drawer-overlay { display: none; }
.drawer-overlay[hidden] { display: none !important; }

@media (max-width: 960px) {
  .topbar { grid-template-columns: auto 1fr auto; }
  .course-name { display: none; }
  .menu-button { display: grid; }
  .course-layout { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 100; top: 0; bottom: 0; left: 0; width: min(300px, 88vw); overflow-y: auto; transform: translateX(-105%); visibility: hidden; transition: transform 200ms ease-out, visibility 200ms; box-shadow: 14px 0 40px rgba(0,0,0,.2); }
  .drawer-open .sidebar { transform: translateX(0); visibility: visible; }
  .drawer-overlay { position: fixed; z-index: 90; inset: 0; display: block; background: rgba(10,18,30,.5); }
  .bottom-nav { left: 0; padding-inline: 24px; }
}

@media (max-width: 680px) {
  .topbar { min-height: 64px; padding: 8px 12px; gap: 8px; }
  .wordmark span { display: none; }
  .wordmark strong { width: 42px; height: 42px; }
  .top-actions { gap: 0; }
  .text-button { padding: 8px; font-size: .9rem; }
  .progress-shell { padding: 8px 14px; flex-wrap: wrap; gap: 6px; }
  .progress-track { flex-basis: 100%; }
  .content-wrap { width: calc(100% - 28px); padding-top: 28px; padding-bottom: 170px; }
  .download-grid, .checklist-grid, .choice-grid { grid-template-columns: 1fr; }
  .order-row { grid-template-columns: 1fr; }
  .bottom-nav { grid-template-columns: 1fr 1fr; gap: 8px; padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); }
  #screen-position { grid-column: 1 / -1; grid-row: 1; }
  #back-button { grid-column: 1; grid-row: 2; }
  #next-button { grid-column: 2; grid-row: 2; }
  .button { width: 100%; padding-inline: 12px; }
  .video-tools .button, .action-row .button, .modal-actions .button, .quiz-actions .button { width: auto; }
  .numbered .reveal-item p { padding-left: 18px; }
}

@media (max-width: 380px) {
  .top-actions .text-button { font-size: .82rem; padding: 6px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}
