/* Layout: sticky search bar, chapter sidebar left, reading column right (65ch); stacks to one column on phones.
   Look: cool "Leinen" neutrals, Waschblau accent, care-label line icons per chapter. */
:root {
  --bg: #f2f4f3;
  --surface: #ffffff;
  --surface-2: #e8edeb;
  --ink: #17201e;
  --muted: #56635f;
  --line: #d3dcd8;
  --accent: #1d4f8c;
  --accent-soft: #e2eaf5;
  --warn-bg: #fff3d6;
  --warn-ink: #6b4500;
  --warn-line: #e8c26a;
  --de: #8a6510;
  --de-bg: #f6efdc;
  --focus: #1d4f8c;
  --font-display: "Bricolage Grotesque", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --font-body: "Literata", "Iowan Old Style", Georgia, "Times New Roman", serif;
  --font-ui: "IBM Plex Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  --step-0: 1.0625rem;
  --step-1: 1.25rem;
  --step-2: 1.6rem;
  --step-3: clamp(1.9rem, 1.4rem + 2vw, 2.6rem);
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111715; --surface: #18201e; --surface-2: #212b28; --ink: #e3ebe8; --muted: #9caaa5; --line: #2c3834;
    --accent: #8db4ec; --accent-soft: #1d2b3d; --warn-bg: #33280f; --warn-ink: #f1cd7c; --warn-line: #6e5520;
    --de: #e3c06e; --de-bg: #2c2513; --focus: #8db4ec; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111715; --surface: #18201e; --surface-2: #212b28; --ink: #e3ebe8; --muted: #9caaa5; --line: #2c3834;
  --accent: #8db4ec; --accent-soft: #1d2b3d; --warn-bg: #33280f; --warn-ink: #f1cd7c; --warn-line: #6e5520;
  --de: #e3c06e; --de-bg: #2c2513; --focus: #8db4ec; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font-ui); font-size: 15px; line-height: 1.5; }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 30; background: var(--surface); }
a { color: var(--accent); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* top bar */
.topbar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar-inner { max-width: 1240px; margin: 0 auto; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 24px;
  padding-block: 10px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--font-display); font-weight: 700; font-size: 1.15rem; color: var(--ink); text-decoration: none; letter-spacing: -0.01em; }
.brand-mark { width: 22px; height: 22px; border: 2px solid var(--accent); border-radius: 3px 3px 9px 9px; position: relative; }
.brand-mark::after { content: ""; position: absolute; left: 3px; right: 3px; top: 5px; height: 2px; background: var(--accent); border-radius: 2px; }
.search { flex: 1 1 280px; display: flex; align-items: center; gap: 8px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 0 14px; min-width: 0; }
.search svg { width: 18px; height: 18px; color: var(--muted); flex: none; }
.search input { flex: 1; min-width: 0; border: 0; background: transparent; color: var(--ink); font: inherit; font-size: 15px; padding: 9px 0; }
.search input:focus { outline: none; }
.search:focus-within { border-color: var(--accent); }

/* layout */
.layout { max-width: 1240px; margin: 0 auto; display: grid; grid-template-columns: 270px minmax(0, 1fr); gap: 40px;
  padding-block: 28px 64px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.sidebar { position: sticky; top: calc(env(safe-area-inset-top, 0px) + 74px); align-self: start; max-height: calc(100vh - 100px); overflow-y: auto; padding-right: 4px; }
.main { min-width: 0; }
.main:focus { outline: none; }
@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); gap: 16px; padding-block: 16px 48px; }
  .sidebar { position: static; max-height: none; overflow: visible; }
}

