/* Community-Handbuch: dokumentorientiertes Layout mit Sticky-Navigation,
   ruhiger Lesespalte und eigenständiger Druckansicht. */

:root {
  color-scheme: light;
  --hb-accent: #245846;
  --hb-accent-strong: #173f32;
  --hb-accent-soft: #e6f0ea;
  --hb-accent-line: #c8ddd1;
  --hb-ink: #18211d;
  --hb-text: #2e3b35;
  --hb-muted: #65716b;
  --hb-faint: #8b958f;
  --hb-bg: #ffffff;
  --hb-surface: #f6f8f7;
  --hb-surface-2: #edf2ef;
  --hb-border: #dfe7e2;
  --hb-border-strong: #cbd6d0;
  --hb-code-bg: #f1f5f3;
  --hb-shadow: 0 1px 2px rgba(23, 63, 50, 0.05), 0 12px 34px rgba(23, 63, 50, 0.07);
  --hb-success: #23835c;
  --hb-warning: #b98a2f;
  --hb-danger: #bc4040;
  --hb-max-width: 1240px;
  --hb-content-width: 900px;
  --hb-header-height: 58px;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --hb-accent: #70c8a2;
  --hb-accent-strong: #a1dec3;
  --hb-accent-soft: #173328;
  --hb-accent-line: #285441;
  --hb-ink: #edf3ef;
  --hb-text: #cfdbd4;
  --hb-muted: #9aa9a1;
  --hb-faint: #718078;
  --hb-bg: #0f1612;
  --hb-surface: #16201b;
  --hb-surface-2: #1c2923;
  --hb-border: #28372f;
  --hb-border-strong: #3b4d43;
  --hb-code-bg: #18231e;
  --hb-shadow: 0 1px 2px rgba(0, 0, 0, 0.28), 0 14px 38px rgba(0, 0, 0, 0.3);
  --hb-success: #70cf9c;
  --hb-warning: #e0bd68;
  --hb-danger: #ef8d8d;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--hb-bg);
  color: var(--hb-text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16.5px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a {
  color: var(--hb-accent-strong);
  text-underline-offset: 2px;
}

a:hover {
  color: var(--hb-accent);
}

code {
  padding: 0.12em 0.38em;
  border: 1px solid var(--hb-border);
  border-radius: 5px;
  background: var(--hb-code-bg);
  color: var(--hb-accent-strong);
  font-family: "SFMono-Regular", ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.86em;
}

.skip-link {
  position: fixed;
  top: 0;
  left: -9999px;
  z-index: 100;
  padding: 10px 16px;
  border-radius: 0 0 9px 0;
  background: var(--hb-accent);
  color: #fff;
}

.skip-link:focus {
  left: 0;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* Kompakte, dauerhaft sichtbare Dokumentleiste. */
.hb-header {
  position: sticky;
  top: 0;
  z-index: 40;
  border-bottom: 1px solid var(--hb-border);
  background: color-mix(in srgb, var(--hb-bg) 90%, transparent);
  backdrop-filter: saturate(1.35) blur(10px);
}

.hb-header-inner {
  display: flex;
  align-items: center;
  gap: 18px;
  max-width: var(--hb-max-width);
  min-height: var(--hb-header-height);
  margin: 0 auto;
  padding: 9px 22px;
}

.hb-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--hb-ink);
  text-decoration: none;
  letter-spacing: -0.01em;
}

.hb-brand img {
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
}

.hb-brand strong {
  font-weight: 680;
}

.hb-brand-edition {
  color: var(--hb-muted);
  font-weight: 500;
}

.hb-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  font-size: 0.84rem;
}

.hb-nav a {
  padding: 6px 8px;
  color: var(--hb-muted);
  text-decoration: none;
}

.hb-nav a:hover {
  color: var(--hb-ink);
}

.hb-header-control,
.theme-toggle,
.hb-lang-toggle {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  min-height: 0;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--hb-ink);
  font: inherit;
  cursor: pointer;
  transition: border-color 180ms ease, background 180ms ease, color 180ms ease;
}

.hb-header-control:hover,
.hb-header-control:focus-visible,
.theme-toggle:hover,
.theme-toggle:focus-visible,
.hb-lang-toggle:hover,
.hb-lang-toggle:focus-visible {
  border-color: color-mix(in srgb, var(--hb-accent) 42%, var(--hb-border));
  background: color-mix(in srgb, var(--hb-accent-soft) 70%, var(--hb-bg));
  color: var(--hb-accent-strong);
}

