:root {
  --bg: #f6f4ef;
  --surface: #ffffff;
  --surface-2: #efece4;
  --text: #22201c;
  --muted: #6d675c;
  --border: #ddd7ca;
  --accent: #2f6b4f;
  --accent-soft: #dcebe2;
  --warn: #a8641a;
  --warn-soft: #f5e6d2;
  --bad: #a23b32;
  --bad-soft: #f4dcd9;
  --heart: #c2335b;
  --bar: #2f6b4f;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .06), 0 2px 8px rgba(0, 0, 0, .04);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #171614; --surface: #211f1c; --surface-2: #2b2925; --text: #ece8df; --muted: #a39d90;
    --border: #3a3732; --accent: #6fbf95; --accent-soft: #23382d; --warn: #e0a35a; --warn-soft: #3b2e1d;
    --bad: #e3786e; --bad-soft: #3d2422; --heart: #ee6d92; --bar: #6fbf95; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #171614; --surface: #211f1c; --surface-2: #2b2925; --text: #ece8df; --muted: #a39d90;
  --border: #3a3732; --accent: #6fbf95; --accent-soft: #23382d; --warn: #e0a35a; --warn-soft: #3b2e1d;
  --bad: #e3786e; --bad-soft: #3d2422; --heart: #ee6d92; --bar: #6fbf95; color-scheme: dark;
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0 0 .5rem; }
h2 { font-size: 1.1rem; margin: 1.5rem 0 .6rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

header.top {
  position: sticky; top: 0; z-index: 10; background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; gap: 1.25rem; align-items: center; padding: .6rem 16px; flex-wrap: wrap;
}
header.top .brand { font-weight: 700; color: var(--text); }
header.top nav { display: flex; gap: 1rem; flex-wrap: wrap; }
main { max-width: 1280px; margin: 0 auto; padding: 1rem 16px 4rem; }

form.filters {
  display: grid; gap: .6rem; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .8rem;
  box-shadow: var(--shadow); margin-bottom: 1rem;
}
form.filters label { display: flex; flex-direction: column; font-size: .8rem; color: var(--muted); gap: .2rem; }
form.filters .check { flex-direction: row; align-items: center; gap: .4rem; color: var(--text); font-size: .9rem; }
input, select, button {
  font: inherit; color: var(--text); background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 7px; padding: .35rem .5rem;
}
button { cursor: pointer; }
button.primary { background: var(--accent); color: var(--surface); border-color: var(--accent); }

.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden; display: flex; flex-direction: column;
}
.card.hl { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.card .img { aspect-ratio: 16 / 9; background: var(--surface-2) center / cover no-repeat; position: relative; display: block; }
.card .body { padding: .7rem .8rem .8rem; display: flex; flex-direction: column; gap: .35rem; flex: 1; }
.card .title { font-weight: 600; line-height: 1.3; }
.card .facts { display: flex; flex-wrap: wrap; gap: .3rem .8rem; font-size: .85rem; color: var(--muted); }
.card .actions { display: flex; gap: .4rem; align-items: center; margin-top: auto; padding-top: .4rem; }
.score {
  position: absolute; top: .5rem; left: .5rem; background: var(--surface); color: var(--text);
  border-radius: 999px; padding: .1rem .55rem; font-weight: 700; font-size: .9rem; box-shadow: var(--shadow);
}
.badge {
  display: inline-block; font-size: .75rem; padding: .05rem .45rem; border-radius: 999px;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--border);
}
.badge.passend { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.badge.grenzfall { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.abgelehnt { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.badge.herz { color: var(--heart); }
.badges { display: flex; flex-wrap: wrap; gap: .3rem; }

.iconbtn { padding: .15rem .45rem; font-size: 1rem; line-height: 1.2; }
.iconbtn.on { background: var(--accent-soft); border-color: var(--accent); }
form.inline { display: inline; margin: 0; }

.detail { display: grid; gap: 1.25rem; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }
@media (max-width: 860px) { .detail { grid-template-columns: 1fr; } }
.panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: .9rem 1rem; box-shadow: var(--shadow);
}
.gallery { display: grid; gap: .4rem; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.gallery img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 6px; }
.description { white-space: pre-wrap; max-height: 28rem; overflow: auto; }
table.kv { width: 100%; border-collapse: collapse; }
table.kv td { padding: .25rem 0; border-bottom: 1px solid var(--border); vertical-align: top; }
table.kv td:first-child { color: var(--muted); width: 45%; padding-right: .6rem; }
.bar { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--bar); }
.sub { display: grid; grid-template-columns: 9rem 1fr 3rem; gap: .5rem; align-items: center; font-size: .9rem; margin: .3rem 0; }
.sub .info { grid-column: 2 / 4; color: var(--muted); font-size: .8rem; margin-top: -.3rem; }

.table-wrap { overflow-x: auto; }
table.compare { border-collapse: collapse; min-width: 100%; background: var(--surface); }
table.compare th, table.compare td { border: 1px solid var(--border); padding: .4rem .6rem; text-align: left; vertical-align: top; }
table.compare th { background: var(--surface-2); font-weight: 600; }
table.compare td.best { background: var(--accent-soft); }
table.data { border-collapse: collapse; width: 100%; }
table.data th, table.data td { border-bottom: 1px solid var(--border); padding: .3rem .5rem; text-align: left; }

#map { height: calc(100vh - 140px); min-height: 420px; border-radius: var(--radius); border: 1px solid var(--border); }
.comparebar {
  position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%); background: var(--surface);
  border: 1px solid var(--border); border-radius: 999px; padding: .4rem .6rem .4rem 1rem; box-shadow: var(--shadow);
  display: none; gap: .6rem; align-items: center; z-index: 20; max-width: calc(100vw - 32px);
}
.comparebar.show { display: flex; }
.cols { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }

/* ---------- v2: Konten, Gruppe, Kommentare ---------- */
header.top .who { margin-left: auto; display: flex; gap: .9rem; align-items: center; flex-wrap: wrap; }
.linkbtn { background: none; border: none; padding: 0; color: var(--accent); cursor: pointer; font: inherit; }
.linkbtn:hover { text-decoration: underline; }
.flash { border-radius: var(--radius); padding: .55rem .8rem; margin-bottom: .8rem; background: var(--accent-soft); color: var(--accent); }
.flash.error { background: var(--bad-soft); color: var(--bad); }
.narrow { max-width: 420px; margin: 2rem auto; }
.stack { display: flex; flex-direction: column; gap: .7rem; }
.stack label { display: flex; flex-direction: column; gap: .25rem; font-size: .9rem; color: var(--muted); }
.stack label.check { flex-direction: row; align-items: center; color: var(--text); }
.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
textarea { font: inherit; color: var(--text); background: var(--surface-2); border: 1px solid var(--border); border-radius: 7px; padding: .45rem .55rem; width: 100%; resize: vertical; }
.badge.group { background: var(--surface-2); color: var(--text); font-weight: 600; }
.badge.group.pos { background: var(--accent-soft); color: var(--accent); }
.badge.group.neg { background: var(--bad-soft); color: var(--bad); }
.voters { display: flex; flex-wrap: wrap; gap: .25rem; }
.chip { font-size: .75rem; padding: .05rem .45rem; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); }
.chip.heart { border-color: var(--heart); }
.chip.down { opacity: .75; }
.ccount { position: absolute; top: .5rem; right: .5rem; background: var(--surface); border-radius: 999px; padding: .1rem .5rem; font-size: .8rem; box-shadow: var(--shadow); }
.vote-row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; margin: .6rem 0; }
.comments { margin-top: 2rem; max-width: 860px; }
.comment { border-left: 3px solid var(--border); padding: .4rem 0 .2rem .8rem; margin: .6rem 0 .6rem calc(var(--depth, 0) * 0px); }
.comment .comment { margin-left: .4rem; }
.comment:target { border-left-color: var(--accent); background: var(--accent-soft); }
.comment header { display: flex; gap: .6rem; align-items: baseline; }
.comment-body p { margin: .3rem 0; }
.comment-actions { display: flex; gap: .9rem; align-items: flex-start; flex-wrap: wrap; color: var(--muted); }
.comment-actions details[open] { flex-basis: 100%; }
.comment-actions summary { cursor: pointer; color: var(--accent); }
.comment-actions form { display: flex; flex-direction: column; gap: .4rem; margin-top: .4rem; }
.weights { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem 1.4rem; }
.weight { border: 1px solid var(--border); border-radius: var(--radius); padding: .6rem .7rem; }
.weight p { margin: .2rem 0 .4rem; }
.weight-head { display: flex; justify-content: space-between; align-items: baseline; }
.weight-head .share { font-weight: 700; color: var(--accent); }
.weight-input { display: flex; gap: .5rem; align-items: center; }
.weight-input input[type=range] { flex: 1; }
.weight-input output { min-width: 1.6rem; text-align: right; font-variant-numeric: tabular-nums; }
.weights .row { grid-column: 1 / -1; }
.checkgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .2rem .8rem; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: .6rem .8rem; }
legend { color: var(--muted); font-size: .9rem; padding: 0 .3rem; }
.bigbtn { display: inline-block; background: var(--accent); color: var(--surface); padding: .6rem 1rem; border-radius: 999px; font-weight: 600; }
.panel.highlight { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); margin-bottom: 1rem; }
section.panel { margin-bottom: 1rem; }
.table-wrap { overflow-x: auto; }
tr.muted td { color: var(--muted); }

