/* Abi Physics — shared stylesheet */
:root {
  --paper: #f7f6f2;
  --paper-2: #ffffff;
  --paper-3: #eeece6;
  --ink: #1d2230;
  --ink-2: #4a5264;
  --ink-3: #7a8294;
  --line: #ddd9d0;
  --accent: #1f5fa8;
  --accent-ink: #ffffff;
  --accent-soft: #e4eef9;
  --ok: #1f8a4c;
  --ok-soft: #e2f3e8;
  --warn: #b7791f;
  --warn-soft: #fbf0d9;
  --bad: #b3392f;
  --bad-soft: #f9e3e0;
  --note: #fff7cc;
  --note-ink: #5a4a00;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 6px 20px rgba(20,24,40,.08);
  --radius: 14px;
  --radius-s: 9px;
  --max: 780px;
  --block-grundlagen: #5b6478;
  --block-wellen: #1f5fa8;
  --block-efeld: #6d3fb5;
  --block-bfeld: #0f7f7a;
  --block-mechanik: #c2571b;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #15181f;
    --paper-2: #1e222b;
    --paper-3: #262b36;
    --ink: #eceef2;
    --ink-2: #b9bfcc;
    --ink-3: #8b93a3;
    --line: #333945;
    --accent: #7fb0ec;
    --accent-ink: #0d1a2e;
    --accent-soft: #1c2d45;
    --ok: #6fcf97;
    --ok-soft: #173321;
    --warn: #e8b85a;
    --warn-soft: #3a2e14;
    --bad: #f08a80;
    --bad-soft: #3d1f1c;
    --note: #3a3418;
    --note-ink: #f3e7a6;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35);
    --block-grundlagen: #a3abbd;
    --block-wellen: #7fb0ec;
    --block-efeld: #b89cf0;
    --block-bfeld: #5ed1cb;
    --block-mechanik: #f0a070;
  }
}
:root[data-theme="dark"] {
  --paper: #15181f;
  --paper-2: #1e222b;
  --paper-3: #262b36;
  --ink: #eceef2;
  --ink-2: #b9bfcc;
  --ink-3: #8b93a3;
  --line: #333945;
  --accent: #7fb0ec;
  --accent-ink: #0d1a2e;
  --accent-soft: #1c2d45;
  --ok: #6fcf97;
  --ok-soft: #173321;
  --warn: #e8b85a;
  --warn-soft: #3a2e14;
  --bad: #f08a80;
  --bad-soft: #3d1f1c;
  --note: #3a3418;
  --note-ink: #f3e7a6;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35);
  --block-grundlagen: #a3abbd;
  --block-wellen: #7fb0ec;
  --block-efeld: #b89cf0;
  --block-bfeld: #5ed1cb;
  --block-mechanik: #f0a070;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5em; letter-spacing: -.01em; }
h1 { font-size: 1.9rem; }
h2 { font-size: 1.35rem; margin-top: 2.2rem; padding-top: .4rem; }
h3 { font-size: 1.1rem; margin-top: 1.4rem; }
p { margin: 0 0 1em; }
ul, ol { padding-left: 1.4em; margin: 0 0 1em; }
li { margin-bottom: .35em; }
strong { font-weight: 650; }
code, kbd { font-family: var(--mono); font-size: .9em; background: var(--paper-3); padding: .1em .35em; border-radius: 5px; }
table { border-collapse: collapse; width: 100%; margin: 0 0 1.2em; font-size: .95em; }
th, td { border-bottom: 1px solid var(--line); padding: .5em .6em; text-align: left; vertical-align: top; }
th { color: var(--ink-2); font-weight: 600; font-size: .85em; text-transform: uppercase; letter-spacing: .04em; }
.tscroll { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 0 1.2em; max-width: 100%; }
.tscroll table { margin: 0; }
hr { border: 0; border-top: 1px solid var(--line); margin: 2em 0; }
.katex-display { overflow-x: auto; overflow-y: hidden; padding: .2em 0; margin: .6em 0 1em; }
.katex { font-size: 1.08em; }
button, .btn {
  font: inherit; font-size: .95rem; font-weight: 600;
  border: 1px solid var(--line); background: var(--paper-2); color: var(--ink);
  border-radius: 999px; padding: .55em 1.1em; cursor: pointer; min-height: 44px;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
button:hover, .btn:hover { border-color: var(--accent); text-decoration: none; }
button.primary, .btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button.small { min-height: 36px; padding: .35em .9em; font-size: .85rem; }
button:disabled { opacity: .5; cursor: default; }

/* ---------- layout ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  background: color-mix(in srgb, var(--paper) 86%, transparent);
  -webkit-backdrop-filter: saturate(160%) blur(14px); backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
}
.topbar-inner {
  max-width: 1180px; margin: 0 auto; display: flex; align-items: center; gap: .8rem;
  padding: .55rem 16px; min-height: 56px;
}
.brand { font-weight: 750; letter-spacing: -.02em; font-size: 1.05rem; color: var(--ink); display: flex; align-items: center; gap: .5rem; white-space: nowrap; }
.brand .logo { width: 28px; height: 28px; border-radius: 8px; background: var(--accent); display: inline-grid; place-items: center; color: var(--accent-ink); font-size: .8rem; font-weight: 800; }
.topbar .spacer { flex: 1; }
.topbar .crumb { color: var(--ink-3); font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.iconbtn { width: 44px; height: 44px; min-height: 44px; padding: 0; border-radius: 12px; display: inline-grid; place-items: center; font-size: 1.1rem; }

.shell { max-width: 1180px; margin: 0 auto; display: grid; grid-template-columns: 1fr; gap: 0; }
@media (min-width: 960px) { .shell { grid-template-columns: 270px minmax(0, 1fr); } }
.sidenav { display: none; }
@media (min-width: 960px) {
  .sidenav { display: block; position: sticky; top: 64px; align-self: start; max-height: calc(100vh - 72px); overflow: auto; padding: 1rem .6rem 2rem 16px; }
}
.sidenav .blk { margin-bottom: 1rem; }
.sidenav .blk-title { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); margin: .6rem 0 .3rem .5rem; font-weight: 700; }
.sidenav a { display: flex; align-items: center; gap: .5rem; padding: .42rem .55rem; border-radius: 9px; color: var(--ink-2); font-size: .92rem; }
.sidenav a:hover { background: var(--paper-3); text-decoration: none; }
.sidenav a.active { background: var(--accent-soft); color: var(--ink); font-weight: 600; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--line); flex: none; }
.dot.p1 { background: var(--warn); } .dot.p2 { background: var(--ok); }

main.page { padding: 1.2rem 16px 5rem; max-width: var(--max); width: 100%; margin: 0 auto; min-width: 0; }
@media (min-width: 960px) { main.page { margin: 0; padding-left: 2.2rem; } }

.chip { display: inline-flex; align-items: center; gap: .4em; font-size: .78rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--blockcolor, var(--accent)); }
.chip::before { content: ""; width: 10px; height: 10px; border-radius: 3px; background: var(--blockcolor, var(--accent)); }
.subtitle { color: var(--ink-2); font-size: 1.08rem; margin-top: -.3rem; }
.pageprog { display: flex; align-items: center; gap: .7rem; margin: .8rem 0 1.2rem; font-size: .85rem; color: var(--ink-3); }
.bar { flex: 1; height: 8px; background: var(--paper-3); border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; width: 0; background: var(--ok); border-radius: 99px; transition: width .3s; }

.toc { display: flex; flex-wrap: wrap; gap: .4rem; margin: 0 0 1.4rem; }
.toc a { font-size: .85rem; padding: .35em .8em; border: 1px solid var(--line); border-radius: 999px; color: var(--ink-2); background: var(--paper-2); }

/* ---------- callouts ---------- */
.kernsatz {
  border-left: 5px solid var(--blockcolor, var(--accent));
  background: var(--paper-2); border-radius: 0 var(--radius) var(--radius) 0;
  padding: 1rem 1.2rem; margin: 1rem 0 1.5rem; box-shadow: var(--shadow); font-size: 1.1rem;
}
.kernsatz .lbl { display: block; font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); font-weight: 700; margin-bottom: .3rem; }
.box { background: var(--paper-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.2rem; margin: 1rem 0; }
.box.tip { border-color: color-mix(in srgb, var(--ok) 40%, var(--line)); background: var(--ok-soft); }
.box.warn { border-color: color-mix(in srgb, var(--warn) 50%, var(--line)); background: var(--warn-soft); }
.box .lbl { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); font-weight: 700; margin-bottom: .3rem; }

details { border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--paper-2); margin: .6rem 0; }
details > summary { cursor: pointer; padding: .7rem 1rem .7rem 2.1rem; font-weight: 600; list-style: none; display: block; position: relative; min-height: 44px; overflow-wrap: anywhere; }
details > summary::-webkit-details-marker { display: none; }
details > summary::before { content: "▸"; color: var(--ink-3); transition: transform .15s; position: absolute; left: .9rem; top: .7rem; }
details[open] > summary::before { transform: rotate(90deg); }
details > .body { padding: 0 1rem 1rem; }

