
:root {
    --page: #f3f6f4;
    --surface: #ffffff;
    --ink: #18231e;
    --muted: #68756e;
    --line: #e2e9e4;
    --brand: #176b45;

    --free: #16834d;
    --free-bg: #e7f5ec;
    --occupied: #a66a13;
    --occupied-bg: #fff4df;
    --unknown: #64716a;
    --unknown-bg: #edf1ee;
    --danger: #b23a32;
    --danger-bg: #fbecea;

    --radius: 17px;
    --shadow: 0 3px 14px rgba(20,42,29,.055);

    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI",
        Roboto, Arial, sans-serif;

    scroll-behavior: smooth;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--page);
    color: var(--ink);
}

button, select {
    font: inherit;
}

button {
    cursor: pointer;
}

.app-shell {
    width: min(100%, 760px);
    margin: 0 auto;
    padding: max(14px, env(safe-area-inset-top)) 15px
        calc(24px + env(safe-area-inset-bottom));
}

.topbar,
.header-actions,
.search-line,
.location-state,
.filters,
.summary-row,
.content-heading,
.station-title-row,
.station-facts,
.station-price-row,
.station-actions,
.app-footer,
.settings-header {
    display: flex;
    align-items: center;
}

.topbar,
.content-heading,
.station-title-row,
.station-price-row,
.settings-header {
    justify-content: space-between;
}

.topbar {
    padding: 10px 2px 18px;
}

.header-title {
    min-width: 0;
}

.header-update {
    display: block;
    margin-top: 5px;
    color: var(--muted);
    font-size: 10px;
    text-align: left;
}

.header-actions {
    gap: 8px;
}

.eyebrow {
    margin: 0 0 4px;
    color: var(--brand);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .16em;
}

h1 {
    margin: 0;
    font-size: 21px;
    letter-spacing: -.035em;
}

.icon-button {
    width: 43px;
    height: 43px;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: var(--surface);
    color: var(--brand);
    font-size: 23px;
}

.search-panel,
.station-card,
.message-panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.search-panel {
    padding: 15px;
}

.location-state {
    gap: 10px;
    min-width: 0;
}

.location-state strong {
    display: block;
    font-size: 13px;
}

.location-state small {
    display: block;
    margin-top: 3px;
    color: var(--muted);
    font-size: 11px;
}

.status-dot {
    width: 9px;
    height: 9px;
    flex: 0 0 auto;
    border-radius: 50%;
    background: #c58a25;
    box-shadow: 0 0 0 4px #fff4df;
}

.status-dot.active {
    background: var(--free);
    box-shadow: 0 0 0 4px var(--free-bg);
}

.status-dot.error {
    background: var(--danger);
    box-shadow: 0 0 0 4px var(--danger-bg);
}

.text-button {
    padding: 9px 2px 9px 10px;
    border: 0;
    background: transparent;
    color: var(--brand);
    font-size: 12px;
    font-weight: 750;
}

.filters {
    gap: 10px;
    margin-top: 15px;
}

.filter-control,
.settings-control {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 9px 11px;
    background: var(--control);
    border: 1px solid var(--line);
    border-radius: 10px;
}

.radius-control {
    width: 100%;
}

.filter-control span,
.settings-control span {
    color: var(--muted);
    font-size: 12px;
}

.filter-control select,
.settings-control select {
    max-width: 170px;
    border: 0;
    outline: 0;
    color: var(--ink);
    background: transparent;
    font-size: 12px;
    font-weight: 700;
}

.summary-row {
    gap: 4px;
    flex-wrap: wrap;
    margin-top: 13px;
}

.summary-chip {
    padding: 6px 7px;
    white-space: nowrap;
    border: 0;
    border-radius: 20px;
    font-size: 11px;
    transition: transform .15s ease, filter .15s ease;
}

.summary-chip b {
    margin-right: 0;
}

.summary-chip.free {
    color: var(--free);
    background: var(--free-bg);
}

