/* StuKo Trainer — dark-first, subject-colored, 8px system */
@font-face {
  font-family: 'Space Grotesk';
  src: url('../fonts/space-grotesk-2.woff2') format('woff2');
  font-weight: 300 700;
  font-display: swap;
}

:root {
  --bg: #0e1117;
  --surface: #171c26;
  --surface2: #1f2532;
  --border: #2a3040;
  --text: #e8eaf0;
  --text2: #9aa3b5;
  --accent: #2dd4bf;
  --accent-ink: #06302b;
  --danger: #f87171;
  --ok: #4ade80;
  --physik: #818cf8;
  --chemie: #34d399;
  --mathe: #fbbf24;
  --informatik: #c084fc;
  --es: #7dd3fc;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(0,0,0,.3);
}
[data-theme="light"] {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface2: #eef1f6;
  --border: #dde2ea;
  --text: #1a1d27;
  --text2: #5b6474;
  --accent: #0d9488;
  --accent-ink: #ffffff;
  --danger: #dc2626;
  --ok: #16a34a;
  --physik: #4f46e5;
  --chemie: #059669;
  --mathe: #d97706;
  --informatik: #9333ea;
  --es: #0369a1;
  --shadow: 0 1px 3px rgba(20,30,60,.10);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { font-size: 16px; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, 'Segoe UI', Roboto, sans-serif;
  line-height: 1.6;
  min-height: 100vh;
  overscroll-behavior-y: none;
  overflow-x: hidden;
}
/* Wide content (long formulas, tables) scrolls sideways inside its own container.
   overflow-y MUST stay hidden: with `visible` the browser promotes it to `auto`, and every
   such box becomes a vertical touch-scroller that steals the page's scroll gesture. */
.katex-display { overflow-x: auto; overflow-y: hidden; padding: 4px 0; }
.section-card .body-de, .section-card .q-text, .q-text, .step .st-de, .es-help, .feedback,
.reader, .tabs, .code-box, .trace-table, .formula-row .fx, .reader table {
  overflow-y: hidden;
}
.flash-face { overflow-x: hidden; overflow-y: auto; }
h1, h2, h3, .sg { font-family: 'Space Grotesk', system-ui, sans-serif; line-height: 1.2; }
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
input { font: inherit; }

#app { max-width: 720px; margin: 0 auto; padding: calc(16px + env(safe-area-inset-top)) 16px calc(40px + env(safe-area-inset-bottom)); }

/* ---------- top bar ---------- */
.topbar { display: flex; align-items: center; gap: 8px; margin-bottom: 24px; min-height: 48px; }
.topbar .back {
  width: 44px; height: 44px; border-radius: 12px; flex: none;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface); border: 1px solid var(--border);
}
.topbar .title { flex: 1; min-width: 0; }
.topbar .title h1 { font-size: 21px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .title .sub { font-size: 13px; color: var(--text2); }
.iconbtn {
  width: 44px; height: 44px; border-radius: 12px; flex: none;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface); border: 1px solid var(--border);
  transition: background .15s;
}
.iconbtn:active { background: var(--surface2); }
.iconbtn svg { width: 20px; height: 20px; stroke: var(--text2); }
.iconbtn.on { border-color: var(--es); }
.iconbtn.on svg { stroke: var(--es); }
.es-chip {
  height: 44px; padding: 0 14px; border-radius: 12px; flex: none;
  display: flex; align-items: center; gap: 6px;
  background: var(--surface); border: 1px solid var(--border);
  font-size: 14px; font-weight: 600; color: var(--text2);
}
.es-chip.on { color: var(--es); border-color: var(--es); }

/* ---------- home ---------- */
.hero { margin: 8px 0 24px; }
.hero .hi { font-size: 15px; color: var(--text2); }
.hero h1 { font-size: 33px; letter-spacing: -0.5px; }
.hero .ring-row { display: flex; align-items: center; gap: 16px; margin-top: 16px; }
.ring { position: relative; width: 72px; height: 72px; flex: none; }
.ring svg { transform: rotate(-90deg); }
.ring .pct { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-family: 'Space Grotesk'; font-weight: 700; font-size: 17px; }
.ring-label { font-size: 14px; color: var(--text2); }

.continue-card {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  background: linear-gradient(120deg, var(--surface), var(--surface2));
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; margin-bottom: 24px; box-shadow: var(--shadow);
}
.continue-card .cc-icon { width: 40px; height: 40px; border-radius: 10px; display: flex; align-items: center; justify-content: center; flex: none; }
.continue-card .cc-body { flex: 1; min-width: 0; }
.continue-card .cc-kicker { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--accent); font-weight: 700; }
.continue-card .cc-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.subject-list { display: flex; flex-direction: column; gap: 12px; }
.subject-card {
  display: flex; align-items: center; gap: 16px; width: 100%; text-align: left;
  background: var(--surface); border: 1px solid var(--border);
  border-left: 4px solid var(--sc, var(--accent));
  border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow);
  transition: transform .15s;
}
.subject-card:active { transform: scale(.985); }
.subject-card .sicon { width: 48px; height: 48px; border-radius: 12px; flex: none; display: flex; align-items: center; justify-content: center; background: color-mix(in srgb, var(--sc) 16%, transparent); }
.subject-card .sicon svg { width: 26px; height: 26px; stroke: var(--sc); }
.subject-card .sbody { flex: 1; min-width: 0; }
.subject-card .sname { font-family: 'Space Grotesk'; font-weight: 700; font-size: 17px; }
.subject-card .smeta { font-size: 13px; color: var(--text2); margin-top: 2px; }
.subject-card .spct { font-family: 'Space Grotesk'; font-weight: 700; font-size: 17px; color: var(--sc); }
.progressbar { height: 6px; background: var(--surface2); border-radius: 3px; overflow: hidden; margin-top: 8px; }
.progressbar > div { height: 100%; border-radius: 3px; background: var(--sc, var(--accent)); transition: width .3s; }

/* ---------- topic list ---------- */
.topic-card {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow);
}
.topic-card .tnum {
  width: 40px; height: 40px; border-radius: 10px; flex: none;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Space Grotesk'; font-weight: 700; font-size: 15px;
  background: color-mix(in srgb, var(--sc) 14%, transparent); color: var(--sc);
}
.topic-card .tbody { flex: 1; min-width: 0; }
.topic-card .ttitle { font-weight: 600; font-size: 15px; }
.topic-card .tmeta { display: flex; gap: 10px; font-size: 12.5px; color: var(--text2); margin-top: 3px; flex-wrap: wrap; }
.topic-card .tmeta .done { color: var(--ok); }
.badge-extra { font-size: 11px; color: var(--mathe); border: 1px solid var(--mathe); border-radius: 6px; padding: 1px 6px; display: inline-block; white-space: nowrap; text-decoration: none; vertical-align: middle; }
.exam-card { border-left: 4px solid var(--text2); }

