:root {
  color-scheme: light dark;
  --bg: #f4efe6;
  --surface: #fffdf8;
  --surface-2: #ebe3d5;
  --ink: #1f1b16;
  --muted: #6b6257;
  --line: #d9cfbf;
  --accent: #c2410c;
  --accent-ink: #fff8f0;
  --danger: #b42318;
  --shadow: 0 1px 2px rgb(60 40 20 / 8%), 0 8px 24px rgb(60 40 20 / 8%);
  --radius: 16px;
  --rail: 44px;
}

/* Dunkel: automatisch nach Geräteeinstellung, solange nicht manuell "Hell" gewählt ist … */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14110f;
    --surface: #1f1b17;
    --surface-2: #2a241e;
    --ink: #f3ece0;
    --muted: #a69a8a;
    --line: #3a322a;
    --accent: #f59e0b;
    --accent-ink: #1a1206;
    --danger: #f97066;
    --shadow: 0 1px 2px rgb(0 0 0 / 40%), 0 8px 24px rgb(0 0 0 / 30%);
  }
}

/* … oder manuell über den Umschalter (theme.js setzt data-theme). */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #14110f;
  --surface: #1f1b17;
  --surface-2: #2a241e;
  --ink: #f3ece0;
  --muted: #a69a8a;
  --line: #3a322a;
  --accent: #f59e0b;
  --accent-ink: #1a1206;
  --danger: #f97066;
  --shadow: 0 1px 2px rgb(0 0 0 / 40%), 0 8px 24px rgb(0 0 0 / 30%);
}
:root[data-theme="light"] { color-scheme: light; }

* { box-sizing: border-box; }
[hidden] { display: none !important; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100dvh;
  padding-bottom: calc(96px + env(safe-area-inset-bottom));
}

h1, h2 { line-height: 1.15; margin: 0; text-wrap: balance; }
h2 { font-size: 1.15rem; }
p { margin: 0; }
a { color: inherit; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

main, .hero, .footer {
  width: min(100% - 32px, 680px);
  margin-inline: auto;
}

/* ------------------------------------------------------------------ Kopf */

.hero { padding: calc(28px + env(safe-area-inset-top)) 0 20px; }
.hero-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.theme-toggle {
  font: inherit;
  font-size: .8rem;
  font-weight: 600;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
  min-height: 36px;
  cursor: pointer;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.theme-toggle:hover { color: var(--ink); }
a.theme-toggle { text-decoration: none; display: inline-flex; align-items: center; }
.theme-toggle[aria-pressed="true"] { color: var(--accent); border-color: var(--accent); }
.hero-actions { display: flex; gap: 6px; }
.steps { margin: 0; padding-left: 1.3em; display: grid; gap: 6px; }
#pushHelpIos { display: grid; gap: 10px; }
.eyebrow {
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--accent);
}
.hero h1 {
  font-size: clamp(2.1rem, 9vw, 3.4rem);
  font-weight: 800;
  letter-spacing: -.03em;
  margin-top: 4px;
}
.subtitle { margin-top: 8px; color: var(--muted); font-size: 1.05rem; }

.banner, .notice {
  border-radius: 12px;
  padding: 10px 14px;
  margin-bottom: 16px;
  font-size: .92rem;
}
.banner { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.notice { background: var(--surface-2); color: var(--muted); }

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  display: grid;
  gap: 12px;
  box-shadow: var(--shadow);
}

/* ------------------------------------------------------------- Countdown */

.countdown { text-align: center; padding: 8vh 0 24px; display: grid; gap: 18px; }
.countdown.compact { padding-top: 8px; }
.countdown-label { color: var(--muted); }
.countdown-label strong { color: var(--ink); }
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.tile {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 4px 12px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 2px;
}
.tile span {
  font-size: clamp(2rem, 11vw, 3.6rem);
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.03em;
}
.tile small {
  color: var(--muted);
  font-size: .7rem;
  letter-spacing: .12em;
  text-transform: uppercase;
}

/* ----------------------------------------------------------------- Karte */

.map-section { margin-bottom: 28px; display: grid; gap: 10px; }
.overview-map {
  height: min(52vh, 340px);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  overflow: hidden;
  z-index: 0;
}
.leaflet-container { font: inherit; background: var(--surface-2); }
.pin {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 2px 6px rgb(0 0 0 / 40%);
  color: #fff;
  font-size: .75rem;
  font-weight: 700;
  display: grid;
  place-items: center;
}

/* ------------------------------------------------------------ Zeitstrahl */

.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before {
  content: "";
  position: absolute;
  left: calc(var(--rail) / 2 - 1px);
  top: 8px;
  bottom: 0;
  width: 2px;
  background: var(--line);
}

.tl-day { position: relative; padding: 18px 0 10px var(--rail); }
.tl-day:first-child { padding-top: 0; }
.tl-day span {
  display: inline-block;
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--bg);
  position: relative;
}
.tl-day::before {
  content: "";
  position: absolute;
  left: calc(var(--rail) / 2 - 5px);
  top: calc(100% - 26px);
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
}
.tl-day:first-child::before { top: 6px; }

