/* Layout: Sidebar links (Suche, Liste, Details), Karte rechts; auf dem Handy Karte oben, Liste darunter. */
:root {
  --bg: #f3f4f6;
  --surface: #ffffff;
  --surface-2: #eceef2;
  --fg: #16181d;
  --muted: #5d6470;
  --line: #d9dce3;
  --accent: #d1202a;      /* Curbstone-Rot */
  --accent-fg: #ffffff;
  --auto: #2563c9;
  --moto: #d1202a;
  --kart: #c98a00;
  --ok: #1f8a4c;
  --warn: #b86e00;
  --bad: #c0262e;
  --shadow: 0 10px 30px rgba(18, 22, 30, .18);
  --font-display: "Barlow Condensed", "Arial Narrow", Arial, sans-serif;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-data: "JetBrains Mono", ui-monospace, "SFMono-Regular", Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111317; --surface: #1a1d23; --surface-2: #23272f; --fg: #eceef2; --muted: #9aa1ad; --line: #2f343d;
    --accent: #ff4b52; --auto: #5b93ff; --moto: #ff4b52; --kart: #f0b429; --ok: #3ccf7f; --warn: #f0a531; --bad: #ff5c63;
    --shadow: 0 10px 30px rgba(0, 0, 0, .5); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111317; --surface: #1a1d23; --surface-2: #23272f; --fg: #eceef2; --muted: #9aa1ad; --line: #2f343d;
  --accent: #ff4b52; --auto: #5b93ff; --moto: #ff4b52; --kart: #f0b429; --ok: #3ccf7f; --warn: #f0a531; --bad: #ff5c63;
  --shadow: 0 10px 30px rgba(0, 0, 0, .5); color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--fg); font: 14px/1.45 var(--font-body); }
a { color: var(--auto); }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.app { display: grid; grid-template-columns: minmax(320px, 400px) 1fr; height: 100%; }
.sidebar { background: var(--surface); border-right: 1px solid var(--line); overflow-y: auto; display: flex; flex-direction: column; min-width: 0; position: relative; }
.map-wrap { position: relative; min-width: 0; }
#map { position: absolute; inset: 0; background: var(--surface-2); }

