:root {
  --accent: #2e75b6;
  --accent-dark: #1f4e79;
  --accent-soft: #e8f1ff;
  --ok: #2e9e6b;
  --warn: #e08a1e;
  --bad: #d1495b;

  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-2: #f7fafc;
  --ink: #1f2937;
  --muted: #6b7280;
  --line: #e3eaf2;
  --shadow: 0 1px 2px rgba(16, 42, 76, .06), 0 8px 24px rgba(16, 42, 76, .06);
  --radius: 14px;
  --sidebar-w: 288px;
}

:root[data-theme="dark"] {
  --accent: #6aa6e6;
  --accent-dark: #9cc4ee;
  --accent-soft: #16324e;
  --bg: #0e141c;
  --surface: #151d28;
  --surface-2: #111823;
  --ink: #e6edf5;
  --muted: #93a1b3;
  --line: #223044;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 10px 30px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html, body { margin: 0; padding: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 20px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }

/* ------------------------------------------------------------- Layout */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; align-self: start;
  height: 100vh; overflow-y: auto;
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 18px 14px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 14px; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 8px; flex: none;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #fff; font-weight: 800; display: grid; place-items: center; font-size: 19px;
}
.brand-txt b { display: block; font-size: 18px; line-height: 1.1; }
.brand-txt span { font-size: 15px; color: var(--muted); }

/* Tab-Bar (Lernen / Üben) */
.tabbar { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 4px 6px 8px; }
.tab { text-align: center; padding: 9px 8px; border-radius: 10px; font-size: 14.5px; font-weight: 700; color: var(--muted); background: var(--surface-2); border: 1px solid var(--line); }
.tab:hover { color: var(--accent-dark); }
.tab.active { background: var(--accent); border-color: transparent; color: #fff; }

.search-wrap { padding: 4px 6px 10px; }
.nav-item.disabled { opacity: .45; pointer-events: none; }
#search {
  width: 100%; padding: 9px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--ink);
  font-size: 17px;
}
#search:focus { outline: 2px solid var(--accent); border-color: transparent; }

#nav-list { display: flex; flex-direction: column; gap: 2px; }
.nav-home {
  display: block; padding: 8px 12px; border-radius: 9px;
  color: var(--muted); font-weight: 600; font-size: 17px; margin-bottom: 4px;
}
.nav-home.active, .nav-home:hover { background: var(--accent-soft); color: var(--accent-dark); }
.nav-item {
  display: grid; grid-template-columns: 26px 1fr 16px; align-items: center; gap: 8px;
  padding: 8px 10px; border-radius: 9px; color: var(--ink); font-size: 17px;
}
.nav-item:hover { background: var(--surface-2); }
.nav-item.active { background: var(--accent-soft); }
.nav-item.active .nav-title { color: var(--accent-dark); font-weight: 700; }
.nav-id {
  font-size: 15px; font-weight: 700; color: #fff; background: var(--accent);
  border-radius: 6px; text-align: center; padding: 2px 0;
}
.nav-item.active .nav-id { background: var(--accent-dark); }
.nav-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-check { color: var(--ok); font-weight: 800; text-align: center; }

/* --------------------------------------------------------------- Topbar */
.content { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 14px;
  padding: 10px 22px; background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
#menu-toggle { display: none; }
.progress { flex: 1; max-width: 360px; }
.progress-track { height: 8px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 99px; overflow: hidden; }
#progress-bar { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--ok)); transition: width .3s ease; }
#progress-label { font-size: 15px; color: var(--muted); margin-top: 3px; display: block; }
.topbar-spacer { flex: 1; }
.iconbtn {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  width: 38px; height: 38px; border-radius: 10px; cursor: pointer; font-size: 20px;
}
.iconbtn:hover { background: var(--surface-2); }

main#view { padding: 26px 30px 80px; max-width: 1080px; width: 100%; margin: 0 auto; }

/* ---------------------------------------------------------------- Hero */
.hero { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px; margin-bottom: 22px; }
.hero-top { display: flex; align-items: center; gap: 16px; }
.hero-id {
  font-size: 26px; font-weight: 800; color: #fff; flex: none;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  width: 54px; height: 54px; border-radius: 12px; display: grid; place-items: center;
}
.hero-title { margin: 0; font-size: 30px; line-height: 1.15; }
.hero-en { color: var(--muted); font-size: 18px; }
.hero-tagline { font-size: 20px; color: var(--ink); margin: 14px 0 16px; }
.hero-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; font-size: 16.5px;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--ink);
  padding: 5px 11px; border-radius: 99px;
}
.chip-link { background: var(--accent-soft); border-color: transparent; color: var(--accent-dark); font-weight: 600; }
.chip-link:hover { background: var(--accent); color: #fff; }
.subtopics { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.subtag { font-size: 16px; color: var(--muted); background: var(--surface-2); border: 1px dashed var(--line); padding: 3px 9px; border-radius: 7px; }
.done-btn { border: 1px solid var(--accent); background: transparent; color: var(--accent-dark); padding: 9px 16px; border-radius: 10px; cursor: pointer; font-weight: 600; font-size: 17px; }
.done-btn:hover { background: var(--accent-soft); }
.done-btn.is-done { background: var(--ok); border-color: var(--ok); color: #fff; }

/* Klausur-Fokus */
.examfocus { background: var(--surface); border: 1px solid var(--line); border-left: 5px solid var(--warn); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; margin: 0 0 22px; }
.examfocus.level-hoch { border-left-color: var(--bad); background: linear-gradient(180deg, color-mix(in srgb, var(--bad) 8%, var(--surface)), var(--surface)); }
.examfocus.level-mittel { border-left-color: var(--warn); }
.examfocus.level-niedrig { border-left-color: var(--muted); }
.ef-head { display: flex; align-items: center; gap: 12px; }
.ef-flame { font-size: 26px; line-height: 1; }
.ef-kicker { font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--bad); }
.examfocus.level-mittel .ef-kicker { color: var(--warn); }
.examfocus.level-niedrig .ef-kicker { color: var(--muted); }
.ef-level { font-size: 19px; font-weight: 700; }
.ef-meta { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 4px; }
.ef-chip { font-size: 14px; background: var(--surface-2); border: 1px solid var(--line); padding: 4px 11px; border-radius: 99px; color: var(--ink); }
.ef-sub { font-weight: 700; margin: 12px 0 6px; font-size: 16px; }
.ef-list { margin: 0; padding-left: 22px; display: grid; gap: 6px; }
.ef-list li { font-size: 16.5px; }

/* -------------------------------------------------------------- Blocks */
.block { margin: 26px 0; }
.sec-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 14px; padding-bottom: 8px; border-bottom: 2px solid var(--line); }
.sec-kicker { font-size: 15px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
.sec-title { margin: 0; font-size: 23px; }

/* Visualisierungen — volle Textspaltenbreite, SVG auf heller Fläche */
.viz-grid { display: grid; grid-template-columns: 1fr; gap: 16px; }
.viz { width: 100%; margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.viz-frame { background: #ffffff; padding: 18px 22px; }
.viz-frame svg { width: 100%; height: auto; display: block; }
.viz-cap { padding: 12px 20px; font-size: 17px; color: var(--muted); border-top: 1px solid var(--line); }
.viz-cap strong { color: var(--ink); }
.viz-expl { padding: 0 20px 16px; font-size: 16.5px; color: var(--ink); line-height: 1.6; }

/* Schritte */
.steps { display: flex; flex-direction: column; gap: 12px; }
.step { display: grid; grid-template-columns: 42px 1fr; gap: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; }
.step-num { width: 34px; height: 34px; border-radius: 9px; background: var(--accent-soft); color: var(--accent-dark); font-weight: 800; display: grid; place-items: center; }
.step-head { margin: 2px 0 6px; font-size: 20px; }
.step-text { margin: 0; }
.formula { margin: 12px 0 2px; padding: 10px 14px; background: var(--surface-2); border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: 8px; overflow-x: auto; }

/* Aus dem Vorlesungsjournal */
.block-journal .sec-head { border-bottom-color: var(--accent); }
.jnotes { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; margin-bottom: 16px; }
.jnote { background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--warn); border-radius: 12px; padding: 13px 16px; box-shadow: var(--shadow); }
.jnote-head { font-weight: 700; color: var(--ink); margin-bottom: 5px; }
.jnote-text { font-size: 16.5px; color: var(--ink); }
.jfig-grid { display: grid; grid-template-columns: 1fr; gap: 16px; }
.jfig { margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.jfig-frame { background: #2b2b2b; padding: 10px; display: grid; place-items: center; }
.jfig-frame.is-svg { background: #ffffff; padding: 14px; }
.jfig-frame.is-svg svg { width: 100%; height: auto; display: block; }
.jfig-img { width: 100%; height: auto; display: block; border-radius: 6px; }
.jfig-cap { padding: 11px 15px 14px; font-size: 16px; color: var(--muted); border-top: 1px solid var(--line); }

/* Konzepte */
.concepts { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.concept { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; box-shadow: var(--shadow); }
.concept-term { font-weight: 700; color: var(--accent-dark); margin-bottom: 4px; }
.concept-def { font-size: 18px; color: var(--ink); }

/* Formeln */
.formulas { display: flex; flex-direction: column; gap: 10px; }
.formula-row { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 8px 16px 12px; box-shadow: var(--shadow); }
.formula-cap { font-size: 17px; color: var(--muted); text-align: center; margin-top: 2px; }
.fbreak { margin-top: 10px; border-top: 1px dashed var(--line); padding-top: 8px; }
.fbreak-sum { cursor: pointer; font-size: 13px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--accent); list-style: none; }
.fbreak-sum::-webkit-details-marker { display: none; }
.fbreak-sum::before { content: "▸ "; }
.fbreak[open] .fbreak-sum::before { content: "▾ "; }
.fparts { display: grid; gap: 6px; margin-top: 8px; }
.fpart { display: grid; grid-template-columns: minmax(64px, auto) 1fr; gap: 12px; align-items: start; padding: 7px 10px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 9px; }
.fpart-sym { display: inline-flex; align-items: center; justify-content: center; padding: 3px 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 7px; }
.fpart-mean { font-size: 16px; color: var(--ink); align-self: center; }

/* Zusammenfassung */
.summary { background: var(--accent-soft); border: 1px solid transparent; border-left: 4px solid var(--accent); border-radius: 12px; padding: 16px 18px; }
.summary-text { margin: 0; font-size: 19px; }
:root[data-theme="dark"] .summary { border-color: var(--line); }

/* Klausurfragen */
.exams { display: flex; flex-direction: column; gap: 8px; }
.exam { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); overflow: hidden; }
.exam-q { cursor: pointer; padding: 13px 16px; display: flex; align-items: center; gap: 10px; font-weight: 600; list-style: none; }
.exam-q::-webkit-details-marker { display: none; }
.exam-q:hover { background: var(--surface-2); }
.exam-badge { font-size: 15px; font-weight: 800; color: #fff; background: var(--accent); border-radius: 6px; padding: 2px 7px; flex: none; }
.exam[open] .exam-badge { background: var(--ok); }
.exam-a { padding: 4px 16px 16px 44px; color: var(--ink); border-top: 1px solid var(--line); font-size: 18.5px; }

/* Prev/Next */
.prevnext { display: flex; justify-content: space-between; gap: 12px; margin-top: 34px; }
.pn { max-width: 46%; padding: 12px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; font-size: 17px; font-weight: 600; box-shadow: var(--shadow); }
.pn:hover { border-color: var(--accent); }
.pn-next { text-align: right; margin-left: auto; }

/* ----------------------------------------------------------- Home-Galerie */
.home-hero { padding: 10px 4px 22px; }
.home-hero h1 { font-size: 32px; margin: 0 0 8px; }
.home-sub { color: var(--muted); font-size: 19px; max-width: 720px; }
/* Klausur-Schwerpunkte (Home) */
.exam-overview { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; margin: 0 0 22px; }
.eo-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 10px; }
.eo-kicker { font-size: 15px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--bad); }
.eo-note { font-size: 13px; color: var(--muted); }
.eo-grid { display: grid; gap: 4px; }
.eo-row { display: grid; grid-template-columns: 30px 1fr auto auto; align-items: center; gap: 12px; padding: 8px 10px; border-radius: 9px; color: var(--ink); border: 1px solid transparent; }
.eo-row:hover { background: var(--surface-2); border-color: var(--line); }
.eo-row.level-hoch { border-left: 3px solid var(--bad); }
.eo-row.level-mittel { border-left: 3px solid var(--warn); }
.eo-row.level-niedrig { border-left: 3px solid var(--line); }
.eo-id { font-size: 13px; font-weight: 800; color: #fff; background: var(--accent); border-radius: 6px; text-align: center; padding: 2px 0; }
.eo-title { font-weight: 600; }
.eo-level { font-size: 13px; font-weight: 700; text-transform: capitalize; }
.eo-level.level-hoch { color: var(--bad); }
.eo-level.level-mittel { color: var(--warn); }
.eo-level.level-niedrig { color: var(--muted); }
.eo-pts { font-size: 13px; color: var(--muted); text-align: right; min-width: 190px; }
.home-card-badges { display: inline-flex; gap: 6px; align-items: center; }
.exam-badge-home { font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); }
.exam-badge-home.level-hoch { background: color-mix(in srgb, var(--bad) 16%, transparent); color: var(--bad); border-color: transparent; }
.exam-badge-home.level-mittel { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); border-color: transparent; }

.home-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.home-card { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; color: var(--ink); transition: transform .12s ease, border-color .12s ease; }
.home-card:hover { transform: translateY(-3px); border-color: var(--accent); }
.home-thumb { background: #fff; border-bottom: 1px solid var(--line); height: 150px; overflow: hidden; display: grid; place-items: center; }
.home-thumb svg { width: 100%; height: 100%; object-fit: contain; }
.home-card-body { padding: 13px 15px 15px; }
.home-card-top { display: flex; justify-content: space-between; align-items: center; }
.home-card-id { font-size: 15px; font-weight: 800; color: #fff; background: var(--accent); border-radius: 6px; padding: 2px 8px; }
.home-card-done { color: var(--ok); font-weight: 800; }
.home-card-title { margin: 8px 0 4px; font-size: 20px; }
.home-card-tag { margin: 0 0 8px; font-size: 17px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.home-card-meta { font-size: 15.5px; color: var(--muted); }

.notfound { padding: 40px; text-align: center; color: var(--muted); }

/* KaTeX etwas zähmen */
.katex { font-size: 1.02em; }
.katex-display { margin: 0; overflow-x: auto; overflow-y: hidden; }
/* versteckte MathML-Ebene (nur a11y) nie ins Layout einrechnen -> kein Randüberlauf mobil */
.katex-mathml { display: none; }

/* -------------------------------------------------------- Interaktive Aufgaben */
.ex-score { display: inline-block; font-size: 15px; font-weight: 700; color: var(--accent-dark); background: var(--accent-soft); border-radius: 99px; padding: 6px 14px; margin-bottom: 14px; }
.exercises-list { display: flex; flex-direction: column; gap: 14px; }
.exercise { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; }
.ex-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.ex-num { width: 30px; height: 30px; border-radius: 8px; background: var(--accent-soft); color: var(--accent-dark); font-weight: 800; display: grid; place-items: center; font-size: 15px; }
.ex-type { font-size: 12px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--accent2); }
.ex-prompt { font-size: 17px; margin-bottom: 12px; line-height: 1.5; }

.opts { display: flex; flex-direction: column; gap: 8px; }
.opt { display: flex; align-items: flex-start; gap: 10px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; background: var(--surface-2); font-size: 16px; }
.opt:hover { border-color: var(--accent2); }
.opt-mark { flex: none; width: 20px; height: 20px; margin-top: 1px; border: 2px solid var(--muted); border-radius: 50%; }
.opts.multi .opt-mark { border-radius: 5px; }
.opt.sel { border-color: var(--accent); background: var(--accent-soft); }
.opt.sel .opt-mark { border-color: var(--accent); background: var(--accent); box-shadow: inset 0 0 0 3px var(--surface); }
.opt.correct { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 14%, var(--surface)); }
.opt.correct .opt-mark { border-color: var(--ok); background: var(--ok); }
.opt.wrong { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 12%, var(--surface)); }
.opt.wrong .opt-mark { border-color: var(--bad); }

.tf-row { display: flex; gap: 10px; }
.tf { padding: 10px 22px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); font-size: 16px; font-weight: 600; cursor: pointer; color: var(--ink); }
.tf:hover { border-color: var(--accent2); }
.tf.sel { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-dark); }
.tf.correct { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 16%, var(--surface)); color: var(--ok); }
.tf.wrong { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 12%, var(--surface)); color: var(--bad); }

.ex-inline { display: flex; align-items: center; gap: 10px; }
.ex-input { padding: 10px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); color: var(--ink); font-size: 16px; width: 160px; }
.ex-input.wide { width: min(420px, 100%); }
.ex-input:focus { outline: 2px solid var(--accent); border-color: transparent; }
.ex-unit { color: var(--muted); font-size: 15px; }

.ord-list { display: flex; flex-direction: column; gap: 8px; }
.ord-item { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); font-size: 16px; }
.ord-item.correct { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, var(--surface)); }
.ord-pos { flex: none; width: 26px; height: 26px; border-radius: 7px; background: var(--accent-soft); color: var(--accent-dark); font-weight: 800; display: grid; place-items: center; font-size: 14px; }
.ord-text { flex: 1; }
.ord-ctrl { display: flex; gap: 4px; }
.ord-btn { width: 34px; height: 30px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); color: var(--ink); cursor: pointer; font-size: 13px; }
.ord-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent-dark); }
.ord-btn:disabled { opacity: .35; cursor: default; }

.ex-bar { display: flex; align-items: center; gap: 14px; margin-top: 14px; flex-wrap: wrap; }
.ex-check { padding: 10px 22px; border: none; border-radius: 10px; background: var(--accent); color: #fff; font-weight: 700; font-size: 15px; cursor: pointer; }
.ex-check:hover { background: var(--accent-dark); }
.ex-feedback { font-weight: 700; font-size: 15.5px; }
.ex-feedback.ok { color: var(--ok); }
.ex-feedback.bad { color: var(--bad); }
.ex-expl { display: none; margin-top: 12px; padding: 12px 16px; background: var(--surface-2); border: 1px solid var(--line); border-left: 3px solid var(--accent2); border-radius: 10px; font-size: 16px; line-height: 1.55; }
.ex-expl.show { display: block; }
.ex-count-badge { font-size: 11.5px; font-weight: 800; color: #fff; background: var(--accent2); border-radius: 6px; padding: 2px 8px; }
.ex-count-badge.muted { background: var(--muted); }

/* ------------------------------------------------------------- Responsive */
/* Tablet & kleiner: Sidebar als Off-Canvas-Menü */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; z-index: 60; left: 0; top: 0; width: 86%; max-width: 340px;
    height: 100vh; height: 100dvh;
    transform: translateX(-100%); transition: transform .22s ease;
    padding-bottom: 28px;
  }
  body.nav-open .sidebar { transform: translateX(0); box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .45); }
  #menu-toggle { display: inline-flex; align-items: center; justify-content: center; }
  main#view { padding: 18px 16px 72px; overflow-x: clip; }
  /* breite Inhalte niemals über den Rand: horizontal scrollen statt Seite sprengen */
  .formula, .katex-display, .ex-expl, .fpart-sym, .viz-frame { overflow-x: auto; }
  /* Umbruch überall im Content/Menü erzwingen (auch lange Wörter/Begriffe) */
  main#view, .sidebar { overflow-wrap: anywhere; }
  /* Flex-/Grid-Textboxen dürfen unter ihre Inhaltsbreite schrumpfen */
  .hero-titles, .step-body, .opt, .opt-text, .home-card-body, .exam, .exam-q,
  .ef-head, .eo-row, .concept, .formula-row, .jnote { min-width: 0; }
}

/* Handy */
@media (max-width: 600px) {
  :root { --sidebar-w: 100%; }
  body { font-size: 16px; }
  /* Fließtext trennen (lang="de" im <html>) statt rauslaufen */
  .hero-tagline, .home-sub, .step-text, .ex-prompt, .concept-def, .summary-text,
  .ef-list li, .jnote-text, .viz-expl, .opt-text, .exam-a, .home-card-tag,
  .fpart-mean, .viz-cap { hyphens: auto; }
  /* Inline-Mathe minimal schmaler, damit es eher in eine Zeile passt */
  .katex { font-size: 0.97em; }
  /* Uppercase-Labels weniger sperren + umbrechen dürfen */
  .sec-kicker, .ex-type, .eo-kicker, .ef-kicker { letter-spacing: .03em; }
  .eo-head { flex-wrap: wrap; }

  .topbar { gap: 8px; padding: 8px 14px; }
  .progress { max-width: 200px; }
  #progress-label { display: none; }
  .iconbtn { width: 40px; height: 40px; }
  main#view { padding: 14px 12px 72px; }

  /* Hero kompakter */
  .hero { padding: 16px 15px; margin-bottom: 16px; }
  .hero-top { gap: 12px; }
  .hero-id { width: 44px; height: 44px; font-size: 20px; border-radius: 10px; }
  .hero-title { font-size: 22px; }
  .hero-en { font-size: 14px; }
  .hero-tagline { font-size: 16px; margin: 12px 0; }
  .chip { font-size: 14px; padding: 5px 10px; }
  .done-btn { width: 100%; padding: 12px; font-size: 15px; }

  /* Abschnitte / Karten */
  .block { margin: 20px 0; }
  .sec-title { font-size: 19px; }
  .viz-frame { padding: 10px 12px; }
  .viz-cap { padding: 10px 14px; font-size: 15.5px; }
  .viz-expl { padding: 0 14px 14px; font-size: 15.5px; }
  .step { padding: 14px; gap: 10px; grid-template-columns: 34px 1fr; }
  .concepts { grid-template-columns: 1fr; }
  .formula { padding: 8px 12px; }

  /* Home-Galerie einspaltig */
  .home-hero h1 { font-size: 22px; }
  .home-sub { font-size: 15px; }
  .home-grid { grid-template-columns: 1fr; }

  /* Klausur-Fokus / Übersicht */
  .examfocus { padding: 15px 16px; }
  .ef-level { font-size: 17px; }
  .ef-list li { font-size: 15.5px; }
  .exam-overview { padding: 14px 14px; }
  .eo-row { grid-template-columns: 26px 1fr auto; row-gap: 2px; padding: 8px; }
  .eo-pts { grid-column: 2 / -1; text-align: left; min-width: 0; font-size: 12.5px; }

  /* Interaktive Aufgaben */
  .exercise { padding: 14px 13px; }
  .ex-prompt { font-size: 15.5px; }
  .opt { font-size: 15px; padding: 11px 12px; }
  .tf { padding: 11px 18px; }
  .ex-input { width: 100%; }
  .ex-input.wide { width: 100%; }
  .ex-inline { flex-wrap: wrap; }
  .ex-bar { gap: 10px; }
  .ex-check { padding: 12px 20px; }
  .fpart { grid-template-columns: minmax(52px, auto) 1fr; gap: 10px; padding: 7px 9px; }

  /* Vor/Zurück gestapelt, gut tappbar */
  .prevnext { flex-direction: column; gap: 8px; }
  .pn { max-width: 100%; width: 100%; }
  .pn-next { text-align: left; }
}

/* Sehr kleine Geräte */
@media (max-width: 380px) {
  body { font-size: 15px; }
  main#view { padding: 12px 10px 72px; }
  .hero { padding: 14px 13px; }
  .hero-title { font-size: 20px; }
  .home-hero h1 { font-size: 20px; }
  .sec-title { font-size: 18px; }
  .exercise { padding: 13px 11px; }
  .opt { padding: 10px 11px; }
  .progress { display: none; }
  .brand-txt b { font-size: 16px; }
}