/* Vorwissen */
.vorwissen .q { font-weight: 600; }
.vorwissen details > summary { font-weight: 500; }

/* Herleitung steps */
.steps { counter-reset: s; list-style: none; padding: 0; margin: 0 0 1rem; }
.steps li { position: relative; padding: .6rem 0 .6rem 2.6rem; border-top: 1px dashed var(--line); margin: 0; }
.steps li::before { counter-increment: s; content: counter(s); position: absolute; left: 0; top: .7rem; width: 30px; height: 30px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-weight: 700; display: grid; place-items: center; font-size: .9rem; }
.steps li.hidden-step > * { visibility: hidden; }
.steps li.hidden-step::after { content: "verdeckt — tippe „nächster Schritt“"; position: absolute; left: 2.6rem; top: .8rem; color: var(--ink-3); font-size: .85rem; visibility: visible; }
.schluss { border-left: 4px solid var(--ok); padding: .4rem 1rem; background: var(--ok-soft); border-radius: 0 9px 9px 0; margin: .6rem 0 1rem; }
.herleitung-ctl { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: .6rem; }

/* Formeln */
.formeln td:first-child { white-space: nowrap; font-weight: 600; }
.formeln td:nth-child(2) { white-space: nowrap; }

/* Fehler */
.fehler { list-style: none; padding: 0; margin: 0 0 1rem; }
.fehler li { display: grid; grid-template-columns: 1fr; gap: .3rem; padding: .8rem 1rem; background: var(--paper-2); border: 1px solid var(--line); border-radius: var(--radius-s); margin-bottom: .6rem; }
@media (min-width: 640px) { .fehler li { grid-template-columns: 1fr 1fr; gap: 1rem; } }
.fehler .f { color: var(--bad); } .fehler .f::before { content: "✗ Typischer Fehler: "; font-weight: 700; }
.fehler .r { color: var(--ok); } .fehler .r::before { content: "✓ So holst du die Punkte: "; font-weight: 700; }

