/* Lernkasten – Gestaltung
   Leitidee: die klassische DIN-A7-Karteikarte (weiß, rote Kopflinie, blaue Lineatur)
   als einziges prägnantes Element. Alles andere bleibt ruhig: Papiergrau, Tintenblau.
   Keine externen Schriften (DSGVO, Offline-fähigkeit): Systemschriften. */

:root {
    --paper: #f3f5f7;
    --sheet: #ffffff;
    --ink: #1c2b4a;
    --ink-soft: #55627a;
    --rule: #dde3ea;
    --royal: #2449b0;
    --royal-ink: #ffffff;
    --card-red: #c7343e;
    --card-lines: #d6e2f3;
    --again: #c7343e;
    --hard: #a8670f;
    --good: #2449b0;
    --easy: #2c7a4b;
    --focus: #2449b0;
    --shadow: 0 1px 2px rgb(28 43 74 / 0.08), 0 8px 24px rgb(28 43 74 / 0.07);
    --desk: #e4e8ee;            /* Fläche hinter PDF-Seiten */
    --pdf-page: #ffffff;        /* PDF-Seiten bleiben auch im Dunkelmodus weiß */
    --mask: #e8a33d;            /* Abdeckungen (Image Occlusion) */
    --mask-edge: #9a5d06;
    --mask-ink: #3b2400;
    --mask-select: #2449b0;     /* Auswahl auf der (immer weißen) Seite */
    --crop: #2449b0;
    --crop-ink: #ffffff;
    --mask-target: #c7343e;     /* abgefragter Begriff beim Lernen (Farbe der Kopflinie) */
    --mask-target-ink: #ffffff;

    /* Fachfarben: zweites Ordnungselement neben dem Karteikarten-Look (ab Schritt 16 je Fach). */
    --fc-green: #2f8a4c;
    --fc-blue: #2f63c9;
    --fc-orange: #d0563b;
    --fc-violet: #7a52c7;
    --fc-teal: #13858a;
    --fc-amber: #b77a12;
    --fc-rose: #b8407a;
    --fc-slate: #5b6b82;
    --fc-none: #8a96a8;         /* „Ohne Fach“ */
    --fc-tab-ink: #ffffff;      /* Schrift auf der Registerlasche */

    --tabbar-h: 4rem;           /* Leiste unten, ohne Safe-Area */
    --study-bg: #d9dfe8;        /* Schreibtisch beim Lernen (Fokusmodus) */
    --box: #3b4f78;             /* Karteikasten auf der Anmeldeseite (Sperre) */

    --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --serif: "Iowan Old Style", Charter, "Bitstream Charter", "Sitka Text", Cambria, Georgia, serif;

    --step--1: 0.875rem;
    --step-0: 1rem;
    --step-1: 1.25rem;
    --step-2: 1.6rem;
    --step-3: 2rem;
    --line: 2rem; /* Lineatur der Karteikarte */

    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --paper: #141a26;
        --sheet: #1d2534;
        --ink: #e4e9f2;
        --ink-soft: #9aa6bb;
        --rule: #2b3548;
        --royal: #7d9cf0;
        --royal-ink: #0f1522;
        --card-red: #e0626a;
        --card-lines: #2a3750;
        --again: #e0626a;
        --hard: #d9a14a;
        --good: #7d9cf0;
        --easy: #5fbf86;
        --focus: #9db4f5;
        --shadow: 0 1px 2px rgb(0 0 0 / 0.4), 0 8px 24px rgb(0 0 0 / 0.3);
        --desk: #0e131c;
        --mask: #d9932c;
        --mask-edge: #7a4800;
        --mask-select: #3d64d6;
        --crop: #3d64d6;
        --fc-green: #5cc27c;
        --fc-blue: #7aa2f2;
        --fc-orange: #f08a70;
        --fc-violet: #b294f0;
        --fc-teal: #4cc3c7;
        --fc-amber: #e0ad4f;
        --fc-rose: #e88ab6;
        --fc-slate: #9aa9bf;
        --fc-none: #7d8898;
        --fc-tab-ink: #0f141c;
        --study-bg: #0b1018;
        --box: #2c3a58;
        color-scheme: dark;
    }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font: 400 var(--step-0)/1.5 var(--sans);
    -webkit-tap-highlight-color: transparent;
    transition: background-color 300ms ease;
}
/* Lernen: Hintergrund wird zum Schreibtisch, die Karteikarte liegt darauf wie unter einer Lampe. */
body.studying { background: var(--study-bg); }

h1, h2 { line-height: 1.2; margin: 0; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: var(--step-3); }
h2 { font-size: var(--step-1); }
p { margin: 0; }

a { color: var(--royal); }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }

/* ---------- Rahmen ---------- */

main {
    max-width: 52rem;
    margin: 0 auto;
    padding: calc(1.5rem + env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) calc(var(--tabbar-h) + 2.5rem + env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
    display: grid;
    grid-template-columns: minmax(0, 1fr); /* Inhalt darf die Seite nie breiter machen */
    gap: 1.75rem;
}
@media (min-width: 40rem) { main { padding-left: max(1.5rem, env(safe-area-inset-left)); padding-right: max(1.5rem, env(safe-area-inset-right)); } }

main:focus { outline: none; }
main.wide { max-width: 80rem; gap: 1rem; padding-top: calc(1.25rem + env(safe-area-inset-top)); }
body.focus main { padding-bottom: calc(2rem + env(safe-area-inset-bottom)); }

/* Leiste unten: Heute · Fächer · Erfassen · Prüfungen · Fortschritt */
.tabbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10;
    display: flex;
    justify-content: space-around;
    gap: 0.25rem;
    padding: 0.3rem max(0.5rem, env(safe-area-inset-right)) calc(0.3rem + env(safe-area-inset-bottom)) max(0.5rem, env(safe-area-inset-left));
    min-height: var(--tabbar-h);
    background: color-mix(in srgb, var(--sheet) 92%, transparent);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--rule);
}
.tabbar a {
    flex: 1 1 0;
    max-width: 8rem;
    display: grid;
    justify-items: center;
    align-content: center;
    gap: 0.15rem;
    min-height: 3.25rem;
    border-radius: 10px;
    color: var(--ink-soft);
    font-size: 0.75rem;
    font-weight: 600;
    text-decoration: none;
}
.tabbar a:hover { color: var(--ink); }
.tabbar a[aria-current="page"] { color: var(--card-red); }
.tabbar .ico { width: 1.5rem; height: 1.5rem; }
.tabbar a.capture .ico {
    width: 2.25rem;
    height: 2.25rem;
    margin-top: -0.35rem;
    padding: 0.4rem;
    border-radius: 50%;
    background: var(--royal);
    color: var(--royal-ink);
}
.tabbar a.capture[aria-current="page"] .ico { background: var(--card-red); color: #fff; }
/* Fokusmodus: Leiste gleitet nach unten weg (und beim Verlassen zurück). */
.tabbar { transition: transform 240ms ease, visibility 0s linear 0s; }
body.focus .tabbar { transform: translateY(100%); visibility: hidden; transition: transform 240ms ease, visibility 0s linear 240ms; }
@media (prefers-reduced-motion: reduce) {
    body, .tabbar, body.focus .tabbar { transition: none; }
}

/* Kopf im Fokusmodus: Schließen links, Titel mittig, Zusatz rechts */
.focus-head { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 0.75rem; }
.focus-close { justify-self: start; margin-left: -0.6rem; padding: 0 0.8rem; color: var(--ink); }
.focus-close kbd { margin-left: 0.15rem; }
.focus-title { font-size: var(--step-0); font-weight: 650; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 60vw; }
.focus-aside { justify-self: end; }
@media (max-width: 30rem) {
    .focus-head { grid-template-columns: auto minmax(0, 1fr) auto; }
    .focus-close span { display: none; } /* nur das × */
}
@media print { .tabbar { display: none; } }

/* Icons aus dem Sprite unter public/vendor/lucide-1.73.0/ (Strichstil wie Lucide) */
.ico {
    width: 1.25rem;
    height: 1.25rem;
    flex: none;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.ico.muted { color: var(--ink-soft); }

.loading { color: var(--ink-soft); }

.page-head { display: grid; gap: 0.4rem; }
.eyebrow { font-size: 0.8rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-soft); }
.section { display: grid; gap: 0.75rem; }
.section-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem 1rem; }
[hidden] { display: none !important; }
.lede { color: var(--ink-soft); max-width: 60ch; }