.theme-toggle svg {
  display: block;
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
}

.theme-toggle-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  line-height: 0;
}

html[data-theme="dark"] .theme-toggle-moon,
html:not([data-theme="dark"]) .theme-toggle-sun {
  display: none;
}

.hb-menu-toggle {
  display: none;
}

.hb-menu-icon {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

.hb-menu-icon span {
  display: block;
  width: 20px;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
}

.hb-menu-icon span:nth-child(2) { width: 14px; }
.hb-menu-icon span:nth-child(3) { width: 17px; }

.hb-lang {
  position: relative;
  display: inline-flex;
}

.hb-lang-toggle {
  width: auto;
  gap: 7px;
  padding: 0 9px 0 10px;
}

.hb-lang-globe {
  display: block;
  width: 20px;
  height: 20px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.hb-lang-current {
  font-size: 0.9rem;
  font-weight: 560;
  line-height: 1;
}

.hb-lang-chevron {
  display: block;
  width: 15px;
  height: 15px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  color: var(--hb-muted);
  transition: transform 180ms ease;
}

.hb-lang-toggle[aria-expanded="true"] .hb-lang-chevron {
  transform: rotate(180deg);
}

.hb-lang-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 60;
  display: flex;
  min-width: 172px;
  flex-direction: column;
  gap: 2px;
  padding: 6px;
  border: 1px solid var(--hb-border);
  border-radius: 12px;
  background: var(--hb-bg);
  box-shadow: 0 18px 40px -24px rgba(0, 0, 0, 0.55), 0 2px 8px -4px rgba(0, 0, 0, 0.28);
}

.hb-lang-menu[hidden] {
  display: none;
}

.hb-lang-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 9px 10px;
  border-radius: 8px;
  color: var(--hb-ink);
  font-size: 0.9rem;
  text-align: left;
  text-decoration: none;
  transition: background 150ms ease, color 150ms ease;
}

.hb-lang-option:hover,
.hb-lang-option:focus-visible {
  background: color-mix(in srgb, var(--hb-accent-soft) 70%, var(--hb-bg));
  color: var(--hb-accent-strong);
}

.hb-lang-option.is-active {
  color: var(--hb-accent-strong);
  font-weight: 650;
}

.hb-lang-check {
  width: 16px;
  height: 16px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0;
}

.hb-lang-option.is-active .hb-lang-check {
  opacity: 1;
}

/* Zweispaltiger Dokumentaufbau wie in der Offline-Referenz. */
.hb-layout {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  gap: 44px;
  align-items: start;
  max-width: var(--hb-max-width);
  margin: 0 auto;
  padding: 0 22px;
}

.hb-sidebar {
  position: sticky;
  top: calc(var(--hb-header-height) + 6px);
  max-height: calc(100vh - var(--hb-header-height) - 20px);
  overflow: auto;
  padding: 22px 8px 40px 0;
  scrollbar-width: thin;
}

.hb-toc strong {
  display: block;
  margin: 0 0 8px 10px;
  color: var(--hb-faint);
  font-size: 0.74rem;
  font-weight: 750;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.hb-toc > ol {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: toc;
}

.hb-toc li {
  margin: 0;
}

.hb-toc > ol > li {
  counter-increment: toc;
}

.hb-toc .hb-toc-steps {
  margin: 0;
  padding: 0;
  list-style: none;
}

.hb-toc a {
  display: grid;
  grid-template-columns: 2.1em minmax(0, 1fr);
  gap: 2px;
  padding: 5px 10px;
  border-left: 2px solid transparent;
  border-radius: 0 7px 7px 0;
  color: var(--hb-muted);
  font-size: 0.84rem;
  line-height: 1.35;
  text-decoration: none;
}

.hb-toc a::before {
  content: counter(toc);
  color: var(--hb-faint);
  font-variant-numeric: tabular-nums;
  font-size: 0.74rem;
  line-height: 1.55;
}

.hb-toc a.hb-toc-sub {
  padding-left: 20px;
  font-size: 0.8rem;
}

.hb-toc a.hb-toc-sub::before {
  content: "";
}

.hb-toc a:hover {
  background: var(--hb-surface);
  color: var(--hb-ink);
}

.hb-toc a.active {
  border-left-color: var(--hb-accent);
  background: var(--hb-accent-soft);
  color: var(--hb-accent-strong);
  font-weight: 650;
}

.hb-toc a.active::before {
  color: var(--hb-accent);
}

.hb-main {
  min-width: 0;
  max-width: var(--hb-content-width);
  padding: 8px 0 90px;
  counter-reset: handbook-section;
}

/* Titelblatt. */
.hb-cover {
  position: relative;
  margin: 26px 0 24px;
  padding: 34px;
  overflow: hidden;
  border: 1px solid var(--hb-border);
  border-radius: 18px;
  background: linear-gradient(155deg, var(--hb-surface), var(--hb-bg));
  box-shadow: var(--hb-shadow);
}

.hb-cover::before {
  content: "";
  position: absolute;
  top: -70px;
  right: -55px;
  width: 250px;
  height: 250px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--hb-accent-soft), transparent 68%);
  pointer-events: none;
}

