:root {
    --gap: 0px;
    --cell-size: min(
        calc((100vh - 24px) / 100),
        calc((100vw - 24px) / 100)
    );
    --border: #dbeafe;
    --bg: #f0f4ff;
    --panel: #ffffff;
    --text: #0f172a;
    --muted: #64748b;
    --accent: #2563eb;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
    font-family: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
    background: radial-gradient(ellipse 1400px 600px at 60% -5%, #dbeafe 0%, #eff6ff 40%, #f0f4ff 100%);
    color: var(--text);
    line-height: 1.45;
}

.container {
    max-width: 100vw;
    margin: 0 auto;
    padding: 12px;
}

header {
    text-align: center;
    margin-bottom: 12px;
}

h1 {
    font-size: clamp(22px, 3.4vw, 34px);
    margin: 0 0 8px;
    letter-spacing: -0.01em;
    color: var(--text);
}

.subtitle {
    color: var(--muted);
    font-size: 15px;
}

.panel {
    background: #ffffff;
    border: 1px solid #dbeafe;
    border-radius: 12px;
    padding: 16px;
    margin: 20px 0 28px;
    box-shadow: 0 1px 3px rgba(37, 99, 235, 0.07), 0 1px 2px rgba(0, 0, 0, 0.04);
}

form {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 12px;
    align-items: start;
}

textarea {
    width: 100%;
    min-height: 84px;
    resize: vertical;
    padding: 12px;
    border-radius: 10px;
    border: 1px solid #dbeafe;
    background: #f8fafc;
    color: var(--text);
    font-size: 15px;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}
textarea::placeholder { color: var(--muted); }
textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

button {
    height: 42px;
    padding: 0 16px;
    border-radius: 10px;
    border: none;
    background: linear-gradient(180deg, #3b82f6, #2563eb);
    color: #fff;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(37, 99, 235, 0.3);
    transition: opacity 0.15s;
}
button:hover { opacity: 0.9; }
button:disabled { opacity: .5; cursor: not-allowed; }

.legend {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    font-size: 13px;
    color: var(--muted);
    margin-top: 8px;
}
.legend .chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border-radius: 999px;
    border: 1px solid #dbeafe;
    background: #f0f4ff;
}
.legend .dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.grid-wrap {
    display: grid;
    place-items: center;
    margin-top: 10px;
}

.grid {
    display: grid;
    grid-template-columns: repeat(100, var(--cell-size));
    grid-template-rows: repeat(100, var(--cell-size));
    gap: var(--gap);
    padding: 0;
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
}

.cell {
    width: var(--cell-size);
    height: var(--cell-size);
    border-radius: 0;
    border: 0;
    background: #f0f4ff;
}

.status {
    margin-top: 12px;
    font-size: 14px;
    color: var(--muted);
}

.error { color: #dc2626; }

footer {
    margin-top: 36px;
    text-align: center;
    color: var(--muted);
    font-size: 13px;
}

@media (max-width: 520px) {
    :root { --gap: 3px; }
}

/* Navigations-Button rechts in Parkhaus-Zeilen */
.nav-btn {
    flex: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #eff6ff;
    color: var(--accent);
    border: 1px solid var(--border);
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
}
.nav-btn:hover,
.nav-btn:focus-visible {
    background: var(--accent);
    color: #fff;
}

/* Stadtauswahl auf der Startseite */
.city-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 16px 0 20px;
}
.city-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(37, 99, 235, 0.07), 0 1px 2px rgba(0, 0, 0, 0.04);
    color: inherit;
    text-decoration: none;
    transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}
