/* ============================================================
   ARCHIV NAK-GESCHICHTE — CSS für die historische Dokumentation
   "Sektenführer als Kinder Ihrer Zeit"
   Design-Konzept: Gelehrtenbibliothek der 1930er–1980er Jahre
   ============================================================ */

/* --- Google Fonts ----------------------------------------- */
@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400;0,600;0,700;0,900;1,400;1,600&family=Crimson+Text:ital,wght@0,400;0,600;0,700;1,400;1,600&family=Courier+Prime:ital,wght@0,400;0,700;1,400&family=IBM+Plex+Sans:wght@400;500;600&display=swap');

/* --- Design Tokens (CSS Custom Properties) ---------------- */
:root {
  /* Basisfarben — Helles Thema (Pergament) */
  --color-bg:            #f5f0e8;
  --color-bg-alt:        #ede4d4;
  --color-surface:       #faf7f2;
  --color-surface-hover: #f0e6d6;
  --color-text:          #2c1810;
  --color-text-secondary:#5c4438;
  --color-text-muted:    #8a7568;
  --color-border:        #c4b8a8;
  --color-border-light:  #ddd2c2;

  /* Akzentfarben — Archiv-Palette */
  --color-accent:        #4a6741;  /* Kardex-Grün */
  --color-accent-hover:  #3a5533;
  --color-accent-light:  #e8f0e4;
  --color-stamp:         #c73e3a;  /* Stempelrot */
  --color-stamp-hover:   #a8322f;
  --color-paper:         #e8dcc8;  /* Vergilbtes Dokument */
  --color-ink:           #3d2b1f;  /* Archiv-Braun */

  /* Typografie */
  --font-display:        'Playfair Display', 'Times New Roman', serif;
  --font-body:           'Crimson Text', 'Georgia', serif;
  --font-mono:           'Courier Prime', 'Courier New', monospace;
  --font-ui:             'IBM Plex Sans', 'Helvetica Neue', sans-serif;

  /* Typografische Skala */
  --text-xs:     0.75rem;
  --text-sm:     0.875rem;
  --text-base:   1.125rem;
  --text-lg:     1.25rem;
  --text-xl:     1.5rem;
  --text-2xl:    1.875rem;
  --text-3xl:    2.25rem;
  --text-4xl:    3rem;

  /* Abstände */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;
  --space-3xl: 4rem;

  /* Layout */
  --sidebar-width: 320px;
  --content-max-width: 750px;
  --marginalia-width: 220px;

  /* Schatten & Texturen */
  --shadow-sm: 0 1px 3px rgba(44, 24, 16, 0.08);
  --shadow-md: 0 4px 12px rgba(44, 24, 16, 0.12);
  --shadow-lg: 0 8px 24px rgba(44, 24, 16, 0.16);

  /* Animation */
  --transition-fast: 150ms ease;
  --transition-base: 250ms ease;
  --transition-slow: 400ms ease;

  /* Texturen (via CSS-Repeating-Gradient für Papierfaser-Effekt) */
  --texture-paper: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(139, 119, 90, 0.015) 2px,
    rgba(139, 119, 90, 0.015) 4px
  );
}

/* --- Dark Theme ------------------------------------------- */
[data-theme="dark"] {
  --color-bg:            #1a1410;
  --color-bg-alt:        #231c17;
  --color-surface:       #2a221c;
  --color-surface-hover: #342b23;
  --color-text:          #d4c9b8;
  --color-text-secondary:#b0a090;
  --color-text-muted:    #7a6e60;
  --color-border:        #4a3f35;
  --color-border-light:  #3a3028;
  --color-accent:        #6a8f5e;
  --color-accent-hover:  #7da870;
  --color-accent-light:  #1a2416;
  --color-paper:         #2a221c;
  --color-ink:           #c4b8a0;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
  --texture-paper: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(200, 180, 150, 0.02) 2px,
    rgba(200, 180, 150, 0.02) 4px
  );
}

/* --- Reset & Basis ---------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: var(--space-xl);
}

body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.75;
  color: var(--color-text);
  background: var(--color-bg);
  background-image: var(--texture-paper);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
}

/* --- Typografie ------------------------------------------- */
h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.3;
  color: var(--color-ink);
}

h1 {
  font-size: var(--text-4xl);
  font-weight: 900;
  letter-spacing: -0.02em;
  margin-bottom: var(--space-sm);
}

h2 {
  font-size: var(--text-2xl);
  margin-top: var(--space-3xl);
  margin-bottom: var(--space-lg);
  padding-bottom: var(--space-sm);
  border-bottom: 2px solid var(--color-border);
  font-weight: 700;
}