/* ---------- tabs ---------- */
.tabs {
  display: flex; gap: 4px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 4px; margin-bottom: 20px; overflow-x: auto; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
  flex: 1; min-width: max-content; padding: 10px 14px; border-radius: 9px;
  font-size: 14px; font-weight: 600; color: var(--text2); white-space: nowrap;
}
.tabs button.active { background: var(--sc, var(--accent)); color: var(--bg); }

/* ---------- content blocks ---------- */
.section-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; margin-bottom: 16px; box-shadow: var(--shadow);
  overflow-wrap: break-word;
}
.section-card h3 { font-size: 17px; margin-bottom: 4px; }
.section-card .t-es { font-size: 13px; color: var(--text2); margin-bottom: 10px; }
.section-card .body-de p, .section-card .body-de li { margin-bottom: 8px; font-size: 15px; }
.section-card .body-de ul, .section-card .body-de ol { padding-left: 22px; margin-bottom: 8px; }
.section-card .body-de table { border-collapse: collapse; margin: 8px 0; width: 100%; font-size: 14px; }
.section-card .body-de td, .section-card .body-de th { border: 1px solid var(--border); padding: 6px 8px; }
.es-help {
  margin-top: 12px; padding: 12px 14px; border-radius: 10px; font-size: 14px;
  background: color-mix(in srgb, var(--es) 9%, transparent);
  border-left: 3px solid var(--es); color: var(--text);
}
.es-help .es-tag { font-size: 11px; font-weight: 700; letter-spacing: .08em; color: var(--es); display: block; margin-bottom: 4px; }

/* mobile: formula on its own line above the description — two narrow columns wreck long formulas */
.formula-row { display: flex; flex-direction: column; gap: 8px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.formula-row:last-child { border-bottom: none; }
.formula-row .fx { text-align: left; overflow-x: auto; overflow-y: hidden; max-width: 100%; padding-bottom: 2px; }
.formula-row .fbody { min-width: 0; }
@media (min-width: 560px) {
  .formula-row { flex-direction: row; align-items: center; gap: 16px; }
  .formula-row .fx { flex: none; max-width: 42%; text-align: center; }
  .formula-row .fbody { flex: 1; }
}
.formula-row .fname { font-weight: 600; font-size: 14.5px; }
.formula-row .fvars { font-size: 13px; color: var(--text2); margin-top: 2px; }
.formula-row .fes { font-size: 13px; color: var(--es); }

.vocab-row { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 14.5px; align-items: baseline; }
.vocab-row:last-child { border-bottom: none; }
.vocab-row .vde { font-weight: 600; flex: 1; }
.vocab-row .ves { color: var(--text2); flex: 1; }
.vocab-row .vnote { font-size: 12.5px; color: var(--es); display: block; }

/* ---------- lesson reader ---------- */
.lesson-item { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 14px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 10px; }
.lesson-item svg { width: 18px; height: 18px; stroke: var(--sc, var(--accent)); flex: none; }
.lesson-item span { font-size: 14.5px; font-weight: 600; }
.reader { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px 16px; overflow-wrap: break-word; }
.reader img { max-width: 100%; height: auto; border-radius: 8px; background: #fff; }
.reader h1, .reader h2, .reader h3, .reader h4 { margin: 16px 0 8px; line-height: 1.3; }
.reader h1 { font-size: 23px; } .reader h2 { font-size: 19px; } .reader h3 { font-size: 17px; }
.reader p, .reader li { margin-bottom: 10px; font-size: 15.5px; }
.reader ul, .reader ol { padding-left: 24px; margin-bottom: 10px; }
.reader table { border-collapse: collapse; margin: 12px 0; max-width: 100%; display: block; overflow-x: auto; font-size: 14px; }
.reader td, .reader th { border: 1px solid var(--border); padding: 6px 10px; }
.reader a { color: var(--accent); }
.reader .katex-display { overflow-x: auto; overflow-y: hidden; padding: 4px 0; }
.reader { overflow-x: auto; }
.reader .MathJax_Preview, .reader .nolink, .reader .filter_mathjaxloader_equation {
  display: inline-block; max-width: 100%; overflow-x: auto; overflow-y: hidden; vertical-align: middle;
}
.katex { font-size: 1.05em; }

/* ---------- quiz ---------- */
.quiz-progress { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.quiz-progress .qp-text { font-size: 13.5px; color: var(--text2); font-weight: 600; flex: none; }
.quiz-progress .progressbar { flex: 1; margin-top: 0; }
.diff-dots { display: inline-flex; gap: 3px; margin-left: 8px; vertical-align: middle; }
.diff-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--border); }
.diff-dots i.on { background: var(--mathe); }
.q-text { font-size: 17px; font-weight: 600; margin-bottom: 16px; }
.q-text .katex-display { overflow-x: auto; }
.opt-list { display: flex; flex-direction: column; gap: 10px; }
.opt {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 14px 16px; min-height: 52px; border-radius: 12px; font-size: 15px;
  background: var(--surface2); border: 1.5px solid var(--border);
  transition: border-color .15s, background .15s;
}
.opt .opt-key { width: 26px; height: 26px; border-radius: 8px; flex: none; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; background: var(--surface); border: 1px solid var(--border); }
.opt.sel { border-color: var(--accent); }
.opt.correct { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 10%, var(--surface2)); }
.opt.wrong { border-color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, var(--surface2)); }
.num-row { display: flex; gap: 10px; align-items: stretch; }
.num-input {
  flex: 1; min-width: 0; padding: 14px 16px; border-radius: 12px; font-size: 17px;
  background: var(--surface2); border: 1.5px solid var(--border); color: var(--text);
}
.num-input:focus { outline: none; border-color: var(--accent); }
.num-unit { display: flex; align-items: center; padding: 0 14px; border-radius: 12px; background: var(--surface2); border: 1px solid var(--border); color: var(--text2); font-size: 15px; }
.feedback { border-radius: 12px; padding: 14px 16px; margin-top: 16px; font-size: 14.5px; }
.feedback.good { background: color-mix(in srgb, var(--ok) 10%, transparent); border: 1px solid var(--ok); }
.feedback.bad { background: color-mix(in srgb, var(--danger) 10%, transparent); border: 1px solid var(--danger); }
.feedback .fb-head { font-weight: 700; margin-bottom: 6px; }
.feedback .fb-solution { margin-bottom: 6px; }
.hint-btn { font-size: 13.5px; color: var(--es); font-weight: 600; padding: 8px 0; }
.hint-box { font-size: 14px; color: var(--es); padding: 10px 14px; border-radius: 10px; background: color-mix(in srgb, var(--es) 9%, transparent); margin-top: 8px; }