.hb-kicker {
  position: relative;
  display: inline-flex;
  margin: 0 0 14px;
  padding: 5px 12px;
  border: 1px solid var(--hb-accent-line);
  border-radius: 999px;
  background: var(--hb-accent-soft);
  color: var(--hb-accent-strong);
  font-size: 0.8rem;
  font-weight: 700;
}

h1 {
  position: relative;
  max-width: 20ch;
  margin: 0 0 10px;
  color: var(--hb-ink);
  font-size: clamp(1.9rem, 4vw, 2.45rem);
  line-height: 1.14;
  letter-spacing: -0.025em;
}

.hb-lead {
  position: relative;
  max-width: 62ch;
  margin: 0;
  color: var(--hb-muted);
  font-size: 1.03rem;
}

.hb-meta {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
  margin: 22px 0 0;
  padding: 0;
  list-style: none;
}

.hb-meta li {
  color: var(--hb-muted);
  font-size: 0.82rem;
  font-weight: 600;
}

.hb-meta li::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  margin: 0 8px 1px 0;
  border-radius: 50%;
  background: var(--hb-accent);
}

.hb-actions {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 24px 0 0;
}

.hb-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 46px;
  padding: 12px 20px;
  border: 1px solid var(--hb-border);
  border-radius: 10px;
  font: inherit;
  font-weight: 650;
  text-decoration: none;
  cursor: pointer;
  transition: background 150ms ease, border-color 150ms ease, color 150ms ease, transform 100ms ease;
}

.hb-btn.primary {
  border-color: var(--hb-accent);
  background: var(--hb-accent);
  color: #fff;
}

html[data-theme="dark"] .hb-btn.primary {
  color: #102219;
}

.hb-btn.secondary {
  background: var(--hb-bg);
  color: var(--hb-ink);
}

.hb-btn:hover {
  transform: translateY(-1px);
}

