/* ============================================================================
 * LATUS Handbuch-Designsystem (Apple-like, LATUS-Farbkanon) — geteilte Basis.
 * Referenz: LATUS-Cloud-Handbuch. Wird von allen Docsify-Handbuechern geladen
 * (NACH dem Inline-<style>, damit es die Alt-Regeln ueberschreibt).
 * ==========================================================================*/
:root {
  --tile-wash-live: color-mix(in srgb, var(--latus-blue-5) 28%, #ffffff);
  --tile-wash-primary: color-mix(in srgb, var(--latus-gold) 8%, #ffffff);
  --tile-border: var(--latus-blue-5);
  --tile-shadow-rest: 0 2px 8px rgba(0,75,100,0.07);
  --tile-shadow-hover: 0 8px 22px rgba(0,75,100,0.16);
  --card-shadow: 0 1px 2px rgba(0,75,100,0.04), 0 18px 44px -22px rgba(0,75,100,0.22);
}

/* === Topbar-Buttons im LATUS-Kompass-Kachel-Stil ========================= */
#latus-topbar .cta {
  box-sizing: border-box; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--font-display, "Montserrat", Arial, sans-serif); font-weight: 500; font-size: 14px; line-height: 1.2;
  color: var(--latus-blue-1) !important; text-decoration: none; height: 38px; padding: 0 16px;
  border-radius: 6px; border: 1px solid var(--latus-gold); background: var(--tile-wash-primary);
  box-shadow: var(--tile-shadow-rest);
  transition: transform 0.15s, box-shadow 0.15s, background-color 0.15s, border-color 0.15s;
}
#latus-topbar .cta:hover, #latus-topbar .cta:focus-visible {
  background: var(--tile-wash-primary); border-color: var(--latus-gold);
  transform: translateY(-1px); box-shadow: var(--tile-shadow-hover); outline: none;
}
#latus-topbar .cta svg { width: 14px; height: 14px; }
#latus-topbar .cta-back { background: var(--tile-wash-live); border-color: var(--tile-border); }
#latus-topbar .cta-back:hover, #latus-topbar .cta-back:focus-visible { background: var(--tile-wash-primary); border-color: var(--latus-gold); }
/* Geocoding-Varianten normalisieren: is-app = Primaer (Gold-Rand), lang-toggle = neutral */
#latus-topbar .cta.is-app { background: var(--tile-wash-primary); border-color: var(--latus-gold); }
#latus-topbar .cta.is-app:hover, #latus-topbar .cta.is-app:focus-visible { background: var(--tile-wash-primary); border-color: var(--latus-gold); }
#latus-topbar .cta.lang-toggle { background: var(--tile-wash-live); border-color: var(--tile-border); padding: 0 14px; min-width: 0; }
#latus-topbar .cta.lang-toggle:hover, #latus-topbar .cta.lang-toggle:focus-visible { background: var(--tile-wash-primary); border-color: var(--latus-gold); }
body.on-cover #latus-topbar .cta { display: none; }
body.on-cover #latus-topbar .cta-back { display: inline-flex; }

/* === Sidebar-TOC: volle Namen (Umbruch statt Ellipsis) + Kernkapitel-Stern = */
.sidebar-nav a,
.sidebar-nav ul li a,
.sidebar-nav > ul > li > a,
.sidebar-nav li ul li a {
  white-space: normal !important; overflow: visible !important; text-overflow: clip !important;
  line-height: 1.35; height: auto !important;
}
.sidebar-nav a.toc-key { color: var(--latus-blue-1) !important; font-weight: 700; }
.sidebar-nav a.toc-key::before { content: "\2605\00a0"; color: var(--latus-gold); }

