/* Gymi-Trainer Mathematik – Stylesheet ohne Build-Schritt. */

:root {
  color-scheme: light;
  --bg: #f4f6fb;
  --bg-elev: #ffffff;
  --bg-soft: #eef2f9;
  --line: #dbe2ee;
  --line-soft: #e9eef6;
  --text: #16202f;
  --text-dim: #5a6b83;
  --text-mute: #8493a8;
  --brand: #1f5eff;
  --brand-soft: #e7eeff;
  --brand-ink: #123bb3;
  --good: #128a5b;
  --good-soft: #dcf5ea;
  --warn: #b8760a;
  --warn-soft: #fdf1da;
  --bad: #c62f42;
  --bad-soft: #fde7ea;
  --shadow: 0 1px 2px rgba(16, 27, 45, .06), 0 8px 24px rgba(16, 27, 45, .06);
  --radius: 14px;
  --radius-s: 9px;
  --nav-w: 232px;
  --top-h: 58px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, "Liberation Mono", monospace;
}

:root[data-theme="dark"], :root.dark {
  color-scheme: dark;
  --bg: #0d1420;
  --bg-elev: #151f2f;
  --bg-soft: #1b2739;
  --line: #27354a;
  --line-soft: #1f2c3f;
  --text: #e8eefa;
  --text-dim: #a2b1c7;
  --text-mute: #74849c;
  --brand: #5b8cff;
  --brand-soft: #1b2a4d;
  --brand-ink: #b9cdff;
  --good: #3ecf8e;
  --good-soft: #14352a;
  --warn: #e3ab4f;
  --warn-soft: #3a2e15;
  --bad: #ff6b7e;
  --bad-soft: #3b1a21;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 10px 30px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

[hidden] { display: none !important; }
img { max-width: 100%; }
a { color: var(--brand); }

h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5em; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.22rem; }
h3 { font-size: 1.02rem; }
p { margin: 0 0 .8em; }

.muted { color: var(--text-dim); }
.mute2 { color: var(--text-mute); font-size: .86rem; }
.center { text-align: center; }
.mono { font-family: var(--mono); }
.nowrap { white-space: nowrap; }

/* ------------------------------------------------------------- Anmeldung */

.gate {
  position: fixed; inset: 0; z-index: 60;
  display: grid; place-items: center;
  padding: calc(16px + env(safe-area-inset-top, 0px)) 16px calc(16px + env(safe-area-inset-bottom, 0px));
  background:
    radial-gradient(900px 500px at 15% -10%, rgba(31, 94, 255, .18), transparent 65%),
    radial-gradient(700px 480px at 95% 105%, rgba(18, 138, 91, .16), transparent 60%),
    var(--bg);
  overflow: auto;
}
.gate[hidden] { display: none; }
.gate-card {
  width: min(430px, 100%);
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 28px 26px 26px;
  text-align: center;
}
.gate-logo {
  width: 54px; height: 54px; margin: 0 auto 12px;
  display: grid; place-items: center;
  border-radius: 16px;
  background: var(--brand); color: #fff;
  font-size: 28px; font-weight: 700;
}
.gate-card h1 { margin-bottom: 2px; }
.gate-sub { color: var(--text-dim); font-size: .88rem; margin-bottom: 20px; }
.gate-card form { text-align: left; }
.gate-tabs { display: flex; gap: 6px; background: var(--bg-soft); padding: 4px; border-radius: 11px; margin-bottom: 18px; }
.gate-tabs button {
  flex: 1; border: 0; background: transparent; padding: 8px; border-radius: 8px;
  font: inherit; font-weight: 600; color: var(--text-dim); cursor: pointer;
}
.gate-tabs button[aria-selected="true"] { background: var(--bg-elev); color: var(--text); box-shadow: var(--shadow); }

/* ----------------------------------------------------------------- Layout */

.app { min-height: 100%; }
.app[hidden] { display: none; }

