:root {
  --bg: #f6f3ec;
  --surface: #ffffff;
  --surface-2: #efeae0;
  --text: #1f2a26;
  --muted: #5f6b66;
  --line: #ddd6c8;
  --brand: #2f5d50;
  --brand-ink: #ffffff;
  --accent: #c8693c;
  --city: #b25a32;
  --nature: #3f7d5c;
  --warn-bg: #fff1dc;
  --warn-line: #e8b26a;
  --ok-bg: #e5f2ea;
  --radius: 14px;
  --shadow: 0 1px 2px rgb(0 0 0 / 6%), 0 4px 16px rgb(0 0 0 / 6%);
  --topbar-h: 56px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141a18;
    --surface: #1c2422;
    --surface-2: #25302d;
    --text: #e8ece9;
    --muted: #a1ada8;
    --line: #33403c;
    --brand: #6fb39b;
    --brand-ink: #0d1412;
    --accent: #e8915f;
    --city: #e08a5f;
    --nature: #79c39c;
    --warn-bg: #3a2d18;
    --warn-line: #8a6a35;
    --ok-bg: #1e3329;
    --shadow: 0 1px 2px rgb(0 0 0 / 40%), 0 4px 16px rgb(0 0 0 / 30%);
  }
}

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

html, body { margin: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--brand); }
img { max-width: 100%; display: block; }
h1 { font-size: clamp(1.5rem, 4vw, 2.1rem); line-height: 1.2; margin: 0.4em 0; }
h2 { font-size: 1.15rem; margin: 0 0 0.6em; }
h3 { font-size: 1rem; margin: 0 0 0.4em; }

/* Kopfzeile */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left));
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; color: var(--text); text-decoration: none; font-weight: 700; min-width: 0; }
.brand span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-mark { width: 30px; height: 30px; color: var(--brand); flex: none; }
.topnav { display: flex; align-items: center; gap: 8px; }
.navlink { color: var(--text); text-decoration: none; padding: 6px 8px; border-radius: 8px; max-width: 9em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.navlink:hover { background: var(--surface-2); }
@media (max-width: 340px) { .brand span { display: none; } }

/* Navigation unten (Handy) */
.tabbar { display: none; }
@media (max-width: 719px) {
  :root { --tabbar-h: 62px; }
  .topnav .desk-only { display: none; }
  body { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); }
  .tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    display: grid; grid-template-columns: repeat(5, 1fr); align-items: stretch;
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
    padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    background: var(--surface); border-top: 1px solid var(--line);
    box-shadow: 0 -2px 12px rgb(0 0 0 / 6%);
  }
  .tabbar a {
    display: grid; justify-items: center; align-content: center; gap: 2px;
    color: var(--muted); text-decoration: none; font-size: 0.72rem; font-weight: 600;
  }
  .tabbar svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
  .tabbar a[aria-current="page"] { color: var(--brand); }
  .tabbar .tab-add svg { width: 44px; height: 44px; padding: 10px; margin-top: -14px; border-radius: 50%; background: var(--brand); color: var(--brand-ink); box-shadow: var(--shadow); }
  .tabbar .tab-add { color: var(--text); }
  .page-map { padding-bottom: 0; }
  .page-map .map-wrap { height: calc(100dvh - var(--topbar-h) - var(--tabbar-h) - env(safe-area-inset-bottom)); }
}