h3 {
  font-size: var(--text-xl);
  margin-top: var(--space-xl);
  margin-bottom: var(--space-md);
  color: var(--color-accent);
}

h4 {
  font-size: var(--text-lg);
  margin-top: var(--space-lg);
  margin-bottom: var(--space-sm);
  font-style: italic;
}

p {
  margin-bottom: var(--space-md);
  text-indent: 1.5em;
}

p:first-of-type { text-indent: 0; }

/* Blockzitate */
blockquote {
  font-family: var(--font-mono);
  font-size: 0.95em;
  line-height: 1.6;
  margin: var(--space-lg) var(--space-xl);
  padding: var(--space-md) var(--space-lg);
  border-left: 4px solid var(--color-accent);
  background: var(--color-surface);
  color: var(--color-text-secondary);
  box-shadow: var(--shadow-sm);
}

blockquote p { text-indent: 0; margin-bottom: var(--space-sm); }

/* Zitate in Dokumenten */
cite {
  display: block;
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-top: var(--space-sm);
  font-style: normal;
}

/* --- Disclaimer-Hinweis (Hero) ----------------------------- */
.disclaimer {
  max-width: 580px;
  margin: var(--space-xl) auto 0;
  padding: var(--space-md) var(--space-lg);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--color-accent);
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  line-height: 1.6;
  text-align: left;
  box-shadow: var(--shadow-sm);
}

.disclaimer p {
  text-indent: 0;
  margin: 0;
}

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

/* Links */
a {
  color: var(--color-accent);
  text-decoration: none;
  border-bottom: 1px dotted var(--color-accent);
  transition: all var(--transition-fast);
}

a:hover {
  color: var(--color-accent-hover);
  border-bottom-style: solid;
}

/* Code/Mono für historische Dokumente */
pre, code, .dokument {
  font-family: var(--font-mono);
  font-size: 0.9em;
}

/* --- Layout: Sidebar + Hauptbereich ----------------------- */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* --- Sidebar / Navigation --------------------------------- */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  z-index: 100;
  box-shadow: var(--shadow-md);
  transition: transform var(--transition-base);
}

.sidebar-header {
  padding: var(--space-lg) var(--space-md);
  border-bottom: 2px solid var(--color-border);
  background: var(--color-bg-alt);
  cursor: pointer;
  transition: background var(--transition-fast);
  user-select: none;
}

.sidebar-header:hover {
  background: var(--color-surface-hover);
}

.sidebar-header:active {
  background: var(--color-border-light);
}

.sidebar-header h1 {
  font-size: var(--text-lg);
  line-height: 1.3;
  margin-bottom: var(--space-xs);
}

.sidebar-subtitle {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.sidebar-meta {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--color-stamp);
  margin-top: var(--space-xs);
  padding: 2px 6px;
  border: 1px solid var(--color-border);
  display: inline-block;
  transform: rotate(-1deg);
}

/* Toolbar in Sidebar */
.sidebar-toolbar {
  display: flex;
  gap: var(--space-xs);
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--color-border-light);
  background: var(--color-bg);
}

.sidebar-toolbar button {
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  padding: 6px 12px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.sidebar-toolbar button:hover {
  background: var(--color-surface-hover);
  color: var(--color-text);
}

.sidebar-toolbar button.active {
  background: var(--color-ink);
  color: var(--color-surface);
  border-color: var(--color-ink);
}

/* Suchfeld */
.search-container {
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--color-border-light);
}

.search-input {
  width: 100%;
  padding: 8px 12px;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  transition: all var(--transition-fast);
}

.search-input:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 2px var(--color-accent-light);
}

.search-results {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  padding: 4px var(--space-md);
}

/* Kapitel-Navigation (Karteikarten-Stil) */
.nav-list {
  list-style: none;
  flex: 1;
  overflow-y: auto;
  padding: var(--space-sm) 0;
}

.nav-item {
  border-bottom: 1px solid var(--color-border-light);
}

.nav-link {
  display: flex;
  align-items: baseline;
  gap: var(--space-sm);
  padding: 10px var(--space-md);
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  text-decoration: none;
  border-bottom: none;
  transition: all var(--transition-fast);
  cursor: pointer;
}

.nav-link:hover {
  background: var(--color-surface-hover);
  color: var(--color-text);
}

.nav-link.active {
  background: var(--color-accent-light);
  color: var(--color-ink);
  font-weight: 500;
  border-left: 3px solid var(--color-accent);
}

.nav-seite {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  min-width: 2rem;
  text-align: right;
}