.tl-item { position: relative; padding: 0 0 16px var(--rail); }
.tl-dot {
  position: absolute;
  left: calc(var(--rail) / 2 - 15px);
  top: 12px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--line);
  display: grid;
  place-items: center;
  font-size: .85rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px 0;
  min-width: 0;
}
.card-head time {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  flex: none;
}
.names { display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; flex: 1; }
.name {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: .88rem;
  font-weight: 600;
  overflow-wrap: anywhere;
}
.name i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: none;
}
.card-head .icon-btn + .icon-btn { margin-left: -6px; }
.distance { padding: 6px 14px 0; font-size: .85rem; color: var(--muted); }
.pin.goal { background: var(--surface); font-size: 1rem; }
.hidden-note { padding: 6px 14px 0; font-size: .82rem; font-weight: 600; color: var(--accent); }
.tl-item.is-hidden .card { border-style: dashed; }
.card-text { padding: 8px 14px 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.card > :last-child:not(.photos):not(.minimap-wrap) { padding-bottom: 14px; }

.photos { display: grid; gap: 3px; margin-top: 12px; grid-template-columns: repeat(2, 1fr); }
.photos.one { grid-template-columns: 1fr; }
.photos.three > :first-child { grid-column: span 2; }
.photos button {
  all: unset;
  cursor: zoom-in;
  display: block;
  aspect-ratio: 4 / 3;
  background: var(--surface-2);
  position: relative;
}
.photos.one button { aspect-ratio: auto; }
.photos img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photos.one img { height: auto; max-height: 70vh; object-fit: contain; }
.photos .more {
  position: absolute;
  inset: 0;
  background: rgb(0 0 0 / 55%);
  color: #fff;
  font-size: 1.5rem;
  font-weight: 700;
  display: grid;
  place-items: center;
}
.photos button:focus-visible { outline: 3px solid var(--accent); outline-offset: -3px; }

.minimap-wrap { margin-top: 12px; position: relative; }
.minimap { height: 170px; z-index: 0; }
.maplink {
  position: absolute;
  right: 8px;
  top: 8px;
  z-index: 1;
  background: var(--surface);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: .78rem;
  font-weight: 600;
  text-decoration: none;
  box-shadow: var(--shadow);
}

.footer-links { display: flex; flex-wrap: wrap; gap: 14px; }
.legal main { display: grid; gap: 12px; padding-bottom: 8px; }
.legal main h2 { margin-top: 14px; }
.legal main ul { margin: 0; padding-left: 1.3em; display: grid; gap: 6px; }
.legal .hero h1 { font-size: clamp(1.8rem, 7vw, 2.6rem); }
.legal .eyebrow, .admin .eyebrow { margin-top: 14px; }
.empty { text-align: center; color: var(--muted); padding: 48px 0; }

.footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: .78rem;
  padding: 24px 0;
}

/* --------------------------------------------------------------- Buttons */

.btn, .icon-btn {
  font: inherit;
  color: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.btn {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 16px;
  font-weight: 600;
  min-height: 44px;
}
a.btn { text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }
.btn.primary { background: var(--accent); border-color: transparent; color: var(--accent-ink); }
.btn.danger { color: var(--danger); }
.btn.active { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .55; cursor: progress; }
.icon-btn {
  background: none;
  border: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--muted);
  flex: none;
}
.icon-btn:hover { background: var(--surface-2); }
:is(.btn, .icon-btn, .theme-toggle, input, textarea, select, summary):focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.fab {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--accent);
  color: var(--accent-ink);
  border: 0;
  border-radius: 999px;
  padding: 14px 26px;
  font: inherit;
  font-weight: 700;
  font-size: 1.02rem;
  box-shadow: 0 6px 24px rgb(0 0 0 / 30%);
  cursor: pointer;
  z-index: 10;
  white-space: nowrap;
}

/* --------------------------------------------------------------- Dialoge */

input[type="text"], input[type="password"], input[type="number"], input[type="datetime-local"], textarea, select {
  width: 100%;
  font: inherit;
  color: inherit;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  min-height: 44px;
}
textarea { resize: vertical; display: block; }
.row { display: flex; gap: 8px; }
.row input { flex: 1; min-width: 0; }

.sheet {
  border: 0;
  padding: 0;
  background: var(--surface);
  color: var(--ink);
  width: min(100%, 560px);
  max-width: 100%;
  max-height: 92dvh;
  margin: auto auto 0;
  border-radius: 22px 22px 0 0;
  box-shadow: 0 -8px 40px rgb(0 0 0 / 35%);
}
.sheet::backdrop, .lightbox::backdrop { background: rgb(0 0 0 / 60%); }
.sheet form {
  padding: 18px 18px calc(18px + env(safe-area-inset-bottom));
  display: grid;
  gap: 10px;
}
.sheet-head { display: flex; justify-content: space-between; align-items: center; }
@media (min-width: 620px) {
  .sheet { margin: auto; border-radius: 22px; }
}

