 :root {
  --bg: #e6e9ed;
  --surface: #f0f3f6;
  --border: #c5ced8;
  --text: #26313d;
  --muted: #647282;
  --accent: #456f97;
  --accent-hover: #315b82;
  --accent-rgb: 69, 111, 151;
  --surface-rgb: 240, 243, 246;

  --row-tint: rgba(49, 82, 115, 0.035);
  --row-tint-hover: rgba(49, 82, 115, 0.075);
  --modal-header-bg: rgba(230, 233, 237, 0.9);

  --scroll-duration: 600ms;
  --scroll-easing: cubic-bezier(0.25, 1, 0.5, 1);
  --modal-width: 90%;

  /* Hell/Dunkel-Schalter */
  --switch-width: 34px;
  --switch-height: 18px;
  --switch-pad: 3px;
  --switch-border: #aab7c5;
  --switch-track: transparent;
  --switch-knob: #788b9e;
  --switch-speed: 0.25s;
}

html[data-theme="dark"] {
  color-scheme: dark;
  scrollbar-color: #536174 #222b36;

  --bg: #222b36;
  --surface: #2b3542;
  --border: #435163;
  --text: #e0e6ee;
  --muted: #a0adbd;
  --accent: #8db2d5;
  --accent-hover: #b0cce5;
  --accent-rgb: 141, 178, 213;
  --surface-rgb: 43, 53, 66;

  --row-tint: rgba(215, 230, 245, 0.035);
  --row-tint-hover: rgba(215, 230, 245, 0.075);
  --modal-header-bg: rgba(34, 43, 54, 0.94);

  --switch-border: #617185;
  --switch-track: transparent;
  --switch-knob: #a0afc0;
}

  * { box-sizing: border-box; }

  html { scroll-behavior: smooth; }

  body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    transition: background-color 0.25s ease, color 0.25s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
  }

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

  /* Gesamter Content zentriert in einem Container-Div */
  .page-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    min-height: 100vh;
  }

  .page {
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    padding: 32px 24px 24px;
  }

  /* Kopfzeile */
  .site-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 20px;
    margin-bottom: 0;
    flex-wrap: wrap;
  }

  .site-header .logo img {
    display: block;
    max-width: 260px;
    height: auto;
  }

  html[data-theme="dark"] .site-header .logo img {
    filter: invert(1) brightness(0.85);
  }

  .site-tagline {
    color: var(--muted);
    font-size: 13px;
    text-align: left;
    max-width: none;
    margin: 12px 0 32px;
  }

  /* Panels mit gleicher Höhe für Liste und Suche */
  .panels {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
  }

  .panel {
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    position: relative;
  }

  .panel h2 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0.03em;
    color: var(--muted);
    border-bottom: 1px solid var(--border);
    padding-bottom: 8px;
  }

  /* Liste-Panel */
  #jumpMenu {
    width: 100%;
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 7px 8px;
    font-size: 13px;
    font-family: inherit;
  }

  .scroll-panel {
    height: 380px;
    overflow-y: auto;
    border: 1px solid var(--border);
    padding: 4px 10px;
  }

  .scroll-panel table { width: 100%; border-collapse: collapse; }
  .scroll-panel td { padding: 4px 6px; font-size: 13px; }
  .scroll-panel tr:nth-child(even) { background: var(--row-tint); }
  .scroll-panel tr:hover { background: var(--row-tint-hover); }
  .scroll-panel td a { display: block; width: 100%; }
  
  .scroll-panel td span.no-link {
    color: var(--muted);
  }

  .scroll-panel .td1 {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.08em;
    padding-top: 14px;
    padding-bottom: 3px;
    border-bottom: 1px solid var(--border);
  }

  .scroll-panel .td1 a {
    color: var(--accent);
    cursor: default;
  }

  .loading-hint { color: var(--muted); font-size: 13px; }

  /* Suche-Panel */
  #searchForm {
    display: flex;
    gap: 8px;
  }

  #searchForm input[type="text"] {
    flex: 1;
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 8px 10px;
    font-size: 13px;
    font-family: inherit;
  }

  #searchForm input[type="text"]:focus,
  #jumpMenu:focus {
    outline: none;
    border-color: var(--accent);
  }

  #searchForm button {
    background: none;
    border: 1px solid var(--border);
    color: var(--text);
    padding: 7px 14px;
    font-size: 13px;
    cursor: pointer;
    font-family: inherit;
  }

  #searchForm button:hover { border-color: var(--accent); }

  .panel-info {
    color: var(--muted);
    font-size: 13px;
    line-height: 1.6;
    height: 380px;
    overflow-y: auto;
  }

  .panel-info .rot { color: var(--accent-hover); }

  #news-content > *:nth-child(even),
  #news-content tr:nth-child(even),
  #news-content p:nth-child(even),
  #news-content div:nth-child(even) {
    background: var(--row-tint);
  }

  #news-content > *:hover,
  #news-content tr:hover {
    background: var(--row-tint-hover);
  }

  .search-field { position: relative; flex: 1; display: flex; }
  #searchForm .search-field input[type="text"] { width: 100%; padding-right: 30px; }
  .search-clear { position: absolute; right: 2px; top: 0; bottom: 0; width: 28px; background: none; border: none; color: var(--muted); font-size: 18px; line-height: 1; cursor: pointer; padding: 0; }
  .search-clear:hover { color: var(--accent); }
  .search-clear[hidden] { display: none; }

  /* Smartphone: Felder mit mindestens 16px, sonst zoomt der Browser beim Antippen hinein */
  @media (max-width: 820px) {
    #searchForm input[type="text"], #searchForm .search-field input[type="text"], #jumpMenu { font-size: 16px; }
  }

  /* Rechtliches (AGB, Impressum): zentriertes Fenster, 90 % */