.city-card:hover,
.city-card:focus-visible {
    border-color: #93c5fd;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.12);
    transform: translateY(-1px);
}
.city-card:active { transform: none; }
.city-card__icon {
    flex: none;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--accent);
    color: #fff;
    font-weight: 700;
    font-size: 15px;
    letter-spacing: 0.04em;
    display: flex;
    align-items: center;
    justify-content: center;
}
.city-card__text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}
.city-card__name {
    font-weight: 600;
    font-size: 17px;
}
.city-card__info {
    color: var(--muted);
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.city-card__chevron {
    flex: none;
    color: #94a3b8;
}
.city-card:hover .city-card__chevron { color: var(--accent); }

/* ---------- Parkhaus-Detailseite ---------- */
.detail-back { margin: 4px 0 8px; font-size: 14px; }
.detail-back a { color: var(--accent); text-decoration: none; }
.detail-header { text-align: left; margin-bottom: 4px; }
.detail-header h1 { font-size: clamp(22px, 5vw, 30px); margin: 0 0 2px; }
.detail .panel { margin: 12px 0; }
.detail-h2 { font-size: 16px; margin: 0 0 12px; }
.detail-note { color: var(--muted); font-size: 12px; margin: 12px 0 0; line-height: 1.45; }
.detail-note a { color: inherit; }

.detail-live__row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.detail-live__number { font-size: 30px; font-weight: 700; line-height: 1.1; }
.detail-live__meta { color: var(--muted); font-size: 13px; margin-top: 4px; }
.detail-live__bar { height: 8px; border-radius: 999px; background: #e2e8f0; overflow: hidden; margin-top: 14px; }
.detail-live__bar span { display: block; height: 100%; border-radius: 999px; }

.nav-btn--wide { width: auto; height: 40px; padding: 0 16px; gap: 6px; border-radius: 999px; font-weight: 600; font-size: 14px; }

.detail-list { display: grid; grid-template-columns: max-content 1fr; gap: 10px 16px; margin: 0; font-size: 14px; }
.detail-list dt { color: var(--muted); }
.detail-list dd { margin: 0; min-width: 0; }
.detail-list a { color: var(--accent); }
.detail-list__label { color: var(--muted); }
.detail-price { display: flex; justify-content: space-between; gap: 12px; padding: 2px 0; }
.detail-price span { color: var(--muted); }
.detail-price strong { white-space: nowrap; font-weight: 600; }
.detail-price__heading { font-weight: 600; margin-top: 6px; }
.detail-price__heading:first-child { margin-top: 0; }
.detail-price__note { color: var(--muted); font-size: 13px; margin-top: 4px; }
.detail-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.detail-chips span { font-size: 12px; padding: 3px 10px; border-radius: 999px; background: #eff6ff; border: 1px solid var(--border); }
@media (max-width: 420px) {
    .detail-list { grid-template-columns: 1fr; gap: 2px; }
    .detail-list dd { margin-bottom: 10px; }
}

.detail-nearby { display: flex; flex-direction: column; padding: 12px 16px; border-top: 1px solid #f1f5f9; color: inherit; text-decoration: none; }
.detail-nearby:hover { background: #f8fafc; }
.detail-nearby__name { font-weight: 600; font-size: 14px; }
.detail-nearby__meta { color: var(--muted); font-size: 12px; }

/* Typische Auslastung (Säulen je Stunde) */
.occ-tabs { display: flex; gap: 4px; margin-bottom: 14px; }
.occ-tab { flex: 1; height: auto; box-shadow: none; padding: 6px 0; border: 1px solid var(--border); border-radius: 8px; background: #f8fafc; color: var(--muted); font: inherit; font-size: 13px; cursor: pointer; }
.occ-tab[aria-selected="true"] { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.occ-chart { display: flex; align-items: flex-end; gap: 2px; height: 120px; border-bottom: 1px solid #cbd5e1; }
.occ-bar { flex: 1; height: 100%; margin: 0; padding: 0; border: 0; border-radius: 0; background: none; box-shadow: none; -webkit-appearance: none; appearance: none; display: flex; align-items: flex-end; cursor: pointer; }
.occ-bar:focus { outline: none; }
.occ-bar:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.occ-bar::before { content: ""; display: block; width: 100%; height: calc(var(--v) * 1%); background: #93c5fd; border-radius: 4px 4px 0 0; }
.occ-bar:hover::before, .occ-bar:focus-visible::before { background: #60a5fa; }
.occ-bar.is-now::before { background: var(--accent); }
.occ-bar.is-empty::before { height: 2px; background: #e2e8f0; }
.occ-axis { position: relative; height: 14px; color: var(--muted); font-size: 11px; margin-top: 4px; }
.occ-axis span { position: absolute; top: 0; transform: translateX(-50%); }
.occ-axis span:first-child, .occ-axis span:last-child { transform: none; }
.occ-caption { font-size: 13px; font-weight: 600; margin: 10px 0 0; min-height: 1.4em; }
.occ-summary { font-size: 13px; color: var(--muted); margin: 4px 0 0; }

/* Parkhaus-Name in Listen als Link zur Detailseite */
.row-link { flex: 1; min-width: 0; color: inherit; text-decoration: none; }
.row-link:hover .row-link__name { color: var(--accent); }

/* Sprachumschalter (Flaggen) oben rechts */
.lang-switch {
    position: absolute;
    top: 10px;
    right: 12px;
    display: flex;
    gap: 6px;
    z-index: 10;
}
.lang-switch a {
    display: flex;
    padding: 3px;
    border-radius: 5px;
    border: 1px solid transparent;
    opacity: 0.55;
    transition: opacity 0.15s, border-color 0.15s;
}
.lang-switch a:hover,
.lang-switch a:focus-visible { opacity: 1; }
.lang-switch a.is-active {
    opacity: 1;
    border-color: var(--border);
    background: #fff;
}
.lang-switch svg { display: block; border-radius: 2px; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.08); }
body { position: relative; }
/* Platz für den Sprachumschalter, damit Überschriften auf schmalen Displays nicht darunter laufen */
.container > header:not(.detail-header) { padding-left: 64px; padding-right: 64px; }
.detail-back { padding-right: 72px; }

/* ---------- Favoriten ---------- */
.fav-btn {
    flex: none;
    width: 32px;
    height: 32px;
    padding: 0;
    border-radius: 50%;
    background: none;
    box-shadow: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #cbd5e1;
}
.fav-btn svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; }
.fav-btn:hover { opacity: 1; color: #f59e0b; }
.fav-btn.is-on { color: #f59e0b; }
.fav-btn.is-on svg { fill: currentColor; }
.fav-btn--lg { width: 40px; height: 40px; }
.fav-btn--lg svg { width: 24px; height: 24px; }
.park-row.is-fav { background: #fffbeb; }

.detail-title { display: flex; align-items: flex-start; gap: 8px; }
.detail-title h1 { flex: 1; min-width: 0; }

.fav-home { padding: 0; overflow: hidden; margin: 16px 0; }
.fav-home__title { font-size: 15px; margin: 0; padding: 12px 16px 6px; }
.fav-home .park-row { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-top: 1px solid #f1f5f9; }
.fav-home .row-link__name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-meta { color: var(--muted); font-size: 12px; }
.badge { display: inline-flex; align-items: center; justify-content: center; min-width: 40px; padding: 6px 10px; color: #fff; border-radius: 999px; font-weight: 600; font-size: 13px; }

/* ---------- Hinweis „Als App installieren“ ---------- */
.install-hint {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 24px 0 0;
    padding: 12px 14px;
    border: 1px dashed #bfdbfe;
    border-radius: 12px;
    color: inherit;
    text-decoration: none;
    font-size: 13px;
}
.install-hint:hover { background: rgba(255, 255, 255, 0.6); }
.install-hint__icon { font-size: 22px; }
.install-hint__text { flex: 1; display: flex; flex-direction: column; }
.install-hint__text span { color: var(--muted); }
.is-standalone .install-hint { display: none; }
@media (display-mode: standalone) { .install-hint { display: none; } }

/* ---------- Seite „Als App installieren“ ---------- */
.app-guide .subtitle { font-size: 14px; margin-top: 4px; }
.app-installed { display: none; }
.is-standalone .app-installed { display: block; }
.app-install-btn { width: 100%; height: 48px; font-size: 16px; margin: 12px 0 0; }
.app-install-btn[hidden] { display: none; }
.app-benefits { margin: 0; padding-left: 20px; line-height: 1.7; font-size: 14px; }
.app-os small { font-weight: 400; color: var(--muted); font-size: 13px; margin-left: 4px; }
.app-os__icon { font-size: 18px; }
.app-steps { margin: 0; padding-left: 22px; line-height: 1.6; font-size: 14px; }
.app-steps li { margin-bottom: 6px; }

/* ---------- Dunkelmodus (folgt der Systemeinstellung) ---------- */
@media (prefers-color-scheme: dark) {
    :root {
        --border: #334155;
        --bg: #0b1220;
        --panel: #162033;
        --text: #e2e8f0;
        --muted: #94a3b8;
        --accent: #60a5fa;
        color-scheme: dark;
    }
    body { background: radial-gradient(ellipse 1400px 600px at 60% -5%, #1e293b 0%, #0f172a 45%, #0b1220 100%); }
    .panel, .city-card { background: var(--panel); border-color: var(--border); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4); }
    .city-card:hover, .city-card:focus-visible { border-color: #3b82f6; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5); }
    .city-card__icon { background: #2563eb; }
    a { color: var(--accent); }

    /* Inline-Farben aus den PHP-Vorlagen abdunkeln */
    [style*="color:#64748b"] { color: var(--muted) !important; }
    [style*="color:#2563eb"] { color: var(--accent) !important; }
    [style*="background:#f8fafc"], [style*="background:#eff6ff"] { background: #1b2740 !important; }
    [style*="border:1px solid #dbeafe"] { border-color: var(--border) !important; }
    [style*="border-bottom:1px solid #f1f5f9"] { border-bottom-color: #22304a !important; }
    [style*="border-color:#fecaca"] { background: #3b1219 !important; border-color: #7f1d1d !important; color: #fca5a5 !important; }
    [style*="color:#94a3b8"] { color: #7c8aa0 !important; }

    .nav-btn { background: #1e3a5f; border-color: #2b4a73; color: #93c5fd; }
    .nav-btn:hover, .nav-btn:focus-visible { background: var(--accent); color: #0b1220; }
    .row-link:hover .row-link__name { color: var(--accent); }
    .park-row.is-fav { background: #2a2414; }
    .fav-btn { color: #475569; }
    .fav-home .park-row, .detail-nearby { border-top-color: #22304a; }
    .detail-nearby:hover { background: #1b2740; }
    .detail-live__bar { background: #334155; }
    .detail-chips span { background: #1b2740; border-color: var(--border); }
    .occ-tab { background: #1b2740; border-color: var(--border); color: var(--muted); }
    .occ-tab[aria-selected="true"] { background: #2563eb; border-color: #2563eb; color: #fff; }
    .occ-bar::before { background: #1e40af; }
    .occ-bar:hover::before, .occ-bar:focus-visible::before { background: #2563eb; }
    .occ-bar.is-now::before { background: #60a5fa; }
    .occ-bar.is-empty::before { background: #334155; }
    .occ-chart { border-bottom-color: #475569; }
    .lang-switch a.is-active { background: var(--panel); border-color: var(--border); }
    .install-hint { border-color: #2b4a73; }
    .install-hint:hover { background: rgba(255, 255, 255, 0.04); }
}

/* ---------- Trend-Pfeil ---------- */
.trend { flex: none; font-size: 16px; font-weight: 700; line-height: 1; min-width: 0; }
.trend:empty { display: none; }
.trend--filling { color: #ea580c; }
.trend--emptying { color: #16a34a; }
.trend--label { display: inline-block; font-size: 13px; font-weight: 600; margin-top: 4px; }

/* ---------- Filter ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0 -8px; }
.filter-chip {
    height: auto;
    padding: 6px 12px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--panel);
    color: var(--text);
    font-weight: 500;
    font-size: 13px;
    box-shadow: none;
}
.filter-chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.filter-empty { color: var(--muted); font-size: 14px; }
.filter-empty[hidden], .park-row[hidden] { display: none !important; }

/* ---------- Teilen ---------- */
.share-btn {
    flex: none;
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: 50%;
    background: none;
    box-shadow: none;
    color: var(--muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.share-btn:hover { color: var(--accent); opacity: 1; }
.toast {
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%);
    background: #0f172a;
    color: #fff;
    padding: 10px 16px;
    border-radius: 999px;
    font-size: 14px;
    z-index: 100;
    transition: opacity 0.4s;
}
.toast.is-out { opacity: 0; }

/* Alte Daten („vor 20 Min.“) hervorheben */
.is-old { color: #ea580c; }

@media (prefers-color-scheme: dark) {
    .trend--filling { color: #fb923c; }
    .trend--emptying { color: #4ade80; }
    .filter-chip[aria-pressed="true"] { background: #2563eb; border-color: #2563eb; }
    .toast { background: #e2e8f0; color: #0f172a; }
    .is-old { color: #fb923c; }
}

/* ---------- Ratgeber „Parken in …“ ---------- */
.guide-link {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 20px 0 0;
    padding: 12px 14px;
    border-radius: 12px;
    background: var(--panel);
    border: 1px solid var(--border);
    color: inherit;
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
}
.guide-link:hover { border-color: var(--accent); }
.guide-link span:last-child { margin-left: auto; color: var(--muted); }
.g-list { list-style: none; margin: 0; padding: 0; }
.g-list li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; padding: 8px 0; border-top: 1px solid #f1f5f9; font-size: 14px; }
.g-list li:first-child { border-top: 0; padding-top: 0; }
.g-list a { font-weight: 600; color: inherit; text-decoration: none; }
.g-list a:hover { color: var(--accent); }
.g-meta { color: var(--muted); }
.g-free { margin-left: auto; font-size: 13px; color: #16a34a; font-weight: 600; white-space: nowrap; }
.g-free.is-off { color: var(--muted); font-weight: 400; }
.g-asof { color: var(--muted); font-size: 13px; }
.g-faq { border-top: 1px solid #f1f5f9; padding: 10px 0; }
.g-faq:first-of-type { border-top: 0; padding-top: 0; }
.g-faq summary { cursor: pointer; font-weight: 600; font-size: 14px; }
.g-faq p { margin: 8px 0 0; font-size: 14px; color: var(--muted); }
@media (prefers-color-scheme: dark) {
    .g-list li, .g-faq { border-top-color: #22304a; }
    .g-free { color: #4ade80; }
}

/* ---------- Anzeige (Amazon-Tipp): warm abgesetzt, damit sie auffällt ---------- */
.aff-card {
    padding: 14px 16px;
    background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
    border: 1px solid #fcd34d;
    border-left: 5px solid #f59e0b;
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.18);
}
.aff-card__row { display: flex; align-items: center; gap: 12px; }
.aff-card__icon {
    flex: none;
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: #f59e0b;
    color: #fff;
    font-weight: 800;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    box-shadow: 0 2px 6px rgba(217, 119, 6, 0.35);
}
.aff-card__body { flex: 1; min-width: 0; }
.aff-card__label { font-size: 11px; font-weight: 700; color: #b45309; text-transform: uppercase; letter-spacing: 0.05em; }
.aff-card__main { color: inherit; text-decoration: none; }
.aff-card__title { font-weight: 700; font-size: 15px; color: #78350f; }
.aff-card__text { color: #92400e; font-size: 13px; line-height: 1.4; }
.aff-card__variants { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.aff-card__btn {
    font-size: 13px;
    font-weight: 600;
    padding: 5px 12px;
    border-radius: 999px;
    background: #f59e0b;
    color: #fff;
    text-decoration: none;
    transition: background 0.15s;
}
.aff-card__btn:hover, .aff-card__btn:focus-visible { background: #d97706; }
.aff-card__note { font-size: 11px; color: #a16207; margin-top: 10px; }

@media (prefers-color-scheme: dark) {
    .aff-card {
        background: linear-gradient(135deg, #2a1f0b 0%, #3a2a0c 100%);
        border-color: #78501a;
        border-left-color: #f59e0b;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
    }
    .aff-card__label { color: #fbbf24; }
    .aff-card__title { color: #fde68a; }
    .aff-card__text { color: #fcd34d; opacity: 0.85; }
    .aff-card__note { color: #d6a756; }
    .aff-card__btn { background: #d97706; }
    .aff-card__btn:hover, .aff-card__btn:focus-visible { background: #f59e0b; color: #1f1505; }
}