.backlink {
    display: inline-flex;
    align-items: center;
    min-height: 2.75rem;
    margin: -0.5rem 0;
    font-size: var(--step--1);
    font-weight: 600;
    color: var(--ink-soft);
    text-decoration: none;
    justify-self: start;
}
.backlink::before { content: "‹ "; }
.backlink:hover { color: var(--royal); }

.title-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.panel {
    background: var(--sheet);
    border-radius: 14px;
    box-shadow: var(--shadow);
    padding: 1.25rem;
}
.panel.empty { display: flex; align-items: center; gap: 0.75rem; color: var(--ink-soft); }

.stack { display: grid; gap: 1rem; }

.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.actions.compact { gap: 0.25rem; }
.hint { color: var(--ink-soft); font-size: var(--step--1); }

/* ---------- Formulare & Knöpfe ---------- */

.field { display: grid; gap: 0.35rem; }
label { font-weight: 600; font-size: var(--step--1); }

input, textarea {
    width: 100%;
    font: inherit;
    color: var(--ink);
    background: var(--paper);
    border: 1px solid var(--rule);
    border-radius: 10px;
    padding: 0.7rem 0.8rem;
    min-height: 3rem;
}
textarea { resize: vertical; min-height: 5rem; font-family: var(--serif); font-size: 1.05rem; line-height: 1.5; }
input:focus, textarea:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 25%, transparent); }

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-height: 3rem; /* Touch-Ziel iPad */
    padding: 0 1.1rem;
    border: 1.5px solid var(--rule);
    border-radius: 12px;
    background: var(--sheet);
    color: var(--ink);
    font: 600 var(--step-0)/1 var(--sans);
    text-decoration: none;
    cursor: pointer;
}
.button:hover { border-color: var(--ink-soft); }
.button.primary { background: var(--royal); border-color: var(--royal); color: var(--royal-ink); }
.button.primary:hover { filter: brightness(1.08); }
.button.small { min-height: 2.25rem; padding: 0 0.7rem; font-size: var(--step--1); }
.button.danger-quiet { color: var(--again); }
.button.ghost { background: transparent; border-color: transparent; }
.button.ghost:hover { background: color-mix(in srgb, var(--ink) 7%, transparent); }
.button.big { width: 100%; min-height: 3.75rem; font-size: var(--step-1); border-radius: 14px; }
.button.small .ico { width: 1rem; height: 1rem; }
.button:disabled, .button[aria-busy="true"] { opacity: 0.6; cursor: progress; }

kbd {
    font: 500 0.75rem/1 var(--sans);
    padding: 0.2rem 0.35rem;
    border-radius: 4px;
    border: 1px solid currentColor;
    opacity: 0.7;
}
@media (hover: none) { kbd { display: none; } }

/* ---------- Listen, Chips ---------- */

/* Weiße Liste mit Trennlinien: eine Zeile = ein Ding, wenig Zahlen. */
.list { list-style: none; margin: 0; padding: 0; background: var(--sheet); border-radius: 14px; box-shadow: var(--shadow); overflow: hidden; }
.list > * + * { border-top: 1px solid var(--rule); }
.item { display: flex; align-items: center; gap: 0.5rem; padding-right: 0.6rem; min-height: 3.75rem; }
.item-main {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 0.85rem;
    align-self: stretch;
    padding: 0.7rem 0.5rem 0.7rem 1.1rem;
    color: inherit;
    text-decoration: none;
}
a.item-main:hover .item-title { color: var(--royal); }
.item-text { flex: 1; min-width: 0; display: grid; gap: 0.1rem; }
.item-title { font-weight: 650; overflow-wrap: anywhere; }
.item-sub { color: var(--ink-soft); font-size: var(--step--1); }
.item-actions { display: flex; gap: 0.1rem; }
.item > .button { flex: none; }

.chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    background: color-mix(in srgb, var(--ink) 7%, transparent);
    color: var(--ink-soft);
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
}
.chip.warn { background: color-mix(in srgb, var(--card-red) 14%, transparent); color: var(--card-red); }

/* Fachfarbe als Punkt; --fc setzt die Klasse .fc-<farbe> des Fachs. */
.dot { width: 0.65rem; height: 0.65rem; border-radius: 50%; flex: none; background: var(--fc, var(--fc-none)); }

@media (max-width: 30rem) {
    .item-main { padding-left: 0.9rem; gap: 0.7rem; }
    .item > .button { padding: 0 0.8rem; }
    .item-actions .button.icon { width: 2.75rem; }
}

/* ---------- Heute ---------- */

.index-card.today-card { display: grid; gap: 0; min-height: 0; max-width: none; line-height: var(--line); }
/* Beschriftung im Kopf der Karte, oberhalb der roten Linie */
.today-label { display: flex; align-items: center; height: calc(var(--line) * 2); margin-top: calc(var(--line) * -2 - 2px); font-size: var(--step--1); font-weight: 600; color: var(--ink-soft); }
.today-big { font-family: var(--serif); font-size: 2.4rem; line-height: calc(var(--line) * 2); font-weight: 600; }
.today-text { font-family: var(--serif); font-size: 1.1rem; }
.today-card .button, .today-card .actions { margin-top: calc(var(--line) * 0.5); font-family: var(--sans); line-height: 1.2; }
.today-card .today-label { justify-content: space-between; gap: 0.5rem; }
.today-card .today-label .chip { font-family: var(--sans); }
.today-card .today-label .chip .ico { width: 0.9rem; height: 0.9rem; }
.today-focus { margin-top: calc(var(--line) * 0.5); font-size: var(--step--1); color: var(--ink-soft); line-height: var(--line); font-family: var(--sans); }
.today-cols { display: grid; gap: 1.5rem; align-items: start; }
@media (min-width: 52rem) { .today-cols { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); } }
.subject-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
a.link-chip { min-height: 2.75rem; padding: 0 0.9rem; color: var(--ink); text-decoration: none; font-size: var(--step--1); }
a.link-chip:hover { background: color-mix(in srgb, var(--fc, var(--ink)) 14%, transparent); }
.link { color: var(--royal); font-weight: 600; text-decoration: none; display: inline-flex; align-items: center; min-height: 2.75rem; }
.link:hover { text-decoration: underline; }
.chip.ok { background: color-mix(in srgb, var(--easy) 16%, transparent); color: var(--easy); }
.item-text .meter { height: 0.4rem; margin: 0.25rem 0 0.1rem; max-width: 16rem; }
.item-text .meter .meter-fill { background: var(--fc, var(--easy)); }