.btn-primary {
  display: block; width: 100%; padding: 15px; min-height: 52px; margin-top: 20px;
  border-radius: 12px; font-size: 16px; font-weight: 700;
  background: var(--accent); color: var(--accent-ink);
  transition: opacity .15s, transform .1s;
}
.btn-primary:active { transform: scale(.98); }
.btn-primary:disabled { opacity: .4; }
.btn-ghost {
  display: block; width: 100%; padding: 13px; min-height: 48px; margin-top: 10px;
  border-radius: 12px; font-size: 15px; font-weight: 600;
  background: none; border: 1.5px solid var(--border); color: var(--text2);
}

/* quiz result */
.result-hero { text-align: center; padding: 32px 16px 24px; }
.result-hero .big { font-family: 'Space Grotesk'; font-size: 48px; font-weight: 700; }
.result-hero .msg { color: var(--text2); margin-top: 4px; }

/* ---------- flashcards ---------- */
.flash-stage { perspective: 1200px; margin-bottom: 16px; }
.flash-card {
  position: relative; width: 100%; min-height: 260px;
  transform-style: preserve-3d; transition: transform .45s;
  cursor: pointer;
}
.flash-card.flipped { transform: rotateY(180deg); }
.flash-face {
  position: absolute; inset: 0; backface-visibility: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; padding: 24px; text-align: center;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  overflow-y: auto;
}
.flash-face.back { transform: rotateY(180deg); }
.flash-face .ff-label { font-size: 11px; font-weight: 700; letter-spacing: .1em; color: var(--text2); text-transform: uppercase; }
.flash-face .ff-main { font-size: 19px; font-weight: 600; }
.flash-face .ff-es { font-size: 14px; color: var(--es); }
.flash-actions { display: flex; gap: 10px; }
.flash-actions button { flex: 1; padding: 14px; min-height: 52px; border-radius: 12px; font-size: 15px; font-weight: 700; border: 1.5px solid var(--border); background: var(--surface); }
.flash-actions .again { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 50%, var(--border)); }
.flash-actions .good { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 50%, var(--border)); }
.flash-stat { text-align: center; font-size: 13.5px; color: var(--text2); margin-bottom: 12px; }
.boxbar { display: flex; gap: 6px; margin: 12px 0 20px; }
.boxbar .bx { flex: 1; text-align: center; font-size: 12.5px; color: var(--text2); background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 8px 4px; }
.boxbar .bx b { display: block; font-family: 'Space Grotesk'; font-size: 17px; color: var(--text); }

/* ---------- problems ---------- */
.step-list { counter-reset: step; }
.step {
  position: relative; padding: 12px 0 12px 40px; border-bottom: 1px solid var(--border);
}
.step:last-child { border-bottom: none; }
.step::before {
  counter-increment: step; content: counter(step);
  position: absolute; left: 0; top: 14px;
  width: 26px; height: 26px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; font-family: 'Space Grotesk';
  background: color-mix(in srgb, var(--sc, var(--accent)) 14%, transparent); color: var(--sc, var(--accent));
}
.step .st-de { font-size: 14.5px; }
.answer-chip { display: inline-block; margin-top: 10px; padding: 8px 14px; border-radius: 10px; background: color-mix(in srgb, var(--ok) 12%, transparent); border: 1px solid var(--ok); font-weight: 600; font-size: 14.5px; }

/* ---------- search ---------- */
.search-bar { display: flex; gap: 10px; margin-bottom: 20px; }
.search-bar input {
  flex: 1; min-width: 0; padding: 13px 16px; border-radius: 12px; font-size: 16px;
  background: var(--surface); border: 1.5px solid var(--border); color: var(--text);
}
.search-bar input:focus { outline: none; border-color: var(--accent); }
.result-row { display: block; width: 100%; text-align: left; padding: 12px 14px; border-radius: 10px; background: var(--surface); border: 1px solid var(--border); margin-bottom: 8px; }
.result-row .rr-kind { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--sc, var(--accent)); }
.result-row .rr-text { font-size: 14.5px; margin-top: 2px; }
.result-row .rr-sub { font-size: 12.5px; color: var(--text2); }

/* ---------- settings ---------- */
.set-row { display: flex; align-items: center; gap: 12px; padding: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 12px; }
.set-row .sr-body { flex: 1; }
.set-row .sr-title { font-weight: 600; font-size: 15px; }
.set-row .sr-sub { font-size: 13px; color: var(--text2); }
.seg { display: flex; background: var(--surface2); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { padding: 8px 12px; border-radius: 8px; font-size: 13.5px; font-weight: 600; color: var(--text2); }
.seg button.active { background: var(--accent); color: var(--accent-ink); }
.switch { position: relative; width: 50px; height: 30px; border-radius: 15px; background: var(--surface2); border: 1px solid var(--border); transition: background .2s; flex: none; }
.switch.on { background: var(--accent); border-color: var(--accent); }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: left .2s; box-shadow: 0 1px 2px rgba(0,0,0,.3); }
.switch.on::after { left: 24px; }
.btn-danger { display: block; width: 100%; padding: 13px; border-radius: 12px; font-size: 15px; font-weight: 600; border: 1.5px solid var(--danger); color: var(--danger); margin-top: 24px; }

/* ---------- misc ---------- */
.empty-state { text-align: center; padding: 48px 24px; color: var(--text2); }
.empty-state svg { width: 44px; height: 44px; stroke: var(--text2); margin-bottom: 12px; opacity: .7; }
.empty-state .es-title { font-weight: 600; color: var(--text); margin-bottom: 4px; }
.empty-state .es-sub { font-size: 14px; }
.loading { text-align: center; padding: 48px; color: var(--text2); }
.spinner { width: 28px; height: 28px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; margin: 0 auto 12px; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.toast {
  position: fixed; bottom: calc(24px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%);
  background: var(--surface2); border: 1px solid var(--border); color: var(--text);
  padding: 12px 20px; border-radius: 12px; font-size: 14.5px; z-index: 30; box-shadow: 0 4px 16px rgba(0,0,0,.3);
  max-width: calc(100vw - 48px);
}
.section-label { font-size: 12.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--text2); margin: 24px 0 10px; }
.card-list { display: flex; flex-direction: column; gap: 10px; }

