/* knowledgebase – mobile first, keine Frameworks.
   Hell/dunkel folgt der Systemeinstellung. */

:root {
  --bg: #fdfdfc;
  --bg-soft: #f4f3f0;
  --fg: #1c1b19;
  --fg-muted: #6b6862;
  --line: #e0ddd6;
  --accent: #2f6f4f;
  --accent-soft: #e6f0ea;
  --danger: #a33;
  --radius: 8px;
  --nav-w: 17rem;
  --topbar-h: 3.25rem;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17181a;
    --bg-soft: #1f2124;
    --fg: #e6e4e0;
    --fg-muted: #9a978f;
    --line: #32353a;
    --accent: #6bbf90;
    --accent-soft: #1e2f26;
    --danger: #e08a8a;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  color: var(--fg);
  background: var(--bg);
  overflow-wrap: break-word;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.skip {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--accent); color: #fff; padding: .6rem 1rem;
}
.skip:focus { left: 0; }

/* ---------------------------------------------------------------- Kopfzeile */

.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: .5rem;
  height: var(--topbar-h);
  padding: 0 .75rem;
  padding-left: max(.75rem, env(safe-area-inset-left));
  padding-right: max(.75rem, env(safe-area-inset-right));
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

.brand { font-weight: 600; color: var(--fg); white-space: nowrap; }
.topbar .search { flex: 1 1 auto; min-width: 0; }

.topbar input[type=search] {
  width: 100%;
  padding: .45rem .7rem;
  font: inherit; font-size: 1rem;   /* 16px verhindert Auto-Zoom auf iOS */
  color: var(--fg);
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  -webkit-appearance: none;
}
.topbar input[type=search]:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.icon-link {
  flex: 0 0 auto;
  display: grid; place-items: center;
  width: 2.25rem; height: 2.25rem;
  color: var(--fg-muted);
  border-radius: var(--radius);
  font-size: 1.05rem;
}
.icon-link:hover { background: var(--bg-soft); text-decoration: none; }

.burger {
  flex: 0 0 auto;
  display: grid; place-content: center; gap: 4px;
  width: 2.25rem; height: 2.25rem;
  padding: 0;
  background: none; border: 0; border-radius: var(--radius);
  cursor: pointer;
}
.burger span { display: block; width: 18px; height: 2px; background: var(--fg); border-radius: 2px; }
.burger:hover { background: var(--bg-soft); }

/* ------------------------------------------------------------------ Gerüst */

.shell { display: block; }

.sidebar {
  position: fixed; z-index: 25;
  top: var(--topbar-h); bottom: 0; left: 0;
  width: var(--nav-w); max-width: 85vw;
  padding: 1rem .75rem 3rem;
  padding-left: max(.75rem, env(safe-area-inset-left));
  background: var(--bg);
  border-right: 1px solid var(--line);
  overflow-y: auto;
  overscroll-behavior: contain;
  transform: translateX(-102%);
  transition: transform .18s ease;
}
.sidebar.open { transform: none; }

.scrim {
  position: fixed; inset: var(--topbar-h) 0 0; z-index: 24;
  background: rgba(0, 0, 0, .35);
}

main {
  min-width: 0;
  padding: 1.25rem;
  padding-left: max(1.25rem, env(safe-area-inset-left));
  padding-right: max(1.25rem, env(safe-area-inset-right));
  padding-bottom: 4rem;
}

@media (min-width: 900px) {
  .burger, .scrim { display: none !important; }
  .shell { display: grid; grid-template-columns: var(--nav-w) minmax(0, 1fr); }
  .sidebar { position: sticky; height: calc(100vh - var(--topbar-h)); transform: none; max-width: none; }
  main { padding: 2rem 2.5rem 5rem; }
  .prose, .results, .crumbs, .pagemeta, .pager, .tagcloud { max-width: 46rem; }
}

/* -------------------------------------------------------------- Navigation */

.nav-home { display: block; padding: .3rem .5rem; font-weight: 600; color: var(--fg); }