/* Wochenstreifen Mo–So */
.week-strip { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(7, 1fr); gap: 0.4rem; }
.week-day { display: grid; gap: 0.3rem; justify-items: center; }
.week-bar { width: 100%; height: 0.6rem; border-radius: 999px; background: var(--rule); }
.week-day.on .week-bar { background: var(--easy); }
.week-day.today .week-bar { outline: 2px solid var(--card-red); outline-offset: 1px; }
.week-day.future .week-bar { opacity: 0.45; }
.week-label { font-size: 0.75rem; color: var(--ink-soft); }
.week-day.today .week-label { color: var(--ink); font-weight: 650; }

/* ---------- Lernen: Fach, Werkzeuge, Quelle ---------- */

.study-tag { display: inline-flex; align-items: center; gap: 0.45rem; margin-bottom: -0.75rem; font-size: var(--step--1); font-weight: 650; color: var(--ink-soft); }
.study-tools { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.5rem; }
.study-tools .button.small { min-height: 2.75rem; color: var(--ink-soft); }
dialog.sheet.wide-sheet { max-width: 56rem; }
.source-figure { display: grid; justify-items: center; }
.source-figure .pdf-sheet { border-top: 2px solid var(--card-red); }

/* ---------- Abschluss einer Lernsitzung ---------- */

.done-view { width: 100%; max-width: 42rem; display: grid; gap: 1.25rem; outline: none; }
.done-hero { display: grid; gap: 0.4rem; justify-items: center; text-align: center; padding-top: 1rem; }
.done-big {
    font-size: clamp(2.4rem, 7vw, 3.2rem); font-weight: 800; letter-spacing: -0.02em; line-height: 1.1;
    background: linear-gradient(90deg, var(--fc-blue), var(--fc-violet), var(--card-red), var(--fc-amber), var(--fc-green));
    -webkit-background-clip: text; background-clip: text; color: transparent;
}
.done-hero .lede { text-align: center; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); gap: 0.75rem; }
.stat { display: grid; gap: 0.15rem; align-content: start; padding: 0.9rem 1rem; border-radius: 14px; background: var(--sheet); box-shadow: var(--shadow); }
.stat-label { display: flex; align-items: center; gap: 0.2rem; font-size: var(--step--1); color: var(--ink-soft); }
.stat-value { font-size: 1.8rem; font-weight: 750; font-variant-numeric: tabular-nums; color: var(--fc, var(--ink)); }
.stat-sub { font-size: var(--step--1); color: var(--ink-soft); }
.dist { display: flex; gap: 2px; height: 0.9rem; border-radius: 999px; overflow: hidden; background: var(--rule); }
.dist-part { display: block; flex: 0 0 0; min-width: 0; background: var(--c); }
.dist-part.again { --c: var(--again); }
.dist-part.hard { --c: var(--hard); }
.dist-part.good { --c: var(--good); }
.dist-part.easy { --c: var(--easy); }
.legend { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.4rem 1rem; font-size: var(--step--1); color: var(--ink-soft); }
.legend li { display: inline-flex; align-items: center; gap: 0.35rem; }
.legend .dist-part { width: 0.7rem; height: 0.7rem; border-radius: 50%; flex: none; }
.panel.ahead { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.75rem 1rem; }
.confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 30; }

/* ---------- Erfassen ---------- */

.capture-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: 1rem; }
.capture-tile {
    display: grid;
    justify-items: center;
    gap: 0.35rem;
    padding: 1.75rem 1rem;
    border: 0;
    border-radius: 16px;
    background: var(--sheet);
    box-shadow: var(--shadow);
    color: var(--ink);
    font: inherit;
    cursor: pointer;
}
.capture-tile:hover { outline: 2px solid var(--royal); }
.capture-tile .ico { width: 2.5rem; height: 2.5rem; color: var(--royal); stroke-width: 1.6; }
.capture-title { font-size: var(--step-1); font-weight: 650; }
.capture-tile:disabled, .capture-tile[aria-busy="true"] { opacity: 0.6; cursor: progress; }

/* ---------- Eingang ---------- */

/* Hinweis auf „Heute“ und unter „Erfassen“: gestrichelt wie ein Ablagekorb. */
.inbox-hint {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem 1rem;
    padding: 0.9rem 1.1rem;
    border: 2px dashed var(--rule);
    border-radius: 14px;
}
.inbox-hint .item-text { flex: 1 1 14rem; }
.inbox-badge {
    display: inline-grid;
    place-items: center;
    flex: none;
    width: 2.75rem;
    height: 2.75rem;
    border-radius: 12px;
    background: color-mix(in srgb, var(--royal) 12%, transparent);
    color: var(--royal);
}
.inbox-layout { display: grid; gap: 1.25rem; }
@media (min-width: 52rem) {
    .inbox-layout { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); align-items: start; }
}
.inbox-preview { display: block; min-width: 0; }
.inbox-preview .pdf-sheet { margin: 0; max-width: 100%; }
.inbox-preview:focus-visible { outline: 2px solid var(--royal); outline-offset: 4px; }
.inbox-action { min-height: 4.25rem; }
.item-title .chip { margin-left: 0.5rem; vertical-align: 0.1em; }
.choice .ico { width: 1.1rem; height: 1.1rem; }

/* ---------- Prüfungen ---------- */

.exam-days { min-width: 3rem; text-align: center; font-size: 1.4rem; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; color: var(--royal); }
.exam-days small { display: block; margin-top: 0.2rem; font-size: 0.7rem; font-weight: 600; color: var(--ink-soft); }
.exam-days.soon { color: var(--card-red); }
.exam-days.past { color: var(--ink-soft); }

/* ---------- Blätter (Formulare) ---------- */

dialog.sheet {
    width: 100%;
    max-width: 40rem;
    max-height: calc(100dvh - 2rem - env(safe-area-inset-top));
    margin: auto auto 0;
    padding: 0;
    border: 0;
    border-radius: 18px 18px 0 0;
    background: var(--paper);
    color: var(--ink);
    box-shadow: 0 -8px 32px rgb(10 14 22 / 0.25);
    overflow: auto;
    overscroll-behavior: contain;
}
dialog.sheet::backdrop { background: rgb(10 14 22 / 0.45); }
.sheet-inner { display: grid; gap: 1rem; padding: 0.75rem max(1.25rem, env(safe-area-inset-right)) calc(1.5rem + env(safe-area-inset-bottom)) max(1.25rem, env(safe-area-inset-left)); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-right: -0.5rem; }
@media (min-width: 60rem) and (min-height: 36rem) {
    dialog.sheet { margin: auto; border-radius: 18px; }
    .sheet-inner { padding: 1rem 1.5rem 1.5rem; }
}
@media (prefers-reduced-motion: no-preference) {
    dialog.sheet[open] { animation: sheet-in 200ms ease-out; }
    @keyframes sheet-in { from { transform: translateY(2rem); opacity: 0; } }
}

/* ---------- Kartensatz ---------- */

.cards { display: grid; gap: 0.75rem; }
.card-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.5rem; }

.card-item {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 1rem;
    background: var(--sheet);
    border: 1px solid var(--rule);
    border-left: 3px solid var(--card-red);
    border-radius: 6px;
    padding: 0.85rem 1rem;
}
.card-item.editing { grid-template-columns: 1fr; }