.legal-content { position: absolute; top: 50%; left: 50%; width: 90%; height: 90%; transform: translate(-50%, -50%); display: flex; flex-direction: column; background: rgb(212, 208, 200); border: 1px solid var(--border); box-shadow: 0 20px 80px rgba(0, 0, 0, 0.35); }
  .legal-header { display: flex; justify-content: flex-end; border-bottom: 1px solid var(--border); }
  .legal-close { background: none; border: none; color: #333; font-size: 1.8rem; line-height: 1; padding: 10px 15px; cursor: pointer; margin-right: auto; }
  .legal-content iframe { flex: 1 1 auto; min-height: 0; width: 100%; border: none; background: #f4f4f4; }

  /* Footer */
  .site-footer {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    border-top: 1px solid var(--border);
    margin-top: 32px;
    padding-top: 16px;
    color: var(--muted);
    font-size: 12px;
  }

  .site-footer a { margin-right: 14px; }
  .site-footer a:last-child { margin-right: 0; }
    
  /* Mobile Anordnung */
  @media (max-width: 820px) {
    .panels { 
      display: flex;
      flex-direction: column;
    }
    /* Reihenfolge nach Position, nicht nach Beschriftung: gilt für Deutsch und Englisch.
       Spalten im HTML: 1 = Liste, 2 = Suche, 3 = News. Mobil: Suche, Liste, News. */
    .panels > .panel:nth-child(2) { order: 1; }
    .panels > .panel:nth-child(1) { order: 2; }
    .panels > .panel:nth-child(3) { order: 3; }
    
    /* Infobereich im Phone-Modus ausblenden */
    .panel-info {
      display: none;
    }
  }

  mark.search-highlight {
    background-color: rgba(var(--accent-rgb), 0.25);
    color: var(--text);
    padding: 0 2px;
    border-radius: 2px;
  }

  .scroll-top-btn {
    position: absolute;
    bottom: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(var(--surface-rgb), 0.9);
    border: 1px solid var(--border);
    color: var(--text);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease, background-color 0.2s ease;
    z-index: 10;
    padding: 0;
  }

  .scroll-top-btn.is-visible {
    opacity: 1;
    visibility: visible;
  }

  .scroll-top-btn:hover {
    background: var(--surface);
    border-color: var(--accent);
  }

  .scroll-top-btn svg {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  /* Dunkelmodus-Umschalter */
  .header-right {
    display: flex;
    align-items: center;
    gap: 14px;
  }

  .theme-toggle {
    flex-shrink: 0;
    position: relative;
    width: var(--switch-width);
    height: var(--switch-height);
    border-radius: calc(var(--switch-height) / 2);
    background: var(--switch-track);
    border: 1px solid var(--switch-border);
    cursor: pointer;
    padding: 0;
    transition: border-color var(--switch-speed) ease;
  }

  .theme-toggle:hover {
    border-color: var(--switch-knob);
  }

  /* Knopf: links = hell, rechts = dunkel */
  .theme-toggle::after {
    content: "";
    position: absolute;
    top: var(--switch-pad);
    left: var(--switch-pad);
    width: calc(var(--switch-height) - 2px - 2 * var(--switch-pad));
    height: calc(var(--switch-height) - 2px - 2 * var(--switch-pad));
    border-radius: 50%;
    background: var(--switch-knob);
    transition: transform var(--switch-speed) ease;
  }

  html[data-theme="dark"] .theme-toggle::after {
    transform: translateX(calc(var(--switch-width) - var(--switch-height)));
  }

  /* Modal-Overlay */
  .modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.4);
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    z-index: 1000;
  }

  .modal-overlay.active {
    visibility: visible;
    opacity: 1;
  }

  .modal-content {
    position: absolute;
    top: 0;
    right: 0;
    width: var(--modal-width);
    max-width: 900px;
    height: 100%;
    background: var(--surface);
    border-left: 1px solid var(--border);
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
  }

  .modal-header {
    background: var(--modal-header-bg);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: flex-start;
  }

  .modal-overlay.active .modal-content {
    transform: translateX(0);
  }

  .modal-close {
    background: none;
    border: none;
    color: var(--text);
    font-size: 1.8rem;
    padding: 10px 15px;
    cursor: pointer;
  }

  .modal-content iframe {
    width: 100%;
    height: 100%;
    border: none;
  }

  #liste-content, #news-content { flex: 1 0 380px; height: auto; }
  #liste-content table { table-layout: fixed; }
  #liste-content col:first-child { width: 44%; }
  #liste-content col:last-child { width: 56%; }
  #liste-content td { overflow-wrap: anywhere; }
  .scroll-panel .td1 { font-size: 16px; font-weight: 750; }
  .modal-content, .modal-content iframe, .modal-header { background: rgb(212, 208, 200); }
  .modal-header .modal-close { color: #333; }
  .language-switch { display:flex;gap:8px;align-items:center;font:11px/1.4 system-ui,sans-serif; }
  .language-switch a {color:var(--muted);text-decoration:none;}
  .language-switch a[aria-current="page"] {color:var(--text);font-weight:700;}

/* Fenster an die neue Farbpalette angleichen */
.legal-content,
.modal-content,
.modal-content iframe {
  background: var(--surface);
}

.legal-header,
.modal-header {
  background: var(--modal-header-bg);
}

.legal-content iframe {
  background: var(--bg);
}

.legal-close,
.modal-header .modal-close {
  color: var(--text);
}

/* ==========================================================
   Rechtsseiten (AGB, Impressum, DE und EN)
   Gilt nur mit <body class="legal-page">; die Hauptseite bleibt unberührt.
   ========================================================== */
body.legal-page {
  display: block;
  min-height: 0;
  padding: 32px 24px 24px;
}

.legal-page .container {
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  overflow-wrap: anywhere;
}

.legal-page h1,
.legal-page h2,
.legal-page h3,
.legal-page .bu,
.legal-page .bgg,
.legal-page .bolld {
  color: var(--text);
  font-weight: 600;
}

.legal-page h1 { font-size: 20px; }
.legal-page h2,
.legal-page h3 { font-size: 15px; }

.legal-page h3 {
  margin: 28px 0 12px;
  scroll-margin-top: 15px;
}

.legal-page p { margin: 0 0 16px; }

.legal-page .bgg {
  margin: 0 0 20px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 15px;
  letter-spacing: 0.03em;
}

.legal-page .section { margin-bottom: 24px; }

.legal-page .language-nav {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-bottom: 20px;
  font-size: 11px;
}

.legal-page .language-nav a { color: var(--muted); }

.legal-page .language-nav a[aria-current="page"] {
  color: var(--text);
  font-weight: 700;
}

.legal-page .legal-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: 12px;
}

.legal-page nav[aria-label="Inhalt"],
.legal-page nav[aria-label="Contents"] {
  font-size: 13px;
  line-height: 1.8;
}

.legal-page > table {
  width: 100%;
  max-width: 800px;
  margin: 24px auto 0;
  border-collapse: collapse;
}

.legal-page td.footer {
  padding: 16px 0 0;
  border-top: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  text-align: left;
  font-size: 11px;
  line-height: 1.6;
}

.legal-page hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 20px 0;
}

.legal-page :focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

@media (max-width: 500px) {
  body.legal-page { padding: 16px 12px; }
  .legal-page .container { padding: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  body.legal-page { transition: none; }
}


/* Vorgemerkte Namen ohne Bilder (Lichttisch) */
.scroll-panel td span.no-link.is-marked {
  color: var(--text);
  font-weight: 600;
}
