/* Das öffentliche Handbuch (scripts/wiki/build.mjs). Auf dem Telefon ohne Zoomen lesbar, am Rechner
   ohne Zusammenkneifen: 17px auf dem Telefon, 18-19px auf breiten Schirmen, Zeilen höchstens etwa
   75 Zeichen. Farben wie das Theme "Klassik 2.0" der App (Navy), dunkel wie "Werkbank". */
:root {
  --bg: #f8fafc; --panel: #ffffff; --text: #1e293b; --muted: #64748b; --line: #e2e8f0;
  --accent: #1f3a6e; --accent-soft: #e8eef8; --shadow: 0 1px 2px rgb(15 23 42 / .06), 0 4px 16px rgb(15 23 42 / .05);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0b1120; --panel: #111827; --text: #e2e8f0; --muted: #94a3b8; --line: #1f2937; --accent: #f59e0b; --accent-soft: #2a1d05; --shadow: none; }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 5rem; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 17px/1.7 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
@media (min-width: 1024px) { body { font-size: 18px; } }
@media (min-width: 1600px) { body { font-size: 19px; } }
a { color: var(--accent); text-underline-offset: .15em; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.skip { position: absolute; left: -999px; top: 0; background: var(--panel); padding: .5rem 1rem; z-index: 10; }
.skip:focus { left: 1rem; }

/* Kopfzeile */
.top {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .75rem 1rem; background: color-mix(in srgb, var(--panel) 92%, transparent); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: .5rem; font-weight: 700; color: var(--text); text-decoration: none; line-height: 1.25; }
.logo { font-size: 1.3em; }
.top-links { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .25rem .9rem; font-size: .9em; }
.top-links a { white-space: nowrap; }
.top-links .app { font-weight: 600; }
@media (min-width: 1024px) { .top { padding: .9rem 2rem; } }

/* Aufbau: eine Spalte auf dem Telefon, Kapitelliste neben dem Text ab 1024px */
.layout { max-width: 78rem; margin: 0 auto; padding: 1rem; }
@media (min-width: 1024px) {
  .layout { display: grid; grid-template-columns: 17rem minmax(0, 1fr); gap: 2.5rem; padding: 2rem; }
}
.sidebar { display: none; }
@media (min-width: 1024px) {
  .sidebar { display: block; position: sticky; top: 5.5rem; align-self: start; max-height: calc(100vh - 7rem); overflow-y: auto; font-size: .92em; }
  .toc-mobile { display: none; }
}
.sidebar-title { margin: 0 0 .5rem; font-size: .8em; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.toc { list-style: none; margin: 0; padding: 0; }
.toc a { display: block; padding: .45rem .75rem; border-radius: .5rem; color: var(--text); text-decoration: none; line-height: 1.35; }
.toc a:hover { background: var(--accent-soft); }
.toc a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.toc-mobile { margin-bottom: 1rem; background: var(--panel); border: 1px solid var(--line); border-radius: .75rem; }
.toc-mobile summary { padding: .8rem 1rem; font-weight: 600; cursor: pointer; }
.toc-mobile .toc { padding: 0 .5rem .5rem; }
.toc-mobile .toc a { padding: .65rem .75rem; } /* fingergroß */

/* Text */
.content {
  min-width: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 1rem; box-shadow: var(--shadow);
  padding: 1.25rem 1.1rem 2rem;
}
.content > * { max-width: 46rem; }
@media (min-width: 640px) { .content { padding: 2rem 2.25rem 2.5rem; } }
@media (min-width: 1024px) { .content { padding: 2.75rem 3.5rem 3rem; } }
h1 { font-size: 1.9em; line-height: 1.2; margin: .2em 0 .6em; letter-spacing: -.01em; }
h2 { font-size: 1.35em; line-height: 1.3; margin: 1.8em 0 .5em; }
@media (min-width: 1024px) { h1 { font-size: 2.3em; } h2 { font-size: 1.5em; } }
p, ul, ol { margin: 0 0 1em; }
ul, ol { padding-left: 1.3em; }
code { background: rgba(127, 127, 127, .14); border-radius: 3px; padding: .05em .3em; font-size: .9em; }
li { margin: .3em 0; }
strong { font-weight: 650; }
figure { margin: 1.5em 0; max-width: 60rem !important; }
figure img { display: block; width: 100%; height: auto; border-radius: .6rem; border: 1px solid var(--line); box-shadow: var(--shadow); }
figcaption { margin-top: .5em; font-size: .88em; color: var(--muted); }
.crumbs { font-size: .85em; color: var(--muted); margin-bottom: .5rem; }
.crumbs a { color: var(--muted); }
.on-page { background: var(--accent-soft); border-radius: .75rem; padding: .8rem 1.1rem; margin-bottom: 1.5em; }
.on-page p { margin: 0 0 .3em; font-weight: 600; font-size: .9em; }
.on-page ul { margin: 0; }

/* Kapitelkarten auf der Startseite */
.cards { list-style: none; padding: 0; display: grid; gap: .75rem; max-width: none !important; }
@media (min-width: 720px) { .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.cards a { display: flex; flex-direction: column; gap: .25rem; height: 100%; padding: 1rem 1.1rem; border: 1px solid var(--line); border-radius: .75rem; text-decoration: none; color: var(--text); }
.cards a:hover { border-color: var(--accent); background: var(--accent-soft); }
.cards strong { color: var(--accent); }
.cards span { font-size: .9em; color: var(--muted); line-height: 1.5; }

/* Zurück / Weiter */
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; margin-top: 2.5em; }
.pager a { display: flex; flex-direction: column; padding: .8rem 1rem; border: 1px solid var(--line); border-radius: .75rem; text-decoration: none; line-height: 1.35; }
.pager a:hover { border-color: var(--accent); }
.pager span { font-size: .8em; color: var(--muted); }
.pager .next { grid-column: 2; text-align: right; }

/* 404 */
.chooser { max-width: 40rem; margin: 12vh auto; padding: 1rem; text-align: center; }
.langs { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 1rem; justify-content: center; }
.langs a { display: block; min-width: 10rem; padding: .9rem 1.5rem; border-radius: .75rem; background: var(--accent); color: #fff; font-weight: 600; text-decoration: none; }

.foot { max-width: 78rem; margin: 0 auto; padding: 1.5rem 1rem 3rem; color: var(--muted); font-size: .85em; text-align: center; }
.foot p { margin: .25rem 0; }
@media (max-width: 639px) { .brand { font-size: .95em; } .top-links { font-size: .85em; } }

/* Bilder groß auf der Seite (build.mjs, render): per :target, ohne Skript. */
figure a { cursor: zoom-in; }
.lightbox { display: none; position: fixed; inset: 0; z-index: 50; align-items: center; justify-content: center; padding: 1rem; background: rgba(2, 6, 23, .92); max-width: none !important; margin: 0 !important; }
.lightbox:target { display: flex; }
.lightbox .lb-backdrop { position: absolute; inset: 0; cursor: zoom-out; }
.lightbox img { position: relative; max-width: 100%; max-height: 90vh; width: auto; height: auto; border-radius: .6rem; background: #fff; box-shadow: 0 10px 40px rgba(0, 0, 0, .4); }
.lightbox .lb-x, .lightbox .lb-prev, .lightbox .lb-next { position: absolute; display: flex; align-items: center; justify-content: center; width: 2.75rem; height: 2.75rem; border-radius: 999px; background: rgba(255, 255, 255, .15); color: #fff; font-size: 1.75rem; line-height: 1; text-decoration: none; }
.lightbox .lb-x { top: .75rem; right: .75rem; }
.lightbox .lb-prev { left: .75rem; top: 50%; transform: translateY(-50%); }
.lightbox .lb-next { right: .75rem; top: 50%; transform: translateY(-50%); }
.lightbox a:hover, .lightbox a:focus-visible { background: rgba(255, 255, 255, .3); }

em { font-style: italic; }
.muted { color: var(--muted); }

/* Suche: in der Seitenleiste, im Inhalt auf dem Telefon und groß auf /suche/ */
.search { display: flex; gap: .4rem; margin: 0 0 1rem; }
.toc-mobile .search { padding: 0 .75rem; }
.search input { flex: 1; min-width: 0; font: inherit; font-size: .9em; padding: .5rem .7rem; border: 1px solid var(--line); border-radius: .5rem; background: var(--panel); color: var(--text); }
.search button { font: inherit; font-size: .85em; font-weight: 600; padding: .5rem .8rem; border: 0; border-radius: .5rem; background: var(--accent); color: #fff; cursor: pointer; }
.search-big input { font-size: 1em; padding: .7rem .9rem; }
.search-big button { font-size: .95em; padding: .7rem 1.1rem; }
.hits { list-style: none; padding: 0; display: grid; gap: .6rem; }
.hits a { display: flex; flex-direction: column; gap: .2rem; padding: .8rem 1rem; border: 1px solid var(--line); border-radius: .75rem; text-decoration: none; color: var(--text); }
.hits a:hover { border-color: var(--accent); background: var(--accent-soft); }
.hits strong { color: var(--accent); }
.hits span { font-size: .9em; color: var(--muted); line-height: 1.5; }