.nav-group > summary {
  list-style: none;
  cursor: pointer;
  padding: .3rem .5rem .3rem 1.2rem;
  position: relative;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: .94rem;
}
.nav-group > summary::-webkit-details-marker { display: none; }
.nav-group > summary::before {
  content: "›";
  position: absolute; left: .4rem;
  color: var(--fg-muted);
  transition: transform .15s ease;
  display: inline-block;
}
.nav-group[open] > summary::before { transform: rotate(90deg); }
.nav-group > summary:hover { background: var(--bg-soft); }
.nav-group > summary a { color: var(--fg); }
.nav-group > * { margin-left: .55rem; }
.nav-group > summary { margin-left: -.55rem; }

.nav-list { list-style: none; margin: 0 0 .25rem; padding: 0 0 0 .6rem; border-left: 1px solid var(--line); }
.nav-list li a {
  display: block;
  padding: .28rem .5rem;
  border-radius: var(--radius);
  color: var(--fg-muted);
  font-size: .94rem;
}
.nav-list li a:hover { background: var(--bg-soft); color: var(--fg); text-decoration: none; }
.nav-list li.active > a { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

/* ------------------------------------------------------------------ Inhalt */

.crumbs { color: var(--fg-muted); font-size: .88rem; margin-bottom: .75rem; }
.crumbs span { opacity: .5; }

.prose h1 { font-size: 1.7rem; line-height: 1.25; margin: 0 0 1rem; }
.prose h2 { font-size: 1.3rem; margin: 2rem 0 .6rem; padding-bottom: .25rem; border-bottom: 1px solid var(--line); }
.prose h3 { font-size: 1.1rem; margin: 1.5rem 0 .4rem; }
.prose p, .prose li { font-size: 1rem; }
.prose ul, .prose ol { padding-left: 1.3rem; }
.prose li { margin: .2rem 0; }
/* Anmerkungen — Stand, Fundstellen, Vorbehalte. Kein Inhalt, deshalb kleiner
   und blasser als der Fliesstext. Konvention: Blockzitat. */
.prose blockquote {
  margin: .8rem 0; padding: .05rem .85rem;
  border-left: 2px solid var(--line);
  color: var(--fg-muted);
  font-size: .82rem;
  line-height: 1.5;
}
.prose blockquote p,
.prose blockquote li { font-size: inherit; margin: .3rem 0; }
.prose img { max-width: 100%; height: auto; border-radius: var(--radius); }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 2rem 0; }

.prose code {
  font-family: var(--mono); font-size: .88em;
  background: var(--bg-soft); padding: .12em .35em; border-radius: 4px;
}
.prose pre {
  background: var(--bg-soft); border: 1px solid var(--line);
  border-radius: var(--radius); padding: .85rem 1rem;
  overflow-x: auto;
}
.prose pre code { background: none; padding: 0; font-size: .85rem; }

.header-anchor { opacity: 0; margin-left: .4rem; color: var(--fg-muted); font-weight: 400; }
h2:hover .header-anchor, h3:hover .header-anchor, h4:hover .header-anchor { opacity: 1; }

/* Breite Tabellen scrollen in sich – der Seitenkörper nie. */
.table-scroll { overflow-x: auto; margin: 1rem 0; -webkit-overflow-scrolling: touch; }
table { border-collapse: collapse; width: 100%; font-size: .93rem; }
/* Volles Raster: senkrechte Linien zwischen allen Spalten, aussen umlaufend.
   Bei Belegungstabellen ist sonst nicht zu sehen, welcher Wert zu welcher
   Spalte gehoert. */
th, td { text-align: left; padding: .45rem .7rem; border: 1px solid var(--line); vertical-align: top; }
th { font-weight: 600; white-space: nowrap; background: var(--bg-soft); }
tbody tr:hover { background: var(--bg-soft); }

/* Gruppentrennung: eine leere Zeile in der Quelle wird zu diesem Strich. */
tbody tr.group-break > td { border-top: 2px solid var(--fg-muted); }

.toc {
  float: right; margin: 0 0 1rem 1.5rem; max-width: 15rem;
  padding: .6rem .9rem; background: var(--bg-soft);
  border-radius: var(--radius); font-size: .88rem;
}
.toc h2 { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--fg-muted); margin: 0 0 .3rem; border: 0; }
.toc ul { list-style: none; margin: 0; padding: 0; }
.toc li { margin: .15rem 0; }
@media (max-width: 640px) { .toc { float: none; margin: 0 0 1.25rem; max-width: none; } }