/* Simulation */
.sim { background: var(--paper-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; margin: 1rem 0 1.5rem; box-shadow: var(--shadow); }
.sim h3 { margin-top: 0; }
.sim canvas { width: 100%; height: auto; display: block; border-radius: 10px; background: var(--paper-3); touch-action: none; }
.sim .controls { display: grid; grid-template-columns: 1fr; gap: .5rem .9rem; margin-top: .8rem; }
@media (min-width: 640px) { .sim .controls { grid-template-columns: 1fr 1fr; } }
.sim .ctl { display: grid; grid-template-columns: 1fr auto; gap: .2rem .6rem; align-items: center; font-size: .9rem; }
.sim .ctl label { color: var(--ink-2); }
.sim .ctl output { font-family: var(--mono); font-size: .88rem; color: var(--ink); text-align: right; }
.sim .ctl input[type=range] { grid-column: 1 / -1; width: 100%; accent-color: var(--accent); height: 34px; margin: 0; }
.sim .ctl.toggle { grid-template-columns: auto 1fr; }
.sim .ctl.toggle input { width: 22px; height: 22px; accent-color: var(--accent); }
.sim .readout { margin-top: .7rem; font-size: .92rem; color: var(--ink-2); background: var(--paper-3); border-radius: 9px; padding: .55rem .8rem; }
.sim .hint { font-size: .88rem; color: var(--ink-3); margin: .6rem 0 0; }
.sim .btnrow { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .6rem; }

/* Fragen */
.frage { background: var(--paper-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.2rem; margin: 1rem 0; box-shadow: var(--shadow); }
.frage .head { display: flex; align-items: baseline; gap: .7rem; flex-wrap: wrap; margin-bottom: .4rem; }
.frage .num { font-weight: 800; color: var(--blockcolor, var(--accent)); }
.frage .typ { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); font-weight: 700; }
.frage .pts { margin-left: auto; font-size: .85rem; color: var(--ink-3); }
.frage .text { margin-bottom: .8rem; }
.frage .opts { display: grid; gap: .5rem; margin: .6rem 0; }
.frage .opt { display: flex; gap: .7rem; align-items: flex-start; padding: .65rem .8rem; border: 1px solid var(--line); border-radius: var(--radius-s); cursor: pointer; background: var(--paper); }
.frage .opt input { margin-top: .25em; width: 20px; height: 20px; accent-color: var(--accent); flex: none; }
.frage .opt.correct { border-color: var(--ok); background: var(--ok-soft); }
.frage .opt.wrong { border-color: var(--bad); background: var(--bad-soft); }
.frage .actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin-top: .6rem; }
.frage .feedback { margin-top: .7rem; padding: .7rem .9rem; border-radius: var(--radius-s); display: none; }
.frage .feedback.show { display: block; }
.frage .feedback.ok { background: var(--ok-soft); } .frage .feedback.bad { background: var(--bad-soft); }
.frage .loesung { display: none; margin-top: .8rem; border-top: 1px dashed var(--line); padding-top: .8rem; }
.frage .loesung.show { display: block; }
.frage .eh { margin: .6rem 0; }
.frage .eh li { display: flex; gap: .6rem; }
.frage .eh .p { flex: none; min-width: 2.6em; font-family: var(--mono); font-size: .85em; color: var(--ink-3); padding-top: .15em; }
.rating { display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; margin-top: .6rem; font-size: .9rem; }
.rating .lbl { color: var(--ink-3); margin-right: .3rem; }
.rating button.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.frage.done { border-color: color-mix(in srgb, var(--ok) 60%, var(--line)); }
.frage .status { font-size: .8rem; color: var(--ink-3); margin-left: auto; }

