:root {
  --bg: #f4f4f6;
  --card: #ffffff;
  --text: #1a1a1a;
  --muted: #6b6b72;
  --border: #d9d9de;
  --accent: #e20074;
  --accent-press: #b8005e;
  --accent-soft: #fce4f0;
  --ok: #2e7d32;
  --ok-bg: #dcf1dd;
  --bad: #c62828;
  --bad-bg: #fbdddd;
  --warn: #d45500;
  --warn-bg: #fff0e0;
  --info: #1e6fd9;
  --lvl1: #2e8b3a;
  --lvl2: #d97a00;
  --lvl3: #d32f2f;
  --track: #e4e4e8;
  --fig: #1a1a1a;
  --fig-bg: #ffffff;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121214;
    --card: #1e1e22;
    --text: #f0f0f2;
    --muted: #a0a0a8;
    --border: #3a3a42;
    --accent: #ff2d95;
    --accent-press: #e20074;
    --accent-soft: #3d1328;
    --ok: #6fcf75;
    --ok-bg: #1d3a20;
    --bad: #ff7a7a;
    --bad-bg: #4a1f22;
    --warn: #ffa152;
    --warn-bg: #3d2610;
    --info: #6aa8ff;
    --lvl1: #6fcf75;
    --lvl2: #ffb74d;
    --lvl3: #ff7a7a;
    --track: #2e2e34;
    --fig: #f0f0f2;
    --fig-bg: #26262b;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121214; --card: #1e1e22; --text: #f0f0f2; --muted: #a0a0a8; --border: #3a3a42;
  --accent: #ff2d95; --accent-press: #e20074; --accent-soft: #3d1328;
  --ok: #6fcf75; --ok-bg: #1d3a20; --bad: #ff7a7a; --bad-bg: #4a1f22;
  --warn: #ffa152; --warn-bg: #3d2610; --info: #6aa8ff;
  --lvl1: #6fcf75; --lvl2: #ffb74d; --lvl3: #ff7a7a; --track: #2e2e34;
  --fig: #f0f0f2; --fig-bg: #26262b;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 17px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}
#app {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 16px) calc(env(safe-area-inset-right) + 16px)
           calc(env(safe-area-inset-bottom) + 24px) calc(env(safe-area-inset-left) + 16px);
}
h1 { font-size: 26px; margin: 8px 0 2px; color: var(--accent); letter-spacing: -0.3px; }
h2 { font-size: 21px; margin: 4px 0 12px; color: var(--accent); }
h3 { font-size: 15px; margin: 0 0 10px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted); }
h4 { font-size: 17px; margin: 16px 0 6px; }
p { margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.center { text-align: center; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  margin: 12px 0;
}

button { font: inherit; color: inherit; cursor: pointer; }
.btn {
  display: block; width: 100%;
  border: none; border-radius: 12px;
  padding: 15px 18px;
  font-size: 17px; font-weight: 600;
  background: var(--accent); color: #fff;
  margin: 10px 0 0;
  touch-action: manipulation;
}
.btn:active { background: var(--accent-press); }
.btn.secondary { background: var(--card); color: var(--accent); border: 1.5px solid var(--accent); }
.btn.secondary:active { background: var(--accent-soft); }
.btn.warn { background: var(--warn); }
.btn.ghost { background: transparent; color: var(--muted); font-weight: 500; font-size: 15px; }
.btn:disabled { opacity: 0.4; }
.btn-row { display: flex; gap: 10px; }
.btn-row .btn { flex: 1; }
.link { background: none; border: none; color: var(--accent); padding: 8px 0 0; font-size: 15px; font-weight: 600; }
.link.muted-link { color: var(--muted); font-weight: 500; }
.link:disabled { opacity: 0.6; }
textarea {
  width: 100%; margin: 12px 0 0; padding: 10px 12px; border-radius: 10px; border: 1.5px solid var(--border);
  background: var(--card); color: var(--text); font: inherit; font-size: 16px; resize: vertical;
}
textarea:focus { outline: none; border-color: var(--accent); }

/* Menü */
.menu { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0; }
.menu-item {
  text-align: left; background: var(--card); border: 1px solid var(--border); border-radius: 14px;
  padding: 14px; display: flex; flex-direction: column; gap: 2px; min-height: 84px;
}
.menu-item strong { color: var(--accent); font-size: 16px; }
.menu-item span { color: var(--muted); font-size: 13px; line-height: 1.3; }
.menu-item:active { background: var(--accent-soft); }
.menu-item.wide { grid-column: 1 / -1; min-height: 0; }

/* Situational Judgement Test */
.sjt-option {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--card); border: 1.5px solid var(--border); border-radius: 12px; padding: 10px 12px; margin-bottom: 10px;
}
.sjt-option p { margin: 0; font-size: 16px; }
.sjt-option .stepper button:disabled { opacity: 0.35; }
.sjt-review { display: flex; gap: 12px; align-items: flex-start; border-top: 1px solid var(--border); padding-top: 8px; margin-top: 8px; }
.sjt-review p { margin: 0 0 4px; }
.sjt-points {
  flex-shrink: 0; width: 30px; height: 30px; border-radius: 50%; background: var(--accent); color: #fff;
  font-weight: 700; display: flex; align-items: center; justify-content: center;
}

/* Tagesziel & Serie */
.daily-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.streak { font-weight: 700; font-size: 17px; white-space: nowrap; }
.week { display: flex; justify-content: space-between; gap: 4px; }
.day {
  flex: 1; text-align: center; font-size: 12px; padding: 6px 0; border-radius: 8px;
  background: var(--track); color: var(--muted);
}
.day.partly { background: var(--accent-soft); color: var(--accent); }
.day.met { background: var(--ok); color: #fff; font-weight: 700; }
.day.today { outline: 2px solid var(--accent); outline-offset: 1px; }
.small-stepper button { width: 32px; height: 30px; font-size: 17px; }
.small-stepper output { min-width: 30px; font-size: 15px; }

.toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 20px); z-index: 60;
  transform: translate(-50%, 40px); opacity: 0; transition: all 0.35s ease;
  background: var(--ok); color: #fff; font-weight: 700; padding: 12px 18px; border-radius: 999px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25); white-space: nowrap;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }

/* Listen (Spickzettel, Interview) */
.list-item {
  display: flex; justify-content: space-between; align-items: center; width: 100%;
  background: none; border: none; border-top: 1px solid var(--border);
  padding: 12px 2px; font-size: 16px; text-align: left;
}
.list-item:first-of-type { border-top: none; }
.list-item span { color: var(--muted); font-size: 20px; }

/* Lernkarten */
.lernkarte { font-size: 16px; }
.lernkarte ul, .lernkarte ol { padding-left: 20px; margin: 6px 0 10px; }
.lernkarte li { margin-bottom: 6px; }
.lernkarte h4:first-child { margin-top: 0; }
.ktable { width: 100%; border-collapse: collapse; margin: 6px 0 12px; font-size: 15px; }
.ktable td, .ktable th { border-bottom: 1px solid var(--border); padding: 6px 6px 6px 0; vertical-align: top; text-align: left; }
.ktable th { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: 0.3px; }
.ktable td:first-child { font-weight: 600; white-space: nowrap; }
.ktable.center-cols td { text-align: center; white-space: normal; padding-right: 0; }

/* Overlay über der laufenden Übung */
.overlay {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.45); z-index: 50;
  display: flex; align-items: flex-end; justify-content: center;
}
.overlay-sheet {
  background: var(--bg); width: 100%; max-width: 560px; max-height: 88vh; overflow-y: auto;
  border-radius: 18px 18px 0 0; padding: 16px 16px calc(env(safe-area-inset-bottom) + 16px);
}
.overlay-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; font-size: 18px; color: var(--accent); }
.overlay-close { background: var(--track); border: none; width: 34px; height: 34px; border-radius: 50%; font-size: 16px; }

/* Bereiche als Chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1.5px solid var(--border); background: var(--card);
  border-radius: 999px; padding: 8px 14px; font-size: 15px;
}
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }

/* Schalter-Zeilen */
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; }
.row + .row { border-top: 1px solid var(--border); }
.switch { position: relative; width: 51px; height: 31px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span {
  position: absolute; inset: 0; background: var(--track); border-radius: 31px; transition: background 0.2s;
}
.switch span::before {
  content: ""; position: absolute; width: 27px; height: 27px; left: 2px; top: 2px;
  background: #fff; border-radius: 50%; transition: transform 0.2s; box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::before { transform: translateX(20px); }

.segmented { display: flex; background: var(--track); border-radius: 10px; padding: 3px; gap: 3px; margin-top: 6px; }
.segmented button { flex: 1; border: none; background: transparent; border-radius: 8px; padding: 8px 4px; font-size: 15px; }
.segmented button.on { background: var(--card); font-weight: 600; box-shadow: 0 1px 3px rgba(0,0,0,0.15); }

.stepper { display: flex; align-items: center; gap: 4px; }
.stepper button {
  width: 40px; height: 36px; border: 1px solid var(--border); background: var(--card);
  border-radius: 9px; font-size: 20px; line-height: 1;
}
.stepper output { min-width: 40px; text-align: center; font-weight: 600; font-variant-numeric: tabular-nums; }

/* Fragen */
.qhead { display: flex; justify-content: space-between; font-size: 14px; color: var(--muted); }
.qmeta { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; font-size: 13px; margin: 6px 0 8px; }
.badge { font-weight: 700; }
.progress { height: 6px; background: var(--track); border-radius: 3px; overflow: hidden; margin-bottom: 16px; }
.progress > div { height: 100%; background: var(--accent); border-radius: 3px; transition: width 0.3s; }
.cat { font-size: 13px; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: 0.5px; }
.qtext { font-size: 19px; font-weight: 500; margin: 6px 0 16px; }
.passage {
  background: var(--card); border: 1px solid var(--border); border-left: 4px solid var(--accent);
  border-radius: 10px; padding: 12px 14px; margin: 8px 0 4px; font-size: 16px; white-space: pre-line;
}
.stem { margin: 0 0 16px; text-align: center; overflow-x: auto; }
.stem svg { max-width: 100%; height: auto; }
.mono {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 20px; letter-spacing: 1.5px;
  background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 12px;
  word-break: break-word; line-height: 1.6; text-align: center;
}
.chart-svg { color: var(--text); width: 100%; height: auto; display: block; background: var(--card); border: 1px solid var(--border); border-radius: 10px; }
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; background: var(--card); border-radius: 10px; overflow: hidden; font-size: 15px; font-variant-numeric: tabular-nums; }
.data-table caption { font-weight: 700; font-size: 14px; padding: 6px 0 8px; }
.data-table th, .data-table td { border: 1px solid var(--border); padding: 7px 6px; text-align: right; }
.data-table th { background: var(--track); font-size: 13px; }
.data-table tr th:first-child { text-align: left; }
.fig-single { width: 130px; margin: 0 auto; background: var(--fig-bg); border: 1px solid var(--border); border-radius: 10px; padding: 6px; }
.fig-svg { color: var(--fig); display: block; margin: 0 auto; width: 100%; height: auto; }
.opt {
  display: block; width: 100%; text-align: left;
  background: var(--card); border: 1.5px solid var(--border); border-radius: 12px;
  padding: 14px 16px; margin: 0 0 10px; font-size: 17px;
  touch-action: manipulation;
}
.opt:active:not(:disabled) { border-color: var(--accent); }
.opt:disabled { opacity: 1; cursor: default; }
.opt.correct { background: var(--ok-bg); border-color: var(--ok); }
.opt.wrong { background: var(--bad-bg); border-color: var(--bad); }
.opt.chosen { border-color: var(--accent); background: var(--accent-soft); }
.optgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 10px; }
.optgrid .opt { margin: 0; padding: 8px; text-align: center; position: relative; }
.optgrid .opt svg { width: 100%; max-width: 120px; height: auto; display: block; margin: 0 auto; }
.optlabel { position: absolute; top: 6px; left: 9px; font-size: 13px; font-weight: 700; color: var(--muted); }
.feedback { border-radius: 12px; padding: 12px 14px; margin-top: 6px; font-size: 16px; }
.feedback.ok { background: var(--ok-bg); color: var(--ok); }
.feedback.bad { background: var(--bad-bg); color: var(--bad); }
.feedback .explain { color: var(--text); display: block; margin-top: 4px; }
.feedback-actions { display: flex; flex-wrap: wrap; gap: 4px 16px; }
.timer { text-align: center; font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; margin-top: 8px; }
.timer.low { color: var(--bad); }

/* Prüfung: Fragennavigation */
.qdots { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 12px; }
.qdot {
  width: 34px; height: 34px; border-radius: 9px; border: 1.5px solid var(--border);
  background: var(--card); font-size: 14px; font-variant-numeric: tabular-nums; padding: 0;
}
.qdot.done { background: var(--track); border-color: var(--track); }
.qdot.current { border-color: var(--accent); color: var(--accent); font-weight: 700; }
.optgrid.review .opt { cursor: default; }

.memo {
  background: var(--card); border: 1.5px solid var(--border); border-radius: 14px;
  padding: 24px 16px; text-align: center; font-size: 22px; font-weight: 700;
  white-space: pre-line; margin: 12px 0;
}

/* Ergebnis & Statistik */
.big { font-size: 56px; font-weight: 800; text-align: center; line-height: 1.1; margin: 8px 0 0; }
.trend-up { color: var(--ok); font-weight: 600; }
.trend-down { color: var(--bad); font-weight: 600; }
.trend-flat { color: var(--muted); font-weight: 600; }
.warn-text { color: var(--warn); }
.opt.muted { color: var(--muted); }
.bar-row { display: grid; grid-template-columns: 10.5em minmax(40px, 1fr) auto; align-items: center; gap: 8px; margin: 7px 0; font-size: 15px; }
.bar { height: 12px; background: var(--track); border-radius: 6px; overflow: hidden; }
.bar > div { height: 100%; border-radius: 6px; }
.bar-val { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 44px; text-align: right; }
.history { display: flex; align-items: flex-end; gap: 6px; height: 130px; padding-top: 18px; }
.history .col { flex: 1; max-width: 56px; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.history .col span { font-size: 11px; color: var(--muted); margin-bottom: 3px; }
.history .col div { width: 100%; border-radius: 4px 4px 0 0; min-height: 2px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; font-size: 15px; }

.scale { display: flex; flex-direction: column; gap: 8px; }
.scale .opt { text-align: center; margin: 0; }
.statement { font-size: 21px; font-weight: 500; text-align: center; margin: 28px 4px 28px; }
ul.hints { padding-left: 18px; margin: 0; }
ul.hints li { margin-bottom: 8px; }