.summary-chip.occupied {
    color: var(--occupied);
    background: var(--occupied-bg);
}

.summary-chip.unknown {
    color: var(--unknown);
    background: var(--unknown-bg);
}

.summary-chip:hover {
    filter: brightness(.95);
    transform: translateY(-1px);
}

.summary-chip:active {
    transform: scale(.97);
}

.summary-chip:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 3px;
}

.content-heading {
    margin: 22px 2px 11px;
}

.content-heading h2 {
    margin: 0;
    font-size: 17px;
}

.content-heading p {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 11px;
}

.map-toggle {
    min-height: 42px;
    padding: 10px 16px;
    border: 1px solid var(--line);
    border-radius: 10px;
    color: var(--brand);
    background: var(--control);
    font-size: 12px;
    font-weight: 800;
    box-shadow: var(--shadow);
}

.map-toggle:active {
    transform: scale(.99);
}

.map-section {
    overflow: hidden;
    margin-bottom: 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

#stationMap {
    width: 100%;
    height: 300px;
    background: var(--map-bg);
}

.message-panel {
    margin: 12px 0;
    padding: 22px 17px;
    text-align: center;
}

.message-panel strong {
    display: block;
    font-size: 14px;
}

.message-panel p {
    margin: 7px 0 15px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.5;
}

.primary-button {
    padding: 12px 16px;
    border: 0;
    border-radius: 10px;
    color: var(--button-ink);
    background: var(--brand);
    font-size: 12px;
    font-weight: 750;
}

.loader {
    width: 22px;
    height: 22px;
    margin: 0 auto 12px;
    border: 3px solid var(--line);
    border-top-color: var(--brand);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.station-list {
    display: grid;
    gap: 13px;
}

.station-card {
    overflow: hidden;
    scroll-margin-top: 15px;
}

.station-main {
    padding: 17px;
}

.station-title-row {
    gap: 8px;
}

.station-name {
    margin: 0;
    font-size: 15px;
    line-height: 1.35;
}

.station-status {
    flex: 0 0 auto;
    padding: 5px 8px;
    border-radius: 20px;
    font-size: 10px;
    font-weight: 800;
}

.station-status.free {
    color: var(--free);
    background: var(--free-bg);
}

.station-status.occupied {
    color: var(--occupied);
    background: var(--occupied-bg);
}

.station-status.outoforder {
    color: var(--danger);
    background: var(--danger-bg);
}

.station-status.unknown {
    color: var(--unknown);
    background: var(--unknown-bg);
}

.station-address {
    margin: 6px 0 11px;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.45;
}

.station-facts {
    gap: 8px 12px;
    flex-wrap: wrap;
    color: var(--facts);
    font-size: 11px;
}

.station-facts span + span::before {
    content: "·";
    margin-right: 8px;
    color: #a3ada6;
}

.station-price-row {
    gap: 8px;
    margin-top: 12px;
}

.station-price {
    color: var(--ink);
    font: inherit;
}

.station-distance {
    color: var(--ink);
    font-size: 14px;
    font-weight: 800;
}

.station-free-count {
    color: var(--free);
    font-size: 11px;
    font-weight: 750;
}

.station-actions {
    gap: 9px;
    margin-top: 15px;
}

.details-toggle {
    flex: 1;
    min-height: 42px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--control);
    color: var(--brand);
    font-size: 11px;
    font-weight: 750;
}

.navigate-button {
    display: flex;
    justify-content: center;
    align-items: center;
    flex: 1.25;
    min-height: 42px;
    padding: 10px;
    border-radius: 10px;
    background: var(--brand);
    color: var(--button-ink);
    text-decoration: none;
    text-align: center;
    font-size: 11px;
    font-weight: 800;
}

.navigate-button:active {
    transform: scale(.99);
}

.station-details {
    padding: 0 17px 15px;
    border-top: 1px solid var(--line);
}

.details-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 13px;
    padding-top: 14px;
}

.details-grid small {
    display: block;
    margin-bottom: 4px;
    color: var(--muted);
    font-size: 10px;
}