.hb-btn.primary:hover {
  border-color: color-mix(in srgb, var(--hb-accent) 86%, #000);
  background: color-mix(in srgb, var(--hb-accent) 86%, #000);
}

.hb-btn.secondary:hover {
  border-color: color-mix(in srgb, var(--hb-accent) 32%, var(--hb-border));
  background: var(--hb-accent-soft);
}

.hb-btn:focus-visible {
  outline: 3px solid var(--hb-accent);
  outline-offset: 3px;
  box-shadow: 0 0 0 2px var(--hb-bg);
}

.hb-facts {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 0 0 40px;
  padding: 0;
  list-style: none;
}

.hb-facts li {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--hb-border);
  border-radius: 11px;
  background: var(--hb-surface);
}

.hb-facts b {
  display: block;
  overflow-wrap: anywhere;
  color: var(--hb-accent-strong);
  font-size: 1.15rem;
  line-height: 1.25;
}

.hb-facts span {
  display: block;
  margin-top: 4px;
  color: var(--hb-muted);
  font-size: 0.78rem;
  line-height: 1.35;
}

/* Kapitel und Lesetext. */
.hb-section {
  margin: 0 0 42px;
  padding-top: 22px;
  border-top: 1px solid var(--hb-border);
  scroll-margin-top: calc(var(--hb-header-height) + 18px);
  counter-increment: handbook-section;
}

.hb-section > h2 {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 0 0 8px;
  color: var(--hb-ink);
  font-size: clamp(1.32rem, 2.5vw, 1.55rem);
  line-height: 1.25;
  letter-spacing: -0.012em;
}

.hb-section > h2::before {
  content: counter(handbook-section);
  color: var(--hb-accent);
  font-size: 0.75em;
  font-variant-numeric: tabular-nums;
  font-weight: 760;
}

.hb-section--step {
  counter-increment: none;
}

.hb-section--step > h2::before {
  content: none;
}

.hb-section h3 {
  margin: 25px 0 5px;
  color: var(--hb-ink);
  font-size: 1.06rem;
}

.hb-section > p,
.hb-section > ul {
  max-width: 76ch;
  color: var(--hb-text);
}

.hb-section p {
  margin: 9px 0;
}

.hb-section ul {
  margin: 9px 0;
  padding-left: 22px;
}

.hb-section li {
  margin: 5px 0;
}

.hb-section li::marker {
  color: var(--hb-accent);
}

.hb-step-tag {
  display: inline-flex;
  align-items: center;
  margin: 0 0 8px;
  padding: 3px 10px;
  border: 1px solid var(--hb-accent-line);
  border-radius: 999px;
  background: var(--hb-accent-soft);
  color: var(--hb-accent-strong);
  font-size: 0.76rem;
  font-weight: 720;
  letter-spacing: 0.03em;
}

.hb-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 18px;
}

.hb-card {
  padding: 16px 18px;
  border: 1px solid var(--hb-border);
  border-radius: 12px;
  background: var(--hb-surface);
}

.hb-card--not {
  background: var(--hb-bg);
}

.hb-card h3 {
  margin: 0 0 7px;
  font-size: 0.96rem;
}

.hb-card ul {
  margin: 0;
  padding-left: 19px;
  color: var(--hb-muted);
  font-size: 0.9rem;
}

.hb-note {
  max-width: 76ch;
  margin: 18px 0;
  padding: 13px 16px;
  border: 1px solid var(--hb-accent-line);
  border-radius: 11px;
  background: var(--hb-accent-soft);
  color: var(--hb-text);
  font-size: 0.92rem;
}

.hb-note strong {
  color: var(--hb-accent-strong);
}

.hb-table-wrap {
  margin: 18px 0;
  overflow-x: auto;
  border: 1px solid var(--hb-border);
  border-radius: 12px;
}