.nav-typ {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 1px 5px;
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
  margin-left: auto;
}

/* Sidebar Footer */
.sidebar-footer {
  padding: var(--space-sm) var(--space-md);
  border-top: 1px solid var(--color-border);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-xs);
}

.theme-toggle,
.share-button {
  background: none;
  border: 1px solid var(--color-border);
  padding: 4px 8px;
  font-size: var(--text-sm);
  cursor: pointer;
  color: var(--color-text-secondary);
  transition: all var(--transition-fast);
  font-family: var(--font-ui);
}

.theme-toggle:hover,
.share-button:hover {
  background: var(--color-surface-hover);
  color: var(--color-text);
}

.share-button.copied {
  background: var(--color-accent);
  color: white;
  border-color: var(--color-accent);
}

/* Toast-Notification */
.share-toast {
  position: fixed;
  bottom: var(--space-xl);
  left: 50%;
  transform: translateX(-50%);
  background: var(--color-ink);
  color: var(--color-surface);
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  padding: var(--space-sm) var(--space-lg);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-lg);
  z-index: 999;
  animation: toastIn 0.3s ease, toastOut 0.3s ease 1.7s forwards;
  pointer-events: none;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

@keyframes toastOut {
  from { opacity: 1; }
  to   { opacity: 0; }
}

/* --- Lesefortschritts-Balken -------------------------------- */
.progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  background: var(--color-accent);
  z-index: 1000;
  transition: width 0.1s linear;
  box-shadow: 0 1px 3px rgba(74, 103, 65, 0.3);
}

/* --- Zurück-nach-oben-Button -------------------------------- */
.scroll-top {
  position: fixed;
  bottom: var(--space-xl);
  right: var(--space-xl);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--color-ink);
  color: var(--color-surface);
  border: 2px solid var(--color-border);
  font-size: 1.3rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  z-index: 200;
  opacity: 0;
  transform: translateY(20px);
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.scroll-top.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.scroll-top:hover {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: white;
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

@media (max-width: 1024px) {
  .scroll-top {
    right: var(--space-md);
    bottom: var(--space-md);
  }
}

/* --- Hauptinhalt ------------------------------------------ */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-width: 0;
}

/* Hero / Deckblatt */
.hero {
  padding: var(--space-3xl) var(--space-2xl);
  text-align: center;
  background: var(--color-bg-alt);
  border-bottom: 4px double var(--color-border);
  position: relative;
}

.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: var(--texture-paper);
  pointer-events: none;
}

.hero h1 {
  font-size: clamp(2rem, 5vw, var(--text-4xl));
  font-weight: 900;
  line-height: 1.2;
  margin-bottom: var(--space-md);
  position: relative;
}

.hero .subtitel {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-style: italic;
  color: var(--color-text-secondary);
}

.hero .portraits {
  display: flex;
  justify-content: center;
  gap: var(--space-3xl);
  margin-top: var(--space-xl);
  flex-wrap: wrap;
}

.hero .portrait {
  text-align: center;
}

.hero .portrait img {
  max-width: 200px;
  border: 4px solid var(--color-surface);
  box-shadow: var(--shadow-md);
  filter: sepia(0.3);
}

.hero .portrait-label {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  margin-top: var(--space-sm);
  color: var(--color-text-secondary);
}

.hero .zitat {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-style: italic;
  max-width: 600px;
  margin: var(--space-xl) auto 0;
  color: var(--color-text-secondary);
  line-height: 1.6;
}

/* Kapitel-Container */
.kapitel {
  padding: var(--space-2xl);
  max-width: calc(var(--content-max-width) + var(--marginalia-width));
  margin: 0 auto;
  position: relative;
}

.kapitel + .kapitel {
  border-top: 1px solid var(--color-border-light);
}

/* Kapitel-Kopf mit Archiv-Stempel */
.kapitel-header {
  position: relative;
  margin-bottom: var(--space-xl);
}

.kapitel-nummer {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--color-stamp);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  display: block;
  margin-bottom: var(--space-xs);
}

.kapitel-stempel {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 3px 10px;
  border: 2px solid var(--color-stamp);
  color: var(--color-stamp);
  transform: rotate(-2deg);
  opacity: 0.7;
  margin-bottom: var(--space-sm);
}

/* Marginalien für Fußnoten */
.fussnote-ref {
  font-size: 0.75em;
  vertical-align: super;
  color: var(--color-accent);
  cursor: pointer;
  border-bottom: none;
  text-decoration: none;
}