.card-text { display: grid; gap: 0.25rem; min-width: 0; }
.card-front, .card-back { white-space: pre-wrap; overflow-wrap: anywhere; display: -webkit-box; -webkit-box-orient: vertical; overflow: hidden; }
.card-front { font-family: var(--serif); font-size: 1.05rem; -webkit-line-clamp: 3; }
.card-back { color: var(--ink-soft); font-size: var(--step--1); -webkit-line-clamp: 2; }

.card-side { display: grid; justify-items: end; align-content: space-between; gap: 0.5rem; }
.status { font-size: var(--step--1); white-space: nowrap; color: var(--ink-soft); }
.status.new { color: var(--royal); }
.status.due { color: var(--card-red); font-weight: 650; }

@media (max-width: 40rem) {
    .card-item { grid-template-columns: 1fr; }
    .card-side { justify-items: start; grid-auto-flow: column; align-items: center; justify-content: space-between; }
}

/* ---------- Lernen ---------- */

.study-head { display: grid; gap: 0.6rem; width: 100%; max-width: 42rem; justify-self: center; }
.study-count { font-size: var(--step--1); color: var(--ink-soft); font-variant-numeric: tabular-nums; white-space: nowrap; }
.study-progress { height: 0.5rem; border-radius: 999px; background: color-mix(in srgb, var(--ink) 12%, transparent); overflow: hidden; }
.study-progress i { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--easy); transition: width 300ms ease; }
@media (prefers-reduced-motion: reduce) { .study-progress i { transition: none; } }

.study-stage { display: grid; gap: 1.5rem; justify-items: center; }

/* Die Karteikarte: das eine prägnante Element der App. */
.index-card {
    width: 100%;
    max-width: 42rem;
    min-height: min(22rem, 55vh);
    background-color: var(--sheet);
    background-image:
        linear-gradient(var(--card-red), var(--card-red)),
        repeating-linear-gradient(to bottom, transparent 0, transparent calc(var(--line) - 1px), var(--card-lines) calc(var(--line) - 1px), var(--card-lines) var(--line));
    background-size: 100% 2px, 100% 100%;
    background-position: 0 calc(var(--line) * 2), 0 calc(var(--line) * 2 + 2px);
    background-repeat: no-repeat, no-repeat;
    border-radius: 4px;
    box-shadow: var(--shadow);
    padding: calc(var(--line) * 2 + 2px) clamp(1.25rem, 5vw, 3rem) var(--line);
    outline: none;
}

.index-card-body { display: grid; }

.face {
    font-family: var(--serif);
    font-size: clamp(1.2rem, 2.4vw, 1.45rem);
    line-height: var(--line);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}
.face.front { font-weight: 600; }
.face.back { color: var(--ink); }

.fold {
    border: 0;
    border-top: 2px dashed var(--ink-soft);
    opacity: 0.45;
    margin: calc(var(--line) - 1px) 0 var(--line);
    height: 0;
}

.index-card.revealed .face.back { animation: uncover 220ms ease-out; }
@keyframes uncover { from { clip-path: inset(0 0 100% 0); } to { clip-path: inset(0 0 0 0); } }

.reveal-row { width: 100%; max-width: 42rem; }
.button.reveal { width: 100%; min-height: 3.5rem; font-size: var(--step-1); }

.ratings {
    width: 100%;
    max-width: 42rem;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
}

.rating {
    --c: var(--good);
    position: relative;
    display: grid;
    justify-items: center;
    gap: 0.2rem;
    min-height: 4rem;
    padding: 0.6rem 0.25rem;
    border-radius: 6px;
    border: 1px solid color-mix(in srgb, var(--c) 45%, var(--rule));
    border-top: 4px solid var(--c);
    background: var(--sheet);
    color: var(--ink);
    font: inherit;
    cursor: pointer;
}
.rating.again { --c: var(--again); }
.rating.hard { --c: var(--hard); }
.rating.good { --c: var(--good); }
.rating.easy { --c: var(--easy); }
.rating:hover { background: color-mix(in srgb, var(--c) 8%, var(--sheet)); }
.rating:disabled { opacity: 0.5; cursor: progress; }
.rating-label { font-weight: 650; color: var(--c); }
.rating-interval { font-size: var(--step--1); color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.rating-key { position: absolute; top: 0.4rem; right: 0.4rem; }

.done { width: 100%; max-width: 42rem; }

/* Abdeckungs-Karte: Seite bzw. Ausschnitt mit Masken statt Karteikarte. */
.occl-study { width: 100%; display: grid; gap: 0.75rem; justify-items: center; outline: none; }
.occl-study-header {
    font-family: var(--serif);
    font-size: clamp(1.1rem, 2.2vw, 1.3rem);
    font-weight: 600;
    text-align: center;
    max-width: 42rem;
    overflow-wrap: anywhere;
}
.study-figure { display: grid; justify-items: center; width: 100%; }
.study-figure-status:empty { display: none; }
.study-sheet { position: relative; overflow: hidden; border-top: 2px solid var(--card-red); }
.study-overlay { position: absolute; inset: 0; pointer-events: none; }
.study-mask {
    position: absolute;
    background: var(--mask);
    border: 1px solid var(--mask-edge);
    border-radius: 2px;
}
.study-mask.target {
    background: var(--mask-target);
    border-color: var(--mask-target);
    display: grid;
    place-items: center;
    color: var(--mask-target-ink);
    font: 700 clamp(0.7rem, 1.6vw, 1rem)/1 var(--sans);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--mask-target) 30%, transparent);
}
.study-mask.target.revealed {
    background: transparent;
    border: 2px dashed var(--mask-target);
    box-shadow: none;
    animation: occl-reveal 220ms ease-out;
}
@keyframes occl-reveal { from { background: var(--mask-target); } to { background: transparent; } }

/* ---------- Dokumente ---------- */

.doc-heading { font-size: var(--step-2); overflow-wrap: anywhere; }

.pdf-viewer { display: grid; gap: 0.75rem; }

.pdf-toolbar {
    position: sticky;
    top: 0;
    z-index: 2;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem 1rem;
    padding: 0.5rem;
    background: var(--sheet);
    border: 1px solid var(--rule);
    border-radius: 10px;
}
.pager, .zoomer { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 0.35rem; }
.pager[hidden] { display: none; }
.page-field { display: inline-flex; align-items: center; gap: 0.4rem; font-weight: 400; font-size: var(--step-0); color: var(--ink-soft); white-space: nowrap; }
.page-input { width: 4.5rem; min-height: 2.75rem; text-align: center; font-variant-numeric: tabular-nums; padding: 0.4rem; }
.zoom-label { min-width: 3.75rem; text-align: center; font-variant-numeric: tabular-nums; color: var(--ink-soft); font-size: var(--step--1); }
.button.icon { width: 3rem; padding: 0; font-size: 1.4rem; font-weight: 500; }
.button:disabled { opacity: 0.4; cursor: default; }

.pdf-stage {
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    max-height: calc(100dvh - 11rem);
    min-height: 60vh;
    padding: 1rem;
    background: var(--desk);
    border-radius: 10px;
    overscroll-behavior: contain;
}
.pdf-stage:focus-visible { outline-offset: -3px; }
.pdf-stage.fit-stage { min-height: 0; max-height: none; } /* Höhe setzt document.js */
.pdf-sheet {
    margin: 0 auto;
    background: var(--pdf-page);
    box-shadow: var(--shadow);
}
.pdf-canvas { display: block; }