.details-grid strong {
    display: block;
    font-size: 12px;
    line-height: 1.4;
}

.app-footer {
    justify-content: space-between;
    gap: 10px;
    margin: 17px 3px 0;
    color: var(--muted);
    font-size: 9px;
}

.leaflet-popup-content {
    font-family: inherit;
    font-size: 12px;
}

.leaflet-popup-content a {
    color: var(--brand);
    font-weight: 700;
}

/* Einstellungsmenü */

.settings-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(12, 25, 18, .42);
}

.settings-panel {
    position: fixed;
    z-index: 1001;
    top: 0;
    right: 0;
    width: min(88vw, 390px);
    height: 100%;
    overflow-y: auto;
    padding: max(20px, env(safe-area-inset-top)) 20px
        calc(22px + env(safe-area-inset-bottom));
    background: var(--surface);
    box-shadow: -8px 0 30px rgba(0,0,0,.12);
    transform: translateX(105%);
    transition: transform .22s ease;
}

.settings-panel.open {
    transform: translateX(0);
}

.settings-header {
    margin-bottom: 25px;
}

.settings-header h2 {
    margin: 0;
    font-size: 22px;
}

.settings-control {
    display: grid;
    grid-template-columns: 85px minmax(0, 1fr);
    align-items: center;
    justify-content: initial;
    gap: 4px;
    min-height: 48px;
    margin: 0 0 16px;
    padding: 9px 10px;
}

.settings-control span {
    text-align: left;
    white-space: nowrap;
}

.settings-control select {
    width: 100%;
    max-width: none;
    min-width: 0;
    margin: 0;
    padding: 8px 2px;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--ink);
    font-size: 12px;
    font-weight: 700;
    text-align: left;
    text-align-last: left;
}

/* Längeres Label erhält Platz; die Auswahl wird rechtsbündig dargestellt. */
.settings-control.refresh-control {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 4px;
}

.settings-control.refresh-control span {
    font-size: 11px;
    white-space: nowrap;
}

.settings-control.refresh-control select {
    width: auto;
    min-width: 112px;
    max-width: 125px;
    text-align: right;
    text-align-last: right;
}

.settings-checkbox {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin: 18px 0;
    font-size: 12px;
    line-height: 1.45;
}

.settings-checkbox input {
    width: 18px;
    height: 18px;
    flex: 0 0 auto;
    accent-color: var(--brand);
}

.wake-lock-status {
    margin: -10px 0 18px 28px;
    color: var(--muted);
    font-size: 11px;
    line-height: 1.45;
}

.settings-note {
    margin: 22px 0;
    color: var(--muted);
    font-size: 11px;
    line-height: 1.5;
}

.save-settings {
    width: 100%;
}

[hidden] {
    display: none !important;
}

@media (min-width: 600px) {
    .app-shell {
        padding-top: 24px;
    }

    .station-list {
        grid-template-columns: 1fr 1fr;
        align-items: start;
    }
}

@media (max-width: 380px) {
    h1 {
        font-size: 19px;
    }

    .header-actions {
        gap: 5px;
    }

    .icon-button {
        width: 39px;
        height: 39px;
    }
}

@media (prefers-reduced-motion: reduce) {
    :root {
        scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: .01ms !important;
        animation-duration: .01ms !important;
    }
}


/* Floating-Button zum Seitenanfang */
.scroll-top-button {
    position: fixed;
    right: max(16px, env(safe-area-inset-right));
    bottom: calc(18px + env(safe-area-inset-bottom));
    z-index: 999;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 50px;
    height: 50px;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 50%;
    background: rgba(21, 37, 31, 0.78);
    color: #fff;
    font-size: 27px;
    line-height: 1;
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.22);
    -webkit-backdrop-filter: blur(5px);
    backdrop-filter: blur(5px);
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(8px);
    transition: opacity .2s ease, visibility .2s ease, transform .2s ease;
}

.scroll-top-button.visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0);
}