.field-label { font-size: .82rem; font-weight: 700; color: var(--muted); margin-top: 4px; }

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 6px;
}
.chips input {
  flex: 1 1 120px;
  border: 0;
  background: none;
  min-height: 32px;
  padding: 2px 6px;
  outline: none;
}
.chips:focus-within { outline: 3px solid var(--accent); outline-offset: 2px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--accent);
  color: var(--accent-ink);
  border: 0;
  border-radius: 999px;
  padding: 4px 10px;
  font: inherit;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
}
.suggestions { display: flex; flex-wrap: wrap; gap: 6px; }
.suggestions:empty { display: none; }
.suggestion {
  background: none;
  border: 1px dashed var(--line);
  border-radius: 999px;
  padding: 4px 10px;
  font: inherit;
  font-size: .85rem;
  color: var(--muted);
  cursor: pointer;
}

.attach-row { display: flex; gap: 8px; }
.attach-row .btn { flex: 1; }
.previews { display: flex; gap: 8px; overflow-x: auto; }
.previews:empty { display: none; }
.preview { position: relative; flex: none; }
.preview img { width: 76px; height: 76px; object-fit: cover; border-radius: 10px; display: block; }
.preview button {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 0;
  background: var(--ink);
  color: var(--bg);
  font-size: .7rem;
  cursor: pointer;
}
.location-state { font-size: .9rem; color: var(--muted); }
.time-details summary { cursor: pointer; font-size: .9rem; color: var(--muted); padding: 4px 0; }
.time-details input { margin: 8px 0 4px; }
.form-error { color: var(--danger); font-weight: 600; font-size: .92rem; }

.lightbox {
  border: 0;
  padding: 0;
  background: none;
  max-width: 100vw;
  max-height: 100dvh;
  width: 100vw;
  height: 100dvh;
}
.lightbox[open] { display: grid; place-items: center; }
.lightbox img { max-width: 100vw; max-height: 100dvh; object-fit: contain; }
.lightbox .icon-btn { position: fixed; background: rgb(0 0 0 / 55%); color: #fff; width: 44px; height: 44px; font-size: 1.3rem; }
.lightbox-close { top: calc(12px + env(safe-area-inset-top)); right: 12px; }
.lightbox-nav { top: 50%; transform: translateY(-50%); }
.lightbox-nav.prev { left: 8px; }
.lightbox-nav.next { right: 8px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(88px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--bg);
  padding: 10px 16px;
  border-radius: 12px;
  font-size: .92rem;
  z-index: 30;
  max-width: calc(100% - 32px);
  text-align: center;
}

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

.admin main, #dashboard { display: grid; gap: 20px; }
.admin .hero h1 { font-size: clamp(1.8rem, 7vw, 2.6rem); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.stat b { display: block; font-size: 1.5rem; font-variant-numeric: tabular-nums; }
.stat small { color: var(--muted); }
.form-grid { display: grid; gap: 14px; }
.form-grid label { display: grid; gap: 4px; font-weight: 600; font-size: .92rem; }
.form-grid label.check { grid-template-columns: auto 1fr; align-items: start; gap: 10px; font-weight: 400; }
.form-grid label.check input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--accent); }
.form-grid label.check b { display: block; }
.form-grid .hint { font-weight: 400; color: var(--muted); font-size: .82rem; }
.two { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
fieldset { border: 0; padding: 0; margin: 0; display: grid; gap: 14px; }
legend { font-weight: 800; font-size: 1.05rem; padding: 0; margin-bottom: 10px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.saved { color: var(--muted); font-size: .9rem; }

.admin-posts { display: grid; gap: 10px; }
.admin-post {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
}
.admin-post.is-hidden { opacity: .6; }
.admin-post .thumb {
  width: 64px;
  height: 64px;
  border-radius: 10px;
  background: var(--surface-2);
  display: grid;
  place-items: center;
  overflow: hidden;
  font-size: 1.4rem;
}
.admin-post .thumb img { width: 100%; height: 100%; object-fit: cover; }
.admin-post .meta { font-size: .85rem; color: var(--muted); }
.admin-post .body { min-width: 0; display: grid; gap: 6px; }
.admin-post .text { white-space: pre-wrap; overflow-wrap: anywhere; }
.admin-post .btn { min-height: 36px; padding: 6px 12px; font-size: .88rem; }

@media (prefers-reduced-motion: no-preference) {
  .sheet[open] { animation: rise .22s ease-out; }
  @keyframes rise { from { transform: translateY(24px); opacity: 0; } }
}