.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 40;
  height: calc(var(--top-h) + env(safe-area-inset-top, 0px));
  padding: env(safe-area-inset-top, 0px) 14px 0;
  display: flex; align-items: center; gap: 10px;
  background: color-mix(in srgb, var(--bg-elev) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 9px; background: var(--brand); color: #fff;
  display: grid; place-items: center; font-size: 19px; font-weight: 700;
}
.brand-text { display: flex; flex-direction: column; font-weight: 680; font-size: .96rem; line-height: 1.15; }
.brand-text small { font-weight: 500; font-size: .7rem; color: var(--text-mute); letter-spacing: .02em; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.countdown-pill {
  font-size: .78rem; font-weight: 650; padding: 5px 11px; border-radius: 999px;
  background: var(--brand-soft); color: var(--brand-ink); white-space: nowrap;
}
.icon-btn {
  width: 34px; height: 34px; border-radius: 9px; border: 1px solid var(--line);
  background: var(--bg-elev); color: var(--text-dim); cursor: pointer; font-size: 15px;
}
.icon-btn:hover { color: var(--text); border-color: var(--brand); }
.user-chip {
  display: flex; align-items: center; gap: 7px; padding: 4px 10px 4px 5px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--bg-elev);
  font-size: .82rem; font-weight: 600; cursor: pointer;
}
.user-chip .av {
  width: 25px; height: 25px; border-radius: 50%; background: var(--brand); color: #fff;
  display: grid; place-items: center; font-size: .74rem; font-weight: 700;
}

.burger { display: none; width: 34px; height: 34px; border: 1px solid var(--line); background: var(--bg-elev); border-radius: 9px; cursor: pointer; padding: 8px 7px; }
.burger span { display: block; height: 2px; background: var(--text-dim); border-radius: 2px; margin: 3px 0; }

.sidebar {
  position: fixed; z-index: 35;
  top: calc(var(--top-h) + env(safe-area-inset-top, 0px));
  bottom: 0; left: 0; width: var(--nav-w);
  padding: 14px 10px calc(20px + env(safe-area-inset-bottom, 0px));
  background: var(--bg-elev); border-right: 1px solid var(--line);
  overflow-y: auto;
}
.sidebar a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; margin-bottom: 2px; border-radius: var(--radius-s);
  color: var(--text-dim); text-decoration: none; font-weight: 570; font-size: .9rem;
}
.sidebar a i { font-style: normal; width: 20px; text-align: center; opacity: .85; }
.sidebar a small { margin-left: auto; font-size: .68rem; color: var(--text-mute); font-weight: 500; }
.sidebar a:hover { background: var(--bg-soft); color: var(--text); }
.sidebar a.active { background: var(--brand-soft); color: var(--brand-ink); }
.sidebar-sep { height: 1px; background: var(--line); margin: 12px 12px; }

.content {
  padding: calc(var(--top-h) + env(safe-area-inset-top, 0px) + 22px) 22px calc(60px + env(safe-area-inset-bottom, 0px));
  margin-left: var(--nav-w);
  max-width: 1120px;
  outline: none;
}
.scrim { display: none; }

@media (max-width: 860px) {
  .burger { display: block; }
  .sidebar { transform: translateX(-100%); transition: transform .22s ease; box-shadow: var(--shadow); }
  .sidebar.open { transform: none; }
  .content { margin-left: 0; padding-left: 16px; padding-right: 16px; }
  .scrim.show { display: block; position: fixed; inset: 0; z-index: 34; background: rgba(8, 14, 24, .45); }
  .brand-text small { display: none; }
  .countdown-pill { display: none; }
}

/* --------------------------------------------------------------- Bausteine */

.card {
  background: var(--bg-elev); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.card.pad-s { padding: 13px 15px; }
.card-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h2, .card-head h3 { margin: 0; }
.card-head .spacer { margin-left: auto; }

.grid { display: grid; gap: 16px; }
.grid.c2 { grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); }
.grid.c3 { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.grid.c4 { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row.tight { gap: 6px; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 1px solid var(--line); background: var(--bg-elev); color: var(--text);
  border-radius: var(--radius-s); padding: 9px 15px;
  font: inherit; font-weight: 600; font-size: .9rem; cursor: pointer;
  text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: var(--brand); color: var(--brand); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); color: #fff; }
.btn.good { background: var(--good); border-color: var(--good); color: #fff; }
.btn.good:hover { color: #fff; filter: brightness(1.08); }
.btn.danger { color: var(--bad); border-color: var(--bad); }
.btn.danger:hover { background: var(--bad); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-dim); }
.btn.ghost:hover { background: var(--bg-soft); color: var(--text); }
.btn.s { padding: 6px 11px; font-size: .82rem; }
.btn.block { width: 100%; }
.btn.xl { padding: 13px 22px; font-size: 1rem; }

label.field { display: block; margin-bottom: 14px; font-size: .85rem; font-weight: 600; color: var(--text-dim); }
input[type=text], input[type=password], input[type=number], input[type=date], select, textarea {
  width: 100%; margin-top: 5px;
  padding: 10px 12px; font: inherit; font-size: .95rem;
  color: var(--text); background: var(--bg); border: 1px solid var(--line);
  border-radius: var(--radius-s);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 1px; border-color: var(--brand); }
textarea { resize: vertical; min-height: 78px; line-height: 1.5; }
input.big { font-size: 1.25rem; font-weight: 600; text-align: center; letter-spacing: .02em; }

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px; font-size: .74rem; font-weight: 650;
  background: var(--bg-soft); color: var(--text-dim); white-space: nowrap;
}
.pill.brand { background: var(--brand-soft); color: var(--brand-ink); }
.pill.good { background: var(--good-soft); color: var(--good); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }

.bar { height: 8px; border-radius: 999px; background: var(--bg-soft); overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--brand); border-radius: 999px; transition: width .35s ease; }
.bar.good > span { background: var(--good); }
.bar.warn > span { background: var(--warn); }
.bar.bad > span { background: var(--bad); }

.stat { text-align: center; padding: 15px 10px; }
.stat b { display: block; font-size: 1.85rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; }
.stat span { font-size: .78rem; color: var(--text-dim); }

table { width: 100%; border-collapse: collapse; font-size: .89rem; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line-soft); }
th { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-mute); font-weight: 650; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }

.empty { text-align: center; padding: 40px 20px; color: var(--text-mute); }
.empty .big { font-size: 2.4rem; display: block; margin-bottom: 8px; opacity: .55; }

.toasts { position: fixed; z-index: 90; bottom: calc(18px + env(safe-area-inset-bottom, 0px)); left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: var(--text); color: var(--bg); padding: 9px 16px; border-radius: 999px; font-size: .86rem; font-weight: 600; box-shadow: var(--shadow); animation: pop .2s ease; max-width: 90vw; }
.toast.bad { background: var(--bad); color: #fff; }
.toast.good { background: var(--good); color: #fff; }
@keyframes pop { from { opacity: 0; transform: translateY(8px); } }

/* ------------------------------------------------------------- Lernplan */

.phase-strip { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 18px; }
.phase-chip { padding: 5px 12px; border-radius: 999px; font-size: .78rem; font-weight: 650; border: 1px solid transparent; cursor: pointer; background: var(--bg-soft); color: var(--text-dim); }
/* Ausgewählt: standardmässig in der Markenfarbe. Im Lernplan überschreibt
   JavaScript den Hintergrund mit der jeweiligen Phasenfarbe. */
.phase-chip.on { background: var(--brand); color: #fff; }

.termin-list { display: grid; gap: 10px; }
.termin {
  display: grid; grid-template-columns: 52px 1fr auto; gap: 14px; align-items: center;
  background: var(--bg-elev); border: 1px solid var(--line); border-left-width: 4px;
  border-radius: var(--radius); padding: 13px 16px; text-decoration: none; color: inherit;
}
.termin:hover { border-color: var(--brand); border-left-color: inherit; transform: translateY(-1px); }
.termin .nr { font-size: 1.32rem; font-weight: 700; text-align: center; color: var(--text-mute); font-variant-numeric: tabular-nums; }
.termin .t { font-weight: 640; }
.termin .d { font-size: .78rem; color: var(--text-mute); }
.termin.done { background: var(--good-soft); }
.termin.done .nr { color: var(--good); }
.termin.ferien { opacity: .72; border-style: dashed; }
.termin.jetzt { box-shadow: 0 0 0 2px var(--brand) inset, var(--shadow); }

/* ------------------------------------------------------------- Aufgaben */

.aufgabe-text { font-size: 1rem; line-height: 1.68; }
.aufgabe-text p { margin: 0 0 .75em; }
.aufgabe-text ul, .aufgabe-text ol { margin: 0 0 .75em; padding-left: 1.35em; }
.aufgabe-text li { margin-bottom: .3em; }
.aufgabe-text b { font-weight: 680; }
.aufgabe-text .hinweis { font-size: .86rem; color: var(--text-dim); background: var(--bg-soft); padding: 9px 12px; border-radius: var(--radius-s); }

.bild-hinweis {
  display: flex; gap: 11px; align-items: flex-start;
  background: var(--warn-soft); color: var(--warn);
  border-radius: var(--radius-s); padding: 11px 14px; font-size: .86rem; margin-bottom: 14px;
}
.bild-hinweis b { display: block; }
.aufgabe-bild { border: 1px solid var(--line); border-radius: var(--radius-s); margin-bottom: 14px; background: #fff; }

.punkte-wahl { display: flex; gap: 8px; flex-wrap: wrap; }
.punkte-wahl button {
  width: 46px; height: 46px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--bg-elev); font: inherit; font-size: 1.05rem; font-weight: 700; cursor: pointer; color: var(--text);
}
.punkte-wahl button:hover { border-color: var(--brand); }
.punkte-wahl button.on { background: var(--brand); border-color: var(--brand); color: #fff; }

.fehler-wahl { display: flex; gap: 6px; flex-wrap: wrap; }
.fehler-wahl button {
  padding: 6px 11px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--bg-elev); font: inherit; font-size: .8rem; font-weight: 600; cursor: pointer; color: var(--text-dim);
}
.fehler-wahl button.on { background: var(--bad); border-color: var(--bad); color: #fff; }

.loesung-box { border: 1px solid var(--good); background: var(--good-soft); border-radius: var(--radius-s); padding: 13px 15px; }
.loesung-box h4 { margin: 0 0 6px; color: var(--good); font-size: .82rem; text-transform: uppercase; letter-spacing: .05em; }
.loesung-box ol, .loesung-box ul { margin: 0; padding-left: 1.25em; }
.loesung-box li { margin-bottom: .25em; }
.loesung-end { font-size: 1.05rem; font-weight: 700; }

/* Gestufte Hinweise. Bewusst ruhiger als der Lösungsweg: Das hier ist eine
   Stütze, kein Ergebnis. Jede Sprosse kommt einzeln dazu. */
.hinweis-box { margin-top: 12px; display: grid; gap: 8px; }
.hinweis {
  border-left: 3px solid var(--warn);
  background: var(--warn-soft);
  border-radius: 0 var(--radius-s) var(--radius-s) 0;
  padding: 9px 13px;
  font-size: .94rem;
  overflow-wrap: break-word;
}
.hinweis b {
  display: block;
  color: var(--warn);
  font-size: .76rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 2px;
}

/* ---------------------------------------------------------- Kopfrechnen */

.drill { text-align: center; padding: 26px 18px; }
.drill .frage { font-size: clamp(1.5rem, 5vw, 2.3rem); font-weight: 680; margin: 8px 0 20px; letter-spacing: -.01em; }
.drill input { max-width: 260px; margin: 0 auto 14px; }
.drill .feedback { min-height: 26px; font-weight: 650; }
.drill .feedback.ok { color: var(--good); }
.drill .feedback.no { color: var(--bad); }

.timer {
  font-family: var(--mono); font-size: 1.05rem; font-weight: 700;
  padding: 6px 13px; border-radius: 999px; background: var(--bg-soft); font-variant-numeric: tabular-nums;
}
.timer.warn { background: var(--warn-soft); color: var(--warn); }
.timer.bad { background: var(--bad-soft); color: var(--bad); }
.timer.xl { font-size: 1.5rem; padding: 9px 18px; }

/* ------------------------------------------------------------- Prüfung */

.pruef-nav { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.pruef-nav button {
  width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg-elev); font: inherit; font-weight: 700; cursor: pointer; color: var(--text-dim);
}
.pruef-nav button.on { border-color: var(--brand); color: var(--brand); box-shadow: 0 0 0 1px var(--brand) inset; }
.pruef-nav button.fertig { background: var(--good-soft); color: var(--good); border-color: var(--good); }

.note-gross { font-size: 3.4rem; font-weight: 750; line-height: 1; letter-spacing: -.03em; }
.note-gross.good { color: var(--good); }
.note-gross.bad { color: var(--bad); }

@media print {
  .topbar, .sidebar, .toasts, .btn, .pruef-nav { display: none !important; }
  .content { margin: 0; padding: 0; max-width: none; }
  .card { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; }
}

/* --------------------------------------------------------------- Fachwahl */

.fachwahl { align-items: stretch; }
.fach-karte {
  display: block; text-decoration: none; color: inherit; margin: 0;
  transition: transform .15s ease, border-color .15s ease;
}
.fach-karte:hover { transform: translateY(-2px); border-color: var(--brand); }
.fach-karte h2 { margin: 12px 0 6px; }
.fach-karte .bar { margin: 6px 0 12px; }
.fach-mark {
  width: 46px; height: 46px; border-radius: 13px; color: #fff;
  display: grid; place-items: center; font-size: 24px; font-weight: 700;
}
.fach-jetzt {
  font-size: .82rem; color: var(--text-dim); background: var(--bg-soft);
  padding: 8px 11px; border-radius: var(--radius-s); margin-bottom: 10px;
}
.ziel-box { background: var(--bg-soft); border-radius: var(--radius-s); padding: 14px 16px; }
.note-ziel { font-size: 1.5rem; font-weight: 750; letter-spacing: -.02em; }

.sidebar .nav-fach { font-weight: 680; color: var(--text); }
.sidebar .nav-fach small { color: var(--brand); }

kbd {
  font-family: var(--mono); font-size: .78rem; padding: 2px 6px;
  border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px;
  background: var(--bg-elev);
}

/* ---------------------------------------------------------------- Deutsch */

.wort-liste { display: grid; grid-template-columns: minmax(140px, 1fr) 2fr; gap: 2px 14px; font-size: .92rem; }
.wort-liste dt { font-weight: 640; padding: 5px 0; border-bottom: 1px solid var(--line-soft); }
.wort-liste dd { margin: 0; padding: 5px 0; color: var(--text-dim); border-bottom: 1px solid var(--line-soft); }
.wort-liste .korr { color: var(--warn); font-size: .8rem; display: block; }

.karteikarte {
  min-height: 210px; display: grid; place-items: center; text-align: center;
  cursor: pointer; user-select: none; padding: 26px 20px;
}
.karteikarte .vorne { font-size: clamp(1.4rem, 4vw, 2rem); font-weight: 680; }
.karteikarte .hinten { font-size: 1.1rem; color: var(--good); font-weight: 600; }

.antwort-wahl { display: grid; gap: 8px; }
.antwort-wahl button {
  text-align: left; padding: 12px 15px; border-radius: var(--radius-s);
  border: 1px solid var(--line); background: var(--bg-elev); color: var(--text);
  font: inherit; font-size: .95rem; cursor: pointer;
}
.antwort-wahl button:hover:not(:disabled) { border-color: var(--brand); }
.antwort-wahl button.richtig { background: var(--good-soft); border-color: var(--good); color: var(--good); font-weight: 650; }
.antwort-wahl button.falsch { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }
.antwort-wahl button:disabled { cursor: default; }

.aufsatz-flaeche {
  width: 100%; min-height: 380px; font-size: 1rem; line-height: 1.7;
  font-family: Georgia, "Times New Roman", serif;
}
.schreib-leiste {
  display: flex; gap: 14px; flex-wrap: wrap; align-items: center;
  font-size: .82rem; color: var(--text-dim);
}
.kriterium { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.kriterium b { min-width: 120px; }
.kriterium input[type=range] { flex: 1; min-width: 140px; }

/* Fachwahl-Seite ohne Seitenleiste: Inhalt mittig */
body.ohne-nav .content { margin-left: auto; margin-right: auto; max-width: 940px; }
body.ohne-nav .burger { visibility: hidden; }

/* ------------------------------------------------- Wortschatzblatt (Deutsch) */

.ws-blatt {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 26px 22px 20px;
  /* Etwas rundere, handschriftnahe Schrift – ohne externe Schriftdatei */
  font-family: "Segoe Print", "Bradley Hand", "Comic Sans MS", var(--font);
}

.ws-kopf { text-align: center; margin-bottom: 22px; }
.ws-kopf h2 {
  display: inline-block; margin: 0 0 6px;
  font-size: clamp(1.25rem, 3.4vw, 1.85rem); font-weight: 700; letter-spacing: 0;
  color: var(--brand-ink);
  border-bottom: 3px solid var(--brand);
  padding-bottom: 3px;
}
.ws-kopf .ws-unter { color: var(--text-dim); font-size: .95rem; }

/* Zwei Spalten wie auf dem Blatt; die Kästen brechen nicht auseinander */
.ws-spalten { columns: 2; column-gap: 18px; }
.ws-spalten > * { break-inside: avoid; page-break-inside: avoid; margin-bottom: 18px; }
@media (max-width: 820px) { .ws-spalten { columns: 1; } }

.ws-box {
  border: 2px solid var(--ws-farbe, var(--line));
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg-elev);
}
.ws-box > h3 {
  margin: 0; padding: 7px 12px;
  font-size: 1rem; font-weight: 700; letter-spacing: 0;
  color: var(--ws-farbe);
  background: color-mix(in srgb, var(--ws-farbe) 15%, var(--bg-elev));
  border-bottom: 1px solid color-mix(in srgb, var(--ws-farbe) 40%, transparent);
}
.ws-box table { font-size: .9rem; }
.ws-box td {
  padding: 5px 12px;
  border-bottom: 1px solid color-mix(in srgb, var(--ws-farbe) 22%, transparent);
  vertical-align: top;
}
.ws-box tr:last-child td { border-bottom: 0; }
.ws-box td.ws-wort { font-weight: 640; width: 42%; color: var(--text); }
.ws-box td.ws-bed { color: var(--text-dim); }
.ws-box .ws-name { font-size: .72rem; color: var(--text-mute); font-weight: 500; }
.ws-box .ws-korr { display: block; font-size: .76rem; color: var(--warn); }

.ws-tipp {
  margin-top: 4px; border: 2px solid var(--good); border-radius: 10px;
  padding: 10px 14px; background: var(--good-soft); color: var(--text);
  font-size: .92rem;
}
.ws-tipp b { color: var(--good); }

@media print {
  .ws-blatt { border: 0; box-shadow: none; padding: 0; }
  .ws-spalten { columns: 2; }
  .ws-box { break-inside: avoid; }
}

/* ------------------------------------------------ Erklärung beim Darüberfahren */

[data-wort] {
  cursor: help;
  border-bottom: 1px dotted color-mix(in srgb, currentColor 45%, transparent);
}
[data-wort]:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 3px; }

.wort-tipp {
  position: fixed; z-index: 80; max-width: min(340px, 88vw);
  background: var(--bg-elev); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--radius-s);
  box-shadow: var(--shadow); padding: 11px 13px;
  font-family: var(--font); font-size: .88rem; line-height: 1.5;
  pointer-events: none;
}
.wort-tipp b { font-size: .95rem; }
.wort-tipp .wt-art {
  font-size: .7rem; font-weight: 650; text-transform: uppercase; letter-spacing: .04em;
  background: var(--brand-soft); color: var(--brand-ink);
  padding: 1px 6px; border-radius: 999px; margin-left: 5px;
}
.wort-tipp .wt-bedeutung { margin-top: 6px; }
.wort-tipp .wt-quelle { font-size: .76rem; color: var(--text-mute); margin-top: 2px; }
.wort-tipp .wt-korr { font-size: .76rem; color: var(--warn); margin-top: 3px; }
.wort-tipp .wt-mehr {
  font-size: .76rem; color: var(--text-dim); margin-top: 8px;
  border-top: 1px solid var(--line-soft); padding-top: 6px;
}

/* ---------------------------------------------------------- Aufbauprogramm */

.aufbau-karte { display: block; text-decoration: none; color: inherit; margin: 0; }
.aufbau-karte:hover { border-color: var(--brand); }

.leiter { display: flex; gap: 6px; margin-top: 12px; }
.sprosse {
  flex: 1; height: 34px; border-radius: 8px;
  display: grid; place-items: center;
  background: var(--bg-soft); color: var(--text-mute);
  font-weight: 700; font-size: .9rem;
  border: 2px solid transparent;
}
.sprosse.begonnen { background: var(--warn-soft); color: var(--warn); }
.sprosse.geschafft { background: var(--good); color: #fff; }
.sprosse.naechste { border-color: var(--brand); color: var(--brand); }
.sprosse.geschafft.naechste { color: #fff; }

/* Lesetexte im Textverständnis */
.lesetext {
  background: var(--bg-soft);
  border-left: 4px solid var(--brand);
  border-radius: var(--radius-s);
  padding: 14px 16px;
  margin-bottom: 4px;
}
.lesetext b { display: block; margin-bottom: 6px; font-size: 1rem; }
.lesetext p { margin: 0; line-height: 1.75; font-family: Georgia, "Times New Roman", serif; }

/* ============================================================================
   iPhone und iPad
   ========================================================================= */

/* Nichts darf seitlich hinauslaufen. Lange Wörter und Formeln brechen um.
   Bewusst kein «overflow-x: hidden» auf html/body: Das würde position:sticky
   aushebeln – etwa den mitlaufenden Punktestand in der Prüfungskorrektur. */
.aufgabe-text, .ws-box td, .wort-liste dd, .lesetext p, .card p,
.termin .t, .termin .d, .antwort-wahl button, .loesung-box li {
  overflow-wrap: break-word;
}
img, svg, video { max-width: 100%; height: auto; }
pre, code { overflow-wrap: break-word; white-space: pre-wrap; }

/* Auf Geräten ohne Maus: keine klebenden Hover-Zustände. */
@media (hover: none) {
  .btn:hover, .icon-btn:hover, .sidebar a:hover,
  .fach-karte:hover, .aufbau-karte:hover, .termin:hover,
  .antwort-wahl button:hover:not(:disabled), .punkte-wahl button:hover {
    background: inherit; border-color: inherit; color: inherit; transform: none;
  }
  .fach-karte:hover, .aufbau-karte:hover { border-color: var(--line); }
  .btn:active, .antwort-wahl button:active:not(:disabled) { filter: brightness(.94); }
}

/* Fingerfreundlich: keine Tippverzögerung, kein versehentliches Markieren. */
.btn, .icon-btn, .phase-chip, .sprosse, .punkte-wahl button, .fehler-wahl button,
.pruef-nav button, .antwort-wahl button, .gate-tabs button, .user-chip, .burger {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

@media (pointer: coarse) {
  /* Mindestens 44 px – so gross ist eine Fingerkuppe. */
  .btn { min-height: 44px; }
  .btn.s { min-height: 38px; padding: 8px 13px; }
  .icon-btn, .burger { width: 42px; height: 42px; }
  .sidebar a { padding: 12px 12px; }
  .phase-chip { padding: 9px 14px; }
  .punkte-wahl button { width: 52px; height: 52px; }
  .pruef-nav button { width: 44px; height: 44px; }
  .antwort-wahl button { padding: 14px 15px; }
  .fehler-wahl button { padding: 9px 13px; }
  .karteikarte { min-height: 240px; }

  /* iOS zoomt die Seite, sobald ein Feld kleiner als 16 px beschriftet ist. */
  input[type=text], input[type=password], input[type=number], input[type=date],
  select, textarea { font-size: 16px; }
  input.big { font-size: 1.3rem; }
}

/* -------------------------------------------------- iPad (bis 1024 px quer) */

@media (max-width: 1024px) {
  .content { max-width: none; }
  .grid.c4 { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
}

/* ------------------------------------------- iPad hochkant und grosse Handys */

@media (max-width: 860px) {
  .sidebar { width: min(300px, 84vw); }
  .topbar { gap: 8px; }
  .brand-mark { width: 30px; height: 30px; font-size: 17px; }
  .user-chip span:last-child { max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .ws-spalten { columns: 1; }
  .aufsatz-flaeche { min-height: 300px; }
}

/* ------------------------------------------------------------- iPhone */

@media (max-width: 640px) {
  body { font-size: 15.5px; }
  .content { padding-left: 14px; padding-right: 14px; }
  h1 { font-size: 1.38rem; }
  h2 { font-size: 1.12rem; }

  .card { padding: 15px; border-radius: 12px; }
  .card.pad-s { padding: 12px 13px; }
  .grid { gap: 12px; }
  .grid.c2, .grid.c3 { grid-template-columns: 1fr; }
  .grid.c4 { grid-template-columns: 1fr 1fr; }      /* Kennzahlen zu zweit nebeneinander */
  .stat b { font-size: 1.5rem; }

  /* Kopfzeilen und Knopfreihen stapeln statt quetschen */
  .spread { flex-direction: column; align-items: flex-start; gap: 8px; }
  .spread > .spacer, .card-head .spacer { margin-left: 0; }
  .card-head { flex-direction: column; }
  .row .spacer { margin-left: 0; }
  .btn.block, .row > .btn { flex: 1 1 auto; }

  /* Termine: Nummer schmaler, Abzeichen darunter */
  .termin { grid-template-columns: 38px 1fr; gap: 10px; padding: 12px 13px; }
  .termin > :last-child { grid-column: 2; margin-top: 2px; }
  .termin .nr { font-size: 1.1rem; }

  /* Wortschatzblatt: eine Spalte, Wort über der Bedeutung */
  .wort-liste { grid-template-columns: 1fr; gap: 0; }
  .wort-liste dt { padding-bottom: 0; border-bottom: 0; }
  .wort-liste dd { padding-top: 2px; }
  .ws-blatt { padding: 18px 14px 14px; }
  .ws-box td.ws-wort { width: 40%; }
  .ws-box table { font-size: .86rem; }

  /* Übungen */
  .drill { padding: 18px 4px; }
  .drill input { max-width: 100%; }
  .leiter { gap: 4px; }
  .sprosse { height: 40px; }
  .timer.xl { font-size: 1.2rem; padding: 7px 13px; }
  .note-gross { font-size: 2.6rem; }

  /* Tabellen dürfen seitlich scrollen, statt die Seite zu sprengen */
  .table-wrap { -webkit-overflow-scrolling: touch; }
  table { font-size: .85rem; }
  th, td { padding: 7px 8px; }

  /* Die Erklärungsblase bleibt im Bild */
  .wort-tipp { max-width: calc(100vw - 24px); }

  /* Bewertungsregler untereinander */
  .kriterium { flex-direction: column; align-items: stretch; gap: 4px; }
  .kriterium b { min-width: 0; }
}

/* -------------------------------------------------- Sehr schmal (SE, Mini) */

@media (max-width: 380px) {
  .grid.c4 { grid-template-columns: 1fr; }
  .brand-text { display: none; }
  .punkte-wahl button { width: 46px; height: 46px; }
}

/* ------------------------------------- Quer am Handy: Kopfzeile flacher */

@media (max-height: 480px) and (orientation: landscape) {
  :root { --top-h: 46px; }
  .drill { padding: 10px 4px; }
  .karteikarte { min-height: 150px; }
}

/* Beim Drucken stört die Bedienung nur */
@media print {
  .sprosse, .leiter, .wort-tipp { display: none !important; }
}

/* ======================================================= Goethe C1 ====== */

/* Modulkarten auf der Übersicht: Farbe kommt je Modul aus --modul. */
.modul-karte {
  display: block; text-decoration: none; color: inherit;
  border-top: 3px solid var(--modul, var(--brand));
  padding: 14px;
}
.modul-karte:hover { border-color: var(--modul); transform: translateY(-1px); }
.modul-karte h4 { margin: 8px 0 4px; }
.modul-mark { font-size: 1.6rem; line-height: 1; }
.modul-gross { border-left: 4px solid var(--modul, var(--brand)); }

/* Themenkarte im Aufbauprogramm und in den Werkstätten */
.thema-karte { display: block; text-decoration: none; color: inherit; padding: 14px; }
.thema-karte:hover { border-color: var(--brand); }
.thema-karte h4 { margin: 0 0 4px; }

/* Phasenbalken auf der Übersicht */
.phase-zeile { margin-bottom: 10px; }
.phase-zeile:last-child { margin-bottom: 0; }
.bar.s { height: 5px; }

/* Kann-Beschreibung und Inhaltspunkte */
.kann-liste, .punkte-liste { margin: 0; padding-left: 1.2em; }
.kann-liste li, .punkte-liste li { margin-bottom: .35em; }

/* Ein Bewertungskriterium */
.kriterium { padding: 10px 0; border-bottom: 1px solid var(--line); }
.kriterium:last-child { border-bottom: 0; }
.kriterium ul { margin: 6px 0 0; padding-left: 1.2em; }
.kriterium li { margin-bottom: .2em; }

/* Der Inputtext einer Schreib- oder Sprechaufgabe */
.input-text {
  margin: 0; padding: 12px 16px;
  border-left: 3px solid var(--brand);
  background: var(--brand-soft);
  border-radius: 0 var(--radius-s) var(--radius-s) 0;
  font-style: italic;
}

/* Schreibfeld der Werkstatt */
.schreibfeld {
  width: 100%; resize: vertical;
  font: inherit; font-size: 1rem; line-height: 1.65;
  padding: 14px 16px;
  border: 1px solid var(--line); border-radius: var(--radius-s);
  background: var(--card); color: var(--ink);
}
.schreibfeld:focus { outline: 2px solid var(--brand); outline-offset: -1px; }

/* Checkliste vor dem Abgeben */
.check-zeile {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 8px 0; border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.check-zeile:last-of-type { border-bottom: 0; }
.check-zeile input { margin-top: 3px; flex: none; width: 18px; height: 18px; }

/* Redemittel-Sammlung */
.redemittel-box { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.redemittel-gruppe h4 { margin: 0 0 6px; font-size: .85rem; text-transform: uppercase;
  letter-spacing: .04em; color: var(--brand); }
.redemittel-gruppe ul { margin: 0; padding-left: 1.1em; }
.redemittel-gruppe li { margin-bottom: .3em; font-size: .93rem; }

/* Überfälliger Termin im Lernplan */
.termin.spaet { border-left: 3px solid var(--bad); }

@media (max-width: 640px) {
  .redemittel-box { grid-template-columns: 1fr; }
  .schreibfeld { font-size: 16px; }   /* sonst zoomt iOS beim Antippen hinein */
}