@media (max-width: 40rem) {
    .pdf-toolbar { justify-content: center; }
    .pdf-stage { padding: 0.5rem; max-height: none; }
}

/* ---------- Occlusion-Editor ---------- */

.occl-notes { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.occl-notes[hidden] { display: none; }
.occl-page { color: var(--ink-soft); font-weight: 400; }

.occl-layout { display: grid; grid-template-columns: minmax(0, 1fr) 19rem; gap: 1rem; align-items: start; }
.occl-toolbar { justify-content: flex-start; }
.occl-tools { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.occl-tools .button[aria-pressed="true"] { background: var(--royal); border-color: var(--royal); color: var(--royal-ink); }
.occl-toolbar .zoomer { margin-left: auto; }
.occl-stage { height: calc(100dvh - 13rem); min-height: 22rem; max-height: none; }
.occl-panel { position: sticky; top: 1rem; }
.occl-summary { font-weight: 650; }
.occl-newdeck { display: grid; grid-template-columns: 1fr auto; gap: 0.5rem; }
.occl-newdeck[hidden], .occl-panel [hidden] { display: none; }
.occl-modes { border: 0; margin: 0; padding: 0; }
.occl-modes legend, .occl-panel .label { font-weight: 600; font-size: var(--step--1); padding: 0; margin-bottom: 0.35rem; }
.occl-choice { display: grid; grid-template-columns: auto 1fr; gap: 0.6rem; align-items: start; font-weight: 400; font-size: var(--step-0); min-height: 2.75rem; padding: 0.3rem 0; cursor: pointer; }
.occl-choice input { width: 1.25rem; height: 1.25rem; margin: 0.15rem 0 0; accent-color: var(--royal); }
.occl-choice > span { display: grid; gap: 0.1rem; }

select.select {
    width: 100%;
    min-height: 2.75rem;
    font: inherit;
    color: var(--ink);
    background: var(--paper);
    border: 1px solid var(--rule);
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
}

.occl-sheet { position: relative; }
.occl-overlay {
    position: absolute;
    inset: 0;
    touch-action: none;                 /* Finger/Pencil zeichnen statt zu scrollen */
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    cursor: crosshair;
}
.occl-overlay[data-tool="pan"] { touch-action: pan-x pan-y pinch-zoom; cursor: grab; }

.occl-mask, .occl-crop { position: absolute; touch-action: none; }
.occl-mask {
    background: var(--mask);
    border: 1px solid var(--mask-edge);
    border-radius: 2px;
    cursor: move;
    display: grid;
    place-items: center;
    overflow: visible;
}
.occl-num {
    font: 700 0.8rem/1 var(--sans);
    color: var(--mask-ink);
    pointer-events: none;
    font-variant-numeric: tabular-nums;
}
.occl-mask.sibling { outline: 2px dashed var(--mask-select); outline-offset: 1px; }
.occl-mask.selected, .occl-crop.selected { outline: 2px solid var(--mask-select); outline-offset: 1px; }
.occl-mask.drawing { opacity: 0.7; }

.occl-crop {
    border: 2px dashed var(--crop);
    background: color-mix(in srgb, var(--crop) 6%, transparent);
    cursor: move;
}
.occl-crop-label {
    position: absolute;
    top: 0;
    left: 0;
    transform: translateY(-100%);
    padding: 0.1rem 0.35rem;
    background: var(--crop);
    color: var(--crop-ink);
    font: 600 0.7rem/1.2 var(--sans);
    border-radius: 3px 3px 0 0;
    white-space: nowrap;
    cursor: move;
}
/* Mit den Rechteck-Werkzeugen lässt sich im Ausschnitt weiterzeichnen; den Rahmen
   greift man dann an Etikett oder Ecken. */
.occl-overlay:not([data-tool="crop"]) .occl-crop { pointer-events: none; }
.occl-overlay:not([data-tool="crop"]) .occl-crop-label,
.occl-overlay:not([data-tool="crop"]) .occl-crop .occl-handle { pointer-events: auto; }

.occl-handle {
    position: absolute;
    width: 12px;
    height: 12px;
    background: var(--pdf-page);
    border: 2px solid var(--mask-select);
    border-radius: 2px;
    transform: translate(-50%, -50%);
}
.occl-handle::before { content: ""; position: absolute; inset: -16px; } /* Trefferfläche ≥ 44 px */
.occl-handle.nw { left: 0; top: 0; cursor: nwse-resize; }
.occl-handle.ne { left: 100%; top: 0; cursor: nesw-resize; }
.occl-handle.sw { left: 0; top: 100%; cursor: nesw-resize; }
.occl-handle.se { left: 100%; top: 100%; cursor: nwse-resize; }

@media (max-width: 60rem) {
    .occl-layout { grid-template-columns: minmax(0, 1fr); }
    .occl-panel { position: static; }
    .occl-stage { height: calc(100dvh - 16rem); }
}
@media (max-width: 40rem) {
    .occl-stage { height: 70dvh; min-height: 18rem; }
    .occl-toolbar .zoomer { margin-left: 0; }
}

/* ---------- Meldungen ---------- */

#toast {
    position: fixed;
    left: 50%;
    bottom: calc(var(--tabbar-h) + 1rem + env(safe-area-inset-bottom));
    z-index: 20;
    transform: translate(-50%, 1rem);
    max-width: min(32rem, calc(100vw - 2rem));
    background: var(--ink);
    color: var(--paper);
    padding: 0.7rem 1rem;
    border-radius: 6px;
    box-shadow: var(--shadow);
    opacity: 0;
    pointer-events: none;
    transition: opacity 160ms, transform 160ms;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast[data-kind="error"] { background: var(--again); color: #fff; }

.error-box {
    display: grid;
    gap: 1rem;
    justify-items: start;
    padding: 1rem 1.25rem;
    border-left: 3px solid var(--again);
    background: var(--sheet);
    border-radius: 6px;
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Fortschritt ---------- */

.field.inline { grid-template-columns: auto minmax(10rem, 18rem); align-items: center; gap: 0.75rem; }
@media (max-width: 40rem) { .field.inline { grid-template-columns: minmax(0, 1fr); width: 100%; } }

.stats-section { display: grid; gap: 0.75rem; }
.stats-section h2 { margin: 0; }
.stats-line { color: var(--ink-soft); font-size: var(--step--1); font-variant-numeric: tabular-nums; }

.stat-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr)); gap: 0.75rem; }
.stat-tile {
    display: grid;
    gap: 0.2rem;
    align-content: start;
    background: var(--sheet);
    border: 1px solid var(--rule);
    border-radius: 10px;
    padding: 0.9rem 1rem;
    min-width: 0;
}
.stat-label { font-size: var(--step--1); font-weight: 600; color: var(--ink-soft); }
.stat-value { font-size: var(--step-2, 1.6rem); font-weight: 650; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat-note { font-size: var(--step--1); color: var(--ink-soft); }

/* Säulendiagramm: Achse links, Säulen, Datumszeile darunter */
.bar-chart {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-rows: 9rem auto;
    gap: 0.25rem 0.5rem;
}
.bar-axis {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--ink-soft);
    text-align: right;
    font-variant-numeric: tabular-nums;
}
.bars {
    display: grid;
    grid-template-columns: repeat(var(--days), minmax(0, 1fr));
    gap: 2px;
    align-items: end;
    border-bottom: 1px solid var(--rule);
    background: repeating-linear-gradient(to top, transparent 0 calc(25% - 1px), var(--rule) calc(25% - 1px) 25%);
}
.bar { height: 100%; display: flex; align-items: flex-end; min-width: 0; }
.bar-stack {
    display: flex;
    flex-direction: column-reverse; /* erster Teil unten */
    width: 100%;
    min-height: 0;
    border-radius: 2px 2px 0 0;
    overflow: hidden;
}
.bar-stack:not(:empty) { min-height: 2px; }
.bar-part { display: block; flex-basis: 0; min-height: 1px; }
.bar-labels {
    grid-column: 2;
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--ink-soft);
}
.bar.today .bar-stack { outline: 2px solid var(--card-red); outline-offset: 1px; }