.hb-table {
  width: 100%;
  min-width: 620px;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.hb-table th,
.hb-table td {
  padding: 10px 13px;
  border-bottom: 1px solid var(--hb-border);
  text-align: left;
  vertical-align: top;
}

.hb-table thead th {
  background: var(--hb-surface-2);
  color: var(--hb-ink);
  font-size: 0.8rem;
  font-weight: 680;
}

.hb-table tbody tr:nth-child(even) {
  background: color-mix(in srgb, var(--hb-surface) 58%, transparent);
}

.hb-table tbody tr:last-child td {
  border-bottom: 0;
}

.hb-table td:first-child {
  white-space: nowrap;
  color: var(--hb-ink);
  font-weight: 650;
}

.hb-figure {
  margin: 20px 0;
  overflow: hidden;
  border: 1px solid var(--hb-border);
  border-radius: 14px;
  background: var(--hb-surface);
  box-shadow: var(--hb-shadow);
}

.hb-figure a,
.hb-figure img {
  display: block;
}

.hb-figure img {
  width: 100%;
  height: auto;
  background: var(--hb-bg);
}

.hb-figure figcaption {
  padding: 10px 15px;
  border-top: 1px solid var(--hb-border);
  color: var(--hb-muted);
  font-size: 0.82rem;
}

.hb-figure figcaption b {
  color: var(--hb-accent-strong);
}

.hb-risk-scale {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 13px 0;
  padding: 0;
  list-style: none;
}

.hb-risk-scale li {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin: 0;
  padding: 5px 10px;
  border: 1px solid var(--hb-border);
  border-radius: 999px;
  background: var(--hb-surface);
  font-size: 0.8rem;
  font-weight: 650;
}

.hb-risk-scale i {
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

.hb-risk-low i { background: var(--hb-success); }
.hb-risk-mid i { background: var(--hb-warning); }
.hb-risk-high i { background: #df703c; }
.hb-risk-crit i { background: var(--hb-danger); }
.hb-risk-scale small { color: var(--hb-muted); font-weight: 500; }

.hb-footer {
  border-top: 1px solid var(--hb-border);
  background: var(--hb-surface);
}

.hb-footer-inner {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(180px, 0.5fr);
  gap: 42px;
  max-width: var(--hb-max-width);
  margin: 0 auto;
  padding: 28px 22px 42px calc(22px + 250px + 44px);
  color: var(--hb-muted);
  font-size: 0.82rem;
}

.hb-footer strong {
  color: var(--hb-ink);
}

.hb-footer p {
  margin: 5px 0;
}

.hb-footer nav {
  display: grid;
  gap: 5px;
  align-content: start;
}

.hb-footer nav span {
  color: var(--hb-faint);
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
}

.hb-footer a {
  color: var(--hb-muted);
}

@media (max-width: 1000px) {
  .hb-layout {
    grid-template-columns: 220px minmax(0, 1fr);
    gap: 30px;
  }

  .hb-facts {
    grid-template-columns: 1fr 1fr;
  }

  .hb-footer-inner {
    padding-left: calc(22px + 220px + 30px);
  }
}

@media (max-width: 900px) {
  .hb-header-inner {
    min-height: 56px;
  }

  .hb-brand-edition,
  .hb-nav > a {
    display: none;
  }

  .hb-menu-toggle {
    display: inline-flex;
  }

  .hb-layout {
    display: block;
    padding: 0 18px;
  }

  .hb-sidebar {
    position: static;
    display: none;
    max-height: none;
    margin: 10px 0 0;
    padding: 15px;
    border: 1px solid var(--hb-border);
    border-radius: 12px;
    background: var(--hb-surface);
  }

  .hb-sidebar.is-open {
    display: block;
  }

  .hb-toc > ol {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 12px;
  }

  .hb-main {
    max-width: none;
    padding-bottom: 58px;
  }

  .hb-grid-2 {
    grid-template-columns: 1fr;
  }

  .hb-footer-inner {
    grid-template-columns: 1fr;
    padding: 26px 18px 36px;
  }
}

@media (max-width: 620px) {
  body {
    font-size: 16px;
  }

  .hb-header-inner {
    padding: 8px 14px;
  }

  .hb-brand img {
    width: 26px;
    height: 26px;
  }

  .hb-brand strong {
    font-size: 0.88rem;
  }

  .hb-lang-toggle {
    width: 42px;
    padding: 0;
  }

  .hb-lang-globe,
  .hb-lang-chevron {
    display: none;
  }

  .hb-cover {
    margin-top: 16px;
    padding: 24px 20px;
    border-radius: 14px;
  }

  .hb-cover::before {
    width: 180px;
    height: 180px;
  }

  .hb-facts,
  .hb-toc > ol {
    grid-template-columns: 1fr;
  }

  .hb-facts {
    gap: 8px;
  }

  .hb-facts li {
    display: grid;
    grid-template-columns: minmax(90px, 0.42fr) minmax(0, 1fr);
    align-items: baseline;
    gap: 10px;
  }

  .hb-actions {
    display: grid;
  }

  .hb-btn {
    width: 100%;
  }

  .hb-section > h2 {
    align-items: flex-start;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}

@media print {
  :root {
    --hb-bg: #fff;
    --hb-surface: #fff;
    --hb-surface-2: #f3f3f3;
    --hb-ink: #151515;
    --hb-text: #292929;
    --hb-muted: #555;
    --hb-border: #d4d4d4;
  }

  .hb-header,
  .hb-sidebar,
  .hb-actions,
  .hb-footer,
  .skip-link {
    display: none !important;
  }

  body {
    font-size: 10.5pt;
    line-height: 1.45;
  }

  .hb-layout {
    display: block;
    max-width: none;
    padding: 0;
  }

  .hb-main {
    max-width: none;
    padding: 0;
  }

  .hb-cover,
  .hb-card,
  .hb-note,
  .hb-table-wrap,
  .hb-figure {
    break-inside: avoid;
    box-shadow: none;
  }

  .hb-cover {
    margin-top: 0;
  }

  .hb-section > h2,
  .hb-section h3 {
    break-after: avoid;
  }

  a {
    color: inherit;
    text-decoration: none;
  }
}
