:root {
  --bg: #f7f7f8;
  --surface: #ffffff;
  --border: #e3e3e6;
  --text: #1b1b1f;
  --muted: #6b6b76;
  --accent: #4a5fd9;
  --win: #1f8a52;
  --loss: #c0392b;
  --unreliable: #9a9aa4;
  --radius: 10px;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #16161a; --surface: #1e1e23; --border: #33333b;
    --text: #ececf1; --muted: #9a9aa8; --accent: #8b9cff;
    --win: #4ecf8a; --loss: #ff7a6b; --unreliable: #6a6a76;
  }
}
:root[data-theme="dark"] {
  --bg: #16161a; --surface: #1e1e23; --border: #33333b;
  --text: #ececf1; --muted: #9a9aa8; --accent: #8b9cff;
  --win: #4ecf8a; --loss: #ff7a6b; --unreliable: #6a6a76;
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}
.wrap { max-width: 1400px; margin: 0 auto; padding: 24px 20px 80px; }
header { margin-bottom: 24px; }
h1 { font-size: 22px; margin: 0 0 4px; letter-spacing: -0.01em; }
h2 { font-size: 16px; margin: 0 0 12px; letter-spacing: -0.01em; }
.sub { color: var(--muted); font-size: 13px; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 28px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.card .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.card .value { font-size: 24px; font-weight: 600; margin-top: 4px; font-variant-numeric: tabular-nums; }
.card .note { color: var(--muted); font-size: 12px; margin-top: 2px; }

section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin-bottom: 20px; }

.scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { padding: 7px 10px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; position: sticky; top: 0; background: var(--surface); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--mono); }
tbody tr:hover { background: color-mix(in srgb, var(--accent) 7%, transparent); }

.matrix td.cell { text-align: center; font-family: var(--mono); font-size: 12px; padding: 4px 8px; }
.matrix td.cell .wr { font-weight: 600; }
.matrix td.cell .n { color: var(--muted); font-size: 11px; }
.matrix td.cell.weak { opacity: .45; }
.matrix td.cell.weak .wr { font-weight: 400; font-style: italic; }
.matrix th.rowhead { position: sticky; left: 0; background: var(--surface); z-index: 1; text-transform: none; font-size: 12px; }

.bar { height: 6px; border-radius: 3px; background: var(--border); overflow: hidden; min-width: 60px; }
.bar > span { display: block; height: 100%; background: var(--accent); }

.pill { display: inline-block; padding: 1px 7px; border-radius: 99px; font-size: 11px; border: 1px solid var(--border); color: var(--muted); }
.win { color: var(--win); } .loss { color: var(--loss); }
.ci { color: var(--muted); font-size: 11px; font-family: var(--mono); }

.controls { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
select, input { background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 7px; padding: 6px 9px; font: inherit; font-size: 13px; }

.callout { border-left: 3px solid var(--accent); background: color-mix(in srgb, var(--accent) 7%, transparent); padding: 10px 14px; border-radius: 0 8px 8px 0; font-size: 13px; color: var(--muted); margin-bottom: 16px; }
.callout strong { color: var(--text); }
details summary { cursor: pointer; color: var(--muted); font-size: 13px; }

/* Tab-Navigation. Klebt oben, damit der Wechsel auch am Ende einer langen
   Tabelle moeglich ist, ohne erst hochzuscrollen. */
.tabs {
  display: flex; gap: 4px; margin-bottom: 20px; position: sticky; top: 0; z-index: 3;
  background: var(--bg); padding: 8px 0; border-bottom: 1px solid var(--border);
}
.tabs .tab {
  appearance: none; border: 1px solid transparent; background: transparent; color: var(--muted);
  font: inherit; font-size: 14px; font-weight: 500; padding: 8px 14px; border-radius: 8px; cursor: pointer;
}
.tabs .tab:hover { color: var(--text); background: color-mix(in srgb, var(--accent) 8%, transparent); }
.tabs .tab.active { color: var(--text); background: var(--surface); border-color: var(--border); }

.panel { display: none; }
.panel.active { display: block; }

button { font: inherit; }
.controls button {
  background: var(--bg); color: var(--text); border: 1px solid var(--border);
  border-radius: 7px; padding: 6px 10px; font-size: 13px; cursor: pointer;
}
.controls button:hover { border-color: var(--accent); color: var(--accent); }

/* Spalten mit Erklaerung sichtbar machen - sonst probiert niemand den Hover aus. */
th.hint { cursor: help; text-decoration: underline dotted 1px; text-underline-offset: 3px; }
th.hint:hover { color: var(--text); }

/* Kopfzahlen mit Erklaerung - gleiche Geste wie bei den Spaltenkoepfen. */
.card.hint { cursor: help; }
.card.hint .label { text-decoration: underline dotted 1px; text-underline-offset: 3px; }

/* Manakurve der Deckliste. Bewusst klein: sie ist Kontext, nicht die Hauptsache. */
.curve { display: flex; gap: 6px; align-items: flex-end; margin: 4px 0 16px; }
.curve-col { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 34px; }
.curve-bar { width: 100%; background: var(--accent); border-radius: 3px 3px 0 0; opacity: .75; }
.curve-n { font-size: 11px; font-family: var(--mono); }
.curve-k { font-size: 11px; color: var(--muted); border-top: 1px solid var(--border); width: 100%; text-align: center; padding-top: 2px; }

/* Seltene Zeilen bleiben im Dokument, werden aber erst auf Wunsch gezeigt. */
.hide-rare tr.rare { display: none; }
tr.rare td { opacity: .65; }
.toggle-rare {
  background: none; border: none; color: var(--accent); font: inherit; font-size: 12px;
  cursor: pointer; padding: 6px 0; text-decoration: underline dotted; text-underline-offset: 3px;
}

/* Antwortzeile: das Ergebnis eines Abschnitts, bevor die Tabelle kommt. */
.answer {
  font-size: 15px; margin: 0 0 14px; padding: 10px 14px; border-radius: 8px;
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  border-left: 3px solid var(--accent);
}
details > summary { cursor: pointer; }
details[open] > summary { margin-bottom: 6px; }