.scroll-top-button:hover {
    background: rgba(21, 37, 31, 0.94);
}

.scroll-top-button:focus-visible {
    outline: 3px solid var(--brand);
    outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
    .scroll-top-button {
        transition: none;
    }
}


/* Standort-Button rechtsbündig */
.search-line {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

#locateButton {
    margin-left: auto;
    flex-shrink: 0;
}

/* Erweiterte Ladepunktinformationen */
.extra-detail {
    grid-column: 1 / -1;
    min-width: 0;
}

.extra-detail strong {
    overflow-wrap: anywhere;
    white-space: pre-line;
}

/* Stationsanzahl und Ladepunkt-Zusammenfassung */
.station-count {
    color: var(--accent);
    font-variant-numeric: tabular-nums;
}

.summary-label {
    color: var(--muted);
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}

/* Gemeinsame Ausblendliste */
.hidden-station-count { font-size: 12px; color: var(--muted); margin: -8px 0 16px; }
.hidden-station-label { font-size: 12px; color: var(--muted); font-weight: 600; margin: 4px 0; }
.hidden-station-toggle { display: block; width: 100%; margin-top: 14px; padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--muted); font: inherit; font-size: 13px; cursor: pointer; }
.hidden-station-toggle:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* Revision 8.0 – Erscheinungsbild */
:root {
    color-scheme: light;
    --control: #f6f8f6;
    --facts: #45534b;
    --map-bg: #e9efeb;
    --accent: #e87500;
    --detail-accent: #d08732;
    --detail-bg: #faf7f2;
    --hidden-bg: #e3e6e9;
    --button-ink: #fff;
}
:root[data-appearance="dark"] {
    color-scheme: dark;
    --page: #14171c;
    --surface: #242930;
    --ink: #edf0f2;
    --muted: #b5bec6;
    --line: #414951;
    --brand: #83d3a7;
    --free: #83d3a7;
    --free-bg: #203e30;
    --occupied: #f1c078;
    --occupied-bg: #48371f;
    --unknown: #c1c9ce;
    --unknown-bg: #343e44;
    --danger: #ffaaa2;
    --danger-bg: #4b2929;
    --control: #30363e;
    --facts: #c2cbd0;
    --map-bg: #30363e;
    --accent: #e5a45e;
    --detail-accent: #e5a45e;
    --detail-bg: #303039;
    --hidden-bg: #454a52;
    --button-ink: #14251b;
    --shadow: 0 3px 14px rgba(0,0,0,.18);
}
@media (prefers-color-scheme: dark) {
:root:not([data-appearance="light"]) {
    color-scheme: dark;
    --page: #14171c;
    --surface: #242930;
    --ink: #edf0f2;
    --muted: #b5bec6;
    --line: #414951;
    --brand: #83d3a7;
    --free: #83d3a7;
    --free-bg: #203e30;
    --occupied: #f1c078;
    --occupied-bg: #48371f;
    --unknown: #c1c9ce;
    --unknown-bg: #343e44;
    --danger: #ffaaa2;
    --danger-bg: #4b2929;
    --control: #30363e;
    --facts: #c2cbd0;
    --map-bg: #30363e;
    --accent: #e5a45e;
    --detail-accent: #e5a45e;
    --detail-bg: #303039;
    --hidden-bg: #454a52;
    --button-ink: #14251b;
    --shadow: 0 3px 14px rgba(0,0,0,.18);
}
}

.station-details {
    margin: 0 12px 12px;
    padding: 0 12px 12px;
    border: 0;
    border-left: 3px solid var(--detail-accent);
    border-radius: 8px;
    background: var(--detail-bg);
}
.station-card.is-hidden-station { background: var(--hidden-bg); }
.hidden-station-label { display: flex; align-items: center; gap: 6px; margin: 4px 0 10px; }
.details-toggle[aria-expanded="true"] { border-color: var(--detail-accent); }
.appearance-control { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.appearance-control span { white-space: normal; }
.appearance-control select { text-align: right; text-align-last: right; }
select option { background: var(--surface); color: var(--ink); }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--surface); color: var(--ink); }
.leaflet-container .leaflet-control-zoom a { background: var(--surface); color: var(--ink); }
.leaflet-container .leaflet-control-attribution { background: var(--surface); color: var(--ink); }
.leaflet-container .leaflet-control-attribution a { color: var(--brand); }

