:root {
  --paper: #faf7f0;
  --surface: #ffffff;
  --ink: #1d2b2a;
  --muted: #5c6b68;
  --line: #ddd8cb;
  --brand: #0f5c55;
  --brand-ink: #ffffff;
  --brand-soft: #dcefe9;
  --accent: #b5502a;
  --accent-soft: #f8e5da;
  --ok: #1d6b45;
  --ok-soft: #dff2e6;
  --no: #a03428;
  --no-soft: #fae3df;
  --radius: 10px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #141c1b;
    --surface: #1d2726;
    --ink: #e9eeec;
    --muted: #a3b1ae;
    --line: #35433f;
    --brand: #6cc7b6;
    --brand-ink: #0b2320;
    --brand-soft: #21403a;
    --accent: #ee9a73;
    --accent-soft: #46291c;
    --ok: #79d2a0;
    --ok-soft: #1c3d2b;
    --no: #f19a8d;
    --no-soft: #472320;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 17px/1.6 var(--sans); }
h1, h2, h3, h4 { font-family: var(--serif); line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: clamp(2rem, 5vw, 3rem); letter-spacing: -.01em; }
h2 { font-size: 1.55rem; }
h3 { font-size: 1.2rem; }
h4 { font-size: 1.05rem; margin-top: 1.2em; }
p { margin: 0 0 1em; }
a { color: var(--brand); text-underline-offset: 2px; }
.wrap { width: min(1120px, 100%); margin: 0 auto; padding: 0 16px; }
.page { padding-top: 40px; padding-bottom: 64px; }
.page-narrow { width: min(760px, 100%); }
.section { padding-top: 48px; padding-bottom: 16px; }
.muted { color: var(--muted); font-size: .92rem; }
.lede { font-size: 1.15rem; }
.eyebrow { color: var(--accent); font-size: .78rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; margin-bottom: .5em; }
.skip-link { position: absolute; left: -999px; }
.skip-link:focus { left: 8px; top: 8px; background: var(--surface); padding: 8px; z-index: 5; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.site-header { background: var(--surface); border-bottom: 1px solid var(--line); }
.site-header-inner { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; padding-top: 12px; padding-bottom: 12px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); font-family: var(--serif); font-weight: 700; text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; background: var(--brand); color: var(--brand-ink); font-size: .85rem; }
.site-nav { display: flex; align-items: center; gap: 16px; font-size: .92rem; flex-wrap: wrap; }
.progress-pill { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.progress-track { display: block; width: 72px; height: 8px; background: var(--line); border-radius: 8px; overflow: hidden; }
.progress-track span { display: block; height: 100%; background: var(--brand); }
.site-footer { border-top: 1px solid var(--line); padding: 20px 0; font-size: .9rem; color: var(--muted); }
.site-footer .wrap { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }

.btn { display: inline-block; padding: 10px 18px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); font: 600 1rem var(--sans); text-decoration: none; cursor: pointer; }
.btn:hover:not(:disabled) { border-color: var(--brand); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-small { padding: 5px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--ink); font: 600 .85rem var(--sans); cursor: pointer; text-align: left; }
.btn-small:hover { border-color: var(--brand); }

label { display: block; font-weight: 600; margin-bottom: 6px; }
input:not([type=radio]):not([type=checkbox]):not([type=range]), textarea, select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--paper); color: var(--ink); font: inherit;
}
input[type=range] { width: 100%; accent-color: var(--brand); }
.field { margin-bottom: 16px; }
.field .muted { margin-bottom: 6px; }
.has-error textarea { border-color: var(--no); }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; margin-bottom: 24px; }
.panel form .btn, form.panel .btn { margin-top: 12px; }
.panel-code { border-color: var(--accent); }
.code-display { font: 700 1.5rem ui-monospace, Menlo, monospace; letter-spacing: .06em; color: var(--accent); margin: 0; overflow-wrap: anywhere; }
.alert { background: var(--no-soft); color: var(--no); padding: 10px 14px; border-radius: 8px; }

