:root {
  color-scheme: light;
  --bg: #f8f7f4;
  --bg-elev: #ffffff;
  --bg-muted: #efede8;
  --text: #1c1b18;
  --text-muted: #5f5c55;
  --border: #dedbd3;
  --accent: #b45309;
  --accent-contrast: #ffffff;
  --link: #9a3412;
  --success: #15803d;
  --danger: #b91c1c;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.06), 0 4px 16px rgba(0, 0, 0, 0.05);
  --radius: 14px;
  --radius-sm: 8px;
  --header-h: 56px;
  --nav-h: 60px;
  --font: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-serif: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, serif;
  --max-w: 1100px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #14161b;
    --bg-elev: #1d2027;
    --bg-muted: #262a33;
    --text: #ece9e2;
    --text-muted: #a5a29a;
    --border: #343843;
    --accent: #f59e0b;
    --accent-contrast: #1a1200;
    --link: #fbbf24;
    --success: #4ade80;
    --danger: #f87171;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 6px 20px rgba(0, 0, 0, 0.35);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #14161b;
  --bg-elev: #1d2027;
  --bg-muted: #262a33;
  --text: #ece9e2;
  --text-muted: #a5a29a;
  --border: #343843;
  --accent: #f59e0b;
  --accent-contrast: #1a1200;
  --link: #fbbf24;
  --success: #4ade80;
  --danger: #f87171;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 6px 20px rgba(0, 0, 0, 0.35);
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  min-height: 100dvh;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
  overflow-x: hidden;
}

h1, h2, h3, h4 {
  font-family: var(--font-serif);
  line-height: 1.2;
  margin: 0 0 0.5em;
  font-weight: 700;
  letter-spacing: -0.01em;
}
h1 { font-size: clamp(1.7rem, 4.5vw, 2.4rem); }
h2 { font-size: clamp(1.3rem, 3.5vw, 1.7rem); margin-top: 1.5em; }
h3 { font-size: 1.15rem; }
p { margin: 0 0 1em; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
img, svg { max-width: 100%; }
button { font: inherit; color: inherit; }
ul { padding-left: 1.2em; }

.skip-link {
  position: absolute; left: -999px; top: 8px; z-index: 100;
  background: var(--accent); color: var(--accent-contrast); padding: 8px 12px; border-radius: 8px;
}
.skip-link:focus { left: 8px; }
/* Programmatisch fokussierte Überschriften (Seitenwechsel) ohne Fokusrahmen. */
.view h1[tabindex="-1"]:focus { outline: none; }

/* Header */
.app-header {
  position: sticky; top: 0; z-index: 50;
  height: var(--header-h);
  display: flex; align-items: center; gap: 12px;
  padding: 0 16px;
  padding-top: env(safe-area-inset-top);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(160%) blur(12px);
  -webkit-backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.brand {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--font-serif); font-weight: 700; font-size: 1.2rem;
  color: var(--text);
}
.brand:hover { text-decoration: none; }
.brand-icon { width: 24px; height: 24px; color: var(--accent); }
.top-nav { display: none; gap: 4px; margin-left: 16px; }
.top-nav a {
  padding: 6px 12px; border-radius: 999px; color: var(--text-muted); font-weight: 500;
}
.top-nav a:hover { background: var(--bg-muted); text-decoration: none; color: var(--text); }
.top-nav a[aria-current="page"] { background: var(--accent); color: var(--accent-contrast); }
/* Zwischen Tablet- und Desktopbreite enger setzen, damit alle Einträge in eine Zeile passen. */
@media (max-width: 1099px) {
  .top-nav { gap: 2px; margin-left: 8px; }
  .top-nav a { padding: 6px 8px; font-size: 0.9rem; }
}
.header-actions { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 50%; border: 0; background: transparent; color: var(--text);
  cursor: pointer;
}
.icon-btn:hover { background: var(--bg-muted); }
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn[aria-current="page"] { color: var(--accent); }
#install-btn { display: none; }
@media (min-width: 600px) { #install-btn:not([hidden]) { display: inline-flex; } }
@media (min-width: 768px) { .icon-btn.mobile-only { display: none; } }

/* Main */
.view {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 20px 16px 32px;
  outline: none;
}
.loading { color: var(--text-muted); padding: 40px 0; text-align: center; }

/* Bottom nav */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--bg-elev);
  border-top: 1px solid var(--border);
}
.bottom-nav a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 0.7rem; color: var(--text-muted); font-weight: 500;
}
.bottom-nav a:hover { text-decoration: none; }
.bottom-nav a svg { width: 24px; height: 24px; }
.bottom-nav a[aria-current="page"] { color: var(--accent); }

@media (min-width: 768px) {
  .view { padding: 28px 24px 48px; }
}
/* Obere Navigation erst, wenn alle Einträge samt Kopfzeilen-Aktionen in eine Zeile passen. */
@media (min-width: 1024px) {
  body { padding-bottom: 0; }
  .top-nav { display: flex; }
  .bottom-nav { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

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