/* Notizen */
.notes-fab {
  position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 40;
  background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 999px;
  padding: .7em 1.2em; box-shadow: var(--shadow); font-weight: 700; display: flex; gap: .5rem; align-items: center;
}
.notes-panel {
  position: fixed; inset: auto 0 0 0; z-index: 45; background: var(--paper-2); border-top: 1px solid var(--line);
  box-shadow: 0 -8px 30px rgba(0,0,0,.18); transform: translateY(105%); transition: transform .25s ease;
  max-height: 70vh; display: flex; flex-direction: column; border-radius: 18px 18px 0 0;
  padding-bottom: env(safe-area-inset-bottom);
}
.notes-panel.open { transform: translateY(0); }
@media (min-width: 960px) {
  .notes-panel { inset: 64px 0 0 auto; width: 400px; max-height: none; border-radius: 0; border-left: 1px solid var(--line); border-top: 0; transform: translateX(105%); }
  .notes-panel.open { transform: translateX(0); }
}
.notes-head { display: flex; align-items: center; gap: .6rem; padding: .7rem 1rem; border-bottom: 1px solid var(--line); }
.notes-head h3 { margin: 0; font-size: 1rem; flex: 1; }
.notes-panel textarea {
  flex: 1; min-height: 220px; resize: none; border: 0; outline: 0; padding: 1rem; font: inherit; font-size: 1rem; line-height: 1.5;
  background: var(--note); color: var(--note-ink);
}
.notes-foot { display: flex; align-items: center; gap: .6rem; padding: .5rem 1rem; border-top: 1px solid var(--line); font-size: .8rem; color: var(--ink-3); }
.notes-foot .spacer { flex: 1; }
.inline-notes { margin-top: 2rem; }
.inline-notes textarea { width: 100%; min-height: 160px; border: 1px solid var(--line); border-radius: var(--radius-s); padding: .8rem; font: inherit; font-size: 1rem; background: var(--note); color: var(--note-ink); resize: vertical; }