/* sidebar nav */
.nav-mobile > summary { display: none; }
@media (max-width: 900px) {
  .nav-mobile > summary { display: flex; align-items: center; justify-content: space-between; cursor: pointer; list-style: none; font-weight: 600;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; }
  .nav-mobile > summary::after { content: "▾"; color: var(--muted); }
  .nav-mobile[open] > summary::after { content: "▴"; }
  .nav-mobile > .nav-list { margin-top: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; }
}
.nav-filter { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 14px; }
.chip { font: inherit; font-size: 13px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 999px; padding: 4px 11px; cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--surface); }
.nav-ch { border-bottom: 1px solid var(--line); }
.nav-ch > summary { display: flex; align-items: center; gap: 10px; padding: 9px 4px; cursor: pointer; list-style: none; font-weight: 600; }
.nav-ch > summary::-webkit-details-marker { display: none; }
.nav-ch > summary .count { margin-left: auto; font-weight: 400; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.nav-ch ul { list-style: none; margin: 0 0 10px; padding: 0 0 0 30px; display: grid; gap: 1px; }
.nav-ch li a { display: block; padding: 4px 8px; border-radius: 6px; color: var(--muted); text-decoration: none; font-size: 14px; line-height: 1.35; }
.nav-ch li a:hover { color: var(--ink); background: var(--surface-2); }
.nav-ch li a[aria-current="page"] { color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.nav-extra { display: block; margin-top: 14px; font-size: 14px; }
.ch-icon { width: 20px; height: 20px; flex: none; color: var(--accent); }
.ch-icon.big { width: 44px; height: 44px; }

/* home */
.hero { max-width: 760px; padding-block: 8px 28px; }
.eyebrow { font-size: 12px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted); margin: 0 0 10px; font-weight: 600; }
.hero h1, .note h1, .chapter-head h1 { font-family: var(--font-display); font-weight: 700; letter-spacing: -0.02em; line-height: 1.08; text-wrap: balance; margin: 0; }
.hero h1 { font-size: var(--step-3); }
.hero-text { font-family: var(--font-body); font-size: var(--step-0); line-height: 1.65; color: var(--muted); max-width: 62ch; margin: 14px 0 22px; }
.quick-row { display: flex; flex-wrap: wrap; gap: 8px; }
.quick { display: inline-flex; align-items: center; gap: 8px; padding: 7px 13px 7px 10px; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; color: var(--ink); text-decoration: none; font-size: 14px; }
.quick:hover { border-color: var(--accent); }
.ch-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 18px; }
.ch-block { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px 16px; min-width: 0; }
.ch-head { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; }
.ch-head h2 { font-family: var(--font-display); font-size: var(--step-1); margin: 0; letter-spacing: -0.01em; }
.ch-head .count { margin-left: auto; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.chapter-intro { color: var(--muted); margin: 6px 0 10px; font-size: 14px; }
.ch-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 2px; }
.ch-list a { color: var(--ink); text-decoration: none; font-size: 14.5px; }
.ch-list a:hover { color: var(--accent); text-decoration: underline; }
.mini-de { font-style: normal; font-size: 10.5px; font-weight: 600; letter-spacing: 0.06em; color: var(--de); background: var(--de-bg); border-radius: 4px; padding: 1px 5px; margin-left: 4px; vertical-align: 1px; }

/* chapter page */
.chapter-head { display: flex; gap: 16px; align-items: center; margin-bottom: 18px; }
.chapter-head h1 { font-size: var(--step-3); }
.note-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; max-width: 820px; }
.note-list a { display: grid; gap: 3px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; color: var(--ink); }
.note-list a:hover { border-color: var(--accent); }
.item-title { font-weight: 600; font-size: 15.5px; }
.item-kurz { color: var(--muted); font-size: 14px; }