/* ---------- Bahnhof-Icons auf Karten ---------- */
:root { --rail-window: #ffffff; --rail: #2e5b9a; --rail-ice: #b0302b; }
.rail-icon { display: flex; align-items: center; justify-content: center; border-radius: 50%;
  background: #ffffff; border: 2.5px solid var(--rail); color: var(--rail); box-shadow: 0 1px 5px rgba(0,0,0,.45); }
.rail-icon svg { width: 72%; height: 72%; }
.rail-icon.ice { border-color: var(--rail-ice); color: var(--rail-ice); }
.legend { display: flex; gap: 1rem; flex-wrap: wrap; align-items: center; font-size: .85rem; color: var(--muted); margin: .4rem 0; }
.rail-marker { background: none; border: none; }
.legend-slot { display: inline-flex; vertical-align: middle; margin-right: .3rem; }
.legend-slot .rail-icon { width: 22px !important; height: 22px !important; }

/* ---------- Bilder-Karussell ---------- */
.gallery a, .card a.img[data-images] { cursor: zoom-in; }
body.noscroll { overflow: hidden; }
.lightbox { position: fixed; inset: 0; z-index: 1000; background: rgba(10, 10, 10, .94);
  display: grid; grid-template-rows: 1fr auto; color: #eee; }
.lightbox[hidden] { display: none; }
.lb-stage { position: relative; display: flex; align-items: center; justify-content: center; min-height: 0; }
.lb-img { max-width: calc(100vw - 130px); max-height: calc(100vh - 110px); object-fit: contain; border-radius: 6px; }
.lightbox .nav, .lightbox .close { position: absolute; background: rgba(255,255,255,.12); color: #fff; border: none;
  border-radius: 999px; width: 48px; height: 48px; display: flex; align-items: center; justify-content: center; cursor: pointer; padding: 0; }
.lightbox .nav:hover, .lightbox .close:hover, .lightbox .nav:focus-visible, .lightbox .close:focus-visible { background: rgba(255,255,255,.26); outline: none; }
.lightbox svg { width: 24px; height: 24px; }
.lightbox .prev { left: 14px; top: 50%; transform: translateY(-50%); }
.lightbox .next { right: 14px; top: 50%; transform: translateY(-50%); }
.lightbox.single .nav { display: none; }
.lightbox .close { right: 14px; top: 14px; z-index: 2; }
.lb-bar { display: flex; gap: 1rem; align-items: center; justify-content: center; flex-wrap: wrap; padding: .6rem 16px .9rem; }
.lb-bar .counter { color: #aaa; font-size: .9rem; min-width: 3.5rem; }
.lb-title { color: #fff; font-weight: 600; max-width: 52ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-vote { display: flex; gap: .4rem; }
.lb-vote .iconbtn { background: rgba(255,255,255,.1); border-color: rgba(255,255,255,.2); color: #fff; font-size: 1.15rem; padding: .3rem .7rem; }
.lb-vote .iconbtn.on { background: rgba(255,255,255,.32); border-color: #fff; }
@media (max-width: 600px) {
  .lb-img { max-width: 100vw; max-height: calc(100vh - 150px); border-radius: 0; }
  .lightbox .prev, .lightbox .next { top: auto; bottom: 8px; transform: none; }
  .lb-title { max-width: 90vw; }
}

.lb-vote[hidden] { display: none; }
.imgcount { position: absolute; bottom: .5rem; right: .5rem; background: rgba(0,0,0,.6); color: #fff; border-radius: 999px;
  padding: .05rem .5rem; font-size: .75rem; }

/* ---------- Kartenrand nach Gruppenwert: rot (negativ) → gelb (neutral) → grün (positiv) ---------- */
.card[data-voted] { border-width: 3px; border-color: hsl(var(--group-hue) 68% 46%); }
.card.hl { border-color: var(--accent); }
.card.hl[data-voted] { border-color: hsl(var(--group-hue) 68% 46%); box-shadow: 0 0 0 3px var(--accent-soft); }

/* ---------- Kennzahlen korrigieren ---------- */
.badge.manual { background: var(--warn-soft); color: var(--warn); border-color: transparent; margin-left: .3rem; }
.edit-fields { margin-top: .8rem; }
.edit-fields summary { cursor: pointer; color: var(--accent); font-weight: 600; }
.fieldgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: .6rem .9rem; margin-top: .6rem; }
.fieldgrid label { display: flex; flex-direction: column; gap: .2rem; font-size: .82rem; color: var(--muted); }
.fieldgrid input::placeholder { color: var(--muted); opacity: .7; }
.fieldgrid .row { grid-column: 1 / -1; }

.rail-icon { transition: transform .15s; }
.zoomed-out .rail-icon { transform: scale(.62); }
.zoomed-out .rail-icon.ice { transform: scale(.75); }