.fussnote-popover {
  position: absolute;
  right: calc(-1 * var(--marginalia-width) - var(--space-lg));
  width: var(--marginalia-width);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  line-height: 1.5;
  padding: var(--space-sm) var(--space-md);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-left: 3px solid var(--color-accent);
  box-shadow: var(--shadow-md);
  color: var(--color-text-secondary);
  opacity: 0;
  transform: translateX(10px);
  transition: all var(--transition-base);
  pointer-events: none;
  z-index: 10;
}

.fussnote-popover.sichtbar {
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
}

/* Bilder in Kapiteln */
.kapitel-bild {
  margin: var(--space-lg) 0;
  text-align: center;
}

.kapitel-bild img {
  max-width: 100%;
  height: auto;
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-md);
  background: var(--color-surface);
  padding: var(--space-sm);
  min-height: 200px;
}

.kapitel-bild .bildunterschrift {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-top: var(--space-xs);
  font-style: italic;
}

/* Dokumenten-Scan (historische Dokumente) */
.dokument-scan {
  background: var(--color-paper);
  padding: var(--space-lg);
  margin: var(--space-lg) 0;
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
}

.dokument-scan img {
  max-width: 100%;
  filter: sepia(0.2) contrast(1.1);
}

/* Zeitstrahl */
.zeitstrahl {
  margin: var(--space-xl) 0;
  padding-left: var(--space-xl);
  border-left: 2px solid var(--color-border);
}

.zeitstrahl-eintrag {
  position: relative;
  padding: var(--space-sm) 0 var(--space-md) var(--space-lg);
}

.zeitstrahl-eintrag::before {
  content: '';
  position: absolute;
  left: calc(-1 * var(--space-xl) - 5px);
  top: 14px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-accent);
  border: 2px solid var(--color-bg);
}

.zeitstrahl-jahr {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--color-accent);
  font-size: var(--text-sm);
}

.zeitstrahl-text {
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
}

/* Personen-Register */
.personen-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: var(--space-md);
  margin: var(--space-lg) 0;
}

.personen-karte {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  padding: var(--space-md);
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-fast);
}

.personen-karte:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.personen-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--text-base);
  color: var(--color-ink);
}

.personen-rolle {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-top: var(--space-xs);
}

/* --- Fußnoten im Text ------------------------------------- */
.fussnote {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  display: block;
  padding: 2px var(--space-md);
  margin: 2px 0;
  border-left: 2px solid var(--color-border-light);
  line-height: 1.4;
}

.fussnote sup {
  color: var(--color-accent);
  font-weight: 700;
  margin-right: 4px;
}

.fussnote a {
  font-size: inherit;
  border-bottom: 1px dotted var(--color-accent);
  color: var(--color-accent);
}

/* --- Inhaltsverzeichnis-Tabelle ---------------------------- */
.toc-table {
  width: 100%;
  border-collapse: collapse;
  margin: var(--space-lg) 0;
}

.toc-row {
  border-bottom: 1px dotted var(--color-border-light);
  transition: background var(--transition-fast);
}

.toc-row:hover {
  background: var(--color-surface-hover);
}

.toc-nummer {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  padding: 8px 12px 8px 0;
  text-align: right;
  width: 3rem;
  vertical-align: top;
  user-select: none;
}

.toc-titel {
  padding: 8px 12px;
  font-size: var(--text-base);
  line-height: 1.4;
}

.toc-titel a {
  color: var(--color-ink);
  text-decoration: none;
  border-bottom: 1px dotted var(--color-accent);
  transition: color var(--transition-fast);
}

.toc-titel a:hover {
  color: var(--color-accent);
  border-bottom-style: solid;
}

.toc-typ {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border);
  padding: 1px 6px;
  margin-left: 8px;
  vertical-align: middle;
  white-space: nowrap;
}

.toc-seite {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  padding: 8px 0 8px 12px;
  text-align: right;
  white-space: nowrap;
  vertical-align: top;
  user-select: none;
}

/* --- Such-Highlights -------------------------------------- */
.search-highlight {
  background: rgba(199, 62, 58, 0.2);
  padding: 1px 2px;
  border-radius: 2px;
  color: inherit;
}

[data-theme="dark"] .search-highlight {
  background: rgba(199, 62, 58, 0.35);
}

/* --- Namen-Hervorhebung (aus Personen-Register) ------------ */
.name-highlight {
  background: rgba(74, 103, 65, 0.25);
  padding: 2px 4px;
  border-radius: 3px;
  color: inherit;
  transition: background 0.4s ease;
  scroll-margin-top: 30vh;
}

.name-highlight.pulse {
  animation: namePulse 2s ease;
}