/* note */
.note { max-width: 760px; }
.crumb { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); text-decoration: none; margin-bottom: 10px; }
.crumb:hover { color: var(--accent); }
.note h1 { font-size: var(--step-3); }
.badges { display: flex; flex-wrap: wrap; gap: 6px; margin: 14px 0 18px; }
.badge { font-size: 12.5px; padding: 3px 9px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.badge-de { background: var(--de-bg); color: var(--de); font-weight: 600; }
.badge-mix { background: var(--de-bg); color: var(--de); }
.lead { background: var(--accent-soft); border-radius: var(--radius); padding: 16px 20px; margin-bottom: 26px; }
.lead-label { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: 0.12em; font-weight: 600; color: var(--accent); margin-bottom: 4px; }
.lead p { margin: 0; font-family: var(--font-body); font-size: 1.12rem; line-height: 1.6; }
.prose { font-family: var(--font-body); font-size: var(--step-0); line-height: 1.7; }
.prose > * { max-width: 68ch; }
.prose h2 { font-family: var(--font-display); font-size: var(--step-2); letter-spacing: -0.015em; line-height: 1.2; margin: 2em 0 0.5em; text-wrap: balance; }
.prose h3 { font-family: var(--font-ui); font-size: 1.05rem; font-weight: 600; margin: 1.6em 0 0.4em; }
.prose p, .prose ul, .prose ol { margin: 0 0 1em; }
.prose ul, .prose ol { padding-left: 1.3em; }
.prose li { margin: 0.25em 0; }
.prose li::marker { color: var(--muted); }
.prose strong { font-weight: 600; }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 2em 0; }
.prose blockquote { margin: 1.2em 0; padding: 12px 16px; border-left: 3px solid var(--line); background: var(--surface); border-radius: 0 var(--radius) var(--radius) 0; }
.prose blockquote p { margin: 0 0 0.5em; }
.prose blockquote p:last-child { margin: 0; }
.prose blockquote.warn { background: var(--warn-bg); color: var(--warn-ink); border-left-color: var(--warn-line); }
.prose blockquote.warn a { color: inherit; }
.prose blockquote.de-note { background: transparent; border-left-color: var(--de); color: var(--muted); font-size: 0.95em; }
.prose code { font-size: 0.9em; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
li.todo { list-style: none; position: relative; }
li.todo .box { position: absolute; left: -1.35em; top: 0.42em; width: 0.85em; height: 0.85em; border: 1.5px solid var(--muted); border-radius: 3px; }
li.todo.done .box { background: var(--accent); border-color: var(--accent); }
.table-wrap { overflow-x: auto; margin: 1.2em 0 1.4em; max-width: 100% !important; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.prose table { border-collapse: collapse; width: 100%; font-family: var(--font-ui); font-size: 14px; line-height: 1.45; font-variant-numeric: tabular-nums; }
.prose th, .prose td { text-align: left; vertical-align: top; padding: 9px 12px; border-bottom: 1px solid var(--line); }
.prose th { background: var(--surface-2); font-weight: 600; }
.prose tr:last-child td { border-bottom: 0; }
.de-section { margin-top: 2.4em; padding: 4px 20px 8px; border: 1px dashed var(--de); border-radius: var(--radius); background: var(--de-bg); }
.de-section > h2 { display: flex; align-items: center; gap: 10px; margin-top: 0.8em; color: var(--de); }
.de-section .flag { width: 18px; height: 12px; border-radius: 2px; background: linear-gradient(#1b1b1b 0 33.3%, #c8102e 33.3% 66.6%, #e8b500 66.6%); flex: none; }
.de-section .table-wrap { background: var(--surface); }
.sources { margin-top: 2.4em; border-top: 1px solid var(--line); padding-top: 8px; }
.sources > summary { cursor: pointer; font-weight: 600; padding: 8px 0; display: flex; gap: 8px; align-items: center; }
.sources .count { color: var(--muted); font-weight: 400; font-variant-numeric: tabular-nums; }
.sources-body { font-size: 13.5px; color: var(--muted); overflow-wrap: anywhere; }
.sources-body ul { padding-left: 1.1em; margin: 0.4em 0 1em; display: grid; gap: 5px; }
.sources-body a { color: var(--muted); }
.sources-body p { margin: 0.6em 0 0.2em; }
.prevnext { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 2.4em; }
.prevnext a { display: grid; gap: 2px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); text-decoration: none; color: var(--ink); font-weight: 600; font-size: 14.5px; min-width: 0; }
.prevnext a span { font-size: 12px; font-weight: 500; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.prevnext .next { text-align: right; }
.prevnext a:hover { border-color: var(--accent); }
@media (max-width: 520px) { .prevnext { grid-template-columns: 1fr; } .prevnext .next { text-align: left; } }

/* search results */
.search-results { max-width: 820px; margin-bottom: 28px; }
.results-head { font-size: 13px; color: var(--muted); margin: 0 0 10px; }
.result-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.result-list a { display: grid; gap: 2px; padding: 12px 14px; border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius); color: var(--ink); text-decoration: none; }
.result-list a:hover { border-color: var(--accent); }
.result-ch { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-weight: 600; }
.result-title { font-weight: 600; }
.result-snip { font-size: 14px; color: var(--muted); }
.result-snip mark { background: var(--warn-bg); color: var(--ink); border-radius: 2px; padding: 0 1px; }
.empty { color: var(--muted); }

.site-foot { border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.site-foot > div { max-width: 1240px; margin: 0 auto; padding-block: 18px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }
