/* Sonnen-optimiert: Standard = helles Hochkontrast-Theme, Dunkel nur per Umschalter */
:root {
  --bg: #ffffff; --surface: #f1f1f3; --card: #ffffff; --text: #0a0a0a; --muted: #3f3f46;
  --line: #52525b; --line-soft: #d4d4d8;
  --accent: #0033a0; --accent-text: #ffffff; --pick-bg: #e3eaff;
  --ok: #05642a; --ok-bg: #d3f5de; --bad: #a10f0f; --bad-bg: #ffe0e0; --info-bg: #eef2ff;
  --focus: #b35900;
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #000000; --surface: #18181b; --card: #111113; --text: #ffffff; --muted: #d4d4d8;
  --line: #a1a1aa; --line-soft: #3f3f46;
  --accent: #7aa7ff; --accent-text: #000000; --pick-bg: #1a2a55;
  --ok: #5ee08a; --ok-bg: #0d3b1e; --bad: #ff8a8a; --bad-bg: #4a1111; --info-bg: #1a1f33;
  --focus: #ff9e00;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 18px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
main { max-width: 680px; margin: 0 auto; padding: 0 16px calc(104px + env(safe-area-inset-bottom)); }
h1 { font-size: 1.5rem; line-height: 1.2; margin: 0; }
h2 { font-size: 1.15rem; margin: 22px 0 10px; }
h3 { font-size: 1rem; margin: 0 0 4px; }
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
button:focus-visible, input:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
img { display: block; max-width: 100%; height: auto; margin: 10px 0; border: 2px solid var(--line-soft); border-radius: 8px; background: #fff; }

.btn { min-height: 48px; padding: 10px 16px; border-radius: 12px; border: 2px solid var(--line); background: var(--card); font-weight: 700; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.wide { width: 100%; margin-top: 14px; }
.btn:disabled { opacity: .4; cursor: default; }
.muted { color: var(--muted); font-size: .95rem; font-weight: 600; }

/* Kopfzeilen */
.bar-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 0 14px; }
.sub { display: block; color: var(--muted); font-size: .95rem; font-weight: 700; margin-top: 4px; }
.qbar {
  position: sticky; top: 0; z-index: 2; display: grid; grid-template-columns: auto 1fr; align-items: center;
  gap: 8px 12px; padding: 10px 0; background: var(--bg); border-bottom: 2px solid var(--line-soft);
}
.qinfo { display: flex; flex-direction: column; align-items: flex-end; min-width: 0; }
.qch { max-width: 100%; color: var(--muted); font-size: .85rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qcount { font-size: 1.15rem; font-weight: 800; }
.progress { display: block; height: 8px; border-radius: 4px; background: var(--line-soft); overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--accent); }
.qbar .progress { grid-column: 1 / -1; height: 6px; }

/* Einstellungen */
.panel { display: grid; gap: 14px; padding: 14px; border-radius: 16px; background: var(--surface); }
.label { display: block; margin-bottom: 6px; color: var(--muted); font-size: .8rem; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; }
.seg { display: flex; gap: 4px; padding: 4px; border: 2px solid var(--line); border-radius: 12px; background: var(--card); }
.seg button { flex: 1; min-height: 48px; border: 0; border-radius: 8px; background: none; font-weight: 700; }
.seg button.on { background: var(--accent); color: var(--accent-text); }
.switch { display: flex; align-items: center; gap: 12px; min-height: 48px; font-weight: 700; }
.switch input { flex: none; width: 26px; height: 26px; accent-color: var(--accent); }

/* Kapitel */
.chapters { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.chapter {
  position: relative; display: grid; gap: 6px; width: 100%; padding: 14px 44px 14px 16px; text-align: left;
  border: 2px solid var(--line); border-radius: 14px; background: var(--card);
}
.ch-title { font-size: 1.05rem; font-weight: 800; }
.ch-meta { color: var(--muted); font-size: .9rem; font-weight: 600; }
.chapter .progress i { background: var(--ok); }
.chev { position: absolute; top: 50%; right: 16px; transform: translateY(-50%); color: var(--muted); font-size: 1.8rem; font-weight: 800; }

/* Frage */
.note { padding: 10px 12px; border-radius: 10px; background: var(--info-bg); font-weight: 700; }
.meta { margin: 14px 0 6px; color: var(--muted); font-size: .9rem; font-weight: 700; }
.stem { margin: 0 0 16px; font-size: 1.1rem; font-weight: 500; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
.hint {
  display: inline-block; margin: 0 0 12px; padding: 4px 14px; border: 2px solid var(--accent); border-radius: 999px;
  background: var(--info-bg); font-size: .95rem; font-weight: 800;
}
.opts { display: grid; gap: 10px; }
.opt {
  display: flex; align-items: flex-start; gap: 12px; width: 100%; min-height: 56px; padding: 14px; text-align: left;
  border: 2px solid var(--line); border-radius: 14px; background: var(--card);
}
.opt .k {
  flex: none; display: grid; place-items: center; width: 34px; height: 34px;
  border: 2px solid var(--line); border-radius: 50%; font-size: 1rem; font-weight: 800;
}
.opt .t { flex: 1; min-width: 0; padding-top: 3px; white-space: pre-wrap; overflow-wrap: anywhere; }
.opt .mark { flex: none; padding-top: 2px; font-size: 1.5rem; font-weight: 900; line-height: 1; }
.opt.picked { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); background: var(--pick-bg); }
.opt.picked .k { border-color: var(--accent); background: var(--accent); color: var(--accent-text); }
.opt.right { border-color: var(--ok); box-shadow: 0 0 0 2px var(--ok); background: var(--ok-bg); }
.opt.right .k, .opt.right .mark { border-color: var(--ok); color: var(--ok); }
.opt.wrong { border-color: var(--bad); box-shadow: 0 0 0 2px var(--bad); background: var(--bad-bg); }
.opt.wrong .k, .opt.wrong .mark { border-color: var(--bad); color: var(--bad); }
.opt:disabled { opacity: 1; cursor: default; }

/* Auflösung */
.reveal { margin-top: 16px; scroll-margin-bottom: calc(104px + env(safe-area-inset-bottom)); }
.result { margin: 0 0 12px; padding: 14px 16px; border: 3px solid var(--accent); border-radius: 14px; background: var(--info-bg); font-size: 1.15rem; font-weight: 800; }
.result.ok { border-color: var(--ok); background: var(--ok-bg); color: var(--ok); }
.result.bad { border-color: var(--bad); background: var(--bad-bg); color: var(--bad); }
.votes { display: grid; gap: 8px; margin-top: 12px; }
.vote, .stat { display: grid; grid-template-columns: 4.2em 1fr 3.4em; align-items: center; gap: 10px; font-size: .95rem; font-weight: 700; }
.stat { grid-template-columns: 3.8em 1fr 6.4em; }
.vote .progress, .stat .progress { height: 12px; border-radius: 6px; }
.stat .progress i { background: var(--ok); }

/* Untere Navigation */
.nav {
  position: fixed; right: 0; bottom: 0; left: 0; z-index: 3; display: flex; justify-content: center; gap: 10px;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); border-top: 2px solid var(--line-soft); background: var(--bg);
}
.nav .btn { flex: 1; max-width: 330px; min-height: 56px; font-size: 1.05rem; }

/* Statistik pro Frage / Problemfragen */
.qstat { display: inline-block; margin: 0 0 12px; padding: 4px 12px; border-radius: 999px; background: var(--surface); font-size: .9rem; font-weight: 700; }
.r { color: var(--ok); }
.w { color: var(--bad); }
.plist { display: grid; gap: 8px; }
.prow {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 10px; width: 100%; min-height: 52px;
  padding: 10px 12px; text-align: left; border: 2px solid var(--line); border-radius: 12px; background: var(--card);
}
.pn { font-weight: 800; }
.ps { overflow: hidden; color: var(--muted); font-size: .9rem; font-weight: 600; white-space: nowrap; text-overflow: ellipsis; }
.pc { font-weight: 800; white-space: nowrap; }
.chapter.problem { border-color: var(--bad); box-shadow: 0 0 0 1px var(--bad); }
