/*
 * keep CALM! Leaderboard – Gestaltung
 * ===================================
 * Farben stehen als Variablen in :root (dunkel) und [data-theme="light"]. Die Akzentfarbe (--accent,
 * --on-accent) setzt main.js aus den Einstellungen (CI). Sektorfarbe Violett = beste Zeit der Liste,
 * wie auf Zeitenmonitoren üblich. Breiten: bis 1099 px Karten statt Tabelle (die Tabelle braucht mit Sektoren rund 1100 px), ab 1100 px Tabelle.
 */
:root {
  --bg: #0d1013; --panel: #161a1f; --panel2: #1e242b; --line: #2a313a; --text: #e9edf0; --muted: #8d98a3;
  --accent: #c8f31d; --on-accent: #0d1013; --best: #c084fc; --bad: #ff6b6b; --ok: #4ade80; --warn: #fbbf24;
  --r: 10px; --num: ui-monospace, "SF Mono", "Cascadia Mono", "Roboto Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: dark;
}
[data-theme="light"] {
  --bg: #f3f4f1; --panel: #ffffff; --panel2: #eceee9; --line: #d5d9d2; --text: #14181c; --muted: #5b6670;
  --best: #7e22ce; --bad: #c62828; --ok: #15803d; --warn: #a16207; color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100dvh; display: flex; flex-direction: column; background: var(--bg); color: var(--text); font: 15px/1.45 var(--sans); overflow-x: hidden; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(22px, 4.2vw, 30px); line-height: 1.15; font-weight: 800; letter-spacing: -.01em; }
h2 { font-size: 17px; font-weight: 700; }
h3 { font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--muted); } .num { font-family: var(--num); font-variant-numeric: tabular-nums; }
.pad { padding: 16px; } .hide { display: none !important; }
.stack { display: flex; flex-direction: column; gap: 14px; } .row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.grow { flex: 1 1 0; min-width: 0; } .right { margin-left: auto; }

/* Kopf und Fuß */
#top { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
#top .in, #view, #foot .in { width: 100%; max-width: 1280px; margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
#top .in { display: flex; align-items: center; gap: 6px 14px; min-height: 56px; flex-wrap: wrap; padding-top: 6px; padding-bottom: 6px; }
.brand { display: flex; align-items: baseline; gap: 8px; text-decoration: none; margin-right: auto; white-space: nowrap; }
.brand b { font-size: 19px; font-weight: 900; letter-spacing: -.02em; } .brand b i { font-style: normal; color: var(--accent); }
.brand span { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .12em; }
nav { display: flex; gap: 4px; align-items: center; }
nav a, nav button { min-height: 40px; padding: 0 12px; border-radius: 20px; border: 0; background: none; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; font-weight: 650; font-size: 14px; white-space: nowrap; }
.ic-theme { width: 18px; height: 18px; border-radius: 50%; border: 2px solid currentColor; background: linear-gradient(90deg, currentColor 50%, transparent 50%); }
table.lb td.nw { white-space: nowrap; }
nav a:hover, nav button:hover { background: var(--panel2); } nav a.on { background: var(--panel2); box-shadow: inset 0 -2px 0 var(--accent); }
#view { flex: 1; padding-top: 22px; padding-bottom: 40px; outline: 0; }
#foot { border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }
#foot .in { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; padding-top: 12px; padding-bottom: max(12px, env(safe-area-inset-bottom)); }
#foot button { background: none; border: 0; padding: 6px 0; color: inherit; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; min-height: 32px; }

/* Bausteine */
.btn { min-height: 42px; padding: 0 16px; border-radius: var(--r); border: 1px solid var(--line); background: var(--panel2); font-weight: 650; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; white-space: nowrap; text-decoration: none; }
.btn:hover { border-color: var(--muted); } .btn.pri { background: var(--accent); color: var(--on-accent); border-color: transparent; } .btn.small { min-height: 34px; padding: 0 12px; font-size: 13px; }
.btn.danger { color: var(--bad); } .btn:disabled { opacity: .5; cursor: default; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; }
.chip { display: inline-flex; align-items: center; height: 24px; padding: 0 8px; border-radius: 6px; background: var(--panel2); font-size: 12px; font-weight: 700; white-space: nowrap; }
.chip.acc { background: var(--accent); color: var(--on-accent); } .chip.warn { color: var(--warn); } .chip.bad { color: var(--bad); } .chip.ok { color: var(--ok); }
label.f { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 700; color: var(--muted); min-width: 0; }
label.f > input, label.f > select, label.f > textarea, input.in, select.in { min-height: 42px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--text); font-size: 15px; font-weight: 500; width: 100%; min-width: 0; }
label.f > input[type="color"] { padding: 4px; } label.c { display: flex; align-items: center; gap: 10px; min-height: 42px; cursor: pointer; font-weight: 600; }
label.c input { width: 20px; height: 20px; accent-color: var(--accent); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.seg button { min-height: 40px; padding: 0 14px; border: 0; background: var(--panel); font-weight: 650; cursor: pointer; font-size: 14px; }
.seg button + button { border-left: 1px solid var(--line); } .seg button.on { background: var(--accent); color: var(--on-accent); }
.empty { padding: 36px 16px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--r); }
.err { color: var(--bad); font-weight: 600; }
#toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 22px; font-weight: 650; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 60; max-width: calc(100vw - 32px); text-align: center; }
#toast.on { opacity: 1; }
dialog { border: 1px solid var(--line); border-radius: 14px; background: var(--panel); color: var(--text); padding: 0; width: min(640px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); }
dialog::backdrop { background: rgba(0, 0, 0, .6); }
dialog .hd { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--panel); z-index: 1; }
dialog .bd { padding: 16px; display: flex; flex-direction: column; gap: 14px; }
dl.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 0; } dl.kv dt { color: var(--muted); } dl.kv dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }

/* Startseite */
.hero { display: grid; gap: 18px; grid-template-columns: 1fr; margin-bottom: 22px; }
.hero p { color: var(--muted); max-width: 60ch; margin-top: 8px; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; }
.stat b { display: block; font: 800 clamp(22px, 5vw, 32px)/1.1 var(--num); } .stat span { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.venues { display: grid; gap: 12px; align-items: start; grid-template-columns: repeat(auto-fill, minmax(min(100%, 380px), 1fr)); margin-top: 14px; }
.venue h2 { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.variant { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 10px 12px; margin: 0 -12px; border-radius: 8px; text-decoration: none; align-items: center; }
.variant:hover { background: var(--panel2); } .variant b { font-weight: 650; overflow-wrap: anywhere; } .variant .t { font: 800 18px var(--num); color: var(--accent); grid-row: span 2; }
.variant small { color: var(--muted); font-size: 12.5px; }
[data-theme="light"] .variant .t { color: var(--text); }

/* Bestenliste */
.crumb { font-size: 13px; color: var(--muted); text-decoration: none; display: inline-block; padding: 4px 0; } .crumb:hover { color: var(--text); }
.filters { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin: 14px 0; }
.board-meta { display: flex; flex-wrap: wrap; gap: 6px 16px; color: var(--muted); font-size: 13px; margin: 10px 0 4px; }
table.lb { width: 100%; border-collapse: collapse; }
table.lb th { text-align: left; font-size: 11.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.lb td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.lb tr.r { cursor: pointer; } table.lb tr.r:hover td { background: var(--panel); }
table.lb .pos { font: 800 15px var(--num); color: var(--muted); width: 1%; } table.lb tr.p1 .pos { color: var(--accent); }
[data-theme="light"] table.lb tr.p1 .pos { color: var(--text); }
table.lb .time { font: 800 17px var(--num); white-space: nowrap; } table.lb .gap, table.lb .sec { font: 500 13px var(--num); color: var(--muted); white-space: nowrap; }
table.lb .sec.best { color: var(--best); font-weight: 800; } table.lb .who b { display: block; font-weight: 700; } table.lb .who small, table.lb .sub { color: var(--muted); font-size: 12.5px; display: block; }
table.lb .secs { display: flex; flex-wrap: wrap; gap: 2px 12px; max-width: 260px; } .lb-cards { display: none; }
.lbc { display: grid; grid-template-columns: auto 1fr auto; gap: 4px 12px; padding: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); cursor: pointer; align-items: baseline; }
.lbc .pos { font: 800 18px var(--num); color: var(--muted); } .lbc.p1 .pos { color: var(--accent); } .lbc .time { font: 800 19px var(--num); text-align: right; }
.lbc .who { font-weight: 700; min-width: 0; overflow-wrap: anywhere; } .lbc .full { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 13px; color: var(--muted); }
.lbc .secs { font: 500 12.5px var(--num); gap: 4px 12px; } .lbc .secs .best { color: var(--best); font-weight: 800; }
[data-theme="light"] .lbc.p1 .pos { color: var(--text); }
.pager { display: flex; justify-content: center; align-items: center; gap: 12px; margin-top: 16px; }

/* Vergleich */
.cmp { display: grid; gap: 10px; } .cmp-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; align-items: baseline; }
.cmp-row b { overflow-wrap: anywhere; } .cmp-row .time { font: 800 16px var(--num); } .cmp-row small { color: var(--muted); grid-column: 1 / -1; font-size: 12.5px; }
.bar { grid-column: 1 / -1; height: 10px; background: var(--panel2); border-radius: 5px; position: relative; overflow: hidden; }
.bar i { position: absolute; inset: 0 auto 0 0; background: var(--accent); border-radius: 5px; } .bar u { position: absolute; top: 0; bottom: 0; width: 3px; background: var(--text); }

/* Verwaltung */
.tabs { display: flex; gap: 6px; overflow-x: auto; margin: 14px 0; padding-bottom: 2px; scrollbar-width: none; } .tabs::-webkit-scrollbar { display: none; }
.tabs button { min-height: 40px; padding: 0 14px; border-radius: 20px; border: 1px solid var(--line); background: var(--panel); font-weight: 650; white-space: nowrap; cursor: pointer; }
.tabs button.on { background: var(--accent); color: var(--on-accent); border-color: transparent; }
.grid2 { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); }
.cls-row { display: grid; grid-template-columns: minmax(60px, .6fr) minmax(0, 1.4fr) minmax(70px, .8fr) auto; gap: 8px; align-items: end; }
.chain { display: flex; flex-wrap: wrap; gap: 6px; align-items: stretch; }
.chain .blk { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 12px; min-width: 0; flex: 1 1 150px; background: var(--panel2); }
.chain .blk code, .hash { font: 12px var(--num); color: var(--muted); overflow-wrap: anywhere; } .chain .arr { align-self: center; color: var(--muted); font-weight: 800; }
.log { display: grid; gap: 8px; } .log .e { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
.log .e .st { grid-row: span 3; font-weight: 800; font-size: 18px; } .log .e .st.ok { color: var(--ok); } .log .e .st.bad { color: var(--bad); }
.auth { max-width: 440px; margin: 6vh auto 0; }

@media (max-width: 1099px) { table.lb { display: none; } .lb-cards { display: grid; gap: 8px; } }
@media (max-width: 759px) {
  .brand span { display: none; } nav a, nav button { padding: 0 10px; }
  .cls-row { grid-template-columns: 1fr 1fr; } .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 900px) { .hero { grid-template-columns: 1.2fr 1fr; align-items: end; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