.bar-part.new, .swatch.new, .stock-part.new { background: var(--royal); }
.bar-part.review, .swatch.review, .stock-part.review { background: var(--easy); }
.bar-part.due { background: var(--good); }
.swatch.learning, .stock-part.learning { background: var(--hard); }

.chart-legend { display: flex; flex-wrap: wrap; gap: 0.35rem 1rem; margin: 0; padding: 0; list-style: none; font-size: var(--step--1); color: var(--ink-soft); }
.chart-legend li { display: inline-flex; align-items: center; gap: 0.4rem; }
.swatch { width: 0.8rem; height: 0.8rem; border-radius: 2px; }

.retention { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 1rem; }
.meter { position: relative; height: 0.75rem; border-radius: 999px; background: var(--rule); }
.meter-fill { position: absolute; inset: 0 auto 0 0; border-radius: 999px; background: var(--easy); }
.meter-target { position: absolute; top: -0.3rem; bottom: -0.3rem; width: 2px; margin-left: -1px; background: var(--card-red); }

.stock { display: flex; height: 1rem; border-radius: 999px; overflow: hidden; background: var(--rule); gap: 2px; }
.stock-part { display: block; flex-basis: 0; }

/* ---------- Prüfungstermine ---------- */

.exam-panel {
    display: grid;
    gap: 0.4rem;
    justify-items: start;
    padding: 0.8rem 1rem;
    border-left: 3px solid var(--rule);
    background: var(--sheet);
    border-radius: 6px;
    max-width: 60ch;
}
.exam-panel.soon { border-left-color: var(--card-red); }
.exam-panel.later { border-left-color: var(--royal); }
.exam-panel.past { color: var(--ink-soft); }
.exam-boost { color: var(--card-red); font-weight: 600; font-size: var(--step--1); }

label.check { display: flex; align-items: center; gap: 0.6rem; min-height: 2.75rem; font-weight: 500; font-size: var(--step-0); cursor: pointer; }
label.check input { width: 1.25rem; height: 1.25rem; margin: 0; flex: none; accent-color: var(--royal); }

.study-exam { font-weight: 500; }
.study-exam.boost { color: var(--card-red); }

/* Pause zwischen Lernschritten */
.wait-clock { font-size: var(--step-2); font-weight: 650; font-variant-numeric: tabular-nums; color: var(--royal); }
.done.wait:focus { outline: none; }

/* ---------- KI-Kartenvorschläge ---------- */

.pdf-toolbar .button[hidden], .suggest-results[hidden], .suggest-footer[hidden], .suggest-panel [hidden] { display: none; }
.suggest-check, .suggest-take { display: flex; align-items: center; gap: 0.6rem; min-height: 44px; font-weight: 600; cursor: pointer; }
.suggest-check input, .suggest-take input { width: 1.35rem; height: 1.35rem; flex: none; accent-color: var(--royal); }
.suggest-list { counter-reset: none; }
.suggest-item { align-items: start; }
.suggest-fields { gap: 0.5rem; }
.suggest-fields textarea { min-height: 3.2rem; }
.suggest-fields textarea + textarea { font-family: var(--sans); font-size: var(--step-0); }
.suggest-item.skipped { opacity: 0.55; border-left-color: var(--rule); }
.suggest-footer { position: sticky; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding: 0.75rem 0; background: var(--paper); }
.card-source { font-size: var(--step--1); color: var(--royal); justify-self: start; }

/* Listenerkennung (Vokabeln, Tabellen): eine Zeile pro Paar, unsichere Paare markiert. */
.vocab-item { grid-template-columns: auto 1fr auto; gap: 0.75rem; align-items: center; padding-block: 0.4rem; }
.vocab-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; min-width: 0; }
.vocab-input { min-height: 44px; min-width: 0; width: 100%; font-family: var(--serif); }
.vocab-item.uncertain { border-left-color: var(--card-red); background: color-mix(in srgb, var(--card-red) 6%, var(--sheet)); }
.vocab-item.uncertain .vocab-input { border-color: var(--card-red); }
.suggest-results [hidden] { display: none; }
@media (max-width: 40rem) {
    .vocab-item { grid-template-columns: auto 1fr; }
    .vocab-fields { grid-template-columns: 1fr; }
    .vocab-item .chip { grid-column: 2; justify-self: start; }
}
body.focus #toast { bottom: calc(1.25rem + env(safe-area-inset-bottom)); }
dialog #toast { top: calc(1rem + env(safe-area-inset-top)); bottom: auto; }

/* ---------- Fächer ---------- */

.fc-green { --fc: var(--fc-green); }
.fc-blue { --fc: var(--fc-blue); }
.fc-orange { --fc: var(--fc-orange); }
.fc-violet { --fc: var(--fc-violet); }
.fc-teal { --fc: var(--fc-teal); }
.fc-amber { --fc: var(--fc-amber); }
.fc-rose { --fc: var(--fc-rose); }
.fc-slate { --fc: var(--fc-slate); }
.fc-none { --fc: var(--fc-none); }

/* Übersicht als Registerkarten: Lasche mit Kürzel in Fachfarbe. */
.subject-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: 1.5rem 1rem; }
.subject-card {
    position: relative;
    display: grid;
    align-content: start;
    gap: 0.4rem;
    margin-top: 1rem;
    padding: 1rem 1.1rem 1.1rem;
    min-height: 7rem;
    background: var(--sheet);
    border-top: 3px solid var(--fc, var(--fc-none));
    border-radius: 0 14px 14px 14px;
    box-shadow: var(--shadow);
    color: inherit;
    text-decoration: none;
}
.subject-card:hover { outline: 2px solid var(--fc, var(--fc-none)); }
.subject-tab {
    position: absolute;
    left: 0;
    bottom: 100%;               /* sitzt auf der farbigen Oberkante */
    padding: 0.15rem 0.7rem;
    border-radius: 6px 6px 0 0;
    background: var(--fc, var(--fc-none));
    color: var(--fc-tab-ink);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    line-height: 1.2;
}
.subject-card-title { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.subject-card-title h2 { font-size: var(--step-1); overflow-wrap: anywhere; }
.subject-card .item-sub { line-height: 1.4; }

.subject-head { border-top: 6px solid var(--fc, var(--fc-none)); padding-top: 0.9rem; }
.subject-cols { display: grid; gap: 1.75rem; align-items: start; }
@media (min-width: 62rem) { .subject-cols { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); } }
.subject-cols > div { display: grid; gap: 1.75rem; }