/* === Apple-like Kapitel-Boxen ========================================== */
.markdown-section .chapter-lead,
.markdown-section .chapter-box {
  background: #ffffff; border: 1px solid rgba(0,75,100,0.12); border-radius: 22px;
  padding: 34px 46px 38px; margin: 0 0 24px; box-shadow: var(--card-shadow);
}
.markdown-section .chapter-lead { background: #fbfdfe; }
.markdown-section .chapter-box > h2:first-child { margin-top: 0; border-bottom: none; padding-bottom: 2px; }
.markdown-section .chapter-box:last-child { margin-bottom: 0; }

/* === Callout-Felder (blockquote) im Kachel-Stil (kein Farb-Balken) ====== */
.markdown-section blockquote {
  border: 1px solid rgba(0,75,100,0.10); background: #f2f7f9; color: #333;
  padding: 16px 20px; margin: 18px 0; font-style: normal; border-radius: 12px; box-shadow: var(--card-shadow);
}
.markdown-section blockquote strong { color: var(--latus-blue-1); }

/* === Code-Bloecke: Kachel statt Balken ================================= */
.markdown-section pre { background: var(--latus-grey-5); border: 1px solid rgba(0,75,100,0.08); border-radius: 12px; padding: 16px 20px !important; }

/* === Screenshots: gleicher Kachel-Schatten + Outline =================== */
.markdown-section img { border-radius: 12px; border: 1px solid rgba(0,75,100,0.12); box-shadow: var(--card-shadow); background: #fff; }

/* === HTML-Flussdiagramme (LATUS-Kachel, kein Balken) ==================== */
.markdown-section .flow-card { background: #f7fafb; border: 1px solid rgba(0,75,100,0.10); border-radius: 14px; padding: 20px 24px; margin: 22px 0; box-shadow: var(--card-shadow); }
.markdown-section .flow-card h4 { margin: 0 0 8px; color: var(--latus-blue-1); font-size: 16px; font-weight: 700; }
.markdown-section .flow-steps { font-family: "SF Mono", "Courier New", Courier, monospace; font-size: 14px; color: #2a2a2a; background: #ffffff; border: 1px solid var(--latus-blue-5); border-radius: 6px; padding: 14px 16px; overflow-x: auto; white-space: pre; line-height: 1.9; margin: 8px 0 6px; }
.markdown-section .flow-steps .node { color: var(--latus-blue-1); font-weight: 700; }
.markdown-section .flow-steps .arrow { color: var(--latus-blue-2); padding: 0 6px; }
.markdown-section .flow-note { font-size: 14px; color: var(--latus-grey-1); font-style: italic; margin: 6px 0 0; }

/* === Echtes Rollen-/Struktur-Diagramm ================================== */
.markdown-section .role-diagram { display: flex; align-items: stretch; gap: 0; flex-wrap: nowrap; background: #f7fafb; border: 1px solid rgba(0,75,100,0.10); border-radius: 14px; padding: 22px 18px; margin: 22px 0; box-shadow: var(--card-shadow); }
.markdown-section .rd-project { flex: 1 1 0; display: flex; flex-direction: column; align-items: center; gap: 9px; padding: 4px 16px; }
.markdown-section .rd-ptitle { font-weight: 700; color: var(--latus-blue-1); font-size: 14px; margin-bottom: 2px; text-align: center; }
.markdown-section .rd-node { width: 100%; max-width: 260px; text-align: center; font-size: 13px; line-height: 1.4; background: #fff; border: 1px solid var(--latus-blue-5); border-radius: 10px; padding: 10px 12px; color: #2a2a2a; box-shadow: 0 1px 2px rgba(0,75,100,0.05); }
.markdown-section .rd-node.rd-folder { background: var(--latus-blue-1); color: #fff; border-color: var(--latus-blue-1); font-weight: 600; }
.markdown-section .rd-arrow { color: var(--latus-blue-3); font-size: 11px; line-height: 1; text-align: center; }
.markdown-section .rd-arrow::before { content: "\25BC"; display: block; font-size: 13px; margin-bottom: 2px; }
.markdown-section .rd-barrier { display: flex; align-items: center; justify-content: center; padding: 0 4px; border-left: 2px dashed var(--latus-gold); }
.markdown-section .rd-barrier span { writing-mode: vertical-rl; text-orientation: mixed; color: var(--latus-gold); font-size: 10px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; white-space: nowrap; }
@media (max-width: 640px) {
  .markdown-section .role-diagram { flex-direction: column; }
  .markdown-section .rd-barrier { border-left: none; border-top: 2px dashed var(--latus-gold); padding: 10px 0; }
  .markdown-section .rd-barrier span { writing-mode: horizontal-tb; }
  .markdown-section .chapter-lead, .markdown-section .chapter-box { padding: 20px 20px 24px; border-radius: 16px; }
}

/* === HTML-Baumdiagramm (flow-tree/flow-step/flow-branch/flow-connector) — aus Geocoding-Shell konsolidiert, genutzt u.a. im AI-Handbuch === */
    .flow-tree {
      display: flex; flex-direction: column; align-items: center;
      gap: 0;
      margin: 24px auto;
      padding: 24px 20px;
      background: var(--latus-grey-5);
      border: 1px solid rgba(0,75,100,0.12);
      border-radius: 14px;
      box-shadow: var(--card-shadow);
      font-family: var(--font-body); font-size: 15px;
      width: 100%;
      max-width: 100%;
      box-sizing: border-box;
      overflow-x: auto;
    }
    .flow-step {
      padding: 14px 20px;
      border: 1px solid var(--tile-border);
      border-radius: 8px;
      box-shadow: var(--tile-shadow-rest);
      background: var(--tile-wash-live);
      color: var(--latus-blue-1);
      min-width: 0;
      width: max-content;
      min-width: 140px;
      max-width: min(280px, 100%);
      text-align: center; line-height: 1.5;
      word-wrap: break-word;
      hyphens: auto;
      transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
      box-sizing: border-box;
    }
    .flow-step:hover {
      box-shadow: var(--tile-shadow-hover);
    }
    .flow-step:focus-visible {
      outline: 2px solid var(--latus-gold);
      outline-offset: 2px;
    }
    /* Trigger: Gold-Wash + Gold-Border (analog .tile.is-primary im Kompass) */
    .flow-step.trigger {
      background: var(--tile-wash-primary);
      border-color: var(--latus-gold);
      font-weight: 600;
      max-width: min(360px, 100%);
    }
    /* Decision: hellstes Blau (latus-blue-5) + dunkler Text - breiter als Endnoten,
       damit die Verzweigung optisch unter der Decision-Box ansetzt (Stephan-Direktive: 
       Anschlusspfeile direkter Kontakt zum Container) */
    .flow-step.decision {
      background: var(--latus-blue-5);
      max-width: min(560px, 100%);
    }
    /* Endnode: mittleres Blau (latus-blue-2) + dunkelblau-1 Border + weisser Text */
    .flow-step.endnode {
      background: var(--latus-blue-2);
      border-color: var(--latus-blue-1);
      color: #ffffff;
      font-weight: 600;
    }
    /* Alt-Endnode: Grau-Wash (Sonderpfad PII) */
    .flow-step.alt-endnode {
      background: var(--latus-grey-5);
      color: var(--latus-grey-1);
    }
    .flow-step-title { font-weight: 500; }
    /* Pfeil: dezente CSS-Linie + diagonale Spitze */
    .flow-arrow {
      width: 2px; height: 22px;
      background: var(--latus-blue-4);
      border-radius: 1px;
      position: relative;
      font-size: 0;
      margin: 2px 0;
    }
    .flow-arrow::after {
      content: "";
      position: absolute; bottom: -2px; left: 50%;
      width: 8px; height: 8px;
      border-right: 2px solid var(--latus-blue-4);
      border-bottom: 2px solid var(--latus-blue-4);
      transform: translateX(-50%) rotate(45deg);
    }
    /* Connector-Linie zwischen Tiles innerhalb eines Branches (kein Pfeilspitze, nur Linie)
       Stephan-Direktive 2026-05-13: Tiles muessen vom Flow her sichtbar verbunden sein */
    .flow-connector {
      width: 2px;
      height: 14px;
      background: var(--latus-blue-4);
      border-radius: 1px;
      margin: 0 auto;
      flex-shrink: 0;
    }

    .flow-branches-2col {
      display: flex;
      flex-direction: row;
      justify-content: center;
      align-items: flex-start;
      gap: 24px;
      width: 100%;
      max-width: 100%;
      box-sizing: border-box;
      flex-wrap: wrap;
    }
    .flow-branch {
      min-width: 0;
      display: flex; flex-direction: column; align-items: center; gap: 0;
      position: relative;
      padding-top: 0;
      flex: 0 1 auto;
    }
    .flow-branch::before { display: none; }
    .flow-branch-label {
      font-size: 11.5px;
      color: var(--latus-blue-1);
      font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em;
      padding: 3px 12px;
      background: #ffffff;
      border: 1px solid var(--latus-blue-4);
      border-radius: 8px;
    }
    .flow-side-branch {
      margin-top: 18px; padding-top: 18px;
      border-top: 1px dashed var(--latus-blue-4);
      width: 100%;
      display: flex; flex-direction: column; align-items: center; gap: 10px;
    }
    .flow-tree-caption {
      font-size: 12.5px; color: var(--latus-grey-1);
      text-align: center; margin-top: 8px; font-style: italic;
    }
    @media (max-width: 960px) {
      .flow-branch .flow-branches-2col {
        flex-direction: column;
        align-items: center;
        gap: 14px;
      }
    }
    @media (max-width: 640px) {
      .flow-branches-2col { flex-direction: column; align-items: center; gap: 16px; }
      .flow-step { padding: 12px 14px; font-size: 14px; }
    }
    @media print {
      .flow-tree { box-shadow: none; break-inside: avoid; }
      .flow-step { box-shadow: none; }
    }

    /* Sub-Text in Tiles (z.B. „Presidio Anonymizer" Unterzeile) */
    .flow-step .tile-sub {
      display: block;
      font-size: 12px;
      font-weight: 400;
      opacity: 0.85;
      margin-top: 4px;
    }
