:root {
  /* Alles abgeleitet aus der zentralen Areki-Theme-Datei — keine eigenen
     Farbwerte. Lokale Alias-Namen bleiben bestehen, damit der Rest dieser
     Datei unverändert funktioniert. */
  --bg: var(--areki-bg);
  --bg-elevated: var(--areki-surface);
  --bg-elevated-2: var(--areki-border);
  --border: var(--areki-border);
  --text: var(--areki-text);
  --text-muted: var(--areki-text-muted);
  --accent: var(--areki-accent);
  --accent-soft: color-mix(in srgb, var(--areki-accent) 12%, transparent);
  --code-bg: var(--areki-bg);
  --sidebar-width: 280px;
  --topbar-height: 56px;
  --radius: var(--areki-radius);
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--areki-body-font);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

[id] {
  scroll-margin-top: 24px;
}

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

code, pre, .example {
  font-family: var(--areki-mono-font);
}

code {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.1em 0.4em;
  font-size: 0.88em;
  color: var(--accent);
  white-space: nowrap;
}

pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.2rem;
  overflow-x: auto;
}
pre code {
  background: none;
  border: none;
  padding: 0;
  white-space: pre;
  color: var(--text-muted);
}

/* ---------- Layout ---------- */

.layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
  padding: 1.5rem 1rem 2rem;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0 0.4rem 1rem;
  border-bottom: 1px solid var(--border);
}

.brand-mark {
  width: 36px;
  height: 36px;
  object-fit: contain;
  flex-shrink: 0;
}

.brand-title {
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: 0.01em;
}
.brand-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.sidebar-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.nav-top-link {
  display: block;
  padding: 0.55rem 0.6rem;
  border-radius: 6px;
  color: var(--text);
  font-weight: 600;
  font-size: 0.92rem;
}
.nav-top-link:hover {
  background: var(--bg-elevated-2);
  text-decoration: none;
}

.sidebar-nav details {
  border-radius: 6px;
}

.sidebar-nav summary {
  list-style: none;
  cursor: pointer;
  padding: 0.55rem 0.6rem;
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: space-between;
  user-select: none;
}
.sidebar-nav summary::-webkit-details-marker { display: none; }
.sidebar-nav summary:hover { background: var(--bg-elevated-2); }
.sidebar-nav summary::after {
  content: "";
  width: 7px;
  height: 7px;
  border-right: 2px solid var(--text-muted);
  border-bottom: 2px solid var(--text-muted);
  transform: rotate(45deg);
  transition: transform 0.15s ease;
  margin-right: 2px;
}
.sidebar-nav details[open] summary::after {
  transform: rotate(-135deg);
}

.sidebar-nav ul {
  list-style: none;
  margin: 0.15rem 0 0.4rem;
  padding: 0 0 0 0.9rem;
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.sidebar-nav ul li a {
  display: block;
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 0.87rem;
}
.sidebar-nav ul li a:hover {
  background: var(--bg-elevated-2);
  color: var(--text);
  text-decoration: none;
}
.sidebar-nav ul li a.active {
  background: var(--accent-soft);
  color: var(--accent);
}

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.85rem;
}
.sidebar-footer a { font-weight: 600; }
.sidebar-footer span { color: var(--text-muted); }

.content {
  flex: 1;
  min-width: 0;
  padding: 3rem 3.5rem 5rem;
  max-width: 920px;
}

/* ---------- Sections ---------- */

.section {
  padding-top: 1rem;
  margin-bottom: 3.5rem;
}
.section + .section {
  border-top: 1px solid var(--border);
  padding-top: 3rem;
}

/* ---------- Hero (Startseite) ---------- */

.hero-grid {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2.5rem;
  flex-wrap: wrap;
}

.hero-copy {
  flex: 1;
  min-width: 280px;
}

.hero-owl {
  width: 200px;
  height: 200px;
  object-fit: contain;
  flex-shrink: 0;
}

@media (max-width: 700px) {
  .hero-grid {
    flex-direction: column-reverse;
  }
  .hero-owl {
    width: 130px;
    height: 130px;
  }
}

.eyebrow {
  font-family: var(--areki-mono-font);
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: var(--areki-eyebrow-tracking);
  font-size: 0.85rem;
  font-weight: 500;
  margin: 0 0 0.5rem;
}

/* Serif-Headlines für die Haupt-Hierarchie (h1 Hero, h2 Komponenten-Titel) —
   an LibreChat angelehnt zurückhaltend gehalten (Inter bleibt Basis-Schrift,
   Serif nur bei den grossen Headlines). H3 bleibt bewusst sans-serif: bei
   ~40 Subsection-Überschriften im Dokument würde durchgängiger Display-Serif
   die Scanbarkeit einer so dichten Referenz-Doku verschlechtern. */
h1 {
  font-family: 'DM Serif Display', serif;
  font-weight: 400;
  font-size: 3.6rem;
  margin: 0 0 1rem;
  letter-spacing: 0;
}