.hero { background: var(--brand-soft); padding: 64px 0; }
.hero-grid { display: grid; grid-template-columns: 1.3fr 1fr; gap: 48px; align-items: center; }
.ladder { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.ladder li { display: flex; align-items: center; gap: 12px; padding: 10px 14px; margin-left: calc((5 - var(--step)) * -0px + (var(--step) - 1) * 24px); background: var(--surface); border-radius: 8px; border-left: 4px solid var(--brand); }
.ladder span { color: var(--accent); font-weight: 700; }
.module-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.module-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.module-card p:last-child { margin: 0; }
.module-card-accent { background: var(--accent-soft); border-color: var(--accent); }
.two-col { display: grid; grid-template-columns: 1.3fr 1fr; gap: 40px; padding-bottom: 64px; }
.ticks { padding: 0; list-style: none; }
.ticks li { padding-left: 26px; position: relative; margin-bottom: 8px; }
.ticks li::before { content: "✓"; position: absolute; left: 0; color: var(--brand); font-weight: 700; }

.module-list { display: grid; gap: 16px; margin-top: 24px; }
.module-row { display: grid; grid-template-columns: 52px 1fr; gap: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.module-row.is-locked { background: transparent; }
.module-row.is-locked h2, .module-row.is-locked p { color: var(--muted); }
.module-row-final { border-color: var(--accent); }
.module-number { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; background: var(--brand); color: var(--brand-ink); font: 700 1.1rem var(--serif); }
.is-locked .module-number { background: var(--line); color: var(--muted); }
.lesson-list { list-style: none; padding: 0; margin: 0; border-top: 1px solid var(--line); }
.lesson-list li { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0 9px 26px; border-bottom: 1px solid var(--line); position: relative; }
.lesson-list li::before { content: "○"; position: absolute; left: 2px; color: var(--muted); }
.lesson-list li.is-done::before { content: "✓"; color: var(--ok); font-weight: 700; }
.resume-line { margin-top: 24px; }

.lesson-layout { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 48px; padding-top: 40px; padding-bottom: 64px; align-items: start; }
.lesson-nav { position: sticky; top: 16px; font-size: .92rem; }
.lesson-nav-title { font-family: var(--serif); font-weight: 700; font-size: 1.1rem; }
.lesson-nav ol { list-style: none; margin: 0; padding: 0; }
.lesson-nav li { padding: 7px 0 7px 12px; border-left: 3px solid var(--line); }
.lesson-nav li.is-current { border-left-color: var(--accent); font-weight: 700; }
.lesson-nav li.is-done { border-left-color: var(--brand); }
.lesson { max-width: 760px; min-width: 0; }
.lesson h2 { margin-top: 1.6em; }
.lesson-complete { margin-top: 40px; padding-top: 20px; border-top: 1px solid var(--line); }

.callout { border-left: 4px solid var(--brand); background: var(--brand-soft); border-radius: 0 var(--radius) var(--radius) 0; padding: 16px 20px; margin: 24px 0; }
.callout-classroom { border-left-color: var(--accent); background: var(--accent-soft); }
.callout h3 { font-size: 1.05rem; }
.callout > :last-child { margin-bottom: 0; }

.activity { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin: 28px 0; }
.activity.is-done { border-color: var(--ok); }
.activity-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; margin-bottom: 12px; }
.activity-head h3 { margin: 0; flex: 1 1 200px; }
.activity-tag { font-size: .72rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); width: 100%; }
.activity-state { font-size: .88rem; font-weight: 700; color: var(--ok); }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 12px 0; }
.row-input input { flex: 1 1 200px; width: auto !important; }
.feedback { padding: 10px 14px; border-radius: 8px; margin: 12px 0; }
.feedback-ok { background: var(--ok-soft); color: var(--ok); }
.feedback-no { background: var(--no-soft); color: var(--no); }
.score-line { font-family: var(--serif); font-size: 1.2rem; font-weight: 700; }
.sort-card { background: var(--paper); border: 1px dashed var(--line); border-radius: 8px; padding: 18px; font-size: 1.05rem; margin-bottom: 12px; }
.sort-bins { display: flex; flex-wrap: wrap; gap: 8px; }
.generated-text { font-family: var(--serif); font-size: 1.25rem; background: var(--paper); border-radius: 8px; padding: 14px; }
.bars { display: grid; gap: 6px; }
.bar { position: relative; display: flex; justify-content: space-between; gap: 12px; padding: 7px 12px; border: 1px solid var(--line); border-radius: 6px; background: var(--paper); color: var(--ink); font: 600 .95rem var(--sans); cursor: pointer; overflow: hidden; }
.bar:hover { border-color: var(--brand); }
.bar-fill { position: absolute; inset: 0 auto 0 0; background: var(--brand-soft); }
.bar-label, .bar-value { position: relative; }
.hotspot-text { background: var(--paper); border-radius: 8px; padding: 14px; margin-bottom: 12px; line-height: 1.9; }
.hotspot { display: inline; padding: 2px 3px; border: 0; border-bottom: 2px dotted var(--line); background: none; color: var(--ink); font: inherit; text-align: left; cursor: pointer; }
.hotspot:hover:not(:disabled) { background: var(--brand-soft); }
.hotspot[aria-pressed=true] { background: var(--accent-soft); border-bottom-color: var(--accent); }
.hotspot.is-flaw { background: var(--no-soft); color: var(--no); border-bottom: 2px solid var(--no); }
.hotspot:disabled { cursor: default; }
.builder-output, .prompt-card pre { margin: 12px 0; padding: 14px; background: var(--paper); border-radius: 8px; font: .92rem/1.55 ui-monospace, Menlo, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
.prompt-card { border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius); padding: 14px 16px; margin: 20px 0; }
.prompt-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.prompt-card pre { margin-bottom: 0; }
details { margin: 12px 0; }
summary { cursor: pointer; font-weight: 600; }
.scenario-text { font-size: 1.05rem; }
.choices { display: grid; gap: 8px; }
.choice { padding: 12px 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); color: var(--ink); font: inherit; text-align: left; cursor: pointer; }
.choice:hover { border-color: var(--brand); }
.choice.is-best { border-color: var(--ok); background: var(--ok-soft); }
.choice.is-other { border-color: var(--no); background: var(--no-soft); }
.train-list { list-style: none; padding: 0; margin: 8px 0; max-height: 260px; overflow-y: auto; font-size: .92rem; }
.train-list li { padding: 6px 8px; border-bottom: 1px solid var(--line); }
.train-tag { display: inline-block; min-width: 88px; margin-right: 8px; font-size: .75rem; font-weight: 700; }
.label-a .train-tag { color: var(--accent); }
.label-b .train-tag { color: var(--brand); }
.prediction { background: var(--paper); border-radius: 8px; padding: 12px 14px; margin-top: 8px; }
.prediction-label { font-family: var(--serif); font-size: 1.2rem; font-weight: 700; margin-bottom: .3em; }