/* ---------- motion & micro-interactions ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes routein { from { opacity: .55; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes shakeX { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
@keyframes popIn { 0% { transform: scale(1); } 45% { transform: scale(1.045); } 100% { transform: scale(1); } }
@keyframes bigPop { 0% { transform: scale(.6); opacity: 0; } 70% { transform: scale(1.08); } 100% { transform: scale(1); opacity: 1; } }
#app.route-in > *:not(.topbar) { animation: routein .22s ease both; }
.subject-card, .topic-card, .lesson-item, .exam-card { animation: rise .3s cubic-bezier(.22,1,.36,1) both; }
.shake { animation: shakeX .35s ease both; }
.pop { animation: popIn .3s ease both; }
.feedback { animation: rise .25s ease both; }
.result-hero .big { animation: bigPop .5s cubic-bezier(.22,1,.36,1) both; display: inline-block; }
.flash-stage { transition: transform .18s ease, opacity .18s ease; }
.flash-stage.exit-right { transform: translateX(70px) rotate(3deg); opacity: 0; }
.flash-stage.exit-left { transform: translateX(-70px) rotate(-3deg); opacity: 0; }
.flash-card { transition: transform .45s cubic-bezier(.3,1.4,.5,1); }
.tabs button { transition: background .18s ease, color .18s ease; }
.opt { transition: border-color .15s, background .15s, transform .12s; }
.opt:active { transform: scale(.98); }
.btn-ghost, .iconbtn, .es-chip { transition: background .15s, border-color .15s, transform .12s; }
.btn-ghost:active { transform: scale(.98); }
.progressbar > div { transition: width .5s cubic-bezier(.22,1,.36,1); }

/* sticky header + tabs (thumb-reachable navigation while reading) */
.topbar {
  position: sticky; top: 0; z-index: 20;
  margin: 0 -16px 24px; padding: calc(8px + env(safe-area-inset-top)) 16px 8px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
.tabs { position: sticky; top: var(--topbarH, 60px); z-index: 19; }

/* pdf viewer */
.pdf-badge { margin-left: auto; font-size: 11px; font-weight: 700; letter-spacing: .05em; color: var(--danger); border: 1px solid var(--danger); border-radius: 6px; padding: 1px 6px; flex: none; }
.reader.pdf-reader { padding: 8px; background: var(--surface2); }
.doc-img { width: 100%; height: auto; border-radius: 8px; background: #fff; }
.pdf-page { display: block; width: 100%; margin: 0 auto 10px; border-radius: 6px; box-shadow: var(--shadow); background: #fff; }

/* stats */
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 8px; }
.stat-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 2px; box-shadow: var(--shadow); }
.stat-box b { font-family: 'Space Grotesk', system-ui; font-size: 27px; line-height: 1.1; }
.stat-box span { font-size: 12.5px; color: var(--text2); }
.heat { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.heat i { aspect-ratio: 1; border-radius: 4px; background: var(--surface2); border: 1px solid var(--border); }
.heat i.on { background: var(--accent); border-color: var(--accent); }
.fsp-badge { font-size: 10px; font-weight: 700; letter-spacing: .06em; color: var(--bg); background: var(--mathe); border-radius: 5px; padding: 2px 5px; margin-left: 8px; vertical-align: middle; }

.daily-card .cc-icon { font-family: 'Space Grotesk', system-ui; font-weight: 700; font-size: 17px; }
.daily-card { border-left: 4px solid var(--mathe); }

/* exam format sheet */
.fmt-row { display: flex; flex-direction: column; gap: 3px; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.fmt-row:last-child { border-bottom: none; }
.fmt-row i { font-style: normal; color: var(--text2); font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.fold-btn { color: var(--accent); font-weight: 600; font-size: 13.5px; padding: 2px 4px; }
.fmt-links { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip { font-size: 12px; font-weight: 600; padding: 6px 11px; border-radius: 8px; background: var(--surface2); border: 1px solid var(--border); color: var(--text2); }
.note-table { display: grid; grid-template-columns: repeat(auto-fit, minmax(104px, 1fr)); gap: 6px; }
.nt-row { display: flex; justify-content: space-between; align-items: baseline; background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px; font-size: 12.5px; color: var(--text2); }
.nt-row b { font-family: 'Space Grotesk', system-ui; font-size: 15px; color: var(--text); }
.warn-card { background: color-mix(in srgb, var(--mathe) 10%, var(--surface)); border-color: var(--mathe); }
.warn-card b { font-size: 13.5px; color: var(--mathe); }

/* ---------- Prüfungssimulation ---------- */
.sim-exam-card .tnum { font-size: 19px; }
.exam-bar { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.exam-clock {
  font-family: 'Space Grotesk', system-ui; font-weight: 700; font-size: 19px;
  font-variant-numeric: tabular-nums; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px; padding: 5px 11px; flex: none;
}
.exam-clock.low { color: var(--danger); border-color: var(--danger); animation: popIn .5s ease infinite; }
.exam-count { font-size: 13px; color: var(--text2); font-weight: 600; flex: none; }
.exam-topic { font-size: 11.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--sc, var(--accent)); margin-bottom: 8px; }
.exam-nav { display: flex; gap: 8px; margin-top: 14px; }
.exam-nav .btn-ghost { margin-top: 0; flex: 1; padding: 12px 6px; font-size: 13.5px; }
.exam-nav .btn-ghost:disabled { opacity: .35; }
.exam-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); gap: 6px; margin-top: 16px; }
.eg {
  aspect-ratio: 1; border-radius: 9px; background: var(--surface); border: 1.5px solid var(--border);
  font-size: 13px; font-weight: 600; color: var(--text2);
}
.eg.done { background: color-mix(in srgb, var(--accent) 18%, var(--surface)); border-color: var(--accent); color: var(--text); }
.eg.flag { border-color: var(--mathe); color: var(--mathe); }
.eg.cur { outline: 2px solid var(--text); outline-offset: 1px; }
.exam-sol { border-left: 4px solid var(--border); }
.exam-sol.ok { border-left-color: var(--ok); }
.exam-sol.bad { border-left-color: var(--danger); }
.exam-sol .es-head { font-size: 12.5px; font-weight: 700; color: var(--text2); margin-bottom: 8px; }
.exam-sol.ok .es-head { color: var(--ok); }
.exam-sol.bad .es-head { color: var(--danger); }
.exam-sol .es-line { font-size: 13.5px; margin-top: 6px; }
.exam-sol .es-line i { color: var(--text2); font-style: normal; }
.exam-sol .es-line.good { color: var(--ok); }
.exam-sol .es-expl { font-size: 14px; margin-top: 10px; }
.hist-row { display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; }
.hist-note { font-family: 'Space Grotesk', system-ui; font-size: 21px; font-weight: 700; color: var(--accent); flex: none; }
.hist-body { display: flex; flex-direction: column; }
.hist-body b { font-size: 14px; }
.hist-body span { font-size: 12.5px; color: var(--text2); }

/* ---------- Glossar: tappable notation + explanation sheet ---------- */
.gl-term {
  border-bottom: 1.5px dotted var(--accent);
  color: inherit; cursor: pointer; padding-bottom: 1px;
}
.gl-term:active { background: color-mix(in srgb, var(--accent) 18%, transparent); border-radius: 3px; }
.gl-formula { cursor: pointer; border-radius: 4px; padding: 1px 2px; margin: -1px -2px; }
.gl-formula:active { background: color-mix(in srgb, var(--accent) 16%, transparent); }
.gl-backdrop {
  position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.45);
  display: flex; align-items: flex-end; opacity: 0; transition: opacity .18s ease;
  -webkit-tap-highlight-color: transparent;
}
.gl-backdrop.open { opacity: 1; }
.gl-sheet {
  width: 100%; max-height: 82vh; overflow-y: auto; overflow-x: hidden;
  background: var(--surface); border-top-left-radius: 20px; border-top-right-radius: 20px;
  border-top: 1px solid var(--border); padding: 8px 16px calc(20px + env(safe-area-inset-bottom));
  transform: translateY(24px); transition: transform .22s cubic-bezier(.22,1,.36,1);
  box-shadow: 0 -6px 24px rgba(0,0,0,.35);
}
.gl-backdrop.open .gl-sheet { transform: none; }
.gl-grab { width: 42px; height: 4px; border-radius: 2px; background: var(--border); margin: 4px auto 12px; }
.gl-src-title { font-size: 12px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--text2); margin-bottom: 10px; }
.gl-entry { padding: 10px 0; border-bottom: 1px solid var(--border); }
.gl-entry:last-of-type { border-bottom: none; }
.gl-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 8px; min-width: 0; }
.gl-term-big {
  font-family: 'Space Grotesk', system-ui; font-size: 24px; font-weight: 700; color: var(--accent);
  min-width: 44px; max-width: 46%; text-align: center; flex: 0 1 auto; line-height: 1.25;
  overflow-wrap: anywhere;
}
.gl-head-wide { display: block; }
.gl-term-wide { font-family: 'Space Grotesk', system-ui; font-size: 17px; color: var(--accent); display: block; overflow-wrap: anywhere; }
.gl-sub-name { display: block; font-size: 13px; color: var(--text2); margin-top: 2px; }
.gl-local-name { display: block; font-size: 13.5px; color: var(--es); margin-top: 2px; overflow-wrap: anywhere; }
.gl-names { min-width: 0; flex: 1; }
/* long German compounds (Elektronegativitätsdifferenz…) must break, or they push the row wide */
.gl-names b { font-size: 15.5px; display: block; overflow-wrap: anywhere; }
.gl-entry, .gl-row span { overflow-wrap: break-word; }
.gl-subj { display: flex; gap: 5px; margin-top: 4px; flex-wrap: wrap; }
.gl-chip {
  font-style: normal; font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  border-radius: 5px; padding: 2px 6px; background: var(--surface2); color: var(--text2);
}
.gl-chip.gl-mathe { color: var(--mathe); } .gl-chip.gl-physik { color: var(--physik); }
.gl-chip.gl-chemie { color: var(--chemie); } .gl-chip.gl-informatik { color: var(--informatik); }
.gl-row { display: flex; gap: 10px; padding: 5px 0; font-size: 14px; align-items: baseline; }
.gl-row i { font-style: normal; color: var(--text2); font-size: 12px; font-weight: 700; min-width: 84px; flex: none; }
.gl-row span { min-width: 0; }
.gl-example {
  margin-top: 10px; padding: 10px 12px; border-radius: 10px; background: var(--surface2);
  overflow-x: auto; overflow-y: hidden; text-align: center;
}
.gl-close { margin-top: 14px; }
.gl-card .gl-entry { padding-top: 0; }
.gl-hint { font-size: 13px; color: var(--text2); margin-bottom: 12px; }