h2 {
  font-family: 'DM Serif Display', serif;
  font-weight: 400;
  font-size: 2.6rem;
  margin: 0 0 0.75rem;
  letter-spacing: 0;
}

.section-heading {
  font-family: var(--areki-mono-font);
  margin-top: 2.5rem;
  font-size: 0.85rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: var(--areki-eyebrow-tracking);
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.6rem;
}

h3 {
  font-family: var(--areki-body-font);
  font-size: 1.45rem;
  margin: 2.2rem 0 0.8rem;
  font-weight: 600;
  color: var(--text);
}

h4 {
  font-family: var(--areki-mono-font);
  font-size: 0.85rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: var(--areki-eyebrow-tracking);
  margin: 1.5rem 0 0.6rem;
  color: var(--accent);
}

.lead {
  color: var(--text-muted);
  font-size: 1.05rem;
  max-width: 65ch;
}

p { margin: 0.8rem 0; }

ul, ol {
  padding-left: 1.3rem;
  margin: 0.8rem 0;
}
li { margin: 0.35rem 0; }
li > ul, li > ol {
  margin-top: 0.4rem;
}

ol.steps {
  counter-reset: step;
  padding-left: 0;
  list-style: none;
}
ol.steps > li {
  position: relative;
  padding-left: 2.6rem;
  margin: 1rem 0;
  counter-increment: step;
}
ol.steps > li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0;
  width: 1.9rem;
  height: 1.9rem;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.source {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 1rem;
}

/* ---------- Cards ---------- */

.card-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-top: 1rem;
}

.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  text-decoration: none;
}
.card-icon { font-size: 1.5rem; }
.card-title { font-weight: 700; color: var(--text); }
.card-desc { font-size: 0.85rem; color: var(--text-muted); }

/* ---------- Tables ---------- */

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

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-elevated);
  font-size: 0.92rem;
}

th, td {
  text-align: left;
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

th {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: var(--areki-eyebrow-tracking);
  background: var(--bg-elevated-2);
}

tr:last-child td { border-bottom: none; }

ul.cell-list {
  margin: 0.4rem 0 0;
  padding-left: 1.1rem;
}
ul.cell-list li { margin: 0.2rem 0; font-size: 0.9em; }

/* ---------- Kontenplan list ---------- */

.kontenplan-list {
  list-style: none;
  padding: 0;
  margin: 1rem 0;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem 1.5rem;
}
.kontenplan-list li {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  margin: 0;
  padding: 0.4rem 0;
  border-bottom: 1px dashed var(--border);
}
.kontenplan-list code {
  flex-shrink: 0;
  min-width: 2.4rem;
  text-align: center;
  white-space: nowrap;
}
.kontenplan-list span {
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ---------- Examples ---------- */

.example-box {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 0.8rem 0;
}
.example {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  padding: 0.7rem 1rem;
  font-size: 0.88rem;
  color: var(--text-muted);
}

/* ---------- Footer ---------- */

.page-footer {
  margin-top: 4rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.85rem;
  display: flex;
  gap: 0.5rem;
}
.dot { opacity: 0.5; }

/* ---------- Mobile nav ---------- */

.nav-toggle {
  display: none;
  position: fixed;
  top: 0.9rem;
  left: 1rem;
  z-index: 40;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
}
.nav-toggle span {
  width: 18px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.nav-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 20;
}

@media (max-width: 900px) {
  .nav-toggle { display: flex; }

  body.nav-open .nav-backdrop { display: block; }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 30;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
  }
  body.nav-open .sidebar {
    transform: translateX(0);
  }

  .content {
    padding: 5rem 1.25rem 4rem;
    max-width: 100%;
  }

  h1 { font-size: 2.9rem; }
  h2 { font-size: 1.9rem; }

  .card-grid {
    grid-template-columns: 1fr 1fr;
  }

  .kontenplan-list {
    grid-template-columns: 1fr;
  }

  [id] {
    scroll-margin-top: 70px;
  }
}

@media (max-width: 520px) {
  .card-grid {
    grid-template-columns: 1fr;
  }
}

/* ---------- Admin page ---------- */

.admin-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  max-width: 920px;
  margin: 0 auto;
  padding: 1.5rem 1.5rem 0;
}

.back-link {
  color: var(--text-muted);
  font-size: 0.9rem;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.back-link:hover { color: var(--text); }

.restricted-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 999px;
  padding: 0.3rem 0.8rem;
  font-size: 0.85rem;
  font-weight: 600;
}

.admin-content {
  max-width: 920px;
  margin: 0 auto;
  padding: 1.5rem 1.5rem 5rem;
}

.admin-content .section {
  margin-bottom: 3rem;
}
.admin-content .section + .section {
  border-top: 1px solid var(--border);
  padding-top: 2.5rem;
}

.access-note {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  padding: 1rem 1.2rem;
  font-size: 0.9rem;
  color: var(--text-muted);
  margin: 1.5rem 0;
}
.access-note strong { color: var(--text); }