/* Auswahl als Knöpfe (Fach, Farbe, Art, Wunschniveau) – Touch-Ziele ≥ 44 px. */
.choices { display: flex; flex-wrap: wrap; gap: 0.5rem; border: 0; margin: 0; padding: 0; }
.choice {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 2.75rem;
    padding: 0 1rem;
    font: inherit;
    color: var(--ink);
    background: var(--sheet);
    border: 1px solid var(--rule);
    border-radius: 999px;
    cursor: pointer;
}
.choice:hover { border-color: var(--ink-soft); }
.choice[aria-pressed="true"] {
    border-color: var(--fc, var(--royal));
    background: color-mix(in srgb, var(--fc, var(--royal)) 14%, var(--sheet));
    font-weight: 650;
}
.choice small { color: var(--ink-soft); font-weight: 500; }
.color-choice { width: 2.75rem; height: 2.75rem; padding: 0; justify-content: center; background: var(--fc); border-color: transparent; }
.color-choice[aria-pressed="true"] { background: var(--fc); outline: 3px solid var(--ink); outline-offset: 2px; }
.color-choice:hover { border-color: transparent; filter: brightness(1.08); }

.topic-checks { display: grid; gap: 0.1rem; }

/* Zuordnen-Dialog: je Zeile ein Thema/Dokument und seine Fach-Auswahl. */
.assign-list { display: grid; gap: 0.75rem; }
.assign-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(9rem, 14rem); gap: 0.4rem 0.75rem; align-items: center; }
.assign-row > label { display: flex; align-items: center; gap: 0.5rem; overflow-wrap: anywhere; font-weight: 500; font-size: var(--step-0); }
@media (max-width: 30rem) { .assign-row { grid-template-columns: minmax(0, 1fr); } }
.field > .label { font-weight: 600; font-size: var(--step--1); }
.subject-tag { display: inline-flex; align-items: center; gap: 0.4rem; font-weight: 650; color: var(--fc, var(--ink)); }
h3 { margin: 0; font-size: var(--step-0); font-weight: 650; }
button.item-main { font: inherit; text-align: left; background: none; border: 0; cursor: pointer; }
button.item-main:hover .item-title { color: var(--royal); }
.item-title .dot { display: inline-block; vertical-align: 0.05em; }
.stack-tight { display: grid; gap: 0.2rem; }
.past-exams { display: grid; gap: 0.6rem; }
.past-exams summary { cursor: pointer; color: var(--ink-soft); font-weight: 600; min-height: 2.75rem; display: flex; align-items: center; }

/* ---------- Prüfungen planen (Schritt 18) ---------- */

.visually-hidden {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.row-between { display: flex; justify-content: space-between; align-items: baseline; gap: 0.75rem; }
.num { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--ink-soft); white-space: nowrap; }

