/* Folien-App · shadcn/ui-Tokens „neutral" wie die Uni-App, Schrift Geist.
   Folien und Notizflächen bleiben auch im Dunkelmodus papierweiß (wie im PDF-Export). */

@font-face { font-family: "Geist"; src: url("/vendor/fonts/Geist-Variable.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }
/* Notizschrift = Exportschrift, damit Zeilenumbrüche und Handschrift im PDF an derselben Stelle landen */
@font-face { font-family: "Notiz"; src: url("/vendor/fonts/DejaVuSans.ttf") format("truetype"); font-display: swap; }

:root {
  --radius: 0.625rem;
  --background: oklch(0.985 0 0);
  --foreground: oklch(0.145 0 0);
  --card: oklch(1 0 0);
  --primary: oklch(0.205 0 0);
  --primary-foreground: oklch(0.985 0 0);
  --secondary: oklch(0.97 0 0);
  --muted-foreground: oklch(0.556 0 0);
  --accent: oklch(0.94 0 0);
  --destructive: oklch(0.577 0.245 27.325);
  --success: oklch(0.596 0.145 163.225);
  --warning: oklch(0.666 0.179 58.318);
  --border: oklch(0.922 0 0);
  --input: oklch(0.922 0 0);
  --ring: oklch(0.708 0 0);
  --shadow-xs: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  --bar: oklch(0.985 0 0 / 0.88);
  --papier: #ffffff;
  --papier-linie: #e8e8e6;
  --radius-md: calc(var(--radius) - 2px); --radius-lg: var(--radius); --radius-xl: calc(var(--radius) + 4px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --background: oklch(0.145 0 0); --foreground: oklch(0.985 0 0); --card: oklch(0.205 0 0);
    --primary: oklch(0.922 0 0); --primary-foreground: oklch(0.205 0 0); --secondary: oklch(0.269 0 0);
    --muted-foreground: oklch(0.708 0 0); --accent: oklch(0.269 0 0);
    --destructive: oklch(0.704 0.191 22.216); --success: oklch(0.765 0.177 163.223); --warning: oklch(0.828 0.189 84.429);
    --border: oklch(1 0 0 / 10%); --input: oklch(1 0 0 / 15%); --ring: oklch(0.556 0 0);
    --shadow-xs: none; --shadow-sm: none; --bar: oklch(0.145 0 0 / 0.88);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --background: oklch(0.145 0 0); --foreground: oklch(0.985 0 0); --card: oklch(0.205 0 0);
  --primary: oklch(0.922 0 0); --primary-foreground: oklch(0.205 0 0); --secondary: oklch(0.269 0 0);
  --muted-foreground: oklch(0.708 0 0); --accent: oklch(0.269 0 0);
  --destructive: oklch(0.704 0.191 22.216); --success: oklch(0.765 0.177 163.223); --warning: oklch(0.828 0.189 84.429);
  --border: oklch(1 0 0 / 10%); --input: oklch(1 0 0 / 15%); --ring: oklch(0.556 0 0);
  --shadow-xs: none; --shadow-sm: none; --bar: oklch(0.145 0 0 / 0.88);
  color-scheme: dark;
}

* { box-sizing: border-box; border-color: var(--border); }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--background); color: var(--foreground);
  font-family: "Geist", ui-sans-serif, system-ui, -apple-system, sans-serif; font-size: 15px; line-height: 1.5;
  -webkit-font-smoothing: antialiased; overscroll-behavior-y: contain;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; text-align: left; }
[hidden] { display: none !important; }
:focus-visible { outline: none; box-shadow: 0 0 0 3px color-mix(in oklab, var(--ring) 50%, transparent); border-radius: var(--radius-md); }
svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------------------------------------------------------------- Login */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.login-box { width: 100%; max-width: 360px; padding: 24px; border: 1px solid var(--border); border-radius: var(--radius-xl); background: var(--card); box-shadow: var(--shadow-sm); }
.login-icon img { width: 48px; height: 48px; border-radius: 12px; }
.login h1 { margin: 16px 0 4px; font-size: 22px; font-weight: 600; letter-spacing: -0.02em; }
.login p { color: var(--muted-foreground); margin: 0 0 20px; font-size: 14px; }
.login input, .dlg input, .dlg select {
  width: 100%; height: 40px; font: inherit; font-size: 16px; padding: 0 12px; border-radius: var(--radius-md); border: 1px solid var(--input);
  background: transparent; color: var(--foreground); outline: none; box-shadow: var(--shadow-xs);
}
.login input:focus, .dlg input:focus, .dlg select:focus { border-color: var(--ring); box-shadow: 0 0 0 3px color-mix(in oklab, var(--ring) 50%, transparent); }
.login button[type="submit"] {
  margin-top: 12px; width: 100%; height: 40px; border-radius: var(--radius-md); background: var(--primary); color: var(--primary-foreground);
  font-weight: 500; font-size: 14px; text-align: center;
}
.login-fehler { color: var(--destructive) !important; min-height: 1.4em; margin: 12px 0 0 !important; font-size: 13px !important; }

/* ---------------------------------------------------------------- Knöpfe */
.knopf {
  display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 12px; border-radius: var(--radius-md); flex: none;
  border: 1px solid var(--border); background: var(--card); box-shadow: var(--shadow-xs); font-size: 14px; font-weight: 500; white-space: nowrap;
}
.knopf svg { width: 17px; height: 17px; }
.knopf.primaer { background: var(--primary); color: var(--primary-foreground); border-color: transparent; }
.knopf.gefahr { color: var(--destructive); }
.knopf:disabled { opacity: .5; cursor: default; }
.icon-knopf { width: 36px; height: 36px; border-radius: var(--radius-md); display: grid; place-items: center; flex: none; }
.icon-knopf svg { width: 22px; height: 22px; }
.icon-knopf:active, .knopf:active { background: var(--accent); }

/* ---------------------------------------------------------------- Bibliothek */
.kopf { position: sticky; top: 0; z-index: 5; padding: calc(env(safe-area-inset-top) + 14px) 16px 10px; background: var(--bar);
  -webkit-backdrop-filter: saturate(160%) blur(16px); backdrop-filter: saturate(160%) blur(16px); border-bottom: 1px solid var(--border); }
.kopf-zeile { display: flex; align-items: center; justify-content: space-between; gap: 12px; max-width: 760px; margin: 0 auto; }
.kopf h1 { margin: 0; font-size: 28px; line-height: 1.15; font-weight: 600; letter-spacing: -0.03em; }
.reiter { display: flex; gap: 2px; padding: 3px; margin-top: 12px; border-radius: var(--radius-lg); background: var(--secondary); }
.reiter button { padding: 5px 14px; border-radius: var(--radius-md); font-size: 14px; font-weight: 500; color: var(--muted-foreground); }
.reiter button.aktiv { background: var(--card); color: var(--foreground); box-shadow: var(--shadow-xs); }
.inhalt { padding: 8px 16px calc(env(safe-area-inset-bottom) + 48px); max-width: 760px; margin: 0 auto; }
.abschnitt { display: flex; align-items: center; gap: 8px; margin: 24px 2px 8px; font-size: 14px; font-weight: 600; }
.abschnitt .anzahl { color: var(--muted-foreground); font-weight: 500; }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; background: var(--muted-foreground); }
.gruppe { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-xl); box-shadow: var(--shadow-sm); overflow: hidden; }
.gruppe > * + * { border-top: 1px solid var(--border); }
.zeile { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 14px; min-height: 56px; }
.zeile:active { background: var(--accent); }
.zeile .art { width: 34px; height: 42px; border-radius: 6px; border: 1px solid var(--border); display: grid; place-items: center; flex: none;
  font-size: 10px; font-weight: 600; text-transform: uppercase; color: var(--muted-foreground); background: var(--secondary); }