/* language picker */
.lang-row { align-items: flex-start; }
.lang-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 6px; margin-top: 10px; }
.lang-btn {
  min-height: 42px; padding: 8px 6px; border-radius: 10px; font-size: 13.5px; font-weight: 600;
  background: var(--surface2); border: 1.5px solid var(--border); color: var(--text2);
}
.lang-btn.active { border-color: var(--accent); color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--surface2)); }

/* ---------- Python-Referenz ---------- */
.py-card { padding: 14px; }
.py-card .code-box { margin-bottom: 10px; }
.py-out { display: flex; gap: 10px; align-items: baseline; background: var(--surface2); border-radius: 9px; padding: 8px 10px; margin-bottom: 10px; overflow-x: auto; overflow-y: hidden; }
.py-out i { font-style: normal; font-size: 10.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text2); flex: none; }
.py-out pre { font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; color: var(--ok); white-space: pre; margin: 0; }
.py-broken { border-left: 4px solid var(--danger); }
.py-broken .py-out pre { color: var(--danger); }
.py-de { font-size: 14.5px; }

/* ---------- Formel-Anschauung: drawings + variable anatomy ---------- */
:root {
  --fvc0: #2dd4bf; --fvc1: #818cf8; --fvc2: #fbbf24; --fvc3: #f87171; --fvc4: #34d399; --fvc5: #c084fc;
}
.fv-panel { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--border); }
.fv-fig { background: var(--surface2); border: 1px solid var(--border); border-radius: 12px; padding: 6px; margin-bottom: 10px; }
.fv-svg { display: block; width: 100%; height: auto; }
.fv-svg text { font: 600 13px system-ui, sans-serif; fill: var(--text); }
.fv-svg .fv-dim { font-size: 11.5px; font-weight: 500; fill: var(--text2); }
.fv-svg .fv-small { font-size: 10.5px; font-weight: 500; fill: var(--text2); }
.fv-svg .fv-big { font-size: 16px; font-weight: 700; }
.fv-svg .fv-inv { fill: #0e1117; font-size: 12px; font-weight: 700; }
.fv-svg .fv-lab { font-size: 12.5px; font-weight: 700; }
.fv-svg .fv-l, .fv-svg .fv-arr { stroke-width: 2; fill: none; stroke: var(--text2); }
.fv-svg .fv-arr { stroke-width: 2.2; }
.fv-svg .fv-ground, .fv-svg .fv-beam { stroke: var(--text2); stroke-width: 2.5; }
.fv-svg .fv-beam { stroke-width: 5; stroke-linecap: round; }
.fv-svg .fv-dash { stroke: var(--text2); stroke-width: 1.4; stroke-dasharray: 4 4; opacity: .75; }
.fv-svg .fv-box, .fv-svg .fv-cell { fill: var(--surface); stroke: var(--border); stroke-width: 1.4; }
.fv-svg .fv-body { fill: var(--fvc1); }
.fv-svg .fv-body2 { fill: var(--fvc0); }
.fv-svg .fv-ghost { fill: none; stroke: var(--text2); stroke-width: 1.4; stroke-dasharray: 4 3; }
.fv-svg .fv-curve { fill: none; stroke: var(--fvc0); stroke-width: 2.6; }
.fv-svg .fv-curve2 { fill: none; stroke: var(--fvc2); stroke-width: 2.2; }
.fv-svg .fv-curve3 { fill: none; stroke: var(--fvc4); stroke-width: 2.2; }
.fv-svg .fv-track { fill: none; stroke: var(--text2); stroke-width: 3; }
.fv-svg .fv-tangent { stroke: var(--fvc3); stroke-width: 2.2; stroke-dasharray: 5 4; }
.fv-svg .fv-limit { stroke: var(--fvc2); stroke-width: 1.8; stroke-dasharray: 6 4; }
.fv-svg .fv-ring { fill: none; stroke: var(--border); stroke-width: 2; }
.fv-svg .fv-dot { fill: var(--fvc2); }
.fv-svg .fv-dot2 { fill: var(--fvc0); }
.fv-svg .fv-nucleus { fill: var(--fvc3); }
.fv-svg .fv-plane { fill: color-mix(in srgb, var(--fvc1) 18%, transparent); stroke: var(--text2); stroke-width: 1.8; }
.fv-svg .fv-right { fill: none; stroke: var(--text2); stroke-width: 1.4; }
.fv-svg .fv-pivot { fill: var(--fvc0); }
.fv-svg .fv-bar1 { fill: var(--fvc1); }
.fv-svg .fv-bar2 { fill: var(--fvc0); }
.fv-svg .fv-plate1 { fill: var(--fvc3); }
.fv-svg .fv-plate2 { fill: var(--fvc1); }
.fv-svg .fv-wire { fill: none; stroke: var(--fvc0); stroke-width: 2.4; }
.fv-svg .fv-res { fill: var(--fvc2); }
.fv-svg .fv-bat-long { stroke: var(--text); stroke-width: 3.5; }
.fv-svg .fv-bat-short { stroke: var(--text); stroke-width: 2; }
.fv-svg .fv-cube { fill: color-mix(in srgb, var(--fvc1) 22%, transparent); stroke: var(--fvc1); stroke-width: 1.8; }
.fv-svg .fv-cube-edge { fill: none; stroke: var(--fvc1); stroke-width: 1.2; opacity: .7; }
.fv-svg .fv-beaker { fill: none; stroke: var(--text2); stroke-width: 2.2; }
.fv-svg .fv-liquid { fill: var(--fvc0); opacity: .85; }
.fv-svg .fv-cyl { fill: color-mix(in srgb, var(--fvc0) 16%, transparent); stroke: var(--text2); stroke-width: 1.8; }
.fv-svg .fv-piston { fill: var(--text2); }
.fv-svg .fv-area { fill: color-mix(in srgb, var(--fvc0) 30%, transparent); stroke: none; }
.fv-svg .fv-set1 { fill: color-mix(in srgb, var(--fvc1) 26%, transparent); stroke: var(--fvc1); stroke-width: 1.8; }
.fv-svg .fv-set2 { fill: color-mix(in srgb, var(--fvc2) 26%, transparent); stroke: var(--fvc2); stroke-width: 1.8; }
.fv-svg .fv-bit-on { fill: var(--fvc0); }
.fv-svg .fv-merc { fill: var(--fvc3); }
.fv-svg .fv-rot-body { fill: color-mix(in srgb, var(--fvc0) 22%, transparent); stroke: none; }
.fv-svg .fv-rot-cap { fill: none; stroke: var(--fvc0); stroke-width: 1.6; stroke-dasharray: 4 3; }
.fv-svg .fv-rot-mirror { fill: none; stroke: var(--fvc0); stroke-width: 1.6; opacity: .5; stroke-dasharray: 5 4; }
.fv-svg .fv-atom { fill: color-mix(in srgb, var(--fvc1) 20%, transparent); stroke: var(--fvc1); stroke-width: 1.8; }
.fv-svg .fv-c1 { stroke: var(--fvc1); fill: var(--fvc1); }
.fv-svg .fv-c2 { stroke: var(--fvc2); fill: var(--fvc2); }
.fv-svg .fv-c3 { stroke: var(--fvc3); fill: var(--fvc3); }
.fv-svg .fv-c4 { stroke: var(--fvc4); fill: var(--fvc4); }
.fv-svg text.fv-c1, .fv-svg text.fv-c2, .fv-svg text.fv-c3, .fv-svg text.fv-c4 { stroke: none; }
.fv-vars { display: flex; flex-direction: column; gap: 6px; }
.fv-var { display: flex; align-items: baseline; gap: 10px; font-size: 13.5px; border-left: 3px solid var(--vc); padding-left: 10px; }
.fv-var b { font-family: 'Space Grotesk', system-ui; font-size: 15px; color: var(--vc); min-width: 34px; }
.fv-var span { color: var(--text2); }
.fv-var i { font-style: normal; color: var(--text); font-weight: 600; }
.fv-es { font-size: 13px; color: var(--es); margin-top: 8px; }
.fv-ico { width: 15px; height: 15px; stroke: currentColor; fill: none; flex: none; }
.fv-toggle {
  display: inline-flex; align-items: center; gap: 6px; margin-top: 8px; min-height: 40px;
  font-size: 12.5px; font-weight: 700; color: var(--accent);
  border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; background: var(--surface2);
}

/* ---------- Labor: simulations ---------- */
.sim-card { padding: 14px; }
.sim-host { margin-top: 10px; }
.sim { display: block; }
.sim-canvas { width: 100%; background: var(--surface2); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.sim-canvas canvas { display: block; touch-action: pan-y; }
.sim-readout { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 4px; }
.ro-pill {
  display: inline-flex; align-items: baseline; gap: 6px;
  background: var(--surface2); border: 1px solid var(--border); border-left: 3px solid var(--rc, var(--accent));
  border-radius: 8px; padding: 5px 9px; font-size: 12.5px; font-variant-numeric: tabular-nums;
}
.ro-pill i { font-style: normal; color: var(--text2); font-size: 11px; }
.sim-controls { margin-top: 8px; }
.sim-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; flex-wrap: wrap; }
.sim-label { font-size: 13px; color: var(--text2); min-width: 108px; flex: none; }
.sim-label b { color: var(--text); font-variant-numeric: tabular-nums; }
.sim-slider { flex: 1; min-width: 130px; -webkit-appearance: none; appearance: none; height: 30px; background: none; }
.sim-slider::-webkit-slider-runnable-track { height: 5px; border-radius: 3px; background: var(--surface2); border: 1px solid var(--border); }
.sim-slider::-webkit-slider-thumb { -webkit-appearance: none; width: 24px; height: 24px; border-radius: 50%; background: var(--accent); margin-top: -10px; border: 3px solid var(--surface); box-shadow: var(--shadow); }
.sim-slider::-moz-range-track { height: 5px; border-radius: 3px; background: var(--surface2); }
.sim-slider::-moz-range-thumb { width: 20px; height: 20px; border: 3px solid var(--surface); border-radius: 50%; background: var(--accent); }
.sim-seg { flex: 1; min-width: 150px; }
.sim-seg button { flex: 1; padding: 8px 6px; font-size: 12.5px; }
.sim-switch { margin-left: auto; }
.sim-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.sim-btn {
  flex: 1; min-width: 108px; min-height: 44px; padding: 10px 12px; border-radius: 10px;
  background: var(--surface2); border: 1px solid var(--border); color: var(--text);
  font-size: 13.5px; font-weight: 600; transition: transform .12s, border-color .15s;
}
.sim-btn:active { transform: scale(.97); border-color: var(--accent); }
.sim-hint { font-size: 12.5px; color: var(--text2); margin-top: 10px; line-height: 1.5; }
.sim-fail { padding: 20px; text-align: center; color: var(--text2); font-size: 13.5px; }

/* periodic table */
.pse-grid { display: grid; grid-template-columns: repeat(18, 1fr); gap: 1.5px; margin: 10px 0; }
.pse-cell {
  aspect-ratio: 1; border-radius: 2px; background: color-mix(in srgb, var(--pc) 26%, var(--surface2));
  border: 1px solid transparent; display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: clamp(6px, 1.7vw, 11px); font-weight: 700; color: var(--text); line-height: 1; padding: 0; min-width: 0;
}
.pse-cell i { font-style: normal; font-size: clamp(4px, 1vw, 7px); color: var(--text2); font-weight: 500; }
.pse-cell.on { border-color: var(--text); transform: scale(1.14); z-index: 2; box-shadow: 0 2px 8px rgba(0,0,0,.4); }
.pse-info { background: var(--surface2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; min-height: 76px; }
.pse-info b { font-size: 15px; }
.pse-info span { font-size: 12.5px; color: var(--text2); }
.pse-legend { display: flex; flex-wrap: wrap; gap: 4px 10px; }
.pse-leg { font-size: 11px; color: var(--text2); display: inline-flex; align-items: center; gap: 4px; }
.pse-leg i { width: 9px; height: 9px; border-radius: 2px; display: inline-block; }

/* SI prefixes */
.pref-scale { display: grid; grid-template-columns: repeat(auto-fit, minmax(58px, 1fr)); gap: 5px; margin-bottom: 10px; }
.pref-cell { background: var(--surface2); border: 1.5px solid var(--border); border-radius: 9px; padding: 7px 3px; display: flex; flex-direction: column; align-items: center; gap: 1px; }
.pref-cell b { font-size: 16px; font-family: 'Space Grotesk', system-ui; }
.pref-cell i { font-style: normal; font-size: 9.5px; color: var(--text2); }
.pref-cell span { font-size: 10.5px; color: var(--text2); }
.pref-cell.from { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 16%, var(--surface2)); }
.pref-cell.to { border-color: var(--mathe); background: color-mix(in srgb, var(--mathe) 16%, var(--surface2)); }

/* binary */
.bit-row { display: flex; gap: 4px; margin-bottom: 10px; }
.bit { flex: 1; min-width: 0; aspect-ratio: .72; border-radius: 9px; background: var(--surface2); border: 1.5px solid var(--border); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
.bit i { font-style: normal; font-size: 9px; color: var(--text2); }
.bit span { font-size: 20px; font-weight: 700; font-family: 'Space Grotesk', system-ui; }
.bit.on { background: color-mix(in srgb, var(--accent) 22%, var(--surface2)); border-color: var(--accent); color: var(--accent); }
.bit-challenge { font-size: 13.5px; color: var(--text2); padding: 8px 0; }
.bit-challenge.ok { color: var(--ok); font-weight: 600; }
.bit-challenge .sim-btn { display: inline-block; flex: none; min-width: 90px; min-height: 36px; margin-left: 8px; }

/* data structures */
.ds-view { min-height: 130px; background: var(--surface2); border: 1px solid var(--border); border-radius: 12px; padding: 10px; display: flex; gap: 6px; align-items: center; }
.ds-view.stack { flex-direction: column-reverse; justify-content: flex-start; }
.ds-item { background: var(--informatik); color: #14121c; font-weight: 700; border-radius: 8px; padding: 8px 14px; font-size: 14px; min-width: 42px; text-align: center; animation: rise .2s ease both; }
.ds-item.head { outline: 2px solid var(--accent); outline-offset: 2px; }
.ds-empty { color: var(--text2); font-size: 13px; margin: auto; }

/* code trace */
.code-box { background: var(--surface2); border: 1px solid var(--border); border-radius: 10px; padding: 12px; font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; line-height: 1.55; overflow-x: auto; white-space: pre; }
.trace-table { margin-top: 10px; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; font-size: 12.5px; }
.trace-table .tr { display: flex; border-bottom: 1px solid var(--border); }
.trace-table .tr:last-child { border-bottom: none; }
.trace-table .tr span { flex: 1; padding: 7px 8px; font-variant-numeric: tabular-nums; }
.trace-table .th { background: var(--surface2); font-weight: 700; color: var(--text2); font-size: 11.5px; }
.trace-table .cur { background: color-mix(in srgb, var(--accent) 14%, transparent); }

/* oop */
.oop-view { background: var(--surface2); border: 1px solid var(--border); border-radius: 12px; padding: 12px; }
.oop-class { border: 1.5px solid var(--informatik); border-radius: 10px; overflow: hidden; margin-bottom: 6px; }
.oop-class b { display: block; background: color-mix(in srgb, var(--informatik) 22%, transparent); padding: 7px 10px; font-size: 13.5px; }
.oop-class.sub { border-color: var(--accent); }
.oop-class.sub b { background: color-mix(in srgb, var(--accent) 20%, transparent); }
.oop-attr, .oop-meth { padding: 5px 10px; font-size: 12.5px; font-family: ui-monospace, Consolas, monospace; border-top: 1px solid var(--border); }
.oop-meth { color: var(--text2); }
.oop-arrow { text-align: center; font-size: 11.5px; color: var(--text2); padding: 2px 0; }
.oop-objs { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.oop-obj { background: var(--surface); border: 1px solid var(--border); border-radius: 9px; padding: 8px 10px; font-size: 12px; display: flex; flex-direction: column; gap: 2px; animation: rise .25s ease both; }
.oop-obj b { font-size: 12.5px; color: var(--accent); }
.oop-obj span { color: var(--text2); font-family: ui-monospace, Consolas, monospace; font-size: 11.5px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* Install, share and reliable offline status. */
[hidden] { display: none !important; }
button:focus-visible, a:focus-visible, summary:focus-visible, input:focus-visible {
  outline: 3px solid var(--accent); outline-offset: 4px;
}
button:disabled { opacity: .6; cursor: default; }
input, select, textarea { font-size: 16px; }
.home-install { display:flex; align-items:center; gap:14px; width:100%; text-align:start; margin-top:24px; padding:16px; border:1px solid var(--border); border-radius:var(--radius); background:linear-gradient(120deg, color-mix(in srgb, var(--accent) 10%, var(--surface)),var(--surface)); }
.home-install img, .pwa-heading img { border-radius:12px; flex:none; }
.home-install > span:first-of-type { flex:1; min-width:0; }
.home-install b { display:block; font-size:14px; }
.home-install small { display:block; color:var(--text2); font-size:12px; margin-top:3px; }
.pwa-panel { margin:24px 0; padding:22px; border-radius:20px; border:1px solid var(--border); background:linear-gradient(145deg, color-mix(in srgb, var(--accent) 8%, var(--surface)),var(--surface) 50%); }
.pwa-heading { display:flex; gap:14px; align-items:center; margin-bottom:18px; }
.pwa-heading h2 { font-size:22px; margin-bottom:6px; }
.pwa-panel p { color:var(--text2); font-size:14px; line-height:1.6; }
.pwa-actions { display:flex; flex-wrap:wrap; gap:10px; }
.pwa-actions > button { flex:1; min-width:140px; margin:0; }
.pwa-panel details { margin-top:18px; font-size:14px; }
.pwa-panel summary { cursor:pointer; padding:8px 0; min-height:44px; }
.pwa-panel details p { margin:12px 0; }
.offline-box { margin-top:20px; padding-top:20px; border-top:1px solid var(--border); }
.offline-heading { display:flex; justify-content:space-between; align-items:center; gap:10px; margin-bottom:8px; }
.offline-heading h3 { font-size:18px; }
.connection-badge { padding:3px 9px; border:1px solid var(--border); border-radius:20px; font-size:11px; color:var(--text2); }
.offline-box #offSub { color:var(--text); margin-top:14px; }
.offline-box progress { display:block; width:100%; height:9px; border:0; border-radius:8px; accent-color:var(--accent); margin:12px 0 8px; overflow:hidden; }
.offline-box progress::-webkit-progress-bar { background:var(--surface2); border-radius:8px; }
.offline-box progress::-webkit-progress-value { background:var(--accent); border-radius:8px; }
.offline-count { font-variant-numeric:tabular-nums; color:var(--text2); font-size:12px; direction:ltr; }
.offline-box .btn-primary { margin:14px 0; }
.pwa-panel .pwa-note { font-size:12px; margin-top:12px; }
.update-box { margin-top:18px; border-top:1px solid var(--border); padding-top:18px; }
.pwa-panel input { width:100%; padding:10px; border:1px solid var(--border); border-radius:8px; background:var(--surface); color:var(--text); direction:ltr; }
[dir="rtl"] .katex, [dir="rtl"] code { direction:ltr; unicode-bidi:isolate; }
@media (max-width:400px) {
  #app { padding-inline:12px; }
  .topbar { gap:6px; }
  .topbar .title h1 { font-size:18px; }
  .pwa-panel { padding:16px; }
  .set-row { flex-wrap:wrap; gap:12px; }
}
@media (min-width:1000px) {
  #app { max-width:900px; padding-top:32px; }
  .subject-list { display:grid; grid-template-columns:1fr 1fr; }
}
/* Account access keeps guest study one tap away. */
.account-panel{max-width:560px;margin:22px auto;padding:24px;background:var(--surface);border:1px solid var(--border);border-radius:22px}
.account-panel h2{font-size:24px;margin:0 0 10px}.account-panel p{color:var(--text2);line-height:1.65}
.account-panel button{min-height:46px}.account-panel a{color:var(--accent)}
.account-symbol{font-size:32px;color:var(--accent);width:40px;text-align:center}
.guest-note{background:var(--surface2);border-radius:14px;padding:16px;margin:20px 0}.guest-note p{margin:6px 0 0}
.account-form{display:grid;gap:14px;margin:22px 0}.account-form label{display:grid;gap:8px;font-size:14px;font-weight:600}
.account-form input{width:100%;box-sizing:border-box;padding:13px 14px;border:1px solid var(--border);border-radius:12px;background:var(--bg);color:var(--text);font:inherit;font-size:16px;direction:ltr}
.account-form .pwa-note{margin:0}.account-email{overflow-wrap:anywhere;font-weight:600;color:var(--text)!important;direction:ltr}
.google-button{display:flex;align-items:center;justify-content:center;gap:14px;width:100%;background:white;color:#1f1f1f;border:1px solid #747775;border-radius:20px;padding:10px 20px;font-size:15px;font-weight:600}
.google-button span{font-size:23px;font-weight:700;color:#4285f4}.text-button{border:0;background:none;color:var(--accent);text-decoration:underline;text-align:start;cursor:pointer}
.guest-button{width:100%}.account-import{padding:16px 0}.account-import summary{cursor:pointer}.account-status{padding:12px;background:var(--surface2);border-radius:12px}
.guest-note .guest-button{margin-top:14px}.email-access{margin-top:12px}.email-access>summary{cursor:pointer;border:1px solid var(--border);border-radius:16px;padding:15px;text-align:center;font-weight:600}
@media(max-width:480px){.account-panel{padding:18px;margin:14px 0}.account-panel h2{font-size:22px}}
