:root {
    --bg: #f3f5f8;
    --surface: #ffffff;
    --text: #1d2733;
    --muted: #5b6877;
    --line: #d9dfe7;
    --accent: #3d5a80;
    --ok-bg: #dcf0e4;
    --ok-text: #1d5a3a;
    --fail-bg: #fbe0dc;
    --fail-text: #8a2a1f;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #12171d;
        --surface: #1a212a;
        --text: #e4e9ef;
        --muted: #98a4b3;
        --line: #2b3541;
        --accent: #8fb0d6;
        --ok-bg: #1f3a2b;
        --ok-text: #9fdcba;
        --fail-bg: #43231f;
        --fail-text: #f0aba2;
    }
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    color: var(--text);
    background: var(--bg);
}

.wrap {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 16px;
}

.site-header {
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}

.site-header .wrap {
    display: flex;
    align-items: center;
    min-height: 56px;
}

.brand {
    font-weight: 700;
    font-size: 1.15rem;
    color: var(--accent);
    text-decoration: none;
}

main {
    padding-top: 24px;
    padding-bottom: 40px;
}

.hero h1 {
    margin: 0 0 4px;
    font-size: 2rem;
}

.lead {
    margin: 0 0 24px;
    color: var(--muted);
    font-size: 1.1rem;
}

a {
    color: var(--accent);
}

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 16px;
    margin-bottom: 20px;
}

.card h2 {
    margin: 0 0 12px;
    font-size: 1.1rem;
}

.badge {
    margin-left: 8px;
    padding: 1px 8px;
    border-radius: 10px;
    border: 1px solid var(--line);
    color: var(--muted);
    font-size: 0.75rem;
    font-weight: 400;
}

table.status {
    width: 100%;
    border-collapse: collapse;
}

table.status td {
    padding: 6px 8px;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
}

table.status td.value {
    font-family: ui-monospace, Consolas, monospace;
    font-size: 0.85rem;
    word-break: break-word;
}

.tag {
    display: inline-block;
    min-width: 56px;
    padding: 1px 8px;
    border-radius: 10px;
    text-align: center;
    font-size: 0.75rem;
    font-weight: 600;
}

.tag.ok {
    background: var(--ok-bg);
    color: var(--ok-text);
}

.tag.fail {
    background: var(--fail-bg);
    color: var(--fail-text);
}

.site-footer {
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 0.85rem;
    padding: 16px 0;
}

/* Navigation */
.site-header .wrap {
    justify-content: space-between;
}

.main-nav {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 0.95rem;
}

.main-nav a {
    text-decoration: none;
}

.nav-user {
    color: var(--muted);
}

.inline-form {
    margin: 0;
}

.link-button {
    display: inline-flex;
    align-items: center;
    padding: 0;
    border: 0;
    background: none;
    color: var(--accent);
    font: inherit;
    cursor: pointer;
    text-decoration: underline;
}

/* Formulare */
.narrow {
    max-width: 380px;
    margin: 0 auto;
}

.form label {
    display: block;
    margin: 12px 0 4px;
    font-weight: 600;
}

.form label:first-of-type {
    margin-top: 0;
}

.form input[type="text"],
.form input[type="password"],
.form input[type="date"],
.form input[type="number"],
.form input[type="search"],
.form input[type="file"],
.form select,
.form textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--bg);
    color: var(--text);
    font: inherit;
}

.form input:focus-visible,
.form select:focus-visible,
.form textarea:focus-visible,
.button:focus-visible,
.link-button:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-top: 16px;
    text-decoration: none;
    padding: 10px 18px;
    border: 0;
    border-radius: 8px;
    background: var(--accent);
    color: var(--bg);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

.alert {
    padding: 10px 12px;
    border-radius: 8px;
    background: var(--fail-bg);
    color: var(--fail-text);
}

ul.plain {
    margin: 0;
    padding-left: 20px;
}

/* Erweiterungen für Touren */
:root {
    --danger: #b3261e;
    --notice-bg: #dcf0e4;
    --notice-text: #1d5a3a;
}

@media (prefers-color-scheme: dark) {
    :root {
        --danger: #e57368;
        --notice-bg: #1f3a2b;
        --notice-text: #9fdcba;
    }
}

.notice {
    padding: 10px 12px;
    border-radius: 8px;
    background: var(--notice-bg);
    color: var(--notice-text);
}