@keyframes namePulse {
  0%   { background: rgba(199, 62, 58, 0.55); box-shadow: 0 0 8px rgba(199, 62, 58, 0.4); }
  30%  { background: rgba(199, 62, 58, 0.3); box-shadow: 0 0 4px rgba(199, 62, 58, 0.2); }
  100% { background: rgba(74, 103, 65, 0.25); box-shadow: none; }
}

[data-theme="dark"] .name-highlight {
  background: rgba(106, 143, 94, 0.25);
}

[data-theme="dark"] .name-highlight.pulse {
  animation: namePulseDark 2s ease;
}

@keyframes namePulseDark {
  0%   { background: rgba(199, 62, 58, 0.55); box-shadow: 0 0 12px rgba(199, 62, 58, 0.5); }
  30%  { background: rgba(199, 62, 58, 0.35); box-shadow: 0 0 6px rgba(199, 62, 58, 0.3); }
  100% { background: rgba(106, 143, 94, 0.25); box-shadow: none; }
}

/* --- Utility ---------------------------------------------- */
.text-stamp {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-stamp);
  border: 2px solid var(--color-stamp);
  padding: 2px 8px;
  display: inline-block;
  transform: rotate(-1deg);
}

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

/* --- Impressum --------------------------------------------- */
.impressum {
  margin-top: var(--space-3xl);
  padding-top: var(--space-2xl);
  border-top: 4px double var(--color-border);
}

.impressum .kapitel-inhalt {
  text-align: center;
  max-width: 500px;
  margin: 0 auto;
}

.impressum p {
  text-indent: 0;
}

/* --- Admin-Panel (Strg+Shift+A) ---------------------------- */
.admin-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 9998;
  animation: fadeIn 0.2s ease;
}

.admin-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  box-shadow: var(--shadow-lg);
  z-index: 9999;
  max-width: 420px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  animation: modalIn 0.25s ease;
}

.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg-alt);
}

.admin-header h2 {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  margin: 0;
  padding: 0;
  border: none;
}

.admin-close {
  background: none;
  border: 1px solid var(--color-border);
  color: var(--color-text-secondary);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 2px 8px;
  transition: all var(--transition-fast);
}

.admin-close:hover {
  background: var(--color-stamp);
  color: white;
  border-color: var(--color-stamp);
}

.admin-body {
  padding: var(--space-lg);
}

.admin-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-md);
  text-align: center;
}

.admin-stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.admin-stat-value {
  font-family: var(--font-display);
  font-size: var(--text-3xl);
  font-weight: 700;
  color: var(--color-accent);
}

.admin-stat-label {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  line-height: 1.2;
}

.admin-body {
  font-size: 0.9rem;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes modalIn {
  from { opacity: 0; transform: translate(-50%, -50%) scale(0.95); }
  to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

/* --- Scrollbar -------------------------------------------- */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--color-bg); }
::-webkit-scrollbar-thumb { background: var(--color-border); }
::-webkit-scrollbar-thumb:hover { background: var(--color-text-muted); }

/* --- Responsive ------------------------------------------- */
@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main-content {
    margin-left: 0;
  }

  .kapitel {
    padding: var(--space-lg);
  }

  .fussnote-popover {
    position: static;
    width: 100%;
    margin: var(--space-sm) 0;
    opacity: 1;
    transform: none;
    pointer-events: auto;
  }

  /* Mobile: Burger-Menü anzeigen */
  .mobile-nav-toggle {
    display: flex;
    position: fixed;
    top: var(--space-md);
    left: var(--space-md);
    z-index: 200;
    width: 44px;
    height: 44px;
    align-items: center;
    justify-content: center;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    cursor: pointer;
    box-shadow: var(--shadow-md);
    color: var(--color-text);
    font-size: 1.5rem;
  }

  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 99;
  }

  .sidebar-overlay.open {
    display: block;
  }
}

@media (min-width: 1025px) {
  .mobile-nav-toggle,
  .sidebar-overlay {
    display: none;
  }
}

/* --- Druck ------------------------------------------------ */
@media print {
  .sidebar,
  .mobile-nav-toggle,
  .sidebar-overlay,
  .search-container,
  .sidebar-toolbar {
    display: none !important;
  }

  .main-content {
    margin-left: 0;
  }

  body {
    font-size: 11pt;
    line-height: 1.4;
    background: white;
    color: black;
  }

  .kapitel {
    page-break-before: always;
  }

  .fussnote-popover {
    position: static;
    opacity: 1;
    border: none;
    font-size: 8pt;
  }
}