.zeile .text { flex: 1; min-width: 0; }
.zeile .name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; line-height: 1.35; }
.zeile .unter { color: var(--muted-foreground); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.zeile-mit-menue { display: flex; align-items: center; }
.zeile-mit-menue .zeile { flex: 1; min-width: 0; }
.zeile-mit-menue .icon-knopf { margin-right: 8px; color: var(--muted-foreground); }
.marke { display: inline-block; font-size: 11.5px; font-weight: 500; padding: 1px 7px; border-radius: var(--radius-md); background: var(--secondary); color: var(--foreground); margin-left: 6px; }
.leer { color: var(--muted-foreground); padding: 40px 16px; font-size: 14px; text-align: center; }
.zeile.laedt { opacity: .6; pointer-events: none; }

/* ---------------------------------------------------------------- Dialog */
.dlg { width: min(440px, calc(100% - 32px)); border: 1px solid var(--border); border-radius: var(--radius-xl); background: var(--card); color: var(--foreground); padding: 20px; box-shadow: 0 10px 40px rgb(0 0 0 / .25); }
.dlg::backdrop { background: rgb(0 0 0 / .4); }
.dlg h2 { margin: 0 0 14px; font-size: 18px; font-weight: 600; }
.dlg label { display: grid; gap: 6px; font-size: 13px; font-weight: 500; margin-bottom: 12px; }
.dlg-knoepfe { display: flex; gap: 8px; margin-top: 8px; }
.dlg-knoepfe span { flex: 1; }
.fortschritt { position: relative; height: 28px; border-radius: var(--radius-md); background: var(--secondary); overflow: hidden; font-size: 13px; }
.fortschritt i { position: absolute; inset: 0 auto 0 0; width: 0; background: color-mix(in oklab, var(--success) 35%, transparent); transition: width .2s; }
.fortschritt span { position: relative; display: block; line-height: 28px; padding: 0 10px; }

/* ---------------------------------------------------------------- Folienansicht: Leiste */
.leiste { position: sticky; top: 0; z-index: 5; padding: calc(env(safe-area-inset-top) + 6px) 10px 6px; background: var(--bar);
  -webkit-backdrop-filter: saturate(160%) blur(16px); backdrop-filter: saturate(160%) blur(16px); border-bottom: 1px solid var(--border);
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; }
.leiste-zeile { display: flex; align-items: center; gap: 8px; flex: 1 1 320px; min-width: 0; }
.leiste-titel { flex: 1; min-width: 0; line-height: 1.25; }
#dok-titel { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status { font-size: 12px; color: var(--muted-foreground); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status.fehler { color: var(--warning); }
.seitenzahl { font-size: 13px; color: var(--muted-foreground); font-feature-settings: "tnum"; white-space: nowrap; }
.werkzeuge { display: flex; align-items: center; gap: 8px; overflow-x: auto; scrollbar-width: none; flex: 0 1 auto; max-width: 100%; }
.werkzeuge::-webkit-scrollbar { display: none; }
.gruppe-w { display: flex; gap: 2px; padding: 3px; border-radius: var(--radius-lg); background: var(--secondary); flex: none; }
.gruppe-w button { width: 36px; height: 34px; border-radius: var(--radius-md); display: grid; place-items: center; color: var(--muted-foreground); }
.gruppe-w button svg { width: 20px; height: 20px; }
.gruppe-w button.aktiv { background: var(--card); color: var(--foreground); box-shadow: var(--shadow-xs); }
.gruppe-w button:disabled { opacity: .35; }
.farben button i { width: 20px; height: 20px; border-radius: 50%; background: var(--f); box-shadow: inset 0 0 0 1px rgb(0 0 0 / .15); }
.farben button.aktiv i { box-shadow: 0 0 0 2px var(--card), 0 0 0 4px var(--f); }
.dicken i { width: 18px; height: var(--g); border-radius: 9px; background: currentColor; }

/* ---------------------------------------------------------------- Folien + Notizen */
.seiten { padding: 16px 12px calc(env(safe-area-inset-bottom) + 40vh); max-width: 1600px; margin: 0 auto; display: grid; gap: 28px; }
.seite { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; scroll-margin-top: 120px; }
.seite .notiz { width: 100%; max-width: 520px; }
/* Querformat: Notizen rechts; Spalte gedeckelt, weil die Schrift mit der Spaltenbreite wächst */
@media (min-width: 900px) and (min-aspect-ratio: 1/1) {
  .seite { grid-template-columns: minmax(0, 1fr) min(38%, 480px); gap: 14px; align-items: stretch; }
  .seite .notiz { max-width: none; }
}
.folie { position: relative; background: #fff; border-radius: 4px; box-shadow: 0 0 0 1px rgb(0 0 0 / .08), var(--shadow-sm); overflow: hidden; align-self: start;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.folie canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.folie .nr { position: absolute; left: 8px; bottom: 6px; font-size: 11px; color: #777; background: rgb(255 255 255 / .8); padding: 0 5px; border-radius: 4px; pointer-events: none; }
svg.ink { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; touch-action: pan-x pan-y pinch-zoom; }
svg.ink path { fill: none; stroke-linecap: round; stroke-linejoin: round; }
svg.ink path.marker { mix-blend-mode: multiply; }
.finger-zeichnet svg.ink, .finger-zeichnet .notiz-flaeche { touch-action: none; }
.radieren svg.ink, .radieren .notiz-flaeche { cursor: cell; }
.folie svg.ink, .notiz-modus-stift .notiz-flaeche { cursor: crosshair; }

.notiz { display: flex; flex-direction: column; min-width: 0; border-radius: 4px; background: var(--papier); color: #1a1a1a;
  box-shadow: 0 0 0 1px rgb(0 0 0 / .08), var(--shadow-sm); container-type: inline-size; }
.notiz-kopf { display: flex; align-items: center; gap: 4px; padding: 4px 6px 4px 12px; border-bottom: 1px solid var(--papier-linie); font-size: 12px; color: #777; }
.notiz-kopf .luecke { flex: 1; }
.notiz-kopf select { height: 26px; border: 0; border-radius: 6px; background: #f1f1ef; color: #555; font: inherit; font-size: 12px; padding: 0 4px; max-width: 76px; }
.stern-knopf { width: 26px; height: 26px; display: grid; place-items: center; border-radius: 6px; color: #bbb; }
.stern-knopf svg { width: 17px; height: 17px; }
.seite.markiert .stern-knopf { color: #e0a800; }
.seite.markiert .stern-knopf svg { fill: #fcd34d; }
.nur-sterne .seite:not(.markiert) { display: none; }
.seite.markiert .folie { box-shadow: 0 0 0 2px #fcd34d, var(--shadow-sm); }
.modus { display: flex; gap: 2px; padding: 2px; border-radius: 8px; background: #f1f1ef; }
.modus button { height: 26px; padding: 0 9px; border-radius: 6px; font-size: 12.5px; font-weight: 500; color: #777; display: inline-flex; align-items: center; gap: 4px; }
.modus button svg { width: 14px; height: 14px; }
body:not(.notiz-modus-stift) .modus [data-modus="text"], body.notiz-modus-stift .modus [data-modus="stift"] { background: #fff; color: #1a1a1a; box-shadow: 0 1px 2px rgb(0 0 0 / .1); }
/* 1000 Zeicheneinheiten = Breite der Fläche = 100cqw; Schrift 36, Rand 30, Zeile 1.45, Karo 40 (gleiche Werte im Export).
   --seite = Höhe einer Seite daneben; die graue Linie trennt die Seiten wie im PDF. */
.notiz-flaeche { position: relative; flex: 1; min-height: 140px; -webkit-touch-callout: none;
  background-image: repeating-linear-gradient(to bottom, transparent 0 calc(var(--seite) - 2px), #b3b3ae calc(var(--seite) - 2px) var(--seite)); }
.notiz-flaeche[data-papier="liniert"] { background-image:
  repeating-linear-gradient(to bottom, transparent 0 calc(var(--seite) - 2px), #b3b3ae calc(var(--seite) - 2px) var(--seite)),
  repeating-linear-gradient(to bottom, #d6dde6 0 1px, transparent 1px 5.22cqw); background-position: 0 0, 0 3cqw; }
.notiz-flaeche[data-papier="kariert"] { background-image:
  repeating-linear-gradient(to bottom, transparent 0 calc(var(--seite) - 2px), #b3b3ae calc(var(--seite) - 2px) var(--seite)),
  linear-gradient(#e1e5ea 1px, transparent 1px), linear-gradient(90deg, #e1e5ea 1px, transparent 1px); background-size: auto, 4cqw 4cqw, 4cqw 4cqw; }
.notiz-flaeche textarea {
  display: block; width: 100%; border: 0; outline: none; resize: none; overflow: hidden; background: transparent; color: #1a1a1a;
  font-family: "Notiz", ui-sans-serif, sans-serif; font-size: 3.6cqw; line-height: 1.45; padding: 3cqw; margin: 0;
  overflow-wrap: break-word; white-space: pre-wrap; tab-size: 4;
}
.notiz-flaeche textarea::placeholder { color: #aaa; }
.notiz-flaeche textarea:focus-visible { box-shadow: none; }
.notiz:focus-within { box-shadow: 0 0 0 1px rgb(0 0 0 / .08), 0 0 0 3px color-mix(in oklab, var(--ring) 40%, transparent); }
.notiz-modus-stift .notiz-flaeche textarea { pointer-events: none; user-select: none; -webkit-user-select: none; }
.notiz-flaeche svg.ink { pointer-events: none; }

/* ---------------------------------------------------------------- Toast */
.toast { position: fixed; z-index: 20; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 20px); transform: translateX(-50%); max-width: calc(100% - 32px);
  display: flex; align-items: center; gap: 12px; padding: 10px 12px 10px 16px; border-radius: var(--radius-xl); background: var(--primary); color: var(--primary-foreground);
  font-size: 14px; box-shadow: 0 8px 30px rgb(0 0 0 / .25); }
.toast .knopf { height: 32px; background: var(--primary-foreground); color: var(--primary); border: 0; }

/* ---------------------------------------------------------------- Quiz (wie die Lernkurse der Uni-App) */
#quizansicht .inhalt { padding-top: 16px; }
.hinweis { font-size: 13px; color: var(--muted-foreground); margin: 16px 2px 0; line-height: 1.55; }
.frage { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-xl); box-shadow: var(--shadow-sm); padding: 16px; margin-top: 14px; }
.frage-kopf { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.frage .typ { display: inline-block; font-size: 11.5px; font-weight: 500; padding: 1px 7px; border-radius: var(--radius-md); border: 1px solid var(--border); color: var(--muted-foreground); }
.frage .marke { margin: 0; }
.frage-text { font-weight: 600; font-size: 15px; line-height: 1.45; margin-top: 10px; }
.optionen { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.option { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: var(--radius-md); border: 1px solid var(--border); background: var(--background); font-size: 14px; line-height: 1.45; }
.option .buchst { flex: none; width: 22px; height: 22px; border-radius: 6px; display: grid; place-items: center; border: 1px solid var(--border); font-size: 12px; font-weight: 600; color: var(--muted-foreground); }
.option.richtig { border-color: var(--success); background: color-mix(in oklab, var(--success) 12%, transparent); }
.option.richtig .buchst { background: var(--success); border-color: var(--success); color: #fff; }
.option.falsch { border-color: var(--destructive); background: color-mix(in oklab, var(--destructive) 10%, transparent); }
.option.falsch .buchst { background: var(--destructive); border-color: var(--destructive); color: #fff; }
.option:disabled { cursor: default; color: var(--foreground); }
.feedback { margin-top: 12px; font-size: 13.5px; line-height: 1.55; padding: 10px 12px; border-radius: var(--radius-lg); border: 1px solid var(--border); }
.feedback.gut b { color: var(--success); }
.feedback.schlecht b { color: var(--destructive); }
.antwort { width: 100%; margin-top: 12px; padding: 8px 12px; border-radius: var(--radius-md); border: 1px solid var(--input); background: transparent; color: var(--foreground); font: inherit; font-size: 15px; line-height: 1.5; resize: vertical; min-height: 88px; outline: none; }
.antwort:focus { border-color: var(--ring); box-shadow: 0 0 0 3px color-mix(in oklab, var(--ring) 50%, transparent); }
.frage > .knopf { margin-top: 10px; }
.loesung { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }
.loesung p { margin: 8px 0 14px; font-size: 14px; white-space: pre-wrap; }
.punkt { display: flex; gap: 10px; align-items: flex-start; width: 100%; padding: 8px 0; font-size: 14px; line-height: 1.45; }
.punkt .haken { flex: none; width: 20px; height: 20px; border-radius: 5px; border: 1px solid var(--input); display: grid; place-items: center; font-size: 13px; color: transparent; }
.punkt.an .haken { background: var(--primary); border-color: var(--primary); color: var(--primary-foreground); }
.knopf.breit { width: 100%; justify-content: center; margin-top: 20px; }