/* Pager */
.pager { display: flex; justify-content: space-between; gap: 1rem; margin-top: 3rem; padding-top: 1.2rem; border-top: 1px solid var(--line); }
.pager a { display: block; padding: .8rem 1rem; border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--paper-2); color: var(--ink); max-width: 48%; }
.pager a span { display: block; font-size: .75rem; color: var(--ink-3); text-transform: uppercase; letter-spacing: .06em; }
.pager a.next { text-align: right; margin-left: auto; }

/* Index */
.hero { padding: 1.5rem 0 1rem; }
.hero h1 { font-size: 2.3rem; }
.hero .lead { font-size: 1.1rem; color: var(--ink-2); max-width: 640px; }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: .7rem; margin: 1rem 0 1.5rem; }
@media (min-width: 640px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat { background: var(--paper-2); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1rem; }
.stat .v { font-size: 1.6rem; font-weight: 750; letter-spacing: -.02em; }
.stat .l { font-size: .8rem; color: var(--ink-3); }
.blockgrid { display: grid; gap: 1rem; margin: 1rem 0 2rem; }
.blockcard { background: var(--paper-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.2rem; box-shadow: var(--shadow); border-top: 4px solid var(--blockcolor, var(--accent)); }
.blockcard h2 { margin-top: 0; font-size: 1.2rem; }
.blockcard .desc { color: var(--ink-2); font-size: .95rem; }
.concepts { list-style: none; padding: 0; margin: .6rem 0 0; display: grid; gap: .4rem; }
@media (min-width: 640px) { .concepts { grid-template-columns: 1fr 1fr; } }
.concepts a { display: flex; align-items: center; gap: .6rem; padding: .6rem .7rem; border-radius: var(--radius-s); background: var(--paper); border: 1px solid var(--line); color: var(--ink); min-height: 48px; }
.concepts a:hover { border-color: var(--blockcolor, var(--accent)); text-decoration: none; }
.concepts .nm { flex: 1; }
.concepts .sc { font-size: .78rem; color: var(--ink-3); font-family: var(--mono); }
.pill { font-size: .72rem; font-weight: 700; padding: .15em .6em; border-radius: 999px; background: var(--warn-soft); color: var(--warn); }
.pill.exam { background: var(--bad-soft); color: var(--bad); }
.notes-list { display: grid; gap: .6rem; }
.notes-list .n { background: var(--note); color: var(--note-ink); border-radius: var(--radius-s); padding: .7rem .9rem; white-space: pre-wrap; font-size: .95rem; }
.notes-list .n b { display: block; margin-bottom: .2rem; }
.tools { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.muted { color: var(--ink-3); font-size: .88rem; }

@media print {
  .topbar, .sidenav, .notes-fab, .notes-panel, .pager, .toc, .sim .controls, .frage .actions, .rating { display: none !important; }
  body { background: #fff; color: #000; font-size: 12pt; }
  .frage .loesung { display: block; }
  .steps li.hidden-step > * { visibility: visible; }
  .steps li.hidden-step::after { display: none; }
}
