/* ExamLab -- Handy-first (Probeklausur), Beamer, Admin; hell/dunkel nach Systemeinstellung oder
   Umschalter. Keine externen Ressourcen. Grundgerüst, Kopfzeile und Knöpfe aus dem FeedbackLab. */

:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --ink: #1d2433;
  --muted: #5f6b7f;
  --line: #d5dae2;
  --accent: #2563eb;
  --accent-ink: #ffffff;
  --ok: #15803d;
  --ok-bg: #e8f6ec;
  --bad: #dc2626;
  --bad-bg: #fdecec;
  --warn: #b45309;
  --warn-bg: #fdf3e2;
  --code-bg: #eef1f6;
  --radius: 12px;
  --logo: #2a2068;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}

/* Dunkles Schema: per Systemeinstellung oder per Umschalter (data-theme, theme.ts) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12161f; --panel: #1b212d; --ink: #e6e9ef; --muted: #9aa5b7; --line: #2f3747;
    --accent: #5b8cff; --ok: #4ade80; --ok-bg: #173323; --bad: #f87171; --bad-bg: #3a1c1c;
    --warn: #fbbf24; --warn-bg: #3a2c12; --code-bg: #252c3a;
    --logo: #c9c3f2;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #12161f; --panel: #1b212d; --ink: #e6e9ef; --muted: #9aa5b7; --line: #2f3747;
  --accent: #5b8cff; --ok: #4ade80; --ok-bg: #173323; --bad: #f87171; --bad-bg: #3a1c1c;
    --warn: #fbbf24; --warn-bg: #3a2c12; --code-bg: #252c3a;
  --logo: #c9c3f2;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font-size: 16px; line-height: 1.4; -webkit-text-size-adjust: 100%; }
main { padding: 16px max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom))
       max(16px, env(safe-area-inset-left)); margin: 0 auto; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.icon { width: 1.15em; height: 1.15em; vertical-align: -0.2em; flex: none; }

/* ---------------------------------------------------------------- Kopfzeile mit Logo */

.site-header {
  display: flex; align-items: center; gap: 12px;
  padding: max(8px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 8px
           max(16px, env(safe-area-inset-left));
  background: var(--panel); border-bottom: 1px solid var(--line);
}
.site-brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink);
              max-width: 1500px; width: 100%; margin: 0 auto; }
.theme-toggle { flex: none; display: grid; place-items: center; width: 44px; height: 44px;
  border: 1px solid var(--line); border-radius: 50%; background: var(--bg); color: var(--ink); cursor: pointer; }
.theme-toggle .icon { width: 22px; height: 22px; }
.hs-logo { height: 30px; width: auto; color: var(--logo); flex: none; }
.site-org { font-weight: 600; color: var(--logo); }
.site-name { font-weight: 800; padding-left: 10px; border-left: 2px solid var(--line); }
.site-brand a { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; }
.site-brand .hs-link:hover .site-org { text-decoration: underline; }
.site-footer { text-align: center; font-size: .8rem; color: var(--muted);
               padding: 24px 16px max(16px, env(safe-area-inset-bottom)); }
.site-footer a { color: inherit; }

@media (max-width: 500px) {
  .site-org { display: none; }
  .site-name { padding-left: 0; border-left: 0; }
}

/* ---------------------------------------------------------------- Knöpfe, Hinweise */

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px;
  padding: 0 20px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel);
  font-weight: 700; cursor: pointer; text-decoration: none; color: var(--ink); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.danger { color: var(--bad); border-color: var(--bad); background: var(--panel); }
.btn.danger.solid { background: var(--bad); color: #fff; }
.btn:disabled { opacity: .6; cursor: default; }
.btn.small { min-height: 36px; padding: 0 12px; font-size: .9rem; }
.notice { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; text-align: center; }
.notice h1 { font-size: 1.4rem; margin: 0 0 8px; }
.notice p { margin: 0 0 12px; color: var(--muted); }
.error { color: var(--bad); font-weight: 600; }

/* ---------------------------------------------------------------- Code-Eingabe, Hinweise */

code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: .95em; background: var(--code-bg);
       padding: 1px 5px; border-radius: 5px; white-space: nowrap; }