table { width: 100%; border-collapse: collapse; margin: 16px 0; font-size: .95rem; }
th, td { padding: 8px 10px; border: 1px solid var(--line); text-align: left; vertical-align: top; }
th { background: var(--brand-soft); }
.table-scroll { overflow-x: auto; }

.quiz-item { border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius); padding: 18px; margin: 0 0 16px; }
.quiz-item legend { float: left; width: 100%; font-weight: 600; margin-bottom: 10px; padding: 0; }
.quiz-item legend span { color: var(--accent); }
.quiz-option { clear: both; display: flex; gap: 10px; align-items: flex-start; font-weight: 400; padding: 8px; border-radius: 6px; cursor: pointer; margin: 0; }
.quiz-option:hover { background: var(--paper); }
.quiz-option input { margin-top: 6px; accent-color: var(--brand); }
.self-check { border: 1px solid var(--line); border-radius: var(--radius); margin: 0 0 20px; padding: 16px; background: var(--surface); }
.self-check legend { font-weight: 700; padding: 0 6px; }
.result-score { font: 700 3rem var(--serif); margin: 0; }
.result-pass { border-color: var(--ok); }
.result-retry { border-color: var(--accent); }
.quiz-review { padding-left: 20px; }
.quiz-review li { margin-bottom: 16px; }
.quiz-review .is-right::marker { color: var(--ok); }
.quiz-review .is-wrong::marker { color: var(--no); }
.quiz-question { font-weight: 600; margin-bottom: .25em; }
.portfolio-item { border-top: 1px solid var(--line); padding-top: 20px; margin-top: 24px; }

.certificate-actions { padding-bottom: 16px; }
.certificate-stage { overflow-x: auto; padding: 0 16px 48px; }
.certificate {
  --cert: #0f5c55; color: #1d2b2a; background: #fffdf8; text-align: center;
  width: 960px; height: 660px; margin: 0 auto; padding: 44px 64px; position: relative;
  border: 12px double var(--cert); display: flex; flex-direction: column; justify-content: center;
  -webkit-print-color-adjust: exact; print-color-adjust: exact;
}
.certificate p { margin: 0; }
.cert-org { font-size: 1rem; letter-spacing: .12em; text-transform: uppercase; color: #5c6b68; }
.cert-kicker { font: 700 2.4rem var(--serif); color: var(--cert); margin: 10px 0 18px !important; }
.cert-small { font-size: 1rem; color: #40504d; max-width: 640px; margin-inline: auto !important; }
.cert-name { font: italic 700 2.7rem var(--serif); border-bottom: 1px solid #b9b2a2; margin: 10px auto 14px !important; padding: 0 32px 6px; min-width: 60%; overflow-wrap: anywhere; }
.cert-course { font: 700 1.6rem var(--serif); color: #b5502a; margin: 8px 0 !important; }
.cert-foot { display: grid; grid-template-columns: 1fr auto 1fr; gap: 24px; align-items: end; margin-top: 30px; font-size: .85rem; color: #5c6b68; }
.cert-line { display: block; font-weight: 700; color: #1d2b2a; border-bottom: 1px solid #b9b2a2; padding-bottom: 4px; margin-bottom: 4px; }
.cert-seal { display: grid; place-items: center; width: 76px; height: 76px; border-radius: 50%; background: var(--cert); color: #fff; font: 700 1.5rem var(--serif); box-shadow: 0 0 0 4px #fffdf8, 0 0 0 6px var(--cert); }
.cert-verify { font-size: .72rem; color: #5c6b68; margin-top: 18px !important; overflow-wrap: anywhere; }

@media (max-width: 860px) {
  .hero-grid, .two-col, .lesson-layout { grid-template-columns: 1fr; }
  .hero { padding: 40px 0; }
  .ladder { display: none; }
  .lesson-layout { gap: 16px; padding-top: 20px; }
  .lesson-nav { position: static; }
  .lesson-nav ol { display: none; }
}

@page { margin: 10mm; }
@page certificate { size: A4 landscape; margin: 10mm; }
@media print {
  .certificate-stage { page: certificate; }
  .site-header, .site-footer, .no-print, .skip-link { display: none !important; }
  body { background: #fff; color: #000; }
  .certificate-stage { padding: 0; overflow: visible; }
  .certificate { break-inside: avoid; margin: 0 auto; }
}