.wide-form {
    max-width: 640px;
}

.form textarea {
    resize: vertical;
}

.form select {
    appearance: auto;
}

.hint {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 0.875rem;
}

.form fieldset {
    margin: 20px 0 0;
    padding: 12px 14px 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.form legend {
    padding: 0 6px;
    font-weight: 600;
}

.form label.choice {
    display: flex;
    gap: 8px;
    align-items: baseline;
    margin: 12px 0 6px;
    font-weight: 400;
}

.form fieldset label.choice:first-of-type {
    margin-top: 4px;
}

.form-actions {
    display: flex;
    gap: 16px;
    align-items: center;
    margin-top: 8px;
}

.button.secondary {
    margin-top: 0;
    background: transparent;
    color: var(--accent);
    border: 1px solid var(--accent);
}

.button.danger {
    margin-top: 0;
    background: transparent;
    color: var(--danger);
    border: 1px solid var(--danger);
}

.link-button.danger-text {
    color: var(--danger);
}

.admin-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    margin: 20px 0;
}

.admin-actions .button {
    padding: 8px 14px;
}

/* Filterleiste */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
}

.filter-bar label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.875rem;
    font-weight: 600;
}

.filter-bar input,
.filter-bar select {
    min-width: 140px;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--bg);
    color: var(--text);
    font: inherit;
    font-weight: 400;
}

.filter-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}

.filter-actions .button {
    margin-top: 0;
    padding: 8px 16px;
    white-space: nowrap;
}

/* Tourenliste */
.tour-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.tour-row {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 16px;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--line);
}

.tour-row:last-child {
    border-bottom: 0;
}

.tour-main {
    flex: 1 1 200px;
    min-width: 0;
    color: inherit;
    text-decoration: none;
}

.tour-title {
    display: block;
    font-weight: 600;
    color: var(--accent);
}

.tour-main:hover .tour-title {
    text-decoration: underline;
}

.tour-meta {
    color: var(--muted);
    font-size: 0.9rem;
}

.type-badge {
    display: inline-block;
    margin: 0 4px;
    padding: 0 8px;
    border-radius: 10px;
    border: 1px solid var(--c, var(--line));
    color: var(--text);
    font-size: 0.8rem;
    font-weight: 600;
    background: color-mix(in srgb, var(--c, transparent) 16%, transparent);
}

.tour-figures {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    min-width: 96px;
    font-size: 0.9rem;
    white-space: nowrap;
}

.tour-figures span {
    color: var(--muted);
}

.tour-actions {
    display: flex;
    gap: 14px;
    align-items: center;
    font-size: 0.9rem;
}

.list-summary,
.list-footer {
    margin: 0 0 8px;
    color: var(--muted);
}

.list-footer {
    margin: 12px 0 0;
}

.day-swatch {
    display: inline-block;
    width: 12px;
    height: 12px;
    margin-right: 6px;
    border-radius: 3px;
    background: var(--c, var(--accent));
}

/* Tourdetail */
.crumbs {
    margin: 0 0 4px;
    font-size: 0.9rem;
}

.tour h1 {
    margin: 0 0 4px;
    font-size: 1.8rem;
    overflow-wrap: anywhere;
}

.tour .tour-meta {
    margin: 0 0 16px;
}

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 10px;
    margin: 0 0 20px;
}

/* Tourenansicht: die 7 Kacheln teilen sich die ganze Kartenbreite (4 + 3 auf mittleren, 2 je Zeile auf schmalen Bildschirmen) */
.stats.stats-7 {
    grid-template-columns: repeat(7, minmax(0, 1fr));
}

.stats.stats-7 dd {
    font-size: 1.05rem;
    overflow-wrap: anywhere;
}