/* Layout */
.container { max-width: 1080px; margin: 0 auto; padding: 16px max(16px, env(safe-area-inset-left)) 48px; }
.narrow { max-width: 620px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 0 0 16px; box-shadow: var(--shadow); }
.grid-2 { display: grid; gap: 12px; grid-template-columns: 1fr; }
.grid-3 { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .grid-2 { grid-template-columns: 1fr 1fr; } }
@media (min-width: 860px) { .grid-3 { grid-template-columns: repeat(3, 1fr); } }
.stack { display: grid; gap: 12px; }
.stack > .btn { justify-self: start; }
.row-form { display: flex; flex-wrap: wrap; align-items: end; gap: 10px; margin: 8px 0; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.pre { white-space: pre-line; margin: 0; }
.prose p, .prose li { max-width: 68ch; }

/* Formulare */
label { display: grid; gap: 4px; font-weight: 600; font-size: 0.95rem; }
label.check { display: flex; align-items: center; gap: 8px; font-weight: 400; margin: 10px 0 0; }
input, select, textarea {
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  font-weight: 400;
  width: 100%;
  min-height: 44px;
}
input[type="checkbox"], input[type="radio"] { width: 20px; height: 20px; min-height: 0; accent-color: var(--brand); }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--brand) 55%, transparent);
  outline-offset: 2px;
}
fieldset { border: 0; padding: 0; margin: 0 0 12px; }
legend { font-weight: 600; margin-bottom: 6px; padding: 0; }
.segmented { display: flex; flex-wrap: wrap; gap: 8px; }
.segmented legend { width: 100%; }
.segmented label { display: flex; align-items: center; gap: 8px; font-weight: 500; background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 8px 16px;
  font: inherit; font-weight: 600; text-decoration: none;
  color: var(--text); background: var(--surface-2);
  border: 1px solid var(--line); border-radius: 999px; cursor: pointer;
}
.btn:hover { filter: brightness(0.97); }
.btn-primary { background: var(--brand); color: var(--brand-ink); border-color: transparent; }
.btn-ghost { background: transparent; }
.btn-small { min-height: 36px; padding: 4px 12px; font-size: 0.9rem; }
.btn[aria-busy="true"] { opacity: 0.7; pointer-events: none; }
.topbar .btn { min-height: 38px; padding: 6px 14px; }
.link-btn { background: none; border: 0; color: var(--muted); text-decoration: underline; cursor: pointer; font: inherit; font-size: 0.85rem; padding: 4px; }
.link-btn.danger { color: var(--city); }
.inline-form { display: inline; margin: 0; }

.alert { background: var(--warn-bg); border: 1px solid var(--warn-line); border-radius: 10px; padding: 10px 14px; }
.alert-soft { margin: 10px 0 0; }
.notice { background: var(--ok-bg); border-radius: 10px; padding: 10px 14px; }
.hint { border-left: 4px solid var(--brand); background: var(--surface); padding: 10px 14px; border-radius: 0 10px 10px 0; margin: 0 0 16px; }
.devbox { border: 2px dashed var(--accent); border-radius: var(--radius); padding: 12px 16px; margin-top: 16px; }

