:root {
  color-scheme: light;
  --background: #f7f5f0;
  --paper: #fffdfa;
  --ink: #20322c;
  --muted: #56655c;
  --rule: #e0e1d8;
  --pine: #174a3e;
  --deep: #102f29;
  --mint: #e6efe6;
  --amber: #f2d596;
  --mobile-nav-height: 67px;
  --serif: Georgia, 'Times New Roman', serif;
  --sans: 'Segoe UI', system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; background: var(--background); color: var(--ink); font: 1rem/1.6 var(--sans); }
button, textarea, select { font: inherit; }
a { color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid #af652f; outline-offset: 4px; }
main [tabindex="-1"]:focus { outline: none; }
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { text-wrap: balance; }
p + p { margin-top: .85rem; }
.skip { position: fixed; z-index: 10; top: .5rem; left: .5rem; padding: .6rem 1rem; border-radius: .3rem; background: var(--paper); transform: translateY(-150%); }
.skip:focus { transform: none; }
.shell { display: grid; grid-template-columns: 238px minmax(0, 1fr); min-height: 100vh; }
.rail { display: flex; flex-direction: column; position: sticky; top: 0; height: 100dvh; overflow: auto; border-right: 1px solid var(--rule); background: #fdfbf6; padding: 28px 18px 20px; }
.brand { display: flex; gap: 11px; align-items: center; margin: 0 3px 33px; text-decoration: none; }
.brand-mark { flex: 0 0 39px; height: 39px; display: grid; place-items: center; border-radius: 11px; color: #f6ddb1; background: var(--pine); font: 1.65rem/1 var(--serif); }
.brand strong, .brand small { display: block; line-height: 1.36; }
.brand strong { font: 700 1.16rem/1.2 var(--serif); }
.brand small { margin-top: 4px; color: var(--muted); font-size: .81rem; }
.nav-title { margin: 0 12px 7px; font-size: .76rem; text-transform: uppercase; letter-spacing: .13em; font-weight: 750; color: var(--muted); }
.nav-title:not(:first-child) { margin-top: 25px; }
.rail nav a { display: flex; align-items: center; gap: 11px; border-radius: 8px; padding: 9px 11px; min-height: 44px; font-size: .93rem; font-weight: 600; text-decoration: none; color: var(--muted); }
.rail nav a:hover, .rail nav a[aria-current] { background: var(--mint); color: var(--pine); }
.rail nav a[aria-current] { font-weight: 750; }
.rail nav a span { width: 21px; text-align: center; font-size: 1.15rem; line-height: 1; }
.rail-progress { margin-top: auto; padding: 17px 10px 2px; }
.rail-progress > div, .activity-top { display: flex; justify-content: space-between; align-items: center; gap: .65rem; }
.rail-progress > div, .rail-progress small { font-size: .83rem; }
.rail-progress small { color: var(--muted); }
progress { display: block; width: 100%; height: 7px; margin: 9px 0; border: 0; border-radius: 50px; background: #e5e8df; accent-color: var(--pine); overflow: hidden; }
progress::-webkit-progress-bar { background: #e5e8df; }
progress::-webkit-progress-value { background: #3a7560; border-radius: 50px; }
progress::-moz-progress-bar { background: #3a7560; border-radius: 50px; }
.workspace { min-width: 0; }
.topbar { height: 70px; padding: 0 clamp(20px, 4.45vw, 74px); border-bottom: 1px solid var(--rule); background: #fdfbf6; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.crumb { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: .9rem; }
.crumb a { text-decoration: none; }
.crumb [data-page-title] { color: var(--ink); font-weight: 700; }
.top-link { color: var(--pine); font-size: .9rem; font-weight: 700; text-decoration: none; white-space: nowrap; }
.top-link:hover, .crumb a:hover { text-decoration: underline; }
.mobile-brand, .mobile-nav, .mobile-progress { display: none; }
.main { width: min(100%, 1400px); padding: 32px clamp(20px, 4.45vw, 74px) 55px; margin: 0 auto; }
.hero { position: relative; isolation: isolate; overflow: hidden; border-radius: 19px; min-height: 340px; padding: clamp(29px, 4.4vw, 63px); display: flex; align-items: center; color: #fff9eb; background: var(--deep); }
.hero::before { position: absolute; inset: 0; content: ''; z-index: -1; background: radial-gradient(ellipse at 86% 36%, #365f51, #143a31 53%, #102f29 78%); }
.hero-map { position: absolute; z-index: -1; right: -8%; top: -8%; width: 68%; height: 125%; object-fit: cover; object-position: 22% center; filter: grayscale(1) sepia(.7); opacity: .74; mix-blend-mode: luminosity; mask-image: linear-gradient(90deg, transparent, #000 41%); }
.hero::after { position: absolute; inset: 0; z-index: -1; content: ''; background: linear-gradient(90deg, #102f29 0%, #102f29ec 37%, #102f2960 67%, #102f2918 100%); }
.hero-copy { max-width: 560px; }
.eyebrow { font-weight: 750; font-size: .77rem; letter-spacing: .15em; text-transform: uppercase; color: #526a5f; }
.hero .eyebrow { color: #f3d89d; }
.hero h1 { font: 500 clamp(2.65rem, 5.1vw, 5rem)/.99 var(--serif); letter-spacing: -.05em; margin: 14px 0 16px; }
.hero p:not(.eyebrow) { max-width: 45ch; color: #f0f1e7; line-height: 1.55; }
.hero-action { margin-top: 23px; }
.map-credit { position: absolute; bottom: 12px; right: 16px; font-size: .75rem; text-decoration: none; color: #fff5df; background: #102f29d9; padding: 2px 8px; border-radius: 4px; }
.map-credit:hover { text-decoration: underline; }
.button { display: inline-flex; justify-content: center; align-items: center; gap: .45rem; min-height: 44px; border: 1px solid transparent; border-radius: 8px; padding: 9px 16px; background: var(--pine); color: #fffdf8; font-weight: 720; font-size: .94rem; line-height: 1.25; text-decoration: none; text-align: center; }
.button:hover { background: #22614f; }
.button.gold { background: var(--amber); color: #222f26; }
.button.gold:hover { background: #ffe0a2; }
.button.secondary { background: var(--paper); border-color: #cbd7ce; color: var(--pine); }
.button.secondary:hover { background: var(--mint); }
.button.secondary[aria-pressed="true"] { background: var(--mint); border-color: #67917c; }
.button:disabled { opacity: .62; cursor: default; }
.button.small { min-height: 39px; padding: 7px 13px; }
.section { margin-top: 34px; }
.section-heading { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 5px 20px; margin-bottom: 15px; }
.section-heading h2, .panel h2, .lecture h2 { font: 500 clamp(1.65rem, 3vw, 2.2rem)/1.16 var(--serif); letter-spacing: -.025em; }
.section-heading a { color: var(--pine); font-size: .9rem; font-weight: 700; text-underline-offset: 4px; }
.chapter-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 13px; }
.topic-card { display: flex; flex-direction: column; align-items: flex-start; min-width: 0; gap: 9px; min-height: 175px; border: 1px solid var(--rule); border-radius: 12px; padding: 15px 16px; background: var(--paper); text-decoration: none; transition: border-color .16s, box-shadow .16s; }
.topic-card:hover { border-color: #a4b9aa; box-shadow: 0 3px 11px #1b402010; }
.topic-card h3 { font: 700 1.2rem/1.18 var(--serif); }
.topic-card p { color: var(--muted); font-size: .91rem; line-height: 1.45; }
.card-top { display: flex; width: 100%; align-items: center; justify-content: space-between; gap: 8px; }
.tile-icon { border-radius: 8px; display: inline-grid; place-items: center; width: 34px; height: 34px; flex: 0 0 34px; color: var(--pine); background: var(--mint); font: 1.2rem/1 var(--sans); }
.topic-card:nth-child(2n) .tile-icon { background: #f2e9d6; color: #79542e; }
.card-top small, .fine { color: var(--muted); font-size: .81rem; }
.completed { color: var(--pine) !important; font-weight: 720; }
.routine { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); align-items: center; gap: 1rem; border-radius: 13px; padding: 22px; background: var(--mint); }
.routine > div > p { margin-top: 6px; color: #3d574b; }
.routine-list { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.routine-list a { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; padding: 7px 11px; background: #fbfdf7; border-radius: 6px; font-size: .9rem; font-weight: 650; text-decoration: none; }
.routine-list a:hover { text-decoration: underline; }
.routine-list span { color: var(--muted); font-size: .84rem; white-space: nowrap; }
.page-head { max-width: 820px; margin-bottom: 24px; }
.page-head h1 { margin: 4px 0 10px; font: 500 clamp(2.35rem, 5.2vw, 4.4rem)/1.02 var(--serif); letter-spacing: -.05em; }
.page-head > p:not(.eyebrow) { max-width: 67ch; color: var(--muted); }
.readable { max-width: 850px; }
.lecture, .panel { border: 1px solid var(--rule); border-radius: 13px; background: var(--paper); padding: clamp(17px, 3.3vw, 32px); }
.lecture + .lecture, .panel + .panel { margin-top: 12px; }
.lecture p, .panel p { margin-top: .7rem; }
.callout { margin-top: 17px; padding: 14px 17px; border-radius: 8px; border-left: 4px solid #437e63; background: var(--mint); }
.callout strong:first-child { display: block; margin-bottom: .2rem; color: var(--pine); }
.lesson-actions, .actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 17px; }
.lesson-actions { justify-content: space-between; }
.lesson-source { margin-top: 18px; }
.writing-panel { margin-top: 12px; }
.writing-examples { margin: .9rem 0 0; }
.writing-examples div { border-top: 1px solid var(--rule); padding: .65rem 0; }
.writing-examples dt { color: var(--pine); font-weight: 730; }
.writing-examples dd { margin: .25rem 0 0; }
.fold { margin-top: 14px; padding: 13px 16px; border: 1px solid var(--rule); border-radius: 9px; background: var(--paper); }
.fold summary { cursor: pointer; color: var(--pine); font-weight: 730; }
.fold > p { margin-top: 8px; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { display: grid; grid-template-columns: 118px minmax(0,1fr); position: relative; gap: 17px; align-items: baseline; padding: 13px 0 13px 20px; border-left: 2px solid #c6d8cb; }
.timeline li::before { content: ''; position: absolute; left: -6px; top: 21px; width: 10px; height: 10px; border-radius: 50%; background: var(--pine); }
.timeline strong { color: var(--pine); }
.timeline p { margin: 0; }
.activity-top { margin-bottom: 12px; color: var(--muted); font-size: .91rem; font-weight: 650; }
.activity-top label select { margin-left: .4rem; }
select { max-width: 100%; border: 1px solid #cbd7ce; background: var(--paper); color: var(--pine); border-radius: 7px; padding: 7px 8px; }
.afb-list { padding-left: 1.3rem; margin-bottom: .5rem; }
.afb-list strong { color: var(--pine); }
.operator-controls { display: grid; grid-template-columns: minmax(140px, 1fr) auto; gap: .3rem .8rem; align-items: center; margin-bottom: 14px; }
.operator-controls label { grid-column: 1 / -1; color: var(--pine); font-weight: 730; }
.operator-controls input { font: inherit; width: 100%; min-height: 44px; border: 1px solid #bfcfc4; border-radius: 8px; padding: 7px 11px; color: var(--ink); background: var(--paper); }
.operator-controls p { color: var(--muted); font-size: .87rem; }
.operator-heading { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 4px 13px; }
.operator-heading small { color: var(--pine); font-weight: 720; font-size: .85rem; }
.operator-entry .fold { background: #f2f6ee; }
.activity > progress { margin-bottom: 22px; }
.activity h2 { max-width: 30ch; }
.flash-face { display: flex; flex-direction: column; justify-content: center; min-height: 210px; padding: 24px; border-radius: 9px; background: #f2f6ee; }
.flash-face p { max-width: 64ch; }
.flash-face .eyebrow { margin: 0 0 7px; }
.answer-options { display: grid; gap: 9px; margin-top: 16px; }
.option { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 49px; text-align: left; color: var(--ink); background: var(--paper); border: 1px solid #d3dbd2; border-radius: 8px; padding: 9px 13px; }
.option:enabled:hover, .option[aria-pressed="true"] { border-color: #437e63; background: #ecf3e9; }
.option[disabled] { cursor: default; opacity: 1; }
.option[data-result="richtig"] { border-color: #437e63; background: #e5f1e4; }
.option[data-result="falsch"] { border-color: #a94f39; background: #fae9e2; }
.option[data-result]::after { margin-left: auto; font-weight: 750; }
.option[data-result="richtig"]::after { content: '✓'; }
.option[data-result="falsch"]::after { content: '×'; }
.option span { flex-shrink: 0; display: grid; place-items: center; width: 25px; height: 25px; color: var(--pine); background: #e8eee5; border-radius: 5px; font-size: .82rem; font-weight: 750; }
.score-number { color: var(--pine); font: 500 3.15rem/1 var(--serif); }
.exam-source { margin-bottom: 16px; }
.source-lines { padding-left: 2.2rem; }
.source-lines li { margin: 4px 0; padding-left: .45rem; }
.source-lines li::marker { color: #536a5c; font-size: .87rem; font-variant-numeric: tabular-nums; }
.exam-task label { display: block; margin-top: .8rem; font-weight: 650; }
textarea { width: 100%; min-height: 115px; resize: vertical; margin-top: 5px; border: 1px solid #bfcfc4; border-radius: 8px; background: #fffefa; color: var(--ink); padding: .7rem; }
.checks { display: grid; gap: 7px; padding: 0; list-style: none; }
.checks label { display: flex; align-items: baseline; gap: 8px; margin: 0; font-weight: 500; }
.checks input { accent-color: var(--pine); }
.storage-note { margin-top: 14px; }
.material-list { padding-left: 1.25rem; }
.material-list li { margin-top: 7px; }
.material-list a { color: var(--pine); text-underline-offset: 3px; }
.nav-demo { margin-top: 13px; }
.coordinate-grid { position: relative; height: 135px; margin: 16px 0 9px; border: 1px solid #c1d6cd; border-radius: 8px; overflow: hidden; background: repeating-linear-gradient(0deg, transparent 0 24%, #c0d7cf 24% 25%), repeating-linear-gradient(90deg, transparent 0 19.5%, #c0d7cf 19.5% 20%), #e8f1e9; }
.coordinate-grid::before { content: ''; display: block; position: absolute; inset: 49% 0 auto; height: 2px; background: #22614f; }
.coordinate-grid[data-mode="length"]::before { inset: 0 auto 0 59%; width: 2px; height: 100%; }
.coordinate-grid span { position: absolute; top: calc(49% - 15px); left: 17%; display: grid; place-items: center; width: 31px; height: 31px; color: white; background: var(--pine); border: 2px solid white; border-radius: 50%; transform: translateX(-50%); font-size: .87rem; }
.coordinate-grid span + span { left: 79%; }
.coordinate-grid[data-mode="length"] span { left: 59%; top: calc(26% - 15px); }
.coordinate-grid[data-mode="length"] span + span { top: calc(74% - 15px); }

@media (max-width: 1050px) {
  .shell { grid-template-columns: 204px minmax(0, 1fr); }
  .rail { padding-inline: 13px; }
  .chapter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hero-map { width: 76%; }
}
@media (max-width: 760px) {
  .shell { display: block; }
  .rail, .crumb { display: none; }
  .topbar { height: auto; min-height: calc(56px + env(safe-area-inset-top)); padding: env(safe-area-inset-top) max(15px, env(safe-area-inset-right)) 0 max(15px, env(safe-area-inset-left)); }
  .mobile-brand { display: inline-flex; align-items: center; gap: 7px; min-height: 44px; color: var(--ink); font: 700 1.04rem/1.1 var(--serif); text-decoration: none; }
  .mobile-brand span { display: grid; width: 26px; height: 26px; place-items: center; color: #f6ddb1; background: var(--pine); border-radius: 7px; }
  .top-link { display: inline-flex; align-items: center; gap: .35rem; min-height: 44px; font-size: .88rem; }
  .main { padding: 17px max(15px, env(safe-area-inset-right)) calc(var(--mobile-nav-height) + env(safe-area-inset-bottom) + 22px) max(15px, env(safe-area-inset-left)); }
  .mobile-nav { position: fixed; z-index: 4; inset: auto 0 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 3px; min-height: calc(var(--mobile-nav-height) + env(safe-area-inset-bottom)); padding: 5px max(7px, env(safe-area-inset-right)) calc(6px + env(safe-area-inset-bottom)) max(7px, env(safe-area-inset-left)); border-top: 1px solid var(--rule); background: #fdfbf6; }
  .mobile-nav a, .mobile-nav button { display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 3px; min-height: 48px; border: 0; border-radius: 9px; padding: 3px 1px; background: transparent; color: var(--muted); font: 680 .82rem/1.2 var(--sans); text-decoration: none; -webkit-tap-highlight-color: transparent; }
  .mobile-nav a:active, .mobile-nav button:active { background: var(--mint); }
  .mobile-nav a[aria-current], .mobile-nav button[data-active], .mobile-nav button[aria-expanded="true"] { background: var(--mint); color: var(--pine); }
  .mobile-nav span { font: 1.25rem/1 var(--sans); }
  body:has(main textarea:focus, main input[type="search"]:focus) .mobile-nav { visibility: hidden; }
  html:has(#mobile-more[open]) { overflow: hidden; }
  #mobile-more { width: min(100%, 480px); max-width: 100%; max-height: calc(100dvh - env(safe-area-inset-top) - 10px); margin: auto auto 0; border: 1px solid var(--rule); border-radius: 20px 20px 0 0; padding: 16px max(16px, env(safe-area-inset-right)) calc(16px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); color: var(--ink); background: var(--paper); }
  #mobile-more::backdrop { background: #102f2978; }
  .mobile-more-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
  .mobile-more-head h2 { font: 700 1.34rem/1.2 var(--serif); }
  .mobile-more-links { display: grid; gap: 8px; }
  .mobile-more-links a { min-height: 48px; display: flex; align-items: center; padding: 8px 12px; border-radius: 8px; background: var(--background); color: var(--pine); text-decoration: none; font-weight: 675; }
  .mobile-more-links a[aria-current] { background: var(--mint); }
  .hero { min-height: 290px; padding: 24px 19px 38px; }
  .hero-map { width: 92%; right: -18%; opacity: .55; }
  .hero::after { background: linear-gradient(90deg, #102f29 0%, #102f29e6 35%, #102f294f 100%); }
  .hero h1 { font-size: clamp(2.15rem, 9.1vw, 4rem); }
  .section { margin-top: 26px; }
  .section-heading a { display: inline-flex; align-items: center; min-height: 44px; }
  .mobile-progress { display: grid; grid-template-columns: auto minmax(35px, 1fr) auto; gap: 9px; align-items: center; margin: -2px 0 12px; color: var(--muted); font-size: .86rem; }
  .mobile-progress progress { margin: 0; }
  .routine { grid-template-columns: 1fr; }
  .routine-list a { min-height: 46px; align-items: center; }
  .button, .button.small { min-height: 46px; }
  .fold { padding-block: 0; }
  .fold summary { min-height: 46px; padding-block: 11px; }
  .fold[open] { padding-bottom: 13px; }
  .answer-options .option { min-height: 52px; }
  .activity-top { flex-wrap: wrap; }
  .activity-top label { display: flex; align-items: center; min-width: 0; }
  .activity-top select, .operator-controls input, textarea { min-width: 0; min-height: 46px; font-size: 1rem; }
  .activity-top select { max-width: min(52vw, 232px); }
  textarea { min-height: 135px; }
  .checks label { align-items: center; min-height: 44px; }
  .checks input { flex: 0 0 19px; width: 19px; height: 19px; margin: 0; }
  .panel { scroll-margin-bottom: calc(var(--mobile-nav-height) + env(safe-area-inset-bottom) + 12px); }
  #quiz-feedback { scroll-margin-bottom: calc(var(--mobile-nav-height) + env(safe-area-inset-bottom) + 8px); }
}
@media (max-width: 540px) {
  .chapter-grid { grid-template-columns: 1fr; }
  .topic-card { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; align-items: start; min-height: auto; gap: 5px 10px; padding: 13px; }
  .card-top { display: contents; }
  .tile-icon { grid-column: 1; grid-row: span 2; }
  .card-top small { grid-column: 3; grid-row: 1; white-space: nowrap; }
  .topic-card h3 { grid-column: 2; grid-row: 1; font-size: 1.13rem; overflow-wrap: anywhere; }
  .topic-card p { grid-column: 2 / -1; grid-row: 2; }
  .timeline li { grid-template-columns: 1fr; gap: 2px; padding-block: 10px; }
  .lesson-actions > *, .quiz-actions .button { width: 100%; }
  .flash-face { min-height: 174px; padding: 16px; }
  .flash-face + .actions, .card-navigation { display: grid; grid-template-columns: 1fr 1fr; }
  .flash-face + .actions [data-action="flash-reveal"] { grid-column: 1 / -1; }
  .operator-controls { grid-template-columns: minmax(0, 1fr) auto; }
}
@media (max-width: 360px) {
  .top-link { font-size: .81rem; }
  .topic-card { grid-template-columns: 30px minmax(0, 1fr) auto; }
  .topic-card .tile-icon { width: 30px; height: 30px; }
  .operator-controls { grid-template-columns: 1fr; }
  .operator-controls p { margin: 0; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}
