:root {
  --brand: #3b5bfe;
  --primary: #1677ff;
  --primary-dark: #0b52b3;
  --bg: #ffffff;
  --bg-soft: #f5f6f7;
  --fg: #1c1e21;
  --fg-muted: #606770;
  --line: #e5e7eb;
  --code-bg: #f6f7f8;
  --active-bg: #e8f0ff;
  --topbar-h: 60px;
  --sidebar-w: 300px;
  --toc-w: 280px;
  --content-w: 900px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #1b1b1d; --bg-soft: #242526; --fg: #e3e3e3; --fg-muted: #a0a6b1; --line: #33363a; --code-bg: #2a2c30; --primary: #69a5ff; --primary-dark: #8fbaff; --active-bg: #26324a;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-padding-top: calc(var(--topbar-h) + 16px); }
body { margin: 0; font: 16px/1.65 var(--font); color: var(--fg); background: var(--bg); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; }
svg { width: 1em; height: 1em; }

/* Topbar */
.topbar { position: sticky; top: 0; z-index: 20; height: var(--topbar-h); background: var(--brand); color: #fff; display: flex; align-items: center; gap: 12px; padding: 0 24px; }
.topbar .brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 700; font-size: 18px; }
.topbar .brand:hover { text-decoration: none; opacity: .9; }
.topbar .brand img { display: block; height: 32px; width: auto; }
.menu-btn { display: none; background: none; border: 0; color: #fff; width: 40px; height: 40px; padding: 8px; border-radius: 8px; }
.menu-btn svg { width: 24px; height: 24px; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.locale { position: relative; font-size: 15px; }
.locale summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 6px; }
.locale summary::-webkit-details-marker { display: none; }
.locale summary:hover { background: rgba(255,255,255,.12); }
.locale summary svg { width: 20px; height: 20px; }
.locale summary .caret { width: 14px; height: 14px; }
.locale ul { position: absolute; right: 0; top: 40px; margin: 0; padding: 6px; list-style: none; background: var(--bg); color: var(--fg); border: 1px solid var(--line); border-radius: 8px; min-width: 140px; box-shadow: 0 6px 20px rgba(0,0,0,.15); }
.locale li a { display: block; padding: 6px 10px; border-radius: 4px; color: var(--fg); font-size: 14px; }
.locale li a:hover { background: var(--bg-soft); text-decoration: none; }
.locale li a.active { color: var(--primary); background: var(--active-bg); }
.theme-btn { background: none; border: 0; color: #fff; width: 36px; height: 36px; border-radius: 50%; padding: 6px; cursor: pointer; }
.theme-btn:hover { background: rgba(255,255,255,.12); }
.theme-btn svg { width: 22px; height: 22px; }
.theme-btn .moon { display: none; }
:root[data-theme="dark"] .theme-btn .sun { display: none; }
:root[data-theme="dark"] .theme-btn .moon { display: inline; }
.search { position: relative; display: flex; align-items: center; gap: 8px; height: 38px; width: 380px; padding: 0 10px 0 12px; border-radius: 8px; background: var(--bg); color: var(--fg-muted); }
.search:focus-within { outline: 2px solid #fff; }
.search-open { display: flex; align-items: center; background: none; border: 0; padding: 0; color: inherit; cursor: default; }
.search-open svg { width: 16px; height: 16px; }
.search input { flex: 1; min-width: 0; border: 0; background: none; font: inherit; font-size: 15px; color: var(--fg); outline: 0; }
.search input::-webkit-search-decoration, .search input::-webkit-search-cancel-button { -webkit-appearance: none; }
.search kbd { font: 11px var(--font); color: var(--fg-muted); border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px; background: var(--bg-soft); }
.results { position: absolute; top: 46px; left: 0; right: 0; margin: 0; padding: 6px; list-style: none; background: var(--bg); color: var(--fg); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.15); max-height: 60vh; overflow: auto; }
.results li a { display: block; padding: 8px 10px; border-radius: 6px; color: var(--fg); }
.results li a:hover, .results li a:focus { background: var(--bg-soft); text-decoration: none; }
.results li a small { display: block; color: var(--fg-muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.results .empty { padding: 8px 10px; color: var(--fg-muted); }

/* Shell */
.shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--toc-w); }
main { padding: 16px 32px 40px; min-width: 0; }
main .markdown, .pager { max-width: var(--content-w); }

/* Sidebar */
.sidebar { position: sticky; top: var(--topbar-h); height: calc(100vh - var(--topbar-h)); overflow-y: auto; padding: 8px 8px 32px 8px; border-right: 1px solid var(--line); font-size: 15px; }
.sidebar ul { list-style: none; margin: 0; padding: 0; }
.sidebar ul ul { padding-left: 12px; }
.sidebar li { margin: 2px 0; }
.sidebar a, .sidebar span { display: block; padding: 7px 12px; border-radius: 6px; color: var(--fg); line-height: 1.35; }
.sidebar a:hover { background: var(--bg-soft); text-decoration: none; }
.sidebar a.active { background: var(--active-bg); color: var(--primary); }
.sidebar summary { display: flex; align-items: center; cursor: pointer; list-style: none; border-radius: 6px; }
.sidebar summary::-webkit-details-marker { display: none; }
.sidebar summary:hover { background: var(--bg-soft); }
.sidebar summary > a, .sidebar summary > span { flex: 1; }
.sidebar summary > a:hover { background: none; }
.sidebar details[open] > summary > a, .sidebar details[open] > summary > span { color: var(--primary); }
.sidebar .chev { width: 18px; height: 18px; margin-right: 10px; color: var(--fg-muted); transition: transform .15s; flex: none; }
.sidebar details[open] > summary .chev { transform: rotate(90deg); }

/* Kopfzeile: Breadcrumbs + Werkzeuge */
.doc-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; max-width: var(--content-w); margin-bottom: 8px; }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; font-size: 13px; color: var(--fg-muted); padding-top: 6px; }
.crumbs a, .crumbs span { padding: 4px 10px; border-radius: 999px; background: var(--bg-soft); color: var(--fg-muted); white-space: nowrap; }
.crumbs a:hover { text-decoration: none; color: var(--primary); }
.crumbs .home { padding: 4px 8px; display: inline-flex; }
.crumbs .home svg { width: 16px; height: 16px; color: var(--fg); }
.crumbs .current { background: var(--active-bg); color: var(--primary); }
.crumbs .sep { width: 14px; height: 14px; color: var(--fg-muted); margin: 0 2px; }
.doc-tools { display: flex; gap: 8px; flex: none; }
.btn { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: 6px; border: 1px solid var(--line); background: var(--bg); color: var(--fg); font: 600 14px var(--font); cursor: pointer; white-space: nowrap; }
.btn svg { width: 16px; height: 16px; }
.btn:hover { text-decoration: none; background: var(--bg-soft); }
.btn-dark { background: #1c1e21; color: #fff; border-color: #1c1e21; }
.btn-dark:hover { background: #333; }
:root[data-theme="dark"] .btn-dark { background: #fff; color: #1c1e21; border-color: #fff; }

/* Content */
.markdown h1 { font-size: 2rem; line-height: 1.25; margin: 0 0 20px; }
.markdown h1.category-title { font-size: 2.6rem; }
.markdown h2 { font-size: 1.5rem; margin: 1.8em 0 .6em; }
.markdown h3 { font-size: 1.25rem; margin: 1.5em 0 .5em; }
.markdown h4 { font-size: 1.05rem; margin: 1.4em 0 .4em; }
.markdown .anchor { color: inherit; }
.markdown .anchor:hover { text-decoration: none; }
.markdown .anchor:hover::after { content: " #"; color: var(--primary); font-weight: 400; }
.markdown p, .markdown ul, .markdown ol { margin: 0 0 1em; }
.markdown li { margin: .25em 0; }
.markdown .subtitle { color: var(--fg-muted); margin-bottom: 20px; }
.markdown blockquote { margin: 1em 0; padding: 8px 16px; border-left: 4px solid var(--line); color: var(--fg-muted); }
.markdown blockquote p { margin: 0; }
.markdown code { font-family: var(--mono); font-size: .9em; background: var(--code-bg); border: 1px solid var(--line); padding: .1em .35em; border-radius: 4px; }
.markdown pre { background: var(--code-bg); padding: 14px 16px; border-radius: 8px; overflow-x: auto; font-size: 14px; line-height: 1.5; }
.markdown pre code { background: none; border: 0; padding: 0; }
.markdown table { border-collapse: collapse; margin: 1em 0; display: block; overflow-x: auto; font-size: 15px; }
.markdown th, .markdown td { border: 1px solid var(--line); padding: 8px 14px; text-align: left; vertical-align: top; }
.markdown th { background: var(--bg-soft); }
.markdown img { display: block; margin: 1em 0; border-radius: 6px; cursor: zoom-in; }
.zoom-overlay { position: fixed; inset: 0; z-index: 50; background: rgba(255,255,255,.92); display: grid; place-items: center; cursor: zoom-out; padding: 24px; }
:root[data-theme="dark"] .zoom-overlay { background: rgba(0,0,0,.9); }
.zoom-overlay img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 6px; box-shadow: 0 10px 40px rgba(0,0,0,.3); }

/* Lineare Flowcharts (vorher Mermaid) */
.flow { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 1em 0 1.5em; }
.flow-step { border: 1px solid var(--primary); background: var(--active-bg); color: var(--fg); border-radius: 6px; padding: 8px 14px; font-size: 14px; }
.flow-arrow { color: var(--fg-muted); font-size: 18px; }
.markdown hr { border: 0; border-top: 1px solid var(--line); margin: 2em 0; }
.markdown kbd { font-family: var(--mono); font-size: .85em; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 0 .4em; }

/* Admonitions (Docusaurus-Farben) */
.admonition { margin: 1.2em 0; padding: 12px 16px; border-left: 5px solid var(--a); border-radius: 8px; background: var(--a-bg); color: var(--a-fg); }
.admonition > :last-child { margin-bottom: 0; }
.admonition a { color: var(--a-fg); text-decoration: underline; }
.admonition-title { font-weight: 700; margin: 0 0 .4em !important; text-transform: uppercase; font-size: .8em; letter-spacing: .04em; }
.admonition-info { --a: #4cb3d4; --a-bg: #eef9fd; --a-fg: #193c47; }
.admonition-tip { --a: #009400; --a-bg: #e6f6e6; --a-fg: #003100; }
.admonition-note { --a: #d4d5d8; --a-bg: #fdfdfe; --a-fg: #474748; }
.admonition-caution, .admonition-warning { --a: #e6a700; --a-bg: #fff8e6; --a-fg: #4d3800; }
.admonition-danger { --a: #e13238; --a-bg: #ffebec; --a-fg: #4b1113; }
:root[data-theme="dark"] .admonition-info { --a-bg: #193c47; --a-fg: #eef9fd; }
:root[data-theme="dark"] .admonition-tip { --a-bg: #003100; --a-fg: #e6f6e6; }
:root[data-theme="dark"] .admonition-note { --a-bg: #474748; --a-fg: #fdfdfe; }
:root[data-theme="dark"] .admonition-caution, :root[data-theme="dark"] .admonition-warning { --a-bg: #4d3800; --a-fg: #fff8e6; }
:root[data-theme="dark"] .admonition-danger { --a-bg: #4b1113; --a-fg: #ffebec; }

/* Video */
.tutorial { margin: 0 0 1.5em; aspect-ratio: 16/9; background: #000; border-radius: 12px; overflow: hidden; }
.tutorial video, .tutorial iframe { width: 100%; height: 100%; display: block; border: 0; }
.tutorial.yt .yt-play { width: 100%; height: 100%; border: 0; background: linear-gradient(135deg, #1c1e21, #3b5bfe); color: #fff; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; font: inherit; }
.tutorial.yt .yt-title { font-weight: 600; font-size: 18px; }
.tutorial.yt .yt-hint { font-size: 13px; opacity: .8; }

/* Branchen (Startseite): volle Breite wie im Original */
.branches { display: flex; flex-direction: column; gap: 14px; margin: 0 0 2em; }
.branch { display: flex; align-items: center; gap: 16px; padding: 16px 20px; border: 1px solid var(--line); border-radius: 10px; color: var(--fg); background: var(--bg); transition: box-shadow .15s, border-color .15s; }
.branch:hover { text-decoration: none; border-color: var(--primary); box-shadow: 0 4px 16px rgba(22,119,255,.12); }
.branch-icon { flex: none; width: 44px; height: 44px; border-radius: 8px; display: grid; place-items: center; }
.branch-icon svg { width: 22px; height: 22px; }
.branch-text { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.branch-text strong { font-size: 15px; }
.branch-text small { color: var(--fg-muted); font-size: 13px; }
.branch .chev { width: 20px; height: 20px; color: var(--fg-muted); flex: none; }

/* Kategorie-Karten: zwei Spalten, Beschreibung einzeilig */
.cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin: 1.5em 0; }
.card { display: flex; flex-direction: column; gap: 10px; padding: 16px; border: 1px solid var(--line); border-radius: 8px; color: var(--fg); background: var(--bg); box-shadow: 0 1px 2px rgba(0,0,0,.08); transition: box-shadow .15s, border-color .15s; }
a.card:hover { text-decoration: none; border-color: var(--primary); box-shadow: 0 4px 16px rgba(22,119,255,.12); }
.card strong { display: flex; align-items: center; gap: 8px; font-size: 16px; }
.card strong svg { width: 20px; height: 20px; color: var(--fg-muted); flex: none; }
.card span { color: var(--fg-muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* TOC */
.toc { position: sticky; top: var(--topbar-h); height: calc(100vh - var(--topbar-h)); overflow-y: auto; padding: 20px 24px 24px 8px; font-size: 13px; }
.toc ul { list-style: none; margin: 0; padding: 0 0 0 10px; border-left: 1px solid var(--line); }
.toc li a { display: block; padding: 4px 8px; color: var(--fg-muted); }
.toc li.d3 a { padding-left: 24px; }
.toc li a:hover, .toc li a.active { color: var(--primary); text-decoration: none; }

/* Pager */
.pager { display: flex; justify-content: space-between; gap: 16px; margin: 48px 0 0; }
.pager a { flex: 1; border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px; color: var(--primary); font-weight: 600; }
.pager a small { display: block; color: var(--fg-muted); font-weight: 400; font-size: 13px; margin-bottom: 4px; }
.pager a.next { text-align: right; }
.pager a:hover { border-color: var(--primary); text-decoration: none; }

/* Footer: volle Breite wie im Original */
.footer { border-top: 1px solid var(--line); background: var(--bg); display: flex; justify-content: space-between; align-items: center; padding: 20px 110px; font-size: 14px; color: var(--fg); }
.footer .links a { color: var(--fg); padding: 0 14px; border-left: 1px solid var(--line); }
.footer .links a:first-child { border-left: 0; }

/* Druck = PDF */
@media print {
  .topbar, .sidebar, .toc, .doc-head, .pager, .footer, .tutorial { display: none !important; }
  .shell { display: block; }
  main { padding: 0; }
  .markdown { max-width: none; }
  a { color: inherit; }
}

/* Responsive */
@media (max-width: 1280px) { .shell { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); } .toc { display: none; } }
@media (max-width: 996px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  main { padding: 16px 16px 40px; }
  .topbar { padding: 0 12px; }
  .menu-btn { display: block; }
  .topbar .brand span { display: none; }
  .locale summary span, .search kbd { display: none; }
  .search { width: 38px; padding: 0; justify-content: center; }
  .search-open { cursor: pointer; width: 38px; height: 38px; justify-content: center; }
  .search input { display: none; }
  body.search-open .search { position: fixed; left: 12px; right: 12px; top: 11px; width: auto; padding: 0 10px 0 12px; justify-content: flex-start; z-index: 30; }
  body.search-open .search input { display: block; }
  .results { left: 0; right: 0; }
  .doc-head { flex-direction: column; }
  .cards { grid-template-columns: 1fr; }
  .footer { padding: 16px; flex-direction: column; gap: 8px; }
  .sidebar { position: fixed; left: 0; top: var(--topbar-h); width: min(320px, 85vw); background: var(--bg); transform: translateX(-100%); transition: transform .2s; z-index: 15; }
  body.nav-open .sidebar { transform: none; box-shadow: 0 0 0 100vmax rgba(0,0,0,.35); }
  .markdown h1 { font-size: 1.6rem; }
}