@media (max-width: 1200px) {
    .stats.stats-7 {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .stats.stats-7 dd {
        font-size: 1.15rem;
    }
}

@media (max-width: 560px) {
    .stats.stats-7 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

.stats > div {
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
}

.stats dt {
    color: var(--muted);
    font-size: 0.8rem;
}

.stats dd {
    margin: 2px 0 0;
    font-size: 1.15rem;
    font-weight: 600;
}

.series-nav {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.series-steps {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 8px 16px;
}

.description {
    overflow-wrap: anywhere;
}

.extra-text h2 {
    margin: 0 0 6px;
    font-size: 1rem;
}

@media (max-width: 600px) {
    .site-header .wrap {
        flex-wrap: wrap;
        padding-bottom: 6px;
        padding-top: 6px;
    }

    .brand {
        white-space: nowrap;
    }

    .main-nav {
        flex-wrap: wrap;
        font-size: 0.9rem;
        gap: 2px 12px;
        justify-content: flex-end;
    }

    .nav-user {
        display: none;
    }

    .tour-figures {
        align-items: flex-start;
        flex-direction: row;
        gap: 12px;
    }
}

/* Auswahl für den Kartenvergleich */
.tour-select {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    margin: -8px 0 -8px -10px;
    cursor: pointer;
}

.tour-select input {
    width: 20px;
    height: 20px;
    accent-color: var(--accent);
    cursor: pointer;
}

.tour-row.selected {
    background: color-mix(in srgb, var(--accent) 10%, transparent);
}

.compare-bar {
    position: sticky;
    bottom: 0;
    z-index: 10;
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
    align-items: center;
    margin-top: -4px;
    padding: 10px 16px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.08);
}

.compare-bar .button {
    margin-top: 0;
    padding: 8px 14px;
}

.compare-bar .button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.compare-count {
    margin-right: auto;
}

.button.secondary[aria-pressed="true"] {
    background: var(--accent);
    color: var(--bg);
}

@media (max-width: 600px) {
    .compare-bar {
        gap: 6px 12px;
        padding: 8px 12px;
    }

    .compare-bar .button {
        flex: 1 1 140px;
        padding: 8px 10px;
        font-size: 0.9rem;
    }
}

/* Seitenkopf mit Schaltfläche (z. B. Tourenliste) */
.page-head {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.page-head h1 {
    margin: 0;
}

.page-head .button {
    margin-top: 0;
}

/* Fahrer */
.tour-riders {
    display: block;
    color: var(--text);
    font-size: 0.9rem;
}

.tour-riders::before {
    content: "Fahrer: ";
    color: var(--muted);
}

.rider-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.rider-list li {
    padding: 8px 0;
    border-bottom: 1px solid var(--line);
}

.rider-list li:last-child {
    border-bottom: 0;
}

.rider-form {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.rider-form input[type="text"] {
    flex: 1 1 180px;
    min-width: 0;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--bg);
    color: var(--text);
    font: inherit;
}

.rider-form .button {
    margin-top: 0;
    padding: 7px 12px;
}

.rider-count {
    color: var(--muted);
    font-size: 0.85rem;
    white-space: nowrap;
}

.wide-form > .hint {
    margin: 0 0 16px;
}

/* Fahrerauswahl im Tourformular: Namen nebeneinander */
.rider-fieldset {
    padding: 8px 14px 10px;
}

.rider-choices {
    display: flex;
    flex-wrap: wrap;
    gap: 2px 18px;
}

.form .rider-choices label {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0;
    padding: 4px 0;
    font-weight: 400;
}

/* Symbole in Schaltflächen: bunte Linienzeichnung auf einem runden Plättchen */
.icon-chip {
    --ic: #4a78b0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.7em;
    height: 1.7em;
    margin: -0.3em 8px -0.3em 0;
    border-radius: 50%;
    vertical-align: middle;
    color: var(--ic);
    background: color-mix(in srgb, var(--ic) 16%, var(--surface));
    text-decoration: none;
    transition: transform 0.15s;
}

/* Auf den grünen Schaltflächen bekommt das Plättchen einen hellen Grund */
.button:not(.secondary):not(.danger) .icon-chip,
.button.secondary[aria-pressed="true"] .icon-chip {
    background: #ffffff;
}

.icon {
    width: 1.05em;
    height: 1.05em;
    fill: color-mix(in srgb, var(--ic) 26%, transparent);
    stroke: currentColor;
    stroke-width: 2.2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.icon-plus { --ic: #2e9e5b; }
.icon-filter { --ic: #ec8a00; }
.icon-map { --ic: #1e88e5; }
.icon-select-all { --ic: #2e9e5b; }
.icon-select-none { --ic: #e0566b; }
.icon-download { --ic: #00897b; }
.icon-image { --ic: #e91e63; }
.icon-edit { --ic: #e59500; }

@media (hover: hover) and (prefers-reduced-motion: no-preference) {
    .button:hover .icon-chip,
    .link-button:hover .icon-chip {
        transform: rotate(-10deg) scale(1.12);
    }
}

/* display:inline-flex würde das hidden-Attribut aushebeln */
.button[hidden],
.link-button[hidden] {
    display: none;
}

.icon-pin { --ic: #ff6f59; }
.icon-search { --ic: #5c6bc0; }
.icon-x { --ic: #e0566b; }
.icon-lock { --ic: #3d5a80; }

/* Ortssuche: Karte mit Suchkreis in der Tourenliste */
.geo-panel {
    margin-top: -4px;
}

.geo-panel[hidden] {
    display: none;
}

.geo-map {
    position: relative;
    isolation: isolate; /* Kartenebenen (z-index bis 1000) bleiben unter der Auswahlleiste */
    height: 380px;
    border: 1px solid var(--line);
    border-radius: 10px;
    overflow: hidden;
}

/* Fadenkreuz in der Kartenmitte: dort sitzt der Mittelpunkt des Kreises */
.geo-map::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 14px;
    height: 14px;
    margin: -7px 0 0 -7px;
    background:
        linear-gradient(#c2185b, #c2185b) center / 2px 100% no-repeat,
        linear-gradient(#c2185b, #c2185b) center / 100% 2px no-repeat;
    pointer-events: none;
    z-index: 500;
}

/* Bei fixiertem Mittelpunkt bleibt der Kreis stehen: kein Fadenkreuz in der Kartenmitte */
.geo-map.locked::after {
    display: none;
}

.geo-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 16px;
    align-items: center;
    margin-top: 10px;
}

.geo-controls .button {
    margin-top: 0;
    padding: 8px 16px;
}

.geo-radius {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
}

.geo-radius input[type="range"] {
    width: 180px;
    accent-color: var(--accent);
}

.geo-radius output {
    min-width: 4.5ch;
    font-weight: 600;
}

.geo-count {
    margin-right: auto;
    font-weight: 600;
}

.geo-panel .hint {
    margin: 8px 0 0;
    font-size: 0.85rem;
    opacity: 0.8;
}

@media (max-width: 600px) {
    .geo-map {
        height: 320px;
    }

    .geo-radius input[type="range"] {
        width: 140px;
    }
}

/* Kompakte Tourenliste (Tourenliste und Startseite): eine Zeile je Tour
   Reihenfolge: Typ, Titel, Weite, Höhe, Datum, Fahrer */
.tour-row--list {
    display: grid;
    grid-template-columns: 6.2rem minmax(0, 1fr) 7.4rem 7.4rem 6rem minmax(8rem, 14rem);
    align-items: center;
    gap: 0 12px;
    padding: 6px 0;
}

.tour-row--list.with-select {
    grid-template-columns: 32px 6.2rem minmax(0, 1fr) 7.4rem 7.4rem 6rem minmax(8rem, 14rem);
}

.tour-row--list .tour-select {
    width: 32px;
    height: 24px;
    margin: 0 0 0 -6px;
}

.tour-row--list .tour-title {
    display: inline; /* damit die Ellipse beim Kürzen langer Titel greift */
}

.tour-row--list .type-badge {
    max-width: 100%;
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: middle;
}

.tour-row--list .cell-title {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tour-row--list .cell-series {
    margin-left: 8px;
    color: var(--muted);
    font-size: 0.8rem;
}

.tour-row--list .series-name {
    display: none; /* breit: nur "Tag n", der Name steht im Tooltip */
}

.tour-row--list .cell-info {
    display: contents; /* die vier Angaben liegen direkt in den Spalten der Zeile */
}

.tour-row--list .cell-dist,
.tour-row--list .cell-asc {
    text-align: right;
    white-space: nowrap;
    font-size: 0.9rem;
}

.tour-row--list .cell-asc {
    font-weight: 600; /* wie die Weite */
}

.tour-row--list .cell-date {
    color: var(--muted);
}

.tour-row--list .cell-date {
    white-space: nowrap;
    font-size: 0.9rem;
}

.tour-row--list .cell-riders {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.9rem;
}

@media (max-width: 760px) {
    .tour-row--list .series-name {
        display: inline;
    }

    /* Schmal: Zeile 1 = Typ und Titel, Zeile 2 = Weite, Höhe, Datum, Fahrer */
    .tour-row--list,
    .tour-row--list.with-select {
        grid-template-columns: auto minmax(0, 1fr);
        gap: 2px 10px;
        padding: 8px 0;
    }

    .tour-row--list.with-select {
        grid-template-columns: 32px auto minmax(0, 1fr);
    }

    .tour-row--list.with-select .tour-select {
        grid-row: 1 / span 2;
        height: 36px;
    }

    .tour-row--list .cell-info {
        display: flex;
        flex-wrap: wrap;
        align-items: baseline;
        gap: 0 12px;
        grid-column: -3 / -1;
    }

    .tour-row--list .cell-riders {
        flex: 1 1 100%;
    }

    .tour-row--list .cell-riders:empty {
        display: none;
    }
}

/* Sortierleiste über der Tourenliste: Spaltenköpfe in denselben Spalten wie die Zeilen */
.list-sort {
    display: grid;
    grid-template-columns: 6.2rem minmax(0, 1fr) 7.4rem 7.4rem 6rem minmax(8rem, 14rem);
    align-items: center;
    gap: 0 12px;
    padding: 6px 0;
    border-bottom: 1px solid var(--line);
    font-size: 0.8rem;
}

.list-sort.with-select {
    grid-template-columns: 32px 6.2rem minmax(0, 1fr) 7.4rem 7.4rem 6rem minmax(8rem, 14rem);
}

.list-sort-label {
    grid-column: 1 / -1;
    display: none;
    color: var(--muted);
}

.list-sort.with-select::before {
    content: "";
}

.list-sort a {
    overflow: hidden;
    color: var(--muted);
    text-overflow: ellipsis;
    text-decoration: none;
    white-space: nowrap;
}

.list-sort a:hover {
    color: var(--text);
    text-decoration: underline;
}

.list-sort a.active {
    color: var(--text);
    font-weight: 600;
}

.list-sort .cell-dist,
.list-sort .cell-asc {
    text-align: right;
}

.sort-arrow {
    margin-left: 3px;
}

@media (max-width: 760px) {
    /* Schmal: eine umbrechende Reihe aus Schaltflächen */
    .list-sort,
    .list-sort.with-select {
        display: flex;
        flex-wrap: wrap;
        gap: 4px 6px;
    }

    .list-sort.with-select::before {
        display: none;
    }

    .list-sort-label {
        display: block;
        flex: 1 1 100%;
    }

    .list-sort a {
        padding: 3px 10px;
        border: 1px solid var(--line);
        border-radius: 999px;
        text-align: left;
    }

    .list-sort a.active {
        border-color: var(--accent);
    }
}

/* Blätterleiste der Tourenliste */
.pager {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 20px;
    align-items: center;
    margin: 4px 0;
    font-size: 0.9rem;
}

.pager-range {
    color: var(--muted);
}

.pager-pages {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    align-items: center;
}

.pager-pages a,
.pager-current {
    min-width: 2rem;
    padding: 3px 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    text-align: center;
    text-decoration: none;
}

.pager-pages a:hover {
    background: color-mix(in srgb, var(--accent) 12%, transparent);
}

.pager-current {
    border-color: var(--accent);
    background: var(--accent);
    color: var(--bg);
    font-weight: 600;
}

.pager-gap {
    color: var(--muted);
}

.pager-size {
    margin: 0 0 0 auto;
}

.pager-size label {
    display: flex;
    align-items: center;
    gap: 8px;
}

.pager-size select {
    padding: 3px 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--bg);
    color: var(--text);
    font: inherit;
}

/* Schaltfläche "Routenfarbe wechseln" in allen Karten */
.leaflet-bar.route-color-control .route-color-button {
    display: flex;
    align-items: center;
    gap: 6px;
    width: auto;
    height: auto;
    padding: 6px 10px;
    font-size: 0.8rem;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
}

.route-color-swatch {
    flex: none;
    width: 14px;
    height: 14px;
    border: 1.5px solid #fff;
    border-radius: 50%;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.45);
}

@media (max-width: 600px) {
    /* Schmal: nur der Farbpunkt, die Beschriftung steht im Tooltip */
    .route-color-label {
        display: none;
    }
}

/* Schaltflächen "Karte vergrößern" und "Vollbild" (oben rechts in jeder Karte) */
.leaflet-bar.size-control .size-button {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Vergrößerte Karte: deutlich höher, die Breite bleibt wie die Seite */
.map.is-expanded {
    height: calc(100vh - 90px);
    min-height: 480px;
    scroll-margin-top: 8px;
}

/* Karte der Ortssuche: ebenfalls nur höher */
.geo-map.is-expanded {
    height: calc(100vh - 230px);
    min-height: 440px;
    scroll-margin-top: 8px;
}

/* Vollbild (echt oder als Ersatz im Fenster) */
.fbt-fs {
    margin: 0;
    border-radius: 0;
    background: var(--bg);
}

.fbt-fs.map {
    width: 100% !important;
    max-width: none !important;
    height: 100% !important;
    min-height: 0 !important;
    margin: 0 !important;
    border: 0;
}

/* !important: Leaflet setzt am Kartencontainer selbst "position: relative" (Inline-Stil) */
.fbt-fs.fbt-fs-fake {
    position: fixed !important;
    inset: 0;
    z-index: 10000;
    width: 100vw !important;
    height: 100vh !important;
    height: 100dvh !important;
}

.geo-panel.fbt-fs {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 10px;
    width: 100%;
    height: 100%;
    border: 0;
    overflow: auto;
}

.geo-panel.fbt-fs .geo-map {
    flex: 1 1 auto;
    height: auto;
    min-height: 200px;
}

.geo-panel.fbt-fs .hint {
    display: none;
}

/* Hinweis je Foto in der Foto-Verwaltung: Aufnahmeort vorhanden oder nicht */
.image-geo {
    margin: 0;
    color: var(--muted);
    font-size: 0.8rem;
}

.image-geo.has-geo {
    color: var(--accent);
    font-weight: 600;
}

/* Mehrfachauswahl in der Filterleiste (Typ, Jahr, Fahrer) */
.multi-filter {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.875rem;
}

.multi-label {
    font-weight: 600;
}

.multi > summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-width: 140px;
    max-width: 220px;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--bg);
    color: var(--text);
    font-weight: 400;
    white-space: nowrap;
    cursor: pointer;
    list-style: none;
    user-select: none;
}

.multi > summary::-webkit-details-marker {
    display: none;
}

.multi > summary::after {
    content: "";
    flex: none;
    width: 7px;
    height: 7px;
    margin-top: -3px;
    border-right: 2px solid var(--muted);
    border-bottom: 2px solid var(--muted);
    transform: rotate(45deg);
}

.multi[open] > summary {
    border-color: var(--accent);
}

.multi > summary:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.multi.has-value > summary {
    border-color: var(--accent);
    font-weight: 600;
}

.multi-panel {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 100%;
    max-height: 300px;
    padding: 6px;
    overflow-y: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
}

.filter-bar .multi-option {
    flex-direction: row;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 6px;
    font-weight: 400;
    white-space: nowrap;
    cursor: pointer;
}

.filter-bar .multi-option:hover {
    background: var(--bg);
}

.filter-bar .multi-option input {
    flex: none;
    width: 18px;
    min-width: 0;
    height: 18px;
    padding: 0;
    accent-color: var(--accent);
}

.multi-clear {
    align-self: flex-start;
    white-space: nowrap;
    margin-top: 4px;
    padding: 6px 8px;
    font-size: 0.8125rem;
}

/* Summen aller Treffer direkt über den Spalten Weite und Höhe (gleiches Raster wie Sortierleiste und Zeilen).
   Dezent: gleiche Schriftgröße wie die Werte in den Zeilen, ohne Hintergrund. */
.list-totals {
    display: grid;
    grid-template-columns: 6.2rem minmax(0, 1fr) 7.4rem 7.4rem 6rem minmax(8rem, 14rem);
    align-items: baseline;
    gap: 0 12px;
    margin: 6px 0 0;
    padding: 6px 0 0;
}

.list-totals.with-select {
    grid-template-columns: 32px 6.2rem minmax(0, 1fr) 7.4rem 7.4rem 6rem minmax(8rem, 14rem);
}

.list-totals .totals-count {
    grid-column: 1 / 3;
    overflow: hidden;
    color: var(--muted);
    font-size: 0.8rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.list-totals.with-select .totals-count {
    grid-column: 1 / 4;
}

.list-totals .totals-count strong {
    color: var(--text);
    font-size: 0.8rem;
}

.list-totals .totals-dist,
.list-totals .totals-asc {
    color: var(--text);
    font-size: 0.9rem;
    font-variant-numeric: tabular-nums;
    text-align: right;
    white-space: nowrap;
}

@media (max-width: 760px) {
    /* Schmal: eine Zeile mit Anzahl und beiden Summen */
    .list-totals,
    .list-totals.with-select {
        display: flex;
        flex-wrap: wrap;
        gap: 2px 14px;
        align-items: baseline;
    }

    .list-totals .totals-count,
    .list-totals.with-select .totals-count {
        flex: 1 1 100%;
        white-space: normal;
    }

    .list-totals .totals-sum-label {
        display: none;
    }
}

/* Benutzerverwaltung (nur Administrator) */
.user-list { margin: 0; padding: 0; list-style: none; }
.user-list li { padding: 12px 0; border-top: 1px solid var(--line); }
.user-list li:first-child { border-top: 0; }
.user-form { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 8px 12px; align-items: center; }
.user-name { min-width: 0; overflow-wrap: anywhere; }
.user-name .hint { margin-left: 4px; }
.user-login { color: var(--muted); font-size: 0.9rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.user-form input[type="text"] { grid-column: 1 / 3; width: 100%; min-width: 0; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--text); font: inherit; }
.user-form .button { white-space: nowrap; }
.user-form .badge { margin-left: 0; white-space: nowrap; }
.user-form .badge-admin { border-color: var(--accent); color: var(--accent); font-weight: 600; }
@media (max-width: 600px) {
    .user-form { grid-template-columns: minmax(0, 1fr) auto; }
    .user-login { grid-column: 1 / -1; }
    .user-form input[type="text"] { grid-column: 1 / -1; }
    .user-form .button { grid-column: 1 / -1; }
}

/* Papierkorb (nur Administrator) */
.trash-list { margin: 0; padding: 0; list-style: none; }
.trash-item { padding: 14px 0; border-top: 1px solid var(--line); }
.trash-item:first-child { border-top: 0; }
.trash-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; }
.trash-head .badge { margin-left: 0; }
.trash-meta { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 12px; margin: 10px 0; font-size: 0.95rem; }
.trash-meta dt { color: var(--muted); }
.trash-meta dd { margin: 0; overflow-wrap: anywhere; }
.trash-reason { white-space: pre-line; }
.trash-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.trash-actions .button { margin-top: 0; }
.trash-map.map { height: 200px; margin: 10px 0; }
.trash-map.map.is-expanded { height: clamp(420px, 70vh, 800px); }
.trash-gallery { margin: 10px 0; }
.trash-gallery .gallery-grid { grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 6px; max-width: 520px; }
.trash-gallery .gallery-private { font-size: 0.65rem; padding: 0 4px; }

/* Dezente Hintergrundmotive: Höhenlinien (Inhaltsbereich, scrollen mit) und Bergkette (über dem Footer).
   Die Motive sind Masken in der Text- bzw. Akzentfarbe und passen sich so Hell/Dunkel an.
   Dateien: public/img/hoehenlinien.svg, public/img/berge.svg */
/* Footer klebt am unteren Fensterrand: ist der Inhalt kurz, entsteht die Leerfläche
   oberhalb (zwischen Inhalt und Bergkette), der Footer selbst bleibt immer gleich hoch. */
body {
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
}

body > main {
    flex: 1 0 auto;
    width: 100%;
}

body::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background: var(--text);
    opacity: 0.1;
    -webkit-mask: url("../img/hoehenlinien.svg") 0 0 / 640px auto repeat;
            mask: url("../img/hoehenlinien.svg") 0 0 / 640px auto repeat;
}

/* Footer einfarbig: deckt die Höhenlinien ab, sie enden an seiner Oberkante (wie die Bergkette) */
.site-footer {
    position: relative;
    margin-top: clamp(40px, 6vw, 80px);
    background: var(--bg);
}

.site-footer::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 100%;
    z-index: -1; /* hinter dem Inhalt: Karten und Schaltflächen überlappen die Bergspitzen */
    height: clamp(70px, 10vw, 140px);
    pointer-events: none;
    background: var(--accent);
    opacity: 0.3;
    -webkit-mask: url("../img/berge.svg") center bottom / 100% 100% no-repeat;
            mask: url("../img/berge.svg") center bottom / 100% 100% no-repeat;
}

@media (prefers-color-scheme: dark) {
    body::before { opacity: 0.15; }
}

@media (max-width: 600px) {
    body::before {
        -webkit-mask-size: 420px auto;
                mask-size: 420px auto;
    }
}

@media print {
    body::before,
    .site-footer::before { display: none; }
}
