/* Kulmira – Designsprache „Wald und Gletscher“: Waldgrün + Blau/Gletscherblau, Barlow Semi Condensed + Inter */
:root {
  color-scheme: light;
  --forest: #12261f; --forest-2: #1a372d; --forest-3: #21443a; --forest-text: #b3c4bc;
  --bg: #ffffff;            /* Light Mode: weiß */
  --surface-1: #ffffff;
  --surface-2: #f5f5f7;
  --border: #e5e5ea;
  --bar-bg: rgba(255,255,255,.82); --bar-fg: #1d1d1f; --bar-muted: #6e6e73;
  --bar-hover: rgba(0,0,0,.05); --bar-active: rgba(46,107,91,.12); --bar-line: rgba(0,0,0,.1);
  --grid: #ececf0;
  --text-primary: #1d1d1f;  /* ink */
  --text-secondary: #6e6e73;
  --text-muted: #86868b;
  --series-1: #2e6b5b;      /* Waldgrün – bestiegen / Wiederholungen */
  --series-2: #1e86c8;      /* Blau – neue Gipfel */
  --series-3: #7a5cc2;      /* Violett – 3. Route */
  --seq-0: #ececf0; --seq-1: #b9d6cb; --seq-2: #7fb5a2; --seq-3: #2e6b5b; --seq-4: #173d33;
  --open: #8e8e93;
  --accent: #2e6b5b;
  --highlight: #1e86c8;     /* Buttons, Links, Hervorhebung */
  --glacier: #8fd3f4;       /* Gletscherblau: Logo, Ring, Leuchten */
  --danger: #c9423a;        /* Alpenrot: offen/fehlend, Fehler, Löschen, Privatzonen, hinter Plan */
  --danger-soft: #f7dcd9;   /* Alpenrot als Fläche */
  --complete-bg: #dcf1ea; --complete-border: #a9d9c8;  /* abgeschlossen: leichtes Türkis */
  --font-display: "Barlow Semi Condensed", "Inter", system-ui, sans-serif;
  --track: #1677c4;         /* kräftiges Blau für Touren auf der Karte */
  --track-casing: #ffffff;
  --track-other: #2e6b5b;   /* Touren ohne Gipfel: Waldgrün, dünn */
  --strava: #fc4c02;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 10px 30px -14px rgba(0,0,0,.14);
  --radius: 20px;
  --ease: cubic-bezier(.22,1,.36,1);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #12261f; --surface-1: #1a372d; --surface-2: #21443a; --border: #2a5143; --grid: #24493c;
    --text-primary: #f5f5f7; --text-secondary: #b3c4bc; --text-muted: #8aa197;
    --series-1: #4f9a83; --series-2: #8fd3f4; --series-3: #b9a3f0;
    --seq-0: #21443a; --seq-1: #2e6b5b; --seq-2: #4f9a83; --seq-3: #8fcab3; --seq-4: #d3efe3;
    --open: #8aa197; --accent: #4f9a83; --highlight: #8fd3f4; --track: #5cc0f5; --track-other: #8fcab3; --danger: #f0786e; --danger-soft: rgba(240,120,110,.18); --complete-bg: #24564a; --complete-border: #3f8a76;
    --shadow: none;
    --bar-bg: rgba(18,38,31,.86); --bar-fg: #f5f5f7; --bar-muted: #b3c4bc;
    --bar-hover: rgba(255,255,255,.12); --bar-active: rgba(255,255,255,.14); --bar-line: rgba(255,255,255,.1);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #12261f; --surface-1: #1a372d; --surface-2: #21443a; --border: #2a5143; --grid: #24493c;
  --text-primary: #f5f5f7; --text-secondary: #b3c4bc; --text-muted: #8aa197;
  --series-1: #4f9a83; --series-2: #8fd3f4; --series-3: #b9a3f0;
  --seq-0: #21443a; --seq-1: #2e6b5b; --seq-2: #4f9a83; --seq-3: #8fcab3; --seq-4: #d3efe3;
  --open: #8aa197; --accent: #4f9a83; --highlight: #8fd3f4; --track: #5cc0f5; --track-other: #8fcab3; --danger: #f0786e; --danger-soft: rgba(240,120,110,.18); --complete-bg: #24564a; --complete-border: #3f8a76;
  --shadow: none;
  --bar-bg: rgba(18,38,31,.86); --bar-fg: #f5f5f7; --bar-muted: #b3c4bc;
  --bar-hover: rgba(255,255,255,.12); --bar-active: rgba(255,255,255,.14); --bar-line: rgba(255,255,255,.1);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 400 14px/1.47 Inter, -apple-system, system-ui, sans-serif;
  font-feature-settings: "tnum" 1, "cv11" 1; /* gleich breite Ziffern für Tabellen */
  letter-spacing: -.01em;
  background: var(--bg); color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
.muted { color: var(--text-muted); }
.small { font-size: 12px; }
h1, h2 { margin: 0; letter-spacing: 0; font-family: var(--font-display); }
h2 { font-size: 19px; font-weight: 600; }

/* --- Topbar (wie jenhikes .lnav: Waldgrün, transluzent) --- */
.topbar {
  position: sticky; top: 0; z-index: 1000;
  display: flex; align-items: center; gap: 24px; padding: 0 24px; height: 56px;
  background: var(--bar-bg); color: var(--bar-fg);
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--bar-line);
}
.brand { display: flex; align-items: flex-end; gap: .125em; font-family: var(--font-display); font-weight: 600; font-size: 25px; line-height: 1; letter-spacing: .01em; cursor: pointer; }
/* Logo: oberste Kachel = Oberkante „K“, Bergfuß = Grundlinie (siehe summitlog/brand.py) */
.brand .logo { height: 1.199em; width: 1.599em; margin-bottom: .068em; flex: none; display: block; }
.brand .logo.dark { display: none; }
.brand svg { color: var(--highlight); }
.brand span b { font-weight: 600; color: var(--highlight); }
.tabs { display: flex; gap: 2px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.tabs button {
  background: none; border: 0; padding: 6px 14px; border-radius: 999px; cursor: pointer;
  font: inherit; font-size: 13px; font-weight: 500; color: var(--bar-muted); white-space: nowrap;
  transition: background-color .25s, color .25s;
}
.tabs button:hover { color: var(--bar-fg); background: var(--bar-hover); }
.tabs button.active { background: var(--bar-active); color: var(--bar-fg); }
.account { display: flex; align-items: center; gap: 12px; }
.athlete { font-weight: 500; font-size: 13px; color: var(--bar-muted); white-space: nowrap; }
.sync { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.sync .muted { color: var(--bar-muted); }
.btn {
  font: inherit; font-weight: 500; border-radius: 999px; padding: 7px 16px; cursor: pointer;
  border: 0; background: var(--surface-2); color: var(--text-primary);
  text-decoration: none; display: inline-flex; align-items: center; gap: 6px;
  transition: transform .1s ease-out, filter .25s, background-color .25s;
}
.btn:active { transform: scale(.97); }
.btn:hover { filter: brightness(1.05); }
.topbar .btn.ghost { background: transparent; color: var(--bar-fg); font-size: 13px; }
.topbar .btn.ghost:hover { background: var(--bar-hover); }
.btn.icon { padding: 6px 10px; }
.btn.strava { background: var(--strava); color: #fff; padding: 14px 26px; font-size: 17px; }
.btn.primary { background: var(--highlight); color: #fff; }
.link { background: none; border: 0; color: var(--highlight); cursor: pointer; font: inherit; font-weight: 500; }

/* --- Filter --- */
.filters {
  display: flex; gap: 16px; align-items: center; flex-wrap: wrap;
  padding: 18px 24px 0; max-width: 1440px; margin: 0 auto;
}
.filters label { display: flex; gap: 8px; align-items: center; color: var(--text-secondary); font-weight: 500; }
select, input[type=search] {
  font: inherit; color: var(--text-primary); background: var(--surface-1);
  border: 1px solid var(--border); border-radius: 999px; padding: 6px 14px;
}
input[type=search] { min-width: 200px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  font: inherit; font-size: 13px; font-weight: 500; padding: 5px 13px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface-1); color: var(--text-secondary);
  transition: background-color .2s, color .2s;
}
.chip[aria-pressed="true"] { background: var(--accent); color: #fff; border-color: var(--accent); }

main { max-width: 1440px; margin: 0 auto; padding: 18px 24px 48px; }
.tab { display: none; }
.tab.active { display: block; animation: materialize .5s var(--ease); }
@keyframes materialize { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* --- Cards --- */
.card {
  background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px 22px; box-shadow: var(--shadow); min-width: 0;
}
.card > header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.span2 { grid-column: span 2; }
.span3 { grid-column: span 3; }
.chart { position: relative; height: 250px; }

/* KPI tiles (wie jenhikes .stat) */
.kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.kpi { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); min-width: 0; }
.kpi .label { color: var(--text-secondary); font-size: 12px; font-weight: 500; }
.kpi .value { font-family: var(--font-display); font-size: 34px; font-weight: 600; letter-spacing: 0; line-height: 1.1; margin-top: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .sub { color: var(--text-muted); font-size: 12px; margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi:first-child .value { color: var(--highlight); }

/* Legend swatches */
.legend { display: flex; gap: 10px; align-items: center; font-size: 12px; color: var(--text-secondary); }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: -4px; }
.sw.s1 { background: var(--series-1); } .sw.s2 { background: var(--series-2); }

/* Top-Gipfel (sortierbare Mini-Tabelle) */
.top-wrap { max-height: 262px; overflow: auto; margin: 0 -8px; }
.top-tbl { width: 100%; border-collapse: collapse; }
.top-tbl th { position: sticky; top: 0; background: var(--surface-1); font-size: 11px; font-weight: 500; color: var(--text-muted);
  text-align: left; padding: 0 8px 6px; cursor: pointer; user-select: none; white-space: nowrap; z-index: 1; }
.top-tbl th.num, .top-tbl td.num { text-align: right; }
.top-tbl th.sorted { color: var(--text-primary); }
.top-tbl th.sorted::after { content: " ↓"; } .top-tbl th.sorted.asc::after { content: " ↑"; }
.top-tbl td { padding: 5px 8px; border-top: 1px solid var(--grid); white-space: nowrap; }
.top-tbl tbody tr { cursor: pointer; }
.top-tbl tbody tr:hover td { background: var(--surface-2); }
.top-tbl td.nm { max-width: 150px; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
.top-tbl td.ele { color: var(--text-secondary); }
.top-tbl td.ct { width: 40%; }
.top-tbl .cnt { display: flex; align-items: center; gap: 8px; justify-content: flex-end; }
.top-tbl .bar { height: 6px; border-radius: 3px; background: var(--series-1); }
.top-tbl .cnt b { min-width: 28px; text-align: right; font-weight: 600; }

/* Calendar heatmap */
.calendar { overflow-x: auto; }
.calendar svg { display: block; }
.calendar .lbl { fill: var(--text-muted); font-size: 10px; font-family: Inter, sans-serif; }

/* List progress */
.list-progress { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.list-progress.big { margin-bottom: 16px; }
.lp { border: 1px solid var(--border); border-radius: 16px; padding: 14px 16px; cursor: pointer; background: var(--surface-1); text-align: left; font: inherit; color: inherit; transition: border-color .2s; }
.lp:hover, .lp.active { border-color: var(--highlight); }
.lp .t { display: flex; justify-content: space-between; font-weight: 600; }
.lp .d { color: var(--text-muted); font-size: 12px; margin: 2px 0 10px; }
.lp .track { height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; container-type: inline-size; }
.lp .fill { height: 100%; background: linear-gradient(90deg, var(--highlight), var(--series-1)) 0 0 / 100cqw 100% no-repeat; border-radius: 3px; min-width: 2px; }

/* Tables */
.split { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 16px; align-items: start; }
.table-card { padding-bottom: 6px; }
.table-scroll { max-height: calc(100vh - 270px); overflow: auto; margin: 0 -22px; }
.table-scroll.tall { max-height: calc(100vh - 240px); }
.tbl { width: 100%; border-collapse: collapse; }
.tbl th, .tbl td { padding: 7px 10px; text-align: left; border-bottom: 1px solid var(--grid); white-space: nowrap; }
.tbl th:first-child, .tbl td:first-child { padding-left: 22px; }
.tbl th:last-child, .tbl td:last-child { padding-right: 22px; }
.tbl th { position: sticky; top: 0; background: var(--surface-1); font-size: 12px; color: var(--text-secondary); font-weight: 500; cursor: pointer; user-select: none; z-index: 1; }
.tbl th.sorted { color: var(--text-primary); }
.tbl th.sorted::after { content: " ↓"; } .tbl th.sorted.asc::after { content: " ↑"; }
.tbl td.num, .tbl th.num { text-align: right; }
.tbl tbody tr { cursor: pointer; }
.tbl tbody tr:hover { background: var(--surface-2); }
.tbl tbody tr.sel { background: var(--surface-2); box-shadow: inset 3px 0 0 var(--highlight); }
.tbl td.wrap { white-space: normal; color: var(--text-secondary); font-size: 13px; min-width: 200px; }
/* lange Tourennamen umbrechen statt die Tabelle zu sprengen */
.tbl td.tour { white-space: normal; min-width: 180px; max-width: 320px; line-height: 1.35; }
.tbl td.peaks-col { min-width: 160px; max-width: 300px; }
.tbl tr.open td { color: var(--text-muted); }
#peakTable td:first-child { max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
.badge { display: inline-block; font-size: 11px; padding: 1px 8px; border-radius: 999px; background: var(--surface-2); color: var(--text-secondary); margin-left: 6px; font-weight: 500; }
.badge.prov { border: 1px dashed var(--text-muted); background: transparent; }
.tick { color: var(--series-1); font-weight: 700; }
.alt-name { color: var(--text-muted); font-size: 12px; margin-left: 6px; }

/* Peak detail */
.detail .empty { color: var(--text-muted); padding: 40px 0; text-align: center; }
.detail h1 { font-size: 26px; font-weight: 600; letter-spacing: -.035em; }
.detail .meta { color: var(--text-secondary); margin: 4px 0 14px; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.detail .stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 14px; }
.detail .stats div { background: var(--surface-2); border-radius: 14px; padding: 10px 12px; }
.detail .stats b { display: block; font-size: 19px; font-weight: 600; letter-spacing: -.03em; }
.detail .stats span { font-size: 12px; color: var(--text-secondary); }
.detail h3 { font-size: 13px; margin: 18px 0 8px; color: var(--text-secondary); font-weight: 600; }
.small-map { height: 320px; border-radius: 14px; }
.routes { display: flex; flex-direction: column; gap: 4px; }
.route { display: grid; grid-template-columns: 14px 1fr auto auto; gap: 10px; align-items: center; padding: 6px 10px; border-radius: 10px; cursor: pointer; }
.route:hover, .route.active { background: var(--surface-2); }
.route i { width: 12px; height: 4px; border-radius: 2px; }
.route .r-n { color: var(--text-secondary); }
.mini-bars { display: flex; align-items: flex-end; gap: 2px; height: 48px; }
.mini-bars div { flex: 1; background: var(--series-1); border-radius: 4px 4px 0 0; min-height: 0; position: relative; }
.mini-years { display: flex; gap: 2px; font-size: 10px; color: var(--text-muted); }
.mini-years span { flex: 1; text-align: center; }
.detail .tbl td, .detail .tbl th { padding: 6px 8px; }
.detail .table-scroll { max-height: 320px; margin: 0; }
.detail .tbl th:first-child, .detail .tbl td:first-child { padding-left: 8px; }

/* Map */
.map-wrap { position: relative; }
.map { height: calc(100vh - 180px); min-height: 420px; border-radius: var(--radius); border: 1px solid var(--border); z-index: 0; }
.map-panel { position: absolute; top: 12px; right: 12px; z-index: 500; display: flex; flex-direction: column; gap: 6px; padding: 14px 16px; width: 260px; border-radius: 16px; }
.map-panel label { display: flex; gap: 8px; align-items: center; cursor: pointer; }
.map-panel input { accent-color: var(--accent); }
.legend-col { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--text-secondary); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; }
.dot.climbed { background: var(--series-1); box-shadow: 0 0 0 2px var(--surface-1); }
.dot.open { border: 2px solid var(--open); background: transparent; }
.ln { display: inline-block; width: 18px; height: 3px; border-radius: 2px; margin-right: 6px; vertical-align: 3px; }
.ln.peak { background: var(--track); height: 4px; box-shadow: 0 0 0 1.5px #fff; }
.ln.other { background: var(--track-other); height: 2px; }
.leaflet-container { font: inherit; background: var(--surface-2); }
.leaflet-popup-content { margin: 10px 12px; }
.leaflet-tooltip { font-family: Inter, sans-serif; border-radius: 8px; }

/* Tooltip */
.tooltip {
  position: fixed; pointer-events: none; z-index: 2000; display: none;
  background: var(--surface-1); color: var(--text-primary); border: 1px solid var(--border);
  border-radius: 10px; padding: 6px 10px; font-size: 12px; box-shadow: 0 8px 24px rgba(0,0,0,.14);
}

/* Connect */
.connect { display: grid; place-items: center; min-height: 80vh; padding: 16px; background: var(--forest); color: #f5f5f7; }
.connect-card { max-width: 560px; text-align: center; }
.connect-card h1 { font-size: clamp(36px, 6vw, 64px); font-weight: 600; letter-spacing: -.035em; line-height: 1.05; margin-bottom: 16px; }
.connect-card h1 em { font-style: normal; background: linear-gradient(100deg, #4f9a83 0%, #9fd3c0 40%, #8fd3f4 70%, #1e86c8 100%); -webkit-background-clip: text; background-clip: text; color: transparent; }
.connect-card p { color: var(--forest-text); font-size: 18px; margin-bottom: 28px; }

@media (max-width: 1100px) {
  /* Tabs in eigene Zeile, damit alle sichtbar bleiben */
  .topbar { flex-wrap: wrap; height: auto; padding-top: 8px; padding-bottom: 6px; row-gap: 4px; }
  .tabs { order: 3; flex-basis: 100%; }
  .account { margin-left: auto; }
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid { grid-template-columns: minmax(0, 1fr); }
  .span2, .span3 { grid-column: auto; }
  .split { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; gap: 6px; padding: 8px 16px; height: auto; }
  .tabs { order: 3; width: 100%; }
  .athlete { display: none; }
  .filters, main { padding-left: 16px; padding-right: 16px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi .value { font-size: 22px; }
  .detail .stats { grid-template-columns: repeat(2, 1fr); }
  .map-panel { position: static; width: auto; margin-top: 10px; }
  input[type=search] { min-width: 0; width: 100%; }
}

/* Listen-Filter */
.list-filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.list-filters input[type=search] { min-width: 220px; }
.list-filters .lf-rule { flex-basis: 100%; margin: 0; }
.lp.complete { border-color: color-mix(in srgb, var(--series-1) 60%, transparent); }
#listProgress { max-height: 420px; overflow: auto; padding-right: 4px; }

/* Logo-Variante je Modus */
:root[data-theme="dark"] .brand .logo.light { display: none; }
:root[data-theme="dark"] .brand .logo.dark { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .brand .logo.light { display: none; }
  :root:not([data-theme="light"]) .brand .logo.dark { display: block; }
}

/* fehlender Listengipfel: roter Punkt wie auf der Karte */
.miss { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--danger); margin: 0 7px 1px 2px; }

/* Ziel-Stern in Listen */
.goal-cell { width: 44px; text-align: center; }
.goal-star { border: 0; background: none; cursor: pointer; font-size: 20px; line-height: 1; padding: 2px 6px; color: var(--text-muted); border-radius: 8px; }
.goal-star:hover { color: #e6b422; background: var(--surface-2); }
.goal-star.on { color: #e6b422; }