.brand { padding: 18px 20px 14px; border-bottom: 1px solid var(--line); }
.kerb { height: 6px; margin: -18px -20px 14px; background: repeating-linear-gradient(90deg, var(--accent) 0 18px, #fff 18px 36px); }
.brand h1 { margin: 0; font: 700 30px/1 var(--font-display); letter-spacing: .02em; text-transform: uppercase; }
.brand h1 span { color: var(--accent); }
.tagline { margin: 4px 0 0; color: var(--muted); }

.panel { padding: 14px 20px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.label { font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.muted { color: var(--muted); font-weight: 500; }
.status { margin: 0; color: var(--muted); font-size: 13px; }
.origin-row, .filter-row { display: flex; gap: 8px; }
.origin-row input, .filter-row input, .filter-row select {
  flex: 1; min-width: 0; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg);
}
.filter-row select { flex: 0 0 140px; }
.btn { border: 0; border-radius: 6px; padding: 8px 12px; background: var(--accent); color: var(--accent-fg); font-weight: 600; cursor: pointer; }
.btn:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; color: var(--fg); border: 1px solid var(--line); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: transparent; cursor: pointer; font-weight: 500; }
.chip.on { background: var(--surface-2); border-color: var(--fg); }
.chip:not(.on) { opacity: .55; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot.auto { background: var(--auto); } .dot.moto { background: var(--moto); } .dot.kart { background: var(--kart); }
.toggle { display: flex; gap: 8px; align-items: center; font-size: 13px; color: var(--muted); }

.list-head { display: flex; justify-content: space-between; padding: 12px 20px 6px; }
.track-list { list-style: none; margin: 0; padding: 0 0 20px; }
.track-item { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 10px 20px; cursor: pointer; border-left: 3px solid transparent; }
.track-item:hover, .track-item.active { background: var(--surface-2); border-left-color: var(--accent); }
.track-item .name { font-weight: 600; min-width: 0; }
.track-item .meta { color: var(--muted); font-size: 12px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.track-item .eta { font-family: var(--font-data); font-size: 13px; text-align: right; font-variant-numeric: tabular-nums; grid-row: span 2; align-self: center; }
.tag { font-size: 11px; padding: 1px 6px; border-radius: 4px; color: #fff; font-weight: 600; }
.tag.auto { background: var(--auto); } .tag.moto { background: var(--moto); } .tag.kart { background: var(--kart); color: #1a1300; }
.tag.osm { background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }

/* Marker */
.pin { width: 18px; height: 18px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.4); }
.pin.small { width: 12px; height: 12px; border-width: 1.5px; }
.pin.auto { background: var(--auto); } .pin.moto { background: var(--moto); } .pin.kart { background: var(--kart); }
.pin.multi { background: conic-gradient(var(--auto) 0 50%, var(--moto) 50% 100%); }
.origin-pin { width: 16px; height: 16px; border-radius: 50%; background: var(--fg); border: 3px solid var(--surface); box-shadow: 0 0 0 2px var(--fg); }

/* Hover-Karte */
.hover-card { position: fixed; z-index: 2000; width: 340px; max-width: calc(100vw - 24px); background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.hc-title { font: 700 21px/1.05 var(--font-display); text-transform: uppercase; letter-spacing: .02em; margin: 0; text-wrap: balance; }
.hc-sub { color: var(--muted); font-size: 12px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-family: var(--font-data); font-variant-numeric: tabular-nums; }
.block-title { font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 0 0 4px; }
.event { background: var(--surface-2); border-radius: 8px; padding: 8px 10px; display: flex; flex-direction: column; gap: 4px; }
.event .when { font-family: var(--font-data); font-weight: 600; }
.book { align-self: flex-start; text-decoration: none; }
.weather { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.wday { background: var(--surface-2); border-radius: 8px; padding: 6px 4px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 12px; }
.wday .d { font-weight: 600; }
.wday .t { font-family: var(--font-data); font-variant-numeric: tabular-nums; }
.wday .p { font-family: var(--font-data); font-size: 11px; }
.wday svg { width: 26px; height: 26px; }
.p.dry { color: var(--ok); } .p.mixed { color: var(--warn); } .p.wet { color: var(--bad); }
.loading { color: var(--muted); font-size: 12px; }
.links { display: flex; flex-wrap: wrap; gap: 6px; }
.links a { font-size: 12px; padding: 4px 8px; border: 1px solid var(--line); border-radius: 6px; text-decoration: none; color: var(--fg); }
.links a:hover { border-color: var(--accent); }

/* Detail */
.detail { position: absolute; inset: 0; background: var(--surface); overflow-y: auto; padding: 14px 20px 30px; display: flex; flex-direction: column; gap: 14px; z-index: 5; }
.back { align-self: flex-start; }
.detail h2 { font: 700 30px/1 var(--font-display); text-transform: uppercase; margin: 0; text-wrap: balance; }
.detail section { display: flex; flex-direction: column; gap: 8px; border-top: 1px solid var(--line); padding-top: 12px; }
.detail h3 { margin: 0; font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.detail p { margin: 0; }
.hotel-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.hotel-list li { display: grid; grid-template-columns: 1fr auto; gap: 0 10px; font-size: 13px; }
.hotel-list .km { font-family: var(--font-data); color: var(--muted); }
.hotel-list .type { color: var(--muted); font-size: 12px; }
.note { font-size: 12px; color: var(--muted); }

.map-note { position: absolute; left: 50%; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--surface); border: 1px solid var(--line); padding: 6px 12px; border-radius: 999px; box-shadow: var(--shadow); font-size: 12px; z-index: 900; max-width: calc(100% - 32px); }

.leaflet-container { font: inherit; background: var(--surface-2); }

@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; grid-template-rows: 55vh auto; height: auto; }
  .map-wrap { order: -1; height: 55vh; }
  .sidebar { border-right: 0; overflow: visible; }
  .detail { position: static; }
  .brand, .panel, .list-head, .track-item, .detail { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
  .kerb { margin-left: calc(-1 * max(16px, env(safe-area-inset-left, 0px))); margin-right: calc(-1 * max(16px, env(safe-area-inset-right, 0px))); }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* Zurück zu Song4youonly */
.home-link { display: inline-block; margin-bottom: 10px; font-size: 12px; color: var(--muted); text-decoration: none; }
.home-link:hover { color: var(--accent); }

/* Kauf-Button "Aufs Handy holen" */
.app-btn {
  margin-top: 12px; width: 100%; display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; border: 0; border-radius: 8px; cursor: pointer; text-align: left;
  background: var(--accent); color: var(--accent-fg); box-shadow: 0 6px 18px color-mix(in srgb, var(--accent) 35%, transparent);
  transition: transform .15s, filter .15s;
}
.app-btn:hover { filter: brightness(1.08); transform: translateY(-1px); }
.app-btn-text { display: flex; flex-direction: column; line-height: 1.2; }
.app-btn-text strong { font: 700 18px/1.1 var(--font-display); letter-spacing: .04em; text-transform: uppercase; }
.app-btn-text small { font-size: 12px; opacity: .9; }

/* Kauf-Dialog */
.app-dialog {
  width: min(440px, calc(100vw - 32px)); max-height: calc(100vh - 32px); overflow-y: auto;
  border: 1px solid var(--line); border-radius: 12px; padding: 0;
  background: var(--surface); color: var(--fg); box-shadow: var(--shadow);
}
.app-dialog::backdrop { background: rgba(10, 12, 16, .55); }
.dlg-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px 0; }
.dlg-head::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 6px; background: repeating-linear-gradient(90deg, var(--accent) 0 18px, #fff 18px 36px); }
.app-dialog { position: fixed; }
.dlg-head h2 { margin: 6px 0 0; font: 700 26px/1 var(--font-display); text-transform: uppercase; letter-spacing: .02em; }
.dlg-close { border: 0; background: transparent; font-size: 28px; line-height: 1; cursor: pointer; color: var(--muted); padding: 4px 8px; }
#appDialogBody { padding: 12px 18px 20px; display: flex; flex-direction: column; gap: 14px; }
.price-row { display: flex; align-items: baseline; gap: 10px; }
.price { font: 700 34px/1 var(--font-display); color: var(--accent); }
.price-note { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
.perks { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 4px; }
.dlg-step { border-top: 1px solid var(--line); padding-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.dlg-step h3 { margin: 0; display: flex; align-items: center; gap: 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; }
.dlg-step .num { width: 22px; height: 22px; border-radius: 50%; display: inline-grid; place-items: center; background: var(--fg); color: var(--surface); font-size: 12px; }
.dlg-step.done .num { background: var(--ok); }
.dlg-step.locked { opacity: .6; }
.btn-big { display: inline-block; text-align: center; text-decoration: none; padding: 12px 16px; font-size: 15px; }
.fine { margin: 0; font-size: 12px; color: var(--muted); }
.ok-line { margin: 0; color: var(--ok); font-weight: 600; }
.steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 4px; }
.mono { font-family: var(--font-data); font-size: 12px; }
.sel { user-select: all; }

/* Testversion / Sperre */
.demo-note { margin: 8px 0 0; font-size: 12px; color: var(--muted); }
.tag.demo { background: var(--ok); color: #fff; vertical-align: 1px; }
.track-item.is-locked .name { color: var(--muted); font-weight: 500; }
.track-item .lock { vertical-align: -1px; margin-right: 5px; color: var(--muted); }
.pin.locked { opacity: .45; filter: grayscale(.6); }
.locked-box { display: flex; gap: 8px; align-items: flex-start; background: var(--surface-2); border-radius: 8px; padding: 10px; font-size: 13px; }
.locked-box .lock { flex-shrink: 0; margin-top: 2px; color: var(--accent); }
.btn-unlock { width: 100%; padding: 10px 12px; }

/* Abo-Auswahl */
.plans { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.plan { position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 12px; text-align: left; cursor: pointer;
  background: var(--surface); border: 2px solid var(--line); border-radius: 10px; }
.plan.on { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.plan-label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.plan-price { font: 700 30px/1 var(--font-display); color: var(--fg); }
.plan.on .plan-price { color: var(--accent); }
.plan-per { font-size: 12px; color: var(--muted); }
.plan-note { font-size: 11px; color: var(--muted); margin-top: 4px; }
.plan-badge { position: absolute; top: -9px; right: 10px; background: var(--ok); color: #fff; font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: 999px; text-transform: uppercase; letter-spacing: .05em; }
.pay-methods { display: flex; gap: 6px; flex-wrap: wrap; }
.pm { font-size: 11px; font-weight: 700; padding: 3px 8px; border: 1px solid var(--line); border-radius: 4px; color: var(--fg); background: var(--surface-2); letter-spacing: .03em; }
@media (max-width: 380px) { .plans { grid-template-columns: 1fr; } }

/* Hinweis Handy-App, Download-Anleitung, QR-Code */
.app-hint { margin: 10px 0 0; display: flex; gap: 8px; align-items: flex-start; font-size: 12.5px; line-height: 1.4; color: var(--fg);
  background: var(--surface-2); border-radius: 8px; padding: 8px 10px; }
.app-hint svg { flex-shrink: 0; margin-top: 1px; color: var(--accent); }
.btn-unlock { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.btn-unlock small { font-weight: 500; font-size: 12px; opacity: .92; }
.howto { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.howto-os { margin: 0 0 4px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.howto .steps { font-size: 12.5px; }
.qr-box { display: flex; gap: 14px; align-items: center; background: var(--surface-2); border-radius: 10px; padding: 10px; }
.qr { flex-shrink: 0; background: #fff; border-radius: 6px; line-height: 0; }
.qr svg { width: 132px; height: 132px; display: block; }
@media (max-width: 420px) { .howto { grid-template-columns: 1fr; } .qr-box { flex-direction: column; text-align: center; } }

/* Bestellformular (solange kein Zahlungslink eingetragen ist) */
.order-box { display: flex; flex-direction: column; gap: 8px; background: var(--surface-2); border-radius: 10px; padding: 12px; }
.order-title { margin: 0; font-weight: 700; }
.field { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); }
.field input { padding: 9px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--fg); font-size: 14px; }
.send-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.send { display: block; text-align: center; padding: 9px 8px; border-radius: 6px; border: 1px solid var(--accent); background: var(--surface);
  color: var(--fg); text-decoration: none; font-weight: 600; font-size: 13px; cursor: pointer; }
.send:hover { background: var(--accent); color: var(--accent-fg); }
.send-grid.off .send { opacity: .4; pointer-events: none; border-color: var(--line); }
.copy-area { width: 100%; min-height: 120px; margin-top: 6px; font: 12px var(--font-data); }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.order-error { margin: 0; color: var(--bad); font-size: 13px; font-weight: 600; }
.order-done { border: 2px solid var(--ok); }
.order-done p { margin: 0; }
.order-done .order-title { color: var(--ok); }
#orderSend[disabled] { opacity: .7; cursor: wait; }
.link-btn { align-self: center; background: none; border: 0; padding: 2px 4px; color: var(--muted); font-size: 12.5px; text-decoration: underline; cursor: pointer; }
.link-btn:hover { color: var(--fg); }

/* Abo verwalten / kündigen (Stripe-Kundenportal) */
.portal-row { display: flex; flex-direction: column; align-items: center; gap: 2px; border-top: 1px solid var(--line); padding-top: 12px; text-align: center; }
.portal-link { font-weight: 600; color: var(--fg); }
.side-portal { display: inline-block; margin-top: 8px; font-size: 12.5px; color: var(--muted); }
.side-portal:hover { color: var(--fg); }