/* Manuelle Farbkorrekturen aus Revision 8.0 */
:root { --hidden-label: #c62828; }
:root[data-appearance="dark"] { --hidden-label: #ff8a80; }
@media (prefers-color-scheme: dark) {
    :root:not([data-appearance="light"]) { --hidden-label: #ff8a80; }
}
.hidden-station-label { color: var(--hidden-label); }

/* Revision 8.1 – EVSE-ID kopieren */
.extra-detail .detail-evse { display: grid; gap: 3px; white-space: normal; }
.evse-row { display: grid; grid-template-columns: minmax(0, 1fr) 36px; align-items: center; column-gap: 8px; }
.evse-value { overflow-wrap: anywhere; user-select: text; -webkit-user-select: text; }
.evse-copy { width: 36px; height: 36px; display: grid; place-items: center; padding: 0; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--muted); cursor: pointer; }
.evse-copy.is-copied { color: var(--free); }
.evse-copy:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.evse-feedback { grid-column: 1 / -1; font-size: 12px; color: var(--muted); font-weight: normal; }
.evse-feedback:empty { display: none; }

/* Revision 8.2 – individueller Ladepunktstatus */
.evse-info { display: grid; gap: 1px; min-width: 0; }
.evse-status { font-size: 12px; font-weight: 600; color: var(--muted); }
.evse-free .evse-status { color: var(--free); }
.evse-occupied .evse-status { color: var(--danger); }
.evse-row:not(.evse-free) .evse-value { color: var(--muted); font-weight: normal; }
.evse-copy:disabled { opacity: .45; cursor: default; }

/* Revision 9.0 */
.mode-switch { display:flex; gap:2px; padding:3px; border:1px solid var(--line); border-radius:10px; background:var(--page); }
.mode-switch button { font:inherit; font-size:12px; padding:9px 7px; border:0; border-radius:7px; background:transparent; color:var(--ink); }
.mode-switch button[aria-pressed="true"] { background:var(--accent); color:#18231e; font-weight:700; }
#updateDistance:disabled { opacity:.5; }
.stale-data { color:var(--danger) !important; }
.search-line { flex-wrap:wrap; gap:8px; }

/* Revision 9.1 – kompakter Kopfbereich */
.topbar { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 5px 8px; padding-bottom: 12px; }
.topbar .location-state { grid-column: 1 / -1; gap: 7px; padding: 2px 0; }
.topbar .location-state > div { display: flex; align-items: baseline; flex-wrap: wrap; gap: 2px 6px; min-width: 0; }
.topbar .location-state small { margin-top: 0; }
.search-line { justify-content: space-between; }
.mode-label { color: var(--muted); font-size: 12px; }
.mode-switch button[aria-pressed="true"] { color: #fff; }
#modeStatic[aria-pressed="true"] { background: #23834b; }
#modeDynamic[aria-pressed="true"] { background: #e87500; }
.search-panel .filters { margin-top: 9px; }

/* Revision 9.2 – Lesbarkeit und kompakte Einstellungen */
.details-toggle, .navigate-button, .map-toggle { font-size: 14px; }
.station-actions > * { min-width: 0; overflow-wrap: normal; }
.details-toggle { padding: 8px 4px; }
.navigate-button { padding: 8px 4px; }
.settings-control { min-height: 0; padding: 9px 11px; }
.settings-control select { padding: 0; }
.evse-info { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 12px; }
.evse-value { min-width: 0; }
.evse-status { flex: 0 0 auto; }

/* Revision 9.3: Blockiergebühr über die gesamte Detailbreite. */
.blocking-detail { grid-column: 1 / -1; min-width: 0; }