.pagemeta {
  display: flex; flex-wrap: wrap; align-items: center; gap: .4rem;
  margin-top: 2.5rem; padding-top: .9rem;
  border-top: 1px solid var(--line);
  font-size: .85rem; color: var(--fg-muted);
}
.pagemeta .raw { margin-left: auto; }

.tag {
  display: inline-block; padding: .1rem .5rem;
  background: var(--bg-soft); border: 1px solid var(--line);
  border-radius: 999px; font-size: .82rem; color: var(--fg-muted);
}
.tag:hover { background: var(--accent-soft); color: var(--accent); text-decoration: none; }
.tag.on { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.tag span { opacity: .6; }
.tagcloud { display: flex; flex-wrap: wrap; gap: .4rem; margin: 1rem 0 2rem; }

.pager { display: flex; justify-content: space-between; gap: 1rem; margin-top: 2rem; }
.pager a {
  flex: 1 1 0; min-width: 0;
  padding: .6rem .8rem;
  border: 1px solid var(--line); border-radius: var(--radius);
  font-size: .92rem;
}
.pager a:hover { border-color: var(--accent); text-decoration: none; }
.pager .next { text-align: right; }
.pager span { display: block; font-size: .75rem; color: var(--fg-muted); text-transform: uppercase; letter-spacing: .04em; }

/* ------------------------------------------------------------------ Treffer */

.results { list-style: none; margin: 0; padding: 0; }
.results li { padding: .85rem 0; border-bottom: 1px solid var(--line); }
.result-title { font-weight: 600; font-size: 1.05rem; }
.result-path { font-family: var(--mono); font-size: .76rem; color: var(--fg-muted); margin-top: .1rem; }
.result-snippet { margin: .35rem 0 0; color: var(--fg-muted); font-size: .92rem; }

/* ------------------------------------------------------- Login / Karte / 404 */

body.centered { display: grid; place-items: center; min-height: 100dvh; padding: 1.25rem; background: var(--bg-soft); }

.card {
  width: 100%; max-width: 22rem;
  padding: 1.75rem;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.card h1 { font-size: 1.35rem; margin: 0 0 1.25rem; }
.card label { display: block; font-size: .85rem; color: var(--fg-muted); margin-bottom: .25rem; }
.card input[type=password], .card input[type=text] {
  width: 100%; padding: .55rem .7rem; margin-bottom: .9rem;
  font: inherit; font-size: 1rem;
  color: var(--fg); background: var(--bg-soft);
  border: 1px solid var(--line); border-radius: var(--radius);
  -webkit-appearance: none;
}
.card .or { text-align: center; color: var(--fg-muted); font-size: .85rem; margin: 1rem 0; }

button {
  font: inherit; font-size: 1rem;
  padding: .55rem 1rem;
  color: var(--fg); background: var(--bg-soft);
  border: 1px solid var(--line); border-radius: var(--radius);
  cursor: pointer;
}
button:hover { border-color: var(--accent); }
button.primary { width: 100%; background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.primary:hover { filter: brightness(1.08); }
button.danger { color: var(--danger); border-color: var(--line); padding: .3rem .7rem; font-size: .85rem; }
button.danger:hover { border-color: var(--danger); }

.card form button[type=submit] { width: 100%; }

.error { color: var(--danger); font-size: .9rem; }
.muted { color: var(--fg-muted); }

#pk-add { width: auto; display: inline-block; margin-left: .4rem; }
#pk-label { width: 14rem; max-width: 100%; padding: .5rem .7rem; font: inherit; color: var(--fg); background: var(--bg-soft); border: 1px solid var(--line); border-radius: var(--radius); }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* ------------------------------------------------- Anmeldung (neutral) */

/* Bewusst ohne Ueberschrift, Logo und Erklaerung. */
.card.bare { max-width: 18rem; padding: 1.5rem; }
.card.bare form { margin: 0; }
.card.bare input[type=password] { margin-bottom: .75rem; }
.card.bare button { width: 100%; }
.card.bare .rule { height: 1px; background: var(--line); margin: 1rem 0; }
.card.bare .error { margin: .9rem 0 0; text-align: center; }

/* Nur fuer Screenreader. */
.vh {
  position: absolute; width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  clip: rect(0 0 0 0); clip-path: inset(50%);
  overflow: hidden; white-space: nowrap;
}