.badges { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0; }
.badge { display: inline-block; font-size: 0.8rem; font-weight: 600; padding: 3px 10px; border-radius: 999px; background: var(--surface-2); }
.badge-nature { background: color-mix(in srgb, var(--nature) 22%, transparent); }
.badge-city { background: color-mix(in srgb, var(--city) 22%, transparent); }
.badge-rain { background: color-mix(in srgb, #4a86c5 22%, transparent); }
.badge-warn { background: var(--warn-bg); }
.badge-muted { color: var(--muted); }

.chip-btn {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 40px; padding: 6px 14px;
  font: inherit; font-size: 0.92rem; font-weight: 600; text-decoration: none;
  color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 999px; cursor: pointer;
}
.chip-btn.active { background: var(--brand); color: var(--brand-ink); border-color: transparent; }
.chip-count { font-weight: 500; opacity: 0.75; font-size: 0.85em; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 20px; }

/* Karte */
.page-map { height: 100dvh; overflow: hidden; }
.map-wrap { position: relative; height: calc(100dvh - var(--topbar-h)); }
#map { position: absolute; inset: 0; }
.filter-panel {
  position: absolute; top: 12px; left: 12px; z-index: 2;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  max-width: min(320px, calc(100vw - 24px));
}
.filter-panel summary { cursor: pointer; padding: 10px 16px; font-weight: 700; list-style: none; }
.filter-panel summary::-webkit-details-marker { display: none; }
.filter-panel summary::before { content: "☰ "; }
.filter-panel .count { font-weight: 500; color: var(--muted); font-size: 0.9rem; }
.filters { display: grid; gap: 10px; padding: 0 16px 16px; }
.toast { position: absolute; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 3; margin: 0; background: var(--surface); border-radius: 999px; padding: 10px 18px; box-shadow: var(--shadow); max-width: calc(100vw - 32px); }
.map-about { position: absolute; left: 12px; bottom: 12px; z-index: 2; background: var(--surface); padding: 4px 10px; border-radius: 999px; font-size: 0.8rem; box-shadow: var(--shadow); text-decoration: none; }
.maplibregl-popup-content { background: var(--surface); color: var(--text); border-radius: 12px; padding: 0; overflow: hidden; min-width: 200px; box-shadow: var(--shadow); }
.maplibregl-popup-tip { border-top-color: var(--surface) !important; border-bottom-color: var(--surface) !important; }
.maplibregl-popup-close-button { font-size: 20px; width: 32px; height: 32px; color: var(--text); background: color-mix(in srgb, var(--surface) 80%, transparent); border-radius: 0 12px 0 12px; }
.popup img { width: 100%; height: 120px; object-fit: cover; }
.popup-body { padding: 10px 14px 12px; }
.popup-body h3 { margin: 0 0 4px; font-size: 1rem; }
.popup-body p { margin: 0 0 8px; color: var(--muted); font-size: 0.9rem; }
.popup-body .btn { min-height: 36px; padding: 4px 14px; font-size: 0.9rem; }

.pick-map { height: 320px; border-radius: 12px; overflow: hidden; margin-bottom: 8px; background: var(--surface-2); }
.area-handle { width: 22px; height: 22px; border-radius: 50%; background: var(--brand); border: 3px solid #fff; box-shadow: 0 1px 4px rgb(0 0 0 / 35%); cursor: move; }
.distance-list { display: grid; gap: 8px; margin-bottom: 8px; }
.distance-row { display: flex; align-items: center; gap: 8px; }
.distance-row input { max-width: 9rem; }
.spot-map { height: 260px; border-radius: var(--radius); overflow: hidden; background: var(--surface-2); }

/* Spot-Seite */
.spot-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: start; gap: 16px; }
.rating-summary { display: grid; justify-items: end; text-align: right; }
@media (max-width: 640px) {
  .rating-summary { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; text-align: left; }
}
.big-score { font-size: 2.2rem; font-weight: 800; line-height: 1; }
.stars { color: var(--accent); letter-spacing: 2px; font-size: 1.1rem; }
.spot-grid { display: grid; gap: 16px; grid-template-columns: 1fr; }
/* Auf dem Handy kommen Karte, Wetter und Tour direkt nach "In der Nähe", vor Bewertungen und Kommentaren. */
@media (max-width: 899px) {
  .spot-grid { gap: 0; }
  .spot-grid > .spot-main { display: contents; }
  .spot-main > * { order: 1; }
  .spot-grid > aside { order: 2; margin-bottom: 16px; }
  .spot-main > #treffen, .spot-main > #bewertung, .spot-main > #kommentare { order: 3; }
  .spot-grid > aside > .spot-map + p { margin-bottom: 16px; }
}
@media (min-width: 900px) {
  .spot-grid { grid-template-columns: minmax(0, 1fr) 340px; }
  .spot-grid > aside { position: sticky; top: calc(var(--topbar-h) + 16px); align-self: start; }
}
.gallery { display: flex; gap: 8px; overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: 4px; margin: 0 -16px; padding-inline: 16px; }
.gallery figure { margin: 0; flex: 0 0 auto; scroll-snap-align: start; }
.gallery img { height: 220px; width: auto; max-width: 80vw; object-fit: cover; border-radius: 12px; }
.gallery figcaption { font-size: 0.8rem; color: var(--muted); padding: 2px 4px; }
.criteria { display: grid; gap: 6px; margin: 0 0 12px; }
.criteria div { display: grid; grid-template-columns: 8.5em 1fr; align-items: center; gap: 8px; }
.criteria dt { color: var(--muted); }
.criteria dd { margin: 0; display: flex; align-items: center; gap: 8px; font-weight: 600; }
.bar { flex: 1; height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--accent); }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; }
.tag { background: var(--surface-2); border-radius: 999px; padding: 3px 10px; font-size: 0.85rem; }