.code-form { text-align: center; }
.code-input { display: block; width: 100%; max-width: 260px; margin: 8px auto 12px; padding: 10px 12px;
              font-size: 2rem; font-weight: 700; letter-spacing: .2em; text-align: center; font-variant-numeric: tabular-nums;
              border: 2px solid var(--line); border-radius: 12px; background: var(--bg); }
.code-input:focus { outline: none; border-color: var(--accent); }
.tipp { font-size: .85rem; color: var(--muted); margin: 8px 0 0; }
.privacy { color: var(--muted); font-size: .85rem; margin-top: 1.5rem; }
.danke .haken { width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; margin: 0 auto 12px;
  background: var(--ok-bg); color: var(--ok); }
.danke .haken .icon { width: 36px; height: 36px; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.row-between { display: flex; flex-wrap: wrap; gap: 10px; align-items: baseline; justify-content: space-between; }
.klein { font-size: .82rem; }

/* ---------------------------------------------------------------- Klausur */

#app { max-width: 720px; }
.form-head h1 { font-size: 1.6rem; margin: 4px 0; }
.form-head p { margin: 0 0 4px; color: var(--muted); }
.zeitleiste { position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; gap: 12px;
  align-items: center; margin: -16px -16px 12px; padding: 10px 16px; background: var(--panel);
  border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.zeitleiste .uhr { display: inline-flex; align-items: center; gap: 6px; }
.zeitleiste strong { font-size: 1.15rem; }
.zeitleiste.knapp { background: var(--warn-bg); color: var(--warn); }
.zeitleiste.offline::after { content: "offline -- Antworten werden nachgereicht"; color: var(--bad); font-size: .85rem; }
.gruppe { margin: 24px 0 8px; font-size: .85rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.frage { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel);
         padding: 14px; margin: 0 0 12px; min-width: 0; scroll-margin-top: 64px; }
.frage .q { font-weight: 600; font-size: 1.05rem; margin-bottom: 10px; overflow-wrap: anywhere; }
.q, .frage-text { white-space: pre-wrap; } /* mehrzeiliger Code in Fragen (text: |-) */
.nr { display: inline-grid; place-items: center; min-width: 1.7em; height: 1.7em; border-radius: 50%;
      background: var(--bg); border: 1px solid var(--line); font-size: .8rem; margin-right: 4px; vertical-align: .1em; }
.wahl { display: flex; flex-direction: column; gap: 6px; }
.option { position: relative; display: flex; align-items: center; gap: 10px; padding: 10px 12px; min-height: 48px;
  border: 1.5px solid var(--line); border-radius: 10px; background: var(--bg); cursor: pointer; }
.option input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.option .marke { flex: none; width: 20px; height: 20px; border: 2px solid var(--muted); border-radius: 50%; }
.option input[type=checkbox] ~ .marke { border-radius: 5px; }
.option:has(input:checked) { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--panel)); }
.option input:checked ~ .marke { border-color: var(--accent); background: var(--accent);
  box-shadow: inset 0 0 0 3px var(--panel); }
.option input:focus-visible ~ .marke { outline: 3px solid var(--accent); outline-offset: 2px; }
.eingabe { display: flex; align-items: center; gap: 8px; }
.eingabe input { flex: 1; min-width: 0; min-height: 48px; padding: 8px 12px; font-size: 1.15rem; border-radius: 10px;
  border: 1.5px solid var(--line); background: var(--bg); font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
.eingabe input:focus { outline: none; border-color: var(--accent); }
.eingabe input::placeholder { font-family: system-ui, sans-serif; font-size: .9rem; }
.einheit { color: var(--muted); }
.wt { border-collapse: collapse; font-variant-numeric: tabular-nums; }
.wt th, .wt td { padding: 4px 12px; text-align: center; border-bottom: 1px solid var(--line); }
.wt th { color: var(--muted); font-weight: 600; }
.wt td.bits { display: flex; gap: 6px; justify-content: center; }
.bit { width: 44px; height: 40px; border-radius: 8px; border: 1.5px solid var(--line); background: var(--bg);
       font: inherit; font-weight: 700; cursor: pointer; }
.bit[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.speicher { min-height: 1.2em; margin-top: 8px; font-size: .8rem; color: var(--muted); text-align: right; }
.speicher[data-s="ok"] { color: var(--ok); }
.speicher[data-s="fehler"] { color: var(--bad); }
.abgabe { padding: 12px 0; } /* nicht klebend: auf dem Handy wäre sonst ein Viertel des Bildschirms belegt */
.abgabe p { margin: 4px 0; }
.abgabe > .btn { width: 100%; font-size: 1.1rem; }
.bestaetigen { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }

/* ---------------------------------------------------------------- Ergebnis */

.ergebnis h2 { font-size: 1.2rem; margin: 24px 0 10px; }
.ergebnis-kopf { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 20px; }
.ergebnis-kopf h1 { font-size: 1.3rem; margin: 0 0 6px; }
.ergebnis-kopf p { margin: 6px 0 0; }
.punkte { font-size: 1.3rem; }
.punkte strong { font-size: 3rem; color: var(--accent); font-variant-numeric: tabular-nums; }
.gebiete { display: flex; flex-direction: column; gap: 14px; }
.gebiet-kopf { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.gebiet-name { font-weight: 600; }
.gebiet-wert { white-space: nowrap; font-variant-numeric: tabular-nums; }
.gebiet-zeile.gut .gebiet-wert { color: var(--ok); }
.gebiet-zeile.mittel .gebiet-wert { color: var(--warn); }
.gebiet-zeile.schwach .gebiet-wert { color: var(--bad); }
.gebiet-wert strong { color: var(--ink); }
.track { position: relative; height: 14px; border-radius: 4px; background: var(--bg); border: 1px solid var(--line);
         margin: 4px 0 2px; }
.fill { height: 100%; border-radius: 3px 4px 4px 3px; background: var(--accent); }
.schnitt { position: absolute; top: -4px; bottom: -4px; width: 3px; margin-left: -1.5px; border-radius: 2px;
           background: var(--ink); box-shadow: 0 0 0 2px var(--panel); }
.gebiet-sub { font-size: .8rem; color: var(--muted); }
.schalter { display: inline-flex; gap: 6px; align-items: center; cursor: pointer; color: var(--muted); }
.frage.auswertung { border-left-width: 5px; }
.frage.auswertung.ok { border-left-color: var(--ok); }
.frage.auswertung.falsch { border-left-color: var(--bad); }
.frage.auswertung.leer { border-left-color: var(--muted); }
.nur-falsch .frage.auswertung.ok { display: none; }
.status-marke { display: inline-flex; align-items: center; gap: 4px; font-size: .85rem; font-weight: 700; margin-bottom: 6px; }
.ok .status-marke { color: var(--ok); }
.falsch .status-marke { color: var(--bad); }
.leer .status-marke { color: var(--muted); }
.vergleich { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; margin: 0; }
.vergleich dt { color: var(--muted); }
.vergleich dd { margin: 0; overflow-wrap: anywhere; }
.wt.klein td, .wt.klein th { padding: 2px 10px; }
.wt.klein tr.falsch td:nth-last-child(2) { color: var(--bad); font-weight: 700; }
.erklaerung { margin: 10px 0 0; }
.folie { margin: 4px 0 0; font-size: .8rem; color: var(--muted); }

/* ---------------------------------------------------------------- Beamer */

#live { max-width: 1500px; }
#live header { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 16px; }
#live .brand { font-weight: 800; font-size: 1.4rem; margin-right: auto; }
.pill { display: inline-block; padding: 6px 14px; border-radius: 999px; font-weight: 600; font-size: .95rem; margin: 0; }
.pill.on { background: var(--ok-bg); color: var(--ok); }
.pill.off { background: var(--panel); color: var(--muted); border: 1px solid var(--line); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.code { background: var(--panel); border: 1px solid var(--line); font-variant-numeric: tabular-nums; letter-spacing: .04em; }
.hero { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 32px; background: var(--panel);
        border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 24px; margin-bottom: 16px; }
.hero .num { font-size: clamp(3.5rem, 11vw, 9rem); font-weight: 800; line-height: 1; color: var(--accent);
             font-variant-numeric: tabular-nums; }
.hero .num.knapp { color: var(--warn); }
.hero .sub { font-size: 1.3rem; color: var(--muted); }
.hero .zugang { margin-left: auto; text-align: right; }
.hero .url { font-size: 1.3rem; font-weight: 700; }
.hero .code { font-size: 1.3rem; color: var(--muted); }
.hero .code b { font-size: clamp(2.2rem, 5vw, 3.6rem); color: var(--ink); letter-spacing: .06em;
                font-variant-numeric: tabular-nums; margin-left: 6px; }
.beamer-auswertung { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 520px), 1fr)); gap: 16px; }
#live .gebiet-name { font-size: 1.15rem; }
.karte { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; min-width: 0; }
.karte h2, .karte h3 { margin: 0 0 12px; font-size: 1.1rem; }
.verteilung { max-width: 100%; height: auto; display: block; overflow: visible; }
.verteilung rect { fill: var(--accent); }
.verteilung rect:hover { opacity: .8; }
.verteilung line { stroke: var(--line); }
.verteilung text { fill: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.verteilung text.wert { fill: var(--ink); font-weight: 700; }

/* ---------------------------------------------------------------- Admin */

.admin { max-width: 1100px; display: flex; flex-direction: column; gap: 16px; }
.admin h1 { margin: 0; }
.admin > h2, .detail > h2 { margin: 16px 0 0; font-size: 1.2rem; }
.admin input:not([type=checkbox]) { padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--panel); min-height: 48px; }
.admin #label { flex: 1; min-width: 220px; }
.minuten { display: inline-flex; align-items: center; gap: 6px; }
.minuten input { width: 5em; }
.start { display: flex; flex-direction: column; gap: 12px; }
.gebiet-wahl { border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 6px 16px; }
.gebiet-wahl legend { padding: 0 4px; color: var(--muted); }
.gebiet-wahl label { display: flex; gap: 8px; align-items: center; min-height: 36px; cursor: pointer; }
.gebiet-wahl input { width: 20px; height: 20px; flex: none; }
.laufend { display: flex; flex-direction: column; gap: 10px; }
.countdown { font-size: 1.6rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.runden { width: 100%; border-collapse: collapse; background: var(--panel); border-radius: var(--radius); overflow: hidden; }
.runden th, .runden td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.runden th { font-size: .85rem; color: var(--muted); font-weight: 600; }
.runden td.n { font-variant-numeric: tabular-nums; text-align: right; }
.runden tr.sel td { background: var(--bg); }
.runden .aktionen { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.table-wrap { overflow-x: auto; }
.detail { display: flex; flex-direction: column; gap: 12px; }
.detail h3 { margin: 8px 0 0; }
.kennzahlen { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.kennzahlen div { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px;
  display: flex; flex-direction: column; }
.kennzahlen strong { font-size: 1.8rem; font-variant-numeric: tabular-nums; }
.kennzahlen span { color: var(--muted); font-size: .9rem; }
.auswertung-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: 14px; }
.fragen-tabelle { width: 100%; border-collapse: collapse; background: var(--panel); }
.fragen-tabelle th, .fragen-tabelle td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.fragen-tabelle thead th { font-size: .85rem; color: var(--muted); }
.fragen-tabelle .gruppe-zeile th { background: var(--bg); font-size: .85rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.fragen-tabelle td.n { font-variant-numeric: tabular-nums; white-space: nowrap; }
.frage-text { min-width: 260px; }
.quote { white-space: nowrap; font-variant-numeric: tabular-nums; }
.quote.gut strong { color: var(--ok); }
.quote.mittel strong { color: var(--warn); }
.quote.schwach strong { color: var(--bad); }
.mini { width: 72px; height: 6px; background: var(--bg); border-radius: 3px; margin-top: 4px; }
.mini i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.chip { display: inline-block; padding: 2px 8px; margin: 0 4px 4px 0; border-radius: 999px; background: var(--bad-bg);
        font-size: .85rem; }
.pool { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; }
.pool summary { cursor: pointer; font-weight: 700; }
.pool h3 { margin: 18px 0 6px; }
.pool-frage { border-top: 1px solid var(--line); padding: 8px 0; }
.pool-frage .q { font-weight: 600; }
.pool-frage ul { margin: 4px 0; padding-left: 1.2em; }
.pool-frage li.richtig { color: var(--ok); font-weight: 700; }
.pool-frage li.richtig::marker { content: "✓ "; }
.pool-frage p { margin: 4px 0; }
.klausur-wahl { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.klausur-wahl select { flex: 1; min-width: 240px; min-height: 48px; padding: 8px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--panel); }