/* Monatskalender */
.calendar { display: grid; gap: 0.5rem; }
.cal-head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.cal-title { text-align: center; }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal-wd { text-align: center; font-size: 0.75rem; font-weight: 600; color: var(--ink-soft); padding: 0.2rem 0; }
.cal-day {
    min-height: 2.9rem;
    display: grid; place-items: center; align-content: center; gap: 3px;
    border: 0; border-radius: 10px;
    background: var(--paper); color: var(--ink);
    font: inherit; font-weight: 600; font-variant-numeric: tabular-nums;
    text-decoration: none;
}
button.cal-day { cursor: pointer; }
button.cal-day:hover:not(:disabled) { outline: 2px solid var(--rule); }
.cal-day.past { color: var(--ink-soft); opacity: 0.55; }
.cal-day.today { outline: 2px solid var(--card-red); outline-offset: -2px; }
.cal-day[aria-pressed="true"] { background: var(--royal); color: var(--royal-ink); }
.cal-marks { display: flex; gap: 3px; height: 0.5rem; }
.cal-marks .dot { width: 0.5rem; height: 0.5rem; }
.cal.large .cal-day { min-height: 4.6rem; align-content: start; justify-items: stretch; place-items: start stretch; padding: 0.35rem; font-size: 0.9rem; }
.cal.large .cal-num { padding-left: 0.1rem; }
.cal-ev {
    display: block; padding: 1px 4px; border-radius: 4px;
    font-size: 0.68rem; font-weight: 700; color: var(--fc-tab-ink); background: var(--fc);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
a.cal-day.has-ev:hover { outline: 2px solid var(--fc-none); }
@media (max-width: 30rem) {
    .cal.large .cal-day { min-height: 3.4rem; }
    .cal.large .cal-ev { font-size: 0; height: 0.45rem; padding: 0; }
}

/* Assistent */
.wizard-page { display: grid; gap: 1.25rem; max-width: 46rem; width: 100%; margin: 0 auto; }
.wizard { display: grid; gap: 1rem; }
.wizard-steps { list-style: none; margin: 0; padding: 0; display: flex; gap: 6px; }
.wizard-steps li { flex: 1; height: 6px; border-radius: 3px; background: var(--rule); }
.wizard-steps li.on { background: var(--royal); }
.wizard-nav { display: flex; justify-content: space-between; gap: 0.75rem; }
label.check-row { display: flex; align-items: center; gap: 0.75rem; cursor: pointer; }
label.check-row input { width: 1.35rem; height: 1.35rem; margin: 0; flex: none; accent-color: var(--royal); }

/* Wunschniveau */
.goal-stops { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.5rem; }
@media (max-width: 34rem) { .goal-stops { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.goal-stop {
    min-height: 5.25rem; display: grid; place-content: center; gap: 2px; padding: 0.5rem;
    border-radius: 14px; border: 1.5px solid var(--rule); background: var(--sheet);
    font: inherit; color: var(--ink); text-align: center; cursor: pointer;
}
.goal-stop small { font-size: 0.78rem; color: var(--ink-soft); font-weight: 500; }
.goal-stop[aria-pressed="true"] { border-color: var(--royal); background: color-mix(in srgb, var(--royal) 10%, var(--sheet)); }
.goal-panel { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }

/* Plan als Balken: neue Karten unten (Tintenblau), Wiederholungen darüber (Fachfarbe). */
.plan-figure { margin: 0; display: grid; gap: 0.6rem; }
.plan-chart { display: flex; align-items: stretch; gap: 3px; height: 10rem; }
.plan-chart.long { gap: 1px; }
.plan-day { flex: 1; min-width: 0; display: grid; grid-template-rows: minmax(0, 1fr) 1.1rem; gap: 4px; position: relative; }
.plan-bar { display: flex; flex-direction: column-reverse; justify-content: flex-start; gap: 1px; min-height: 0; }
.plan-bar i { display: block; border-radius: 2px; min-height: 0; }
.plan-bar .bar-new { background: var(--royal); }
.plan-bar .bar-rev { background: color-mix(in srgb, var(--fc, var(--fc-none)) 60%, transparent); }
.plan-lab { font-size: 0.68rem; text-align: center; color: var(--ink-soft); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; }
/* Lange Pläne: Beschriftung nur montags, links am Balken ausgerichtet, ohne die Spalte zu verbreitern. */
.plan-chart.long .plan-lab { position: absolute; left: 0; bottom: 0; overflow: visible; text-align: left; }
@media (max-width: 40rem) { .plan-chart.long .plan-lab.alt { display: none; } }
.plan-day.buffer .plan-lab { color: var(--easy); font-weight: 700; }
.plan-day.buffer .plan-bar { background: color-mix(in srgb, var(--easy) 14%, transparent); border-radius: 2px; }
.plan-day.today .plan-lab { color: var(--card-red); font-weight: 700; }
.legend { display: flex; flex-wrap: wrap; gap: 1rem; font-size: 0.8rem; color: var(--ink-soft); }
.legend span { display: inline-flex; align-items: center; gap: 0.35rem; }
.legend i { width: 0.75rem; height: 0.75rem; border-radius: 3px; display: inline-block; }
.legend .lg-new { background: var(--royal); }
.legend .lg-rev { background: color-mix(in srgb, var(--fc, var(--fc-none)) 60%, transparent); }
.legend .lg-buffer { color: var(--easy); font-weight: 700; }

.timeline { margin: 0; display: grid; background: var(--sheet); border-radius: 14px; box-shadow: var(--shadow); padding: 0.25rem 1.25rem; }
.timeline > div { display: grid; grid-template-columns: 6rem minmax(0, 1fr); gap: 0.75rem; padding: 0.65rem 0; }
.timeline > div + div { border-top: 1px solid var(--rule); }
.timeline dt { font-weight: 650; font-size: var(--step--1); }
.timeline dd { margin: 0; }

/* Prüfungsseite */
.exam-days.big { font-size: 2.6rem; min-width: 4.5rem; }
.exam-days.big.later { color: var(--fc, var(--royal)); }
.cover-doc { display: grid; gap: 0.4rem; }
.cover-title { display: inline-flex; align-items: center; gap: 0.4rem; font-weight: 600; color: var(--ink); text-decoration: none; min-height: 2.75rem; }
.cover-title:hover { color: var(--royal); }
.cover { display: flex; flex-wrap: wrap; gap: 4px; }
.cover-page { display: block; width: 1.4rem; height: 1.8rem; border-radius: 3px; border: 1.5px dashed var(--ink-soft); background: transparent; }
a.cover-page:hover { border-color: var(--royal); background: color-mix(in srgb, var(--royal) 12%, transparent); }
.cover-page.on { border: 0; background: var(--fc, var(--easy)); }
@media (pointer: coarse) { .cover { gap: 6px; } .cover-page { width: 2rem; height: 2.75rem; } }

/* ---------- Anmeldung (Schritt 11) ---------- */

main.login { min-height: 100dvh; align-content: center; justify-items: center; position: relative; z-index: 1; touch-action: none; }
body:has(main.login) { background: var(--study-bg); overflow: hidden; }
/* Hintergrund: treibende Karteikarten (login-bg.js) */
.login-bg { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; }

.login-stage { position: relative; width: min(26rem, 100%); touch-action: manipulation; }
.login-mover { transition: transform 700ms cubic-bezier(.5, -0.2, .3, 1.2), opacity 500ms ease; }
.login-flip { display: grid; transform-style: preserve-3d; transition: transform 700ms cubic-bezier(.4, 0, .2, 1); }
.login-face {
    grid-area: 1 / 1; max-width: none; min-height: 0;
    -webkit-backface-visibility: hidden; backface-visibility: hidden;
}
.login-card { position: relative; display: grid; gap: var(--line); }
.login-back { transform: rotateY(180deg); display: grid; align-content: start; }
.login-title { display: flex; align-items: center; gap: 0.6rem; font-family: var(--serif); font-size: var(--step-2); line-height: var(--line); }
.login-title .ico { color: var(--card-red); }
.login-card .hint { margin: 0; line-height: var(--line); }
.login-form { display: grid; gap: 1rem; }
.login-error { margin: 0; min-height: 1.4em; color: var(--again); font-weight: 600; }
.login-error:empty { min-height: 0; }

/* Rückseite nach erfolgreicher Anmeldung */
.login-welcome { font-family: var(--serif); font-size: var(--step-2); font-weight: 600; line-height: calc(var(--line) * 2); }
.login-due { font-family: var(--serif); font-size: var(--step-1); line-height: var(--line); color: var(--ink-soft); opacity: 0; transition: opacity 400ms ease; }
.login-due.show { opacity: 1; }
.login-stage.flipped .login-flip { transform: rotateY(180deg); }
.login-stage.leave .login-mover { transform: translateY(-115vh) rotate(-10deg); opacity: 0; transition: transform 550ms cubic-bezier(.6, 0, .9, .4), opacity 550ms ease-in; }

/* Falsches Passwort: Wackeln und Stempel „Nochmal“ */
.login-flip.shake { animation: login-shake 420ms ease; }
@keyframes login-shake {
    20% { transform: translateX(-10px) rotate(-1.5deg); }
    40% { transform: translateX(9px) rotate(1.2deg); }
    60% { transform: translateX(-6px) rotate(-0.6deg); }
    80% { transform: translateX(3px); }
}
.login-stamp {
    position: absolute; top: 1.1rem; right: 1.2rem; pointer-events: none;
    padding: 0.15rem 0.7rem; border: 3px solid var(--again); border-radius: 6px;
    color: var(--again); font-weight: 800; font-size: var(--step-1); letter-spacing: 0.08em; text-transform: uppercase;
    opacity: 0; transform: rotate(-12deg);
}
.login-stamp.show { animation: login-stamp 1900ms ease forwards; }
@keyframes login-stamp {
    0% { opacity: 0; transform: rotate(-12deg) scale(1.9); }
    12% { opacity: 0.9; transform: rotate(-12deg) scale(0.95); }
    18% { transform: rotate(-12deg) scale(1); }
    75% { opacity: 0.9; }
    100% { opacity: 0; transform: rotate(-12deg) scale(1); }
}

/* Sperre: Die Karte rutscht in den Karteikasten. */
.login-box {
    position: absolute; left: -1.25rem; right: -1.25rem; top: 50%; height: calc(76% + 1rem);
    display: grid; place-items: center; z-index: 2;
    background: linear-gradient(to bottom, color-mix(in srgb, var(--box) 82%, white) 0 6px, var(--box) 6px);
    border-radius: 6px 6px 12px 12px; box-shadow: var(--shadow);
    opacity: 0; transform: translateY(40%); pointer-events: none;
    transition: transform 500ms cubic-bezier(.3, 1.3, .5, 1), opacity 300ms ease;
}
.login-box-label {
    display: grid; gap: 0.15rem; text-align: center; padding: 0.5rem 1.1rem; border-radius: 3px;
    background: var(--sheet); color: var(--ink); box-shadow: inset 0 0 0 1px var(--rule);
}
.login-box-title { font-family: var(--serif); font-weight: 600; font-size: var(--step-1); }
.login-box-time { color: var(--ink-soft); font-size: var(--step--1); }
.login-stage.locked .login-box { opacity: 1; transform: none; pointer-events: auto; transition-delay: 0s; }
.login-stage.locked .login-mover { transform: translateY(22%) scale(0.94); transition-delay: 120ms; }
.login-stage.locked .login-error { visibility: hidden; }

@media (prefers-reduced-motion: reduce) {
    .login-mover, .login-flip, .login-box, .login-due { transition-duration: 1ms !important; }
    .login-flip.shake { animation: none; }
    .login-stamp.show { animation: login-stamp-still 1900ms steps(1) forwards; }
    @keyframes login-stamp-still { 0% { opacity: 0.9; } 100% { opacity: 0; } }
    .login-stage.leave .login-mover { transform: none; transition: opacity 300ms ease !important; }
}
.logout-row { display: flex; justify-content: flex-end; }