.star-field { margin-bottom: 10px; }
.star-input { display: inline-flex; flex-direction: row-reverse; justify-content: flex-end; }
.star-input input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.star-input label { font-size: 1.9rem; line-height: 1; color: var(--line); cursor: pointer; padding: 0 3px; font-weight: 400; }
.star-input input:checked ~ label,
.star-input label:hover,
.star-input label:hover ~ label { color: var(--accent); }
.star-input input:focus-visible + label { outline: 3px solid color-mix(in srgb, var(--brand) 55%, transparent); border-radius: 6px; }
.tag-picker { display: flex; flex-wrap: wrap; gap: 8px; }
.tag-check { display: inline-flex; font-weight: 500; }
.tag-check input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.tag-check span { border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; cursor: pointer; }
.tag-check input:checked + span { background: var(--brand); color: var(--brand-ink); border-color: transparent; }
.tag-check input:focus-visible + span { outline: 3px solid color-mix(in srgb, var(--brand) 55%, transparent); }

.comments { list-style: none; padding: 0; margin: 16px 0 0; display: grid; gap: 14px; }
.comment { border-top: 1px solid var(--line); padding-top: 12px; }
.comment-meta { margin: 0 0 4px; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; }
.comment-meta .inline-form { margin-left: auto; }
.comment-photos { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.comment-photos img { width: 96px; height: 96px; object-fit: cover; border-radius: 8px; }

.nearby-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.nearby-group ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 4px; }
.nearby-group h3 { display: flex; align-items: center; gap: 6px; }
.nearby-group h3::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--brand); }
.nearby-toilets h3::before { background: #4a86c5; }
.nearby-water h3::before { background: #3fb0c8; }
.nearby-shelter h3::before { background: #8a6d4d; }
.nearby-shop h3::before { background: var(--accent); }
.nearby-bus h3::before, .nearby-station h3::before { background: #7b5ea7; }

.report { margin-top: 16px; }
.report summary { cursor: pointer; color: var(--muted); }
.report form { margin-top: 10px; }

.file-drop { border: 2px dashed var(--line); border-radius: 12px; padding: 16px; text-align: center; cursor: pointer; font-weight: 500; }
.file-drop input { margin-top: 8px; }
.photo-preview { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.photo-preview img { width: 80px; height: 80px; object-fit: cover; border-radius: 8px; }

.stats { display: flex; flex-wrap: wrap; gap: 8px 20px; color: var(--muted); }
.stats strong { color: var(--text); font-size: 1.2rem; }
.link-list { padding-left: 1.1em; margin: 0; display: grid; gap: 4px; }

/* Touren */
.tour-section { margin-top: 24px; }
.tour-list { list-style: none; padding: 0; margin: 0 0 16px; display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.tour-card { margin: 0; display: grid; gap: 2px; }
.tour-card p { margin: 0; }
.row-form .grow { flex: 1 1 240px; }
.row-form .segmented { margin: 0; }
.tour-stats { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.tour-stats > div { display: grid; min-width: 88px; padding: 8px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.stat-value { font-weight: 800; font-size: 1.25rem; line-height: 1.2; }
.stat-label { color: var(--muted); font-size: 0.8rem; }
.tour-grid { display: grid; gap: 16px; grid-template-columns: 1fr; margin-bottom: 16px; }
.tour-map { height: 58vh; min-height: 300px; border-radius: var(--radius); overflow: hidden; background: var(--surface-2); }
@media (min-width: 900px) {
  .tour-grid { grid-template-columns: minmax(0, 1fr) 360px; }
  .tour-map { height: 560px; }
  .tour-grid > .card { max-height: 560px; overflow-y: auto; margin: 0; }
}
.stops { list-style: none; padding: 0; margin: 0 0 8px; }
.stop .leg { display: block; padding: 0 0 0 40px; }
.stop-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
.stop-n { flex: none; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--brand); color: var(--brand-ink); font-weight: 700; font-size: 0.9rem; }
.stop-thumb { flex: none; width: 44px; height: 44px; border-radius: 8px; object-fit: cover; }
.stop-text { display: grid; flex: 1; min-width: 0; }
.stop-text a { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stop-tools { display: flex; gap: 2px; flex: none; }
.icon-btn { width: 36px; height: 36px; padding: 0; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); color: var(--text); font: inherit; cursor: pointer; }
.icon-btn:disabled { opacity: 0.35; cursor: default; }
.stop-marker { width: 30px; height: 30px; padding: 0; border-radius: 50%; border: 3px solid #fff; background: #2f5d50; color: #fff; font: 700 14px/1 system-ui, sans-serif; box-shadow: 0 1px 4px rgb(0 0 0 / 35%); cursor: pointer; }
.popup-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.offline-box { margin: -8px 0 16px; padding: 10px 14px; border-radius: 12px; background: var(--ok-bg); }
.offline-box p { margin: 0; }
.offline-box progress { width: 100%; margin-top: 8px; accent-color: var(--brand); }
.qr-box summary { cursor: pointer; font-weight: 700; }
.qr-content { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; margin-top: 12px; }
.qr-content svg { width: 160px; height: 160px; border-radius: 8px; flex: none; }
.qr-content p { flex: 1 1 240px; margin: 0; }
@media (max-width: 640px), (hover: none) and (pointer: coarse) { .qr-box { display: none; } }

/* Licht und Wetter */
.sun-times { display: flex; flex-wrap: wrap; gap: 8px 16px; margin: 0 0 12px; }
.sun-times div { display: grid; }
.sun-times dt { color: var(--muted); font-size: 0.8rem; }
.sun-times dd { margin: 0; font-weight: 700; }
.weather-days { list-style: none; padding: 0; margin: 0 0 8px; display: grid; gap: 10px; }
.weather-days > li { border-top: 1px solid var(--line); padding-top: 8px; }
.weather-head { display: flex; align-items: baseline; gap: 6px; }
.weather-icon { font-size: 1.1rem; }
.weather-hints { margin: 4px 0 0; padding-left: 1.1em; font-size: 0.9rem; }

/* Treffen */
.hangout-list { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 10px; }
.hangout-list.compact .hangout-card { box-shadow: none; padding: 10px 12px; background: var(--bg); }
.hangout-card { display: flex; align-items: center; gap: 14px; margin: 0; }
.hangout-card.is-cancelled { opacity: 0.7; }
.hangout-text { display: grid; gap: 2px; min-width: 0; }
.date-badge { flex: none; display: grid; place-items: center; width: 52px; height: 56px; border-radius: 12px; background: color-mix(in srgb, var(--accent) 18%, var(--surface)); line-height: 1.1; }
.date-badge span:first-child { font-size: 1.35rem; font-weight: 800; }
.date-badge span:last-child { font-size: 0.75rem; font-weight: 600; color: var(--muted); }
.eyebrow { margin: 0; color: var(--accent); font-weight: 700; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.06em; }
.hangout-when { font-size: 1.15rem; font-weight: 700; margin: 0 0 4px; }
.people { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.people li { background: var(--surface-2); border-radius: 999px; padding: 4px 12px; }
