/*
 * The website («Heft»): paper and ink with the material on a teacher's desk:
 * highlighters, sticky notes, a binder's register tabs, tape and a paper
 * clip, and a few words by hand. Only var() tokens from tokens.css (linked
 * before this file, which declares the cascade layers). The motion is all in
 * one block at the end of the pages layer.
 */

@layer reset {
    *, *::before, *::after { box-sizing: border-box; }
    body, h1, h2, h3, h4, p, ol, ul, dl, dd, figure { margin: 0; }
    ol, ul { padding: 0; list-style: none; }
    img, svg { display: block; max-width: 100%; }
    img { height: auto; }
    table { border-collapse: collapse; }
}

@layer base {
    html { font-size: var(--root-size); -webkit-text-size-adjust: 100%; }
    /* A column, so the footer of a short page (404, Impressum) sits at the
       bottom of the window. */
    body {
        display: flex;
        flex-direction: column;
        min-height: 100dvh;
        background: var(--bg);
        color: var(--text);
        font-family: var(--font-body);
        font-size: var(--text-base);
        line-height: var(--leading-normal);
    }
    h1, h2, h3, h4 {
        color: var(--text-heading);
        font-family: var(--font-head);
        font-weight: var(--weight-bold);
        line-height: var(--leading-tight);
        letter-spacing: var(--tracking-tight);
        text-wrap: balance;
    }
    h1 { font-size: var(--text-hero); }
    h2 { font-size: var(--text-h2); }
    h3, h4 { font-size: var(--text-h3); font-weight: var(--weight-semibold); }
    p { text-wrap: pretty; }
    a {
        color: var(--primary);
        text-decoration-thickness: var(--border-width);
        text-underline-offset: var(--underline-offset);
    }
    a:hover { color: var(--primary-hover); text-decoration-thickness: var(--underline-hover); }
    :focus-visible {
        outline: var(--focus-width) solid var(--focus-ring);
        outline-offset: var(--focus-offset);
    }
    ::selection { background: var(--selection); }
    small { font-size: var(--text-xs); }
}

@layer layout {
    .wrap {
        width: 100%;
        max-width: var(--page-max);
        margin-inline: auto;
        padding-inline: var(--gutter);
    }

    /* ---------- Header: wordmark, the three register tabs, the app ---------- */
    .site-head {
        border-bottom: var(--tab-rule) solid var(--text-heading);
        background: var(--bg);
    }
    .site-head-inner {
        display: flex;
        flex-wrap: wrap;
        align-items: flex-end;
        gap: var(--space-2) var(--space-6);
        padding-top: var(--space-3);
    }
    .site-head-inner > .wordmark, .head-tools { margin-bottom: var(--space-3); }
    /* The theme button and «Zur App» wrap together. */
    .head-tools { display: flex; gap: var(--space-2); }
    .site-nav { display: flex; gap: var(--space-1); margin-left: auto; }

    /* ---------- Sections: each one a divider with its register tab ---------- */
    /* The bottom padding leaves room for the next section's tab. */
    .section {
        position: relative;
        padding-block: var(--section-pad) calc(var(--section-pad) + var(--space-6));
        border-top: var(--tab-rule) solid var(--register, var(--border));
        scroll-margin-top: var(--scroll-offset);
    }
    .section-title { max-width: var(--measure); margin-bottom: var(--space-7); }

    /* Text beside a photo; one column until 64rem. */
    .split, .split-head { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-8); }
    .split-head { gap: var(--space-2) var(--space-8); }

    /* ---------- Footer ---------- */
    .site-foot { padding-block: var(--space-7); border-top: var(--tab-rule) solid var(--text-heading); background: var(--nav-bg); }
    .site-foot-inner {
        display: flex;
        flex-wrap: wrap;
        align-items: baseline;
        gap: var(--space-3) var(--space-7);
        color: var(--text-muted);
        font-size: var(--text-sm);
    }
    /* Links a finger can hit (44px under pointer: coarse). */
    .site-foot a { display: inline-flex; align-items: center; min-height: var(--target-min); }
    .foot-nav { display: flex; gap: var(--space-5); margin-left: auto; }

    @media (max-width: 39.99rem) {
        /* Wordmark, theme button and «Zur App» share a row from 390 px. */
        .site-head-inner { column-gap: var(--space-3); }
        .site-head-inner > .wordmark { margin-right: auto; }
        .site-nav {
            display: grid;
            grid-template-columns: repeat(3, minmax(0, 1fr));
            order: 3;
            width: 100%;
            margin-left: 0;
        }
        .foot-nav { margin-left: 0; }
    }
    @media (min-width: 40rem) {
        /* The tabs stay in reach while reading; on a phone the page keeps
         * its height. */
        .site-head { position: sticky; top: 0; z-index: var(--z-sticky); }
    }
    @media (min-width: 64rem) {
        .split { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: var(--space-9); }
        .split-even { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
        .split-head { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); }
    }
}

@layer components {
    /* ---------- Wordmark ---------- */
    .wordmark {
        display: inline-flex;
        align-items: center;
        gap: var(--space-2);
        color: var(--text-heading);
        font-family: var(--font-head);
        font-size: var(--text-lg);
        font-weight: var(--weight-bold);
        letter-spacing: var(--tracking-tight);
        text-decoration: none;
    }
    .wordmark:hover { color: var(--text-heading); }
    .wordmark-mark { width: var(--mark-size); height: var(--mark-size); }
    .wordmark-rule { stroke: var(--primary); }
    .wordmark-margin { stroke: var(--accent); }

    /* ---------- Buttons and links ---------- */
    .button, .outline {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: var(--space-2);
        min-height: max(var(--control-h), var(--target-min));
        padding: var(--control-pad-y) var(--space-5);
        border: var(--border-width) solid var(--primary-fill);
        border-radius: var(--radius-md);
        background: var(--primary-fill);
        color: var(--on-primary);
        font-size: var(--text-base);
        font-weight: var(--weight-bold);
        line-height: var(--leading-tight);
        text-decoration: none;
    }
    .button:hover { border-color: var(--primary-fill-hover); background: var(--primary-fill-hover); color: var(--on-primary); }
    .outline {
        padding-inline: var(--control-pad-x);
        border-color: var(--border-strong);
        background: var(--surface);
        color: var(--primary);
        font-size: var(--text-sm);
    }
    .outline:hover { border-color: var(--primary); color: var(--primary-hover); }
    /* The theme button (theme.js): a square .outline with the moon while
     * the page is light and the sun while it is dark. */
    .theme-toggle {
        min-width: max(var(--control-h), var(--target-min));
        padding-inline: 0;
        cursor: pointer;
    }
    .theme-toggle:not(.is-dark) .icon-sun, .theme-toggle.is-dark .icon-moon { display: none; }
    /* Its underline is a background, so that it can grow from the left. */
    .arrow-link {
        display: inline-flex;
        align-items: center;
        gap: var(--space-1);
        background: linear-gradient(currentColor, currentColor) 0 100% / 0% var(--underline-hover) no-repeat;
        font-weight: var(--weight-bold);
        text-decoration: none;
    }
    .arrow-link:hover { background-size: 100% var(--underline-hover); }
    .icon { flex: none; width: var(--icon-size); height: var(--icon-size); }
    .actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3) var(--space-6); }

    .skip-link {
        position: absolute;
        top: var(--space-2);
        left: var(--space-4);
        z-index: var(--z-skip);
        padding: var(--space-2) var(--space-4);
        border-radius: var(--radius-md);
        background: var(--primary-fill);
        color: var(--on-primary);
    }
    .skip-link:not(:focus) {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip-path: inset(50%);
        white-space: nowrap;
    }

    /* ---------- Register tabs: a binder's coloured dividers ---------- */
    .reg-tab {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-width: var(--tab-min);
        padding: var(--space-2) var(--space-4);
        border-radius: var(--radius-tab);
        background: var(--register);
        color: var(--on-marker);
        font-size: var(--text-sm);
        font-weight: var(--weight-bold);
        line-height: var(--leading-tight);
        text-decoration: none;
        white-space: nowrap;
    }
    a.reg-tab { min-height: var(--target-min); }
    a.reg-tab:hover { color: var(--on-marker); text-decoration: underline; }
    /* Above each section's top edge; each register one step further right. */
    .section-tab {
        position: absolute;
        bottom: calc(100% + var(--tab-rule));
        left: calc(max(0px, (100% - var(--page-max)) / 2) + var(--gutter) + var(--tab-step) * var(--tab-index, 0));
    }

    /* ---------- Highlighter ---------- */
    /* A stroke behind the lower part of the words, in the register's colour
     * unless a .hl-* class picks one. */
    .hl {
        --hl: var(--register, var(--marker-yellow));
        --hl-stroke: linear-gradient(transparent var(--marker-top), var(--hl) var(--marker-top),
            var(--hl) var(--marker-bottom), transparent var(--marker-bottom));
        margin-inline: calc(var(--marker-pad) * -1);
        padding-inline: var(--marker-pad);
        border-radius: var(--radius-marker);
        background: var(--hl-stroke);
        color: var(--hl-text);
        -webkit-box-decoration-break: clone;
        box-decoration-break: clone;
    }
    /* A state, fully marked, as the app's chips: «Jetzt», «vorbereitet»,
     * due, absent. */
    .state {
        display: inline-block;
        padding: 0 var(--space-2);
        border-radius: var(--radius-marker);
        background: var(--hl, var(--marker-yellow));
        color: var(--on-marker);
        font-size: var(--text-2xs);
        font-weight: var(--weight-bold);
        line-height: var(--leading-normal);
        white-space: nowrap;
    }

    /* ---------- Sticky notes: turned a little, written by hand ---------- */
    .note {
        width: fit-content;
        max-width: var(--note-width);
        padding: var(--space-4) var(--space-5) var(--space-5);
        border-radius: var(--radius-note);
        background: var(--note-bg);
        color: var(--note-text);
        box-shadow: var(--note-shadow);
        font-family: var(--font-hand);
        font-size: var(--text-hand);
        font-weight: var(--weight-medium);
        line-height: var(--leading-snug);
        rotate: var(--tilt-note);
    }
    .note b { display: block; font-size: var(--text-hand-lg); font-weight: var(--weight-bold); }

    /* Handwriting: margin notes and the «Vorher» lines only. */
    .hand {
        font-family: var(--font-hand);
        font-size: var(--text-hand);
        font-weight: var(--weight-medium);
        line-height: var(--leading-snug);
    }

    /* ---------- Photos as prints: tape or a paper clip ---------- */
    .print {
        position: relative;
        padding: var(--photo-mat);
        background: var(--photo-frame);
        box-shadow: var(--photo-shadow);
        rotate: var(--tilt-photo);
    }
    .print-alt { rotate: var(--tilt-photo-alt); }
    .photo {
        width: 100%;
        filter: var(--photo-filter);
        object-fit: cover;
    }
    .print-tape::before, .print-tape::after {
        content: "";
        position: absolute;
        top: calc(var(--tape-h) / -2);
        z-index: var(--z-raised);
        width: var(--tape-w);
        height: var(--tape-h);
        background: var(--tape);
        clip-path: var(--tape-shape);
    }
    .print-tape::before { left: var(--space-5); rotate: var(--tilt-tape); }
    .print-tape::after { right: var(--space-5); rotate: var(--tilt-tape-alt); }
    .clip {
        position: absolute;
        top: calc(var(--clip-h) / -4);
        left: var(--space-7);
        z-index: var(--z-raised);
        width: var(--clip-w);
        height: var(--clip-h);
        color: var(--clip-metal);
    }

    /* ---------- Index cards ---------- */
    /* The red line under the title, light blue ruling under the text. */
    .cards { display: grid; gap: var(--space-4); }
    .card {
        padding: var(--space-5) var(--space-5) var(--space-6);
        border: var(--border-width) solid var(--border);
        border-radius: var(--radius-sm);
        background: var(--surface);
    }
    .card :is(h3, h4) {
        margin-bottom: var(--space-3);
        padding-bottom: var(--space-2);
        border-bottom: var(--margin-width) solid var(--margin-line);
    }
    .card p:last-child {
        background-image: repeating-linear-gradient(180deg,
            transparent 0,
            transparent calc(1lh - var(--border-width)),
            var(--card-rule) calc(1lh - var(--border-width)),
            var(--card-rule) 1lh);
    }
    .kicker {
        margin-bottom: var(--space-2);
        color: var(--accent-text);
        font-size: var(--text-xs);
        font-weight: var(--weight-bold);
        letter-spacing: var(--tracking-caps);
        text-transform: uppercase;
    }
    @media (min-width: 40rem) {
        .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    }

    /* A sheet from an exercise book: the red margin line on the left, the
     * text to its right, step numbers in the margin. */
    .sheet {
        --sheet-margin: var(--space-8);
        padding: var(--space-7) var(--space-6) var(--space-7) calc(var(--sheet-margin) + var(--space-5));
        border: var(--border-width) solid var(--border);
        border-radius: var(--radius-sm);
        background-color: var(--surface);
        background-image: linear-gradient(90deg,
            transparent calc(var(--sheet-margin) - var(--margin-width)),
            var(--margin-line) calc(var(--sheet-margin) - var(--margin-width)),
            var(--margin-line) var(--sheet-margin),
            transparent var(--sheet-margin));
    }
    .sheet > * + * { margin-top: var(--space-4); }
    .sheet .section-title { margin-bottom: var(--space-5); }
    .sheet h3 { margin-top: var(--space-7); }
    @media (max-width: 39.99rem) {
        .sheet { --sheet-margin: var(--space-7); padding-right: var(--space-5); }
    }

    /* Subject markers: the colour comes from a .subject-n class. */
    .tile, .agenda-item { --subject: var(--border-strong); }
}

@layer pages {
    /* ---------- 2 Hero: ruled paper with a red margin line ---------- */
    .hero {
        /* Where the text starts, less a little: the margin line. */
        --margin-pos: calc(max(0px, (100% - var(--page-max)) / 2) + var(--gutter) - var(--space-4));
        --hero-margin: linear-gradient(90deg,
            transparent var(--margin-pos),
            var(--margin-line) var(--margin-pos),
            var(--margin-line) calc(var(--margin-pos) + var(--margin-width)),
            transparent calc(var(--margin-pos) + var(--margin-width)));
        padding-block: var(--space-9) calc(var(--section-pad) + var(--space-6));
        background-color: var(--bg);
        background-image:
            var(--hero-margin),
            repeating-linear-gradient(180deg,
                transparent 0,
                transparent calc(var(--rule-gap) - var(--border-width)),
                var(--rule-line) calc(var(--rule-gap) - var(--border-width)),
                var(--rule-line) var(--rule-gap));
    }
    .hero-top { display: grid; gap: var(--space-7); align-items: start; margin-bottom: var(--space-9); }
    .hero-text { max-width: var(--hero-text-max); }
    .hero h1 { margin-bottom: var(--space-6); }
    /* The marked phrase stays on one line (WebKit's balance split it). */
    @media (min-width: 40rem) {
        .hero h1 .hl { white-space: nowrap; }
    }
    .lead { max-width: var(--measure); margin-bottom: var(--space-7); font-size: var(--text-md); }
    .hero-note { rotate: var(--tilt-note-alt); }

    /* Laptop and phone side by side, the phone overlapping a little. */
    .devices { display: flex; align-items: flex-end; padding-bottom: var(--space-6); }
    .laptop { flex: 1 1 auto; min-width: 0; padding-inline: var(--space-5); }
    .laptop-screen {
        container-type: inline-size;
        overflow: hidden;
        border: var(--bezel) solid var(--device-frame);
        border-bottom-width: var(--space-3);
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
        background: var(--bg);
    }
    .laptop-base {
        height: var(--space-3);
        margin-inline: calc(var(--space-5) * -1);
        border-radius: 0 0 var(--radius-lg) var(--radius-lg);
        background: var(--device-base);
    }
    .phone {
        container-type: inline-size;
        display: flex;
        flex: none;
        flex-direction: column;
        width: var(--phone-width);
        margin-left: calc(var(--space-8) * -1);
        margin-bottom: calc(var(--space-6) * -1);
        overflow: hidden;
        border: var(--bezel) solid var(--device-frame);
        border-radius: var(--radius-phone);
        background: var(--bg);
        /* A ring of canvas cuts the phone out of the laptop: flat, no shadow. */
        box-shadow: 0 0 0 var(--space-1) var(--bg);
        font-size: var(--text-xs);
        line-height: var(--leading-snug);
    }

    /* The app inside the laptop, as templates/_nav.html and today.html draw
     * it: the sidebar, «Heute» with one agenda and the panel beside it.
     * Narrow screens drop the sidebar first, then the panel. */
    .app {
        display: grid;
        grid-template-columns: var(--replica-nav) minmax(0, 1fr);
        font-size: var(--text-xs);
        line-height: var(--leading-snug);
    }
    .app-nav {
        display: flex;
        flex-direction: column;
        gap: var(--space-0);
        padding: var(--space-3) var(--space-2);
        border-right: var(--border-width) solid var(--border);
        background: var(--nav-bg);
    }
    .app-brand {
        color: var(--text-heading);
        font-family: var(--font-head);
        font-size: var(--text-sm);
        font-weight: var(--weight-bold);
    }
    .app-nav .app-brand { padding: 0 var(--space-2) var(--space-3); }
    .app-nav-item { padding: var(--space-1) var(--space-2); border-radius: var(--radius-sm); color: var(--text-quiet); }
    .nav-current {
        background: var(--nav-current-bg);
        color: var(--nav-current-text);
        font-weight: var(--weight-bold);
        box-shadow: inset var(--border-thick) 0 0 var(--nav-current-edge);
    }
    .app-nav-group {
        margin-top: var(--space-3);
        padding: 0 var(--space-2) var(--space-1);
        color: var(--text-muted);
        font-size: var(--text-2xs);
        font-weight: var(--weight-semibold);
        letter-spacing: var(--tracking-caps);
        text-transform: uppercase;
    }
    /* Einrichtung at the foot of the sidebar. */
    .app-nav-end { margin-top: auto; padding-top: var(--space-6); }
    .app-main { display: flex; flex-direction: column; gap: var(--space-3); min-width: 0; padding: var(--space-4) var(--space-5) var(--space-5); }
    .app-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; }
    .app-eyebrow { grid-column: 1; color: var(--text-muted); font-size: var(--text-2xs); }
    .app-head .app-outline { grid-row: 1 / span 2; grid-column: 2; }
    .app-title {
        color: var(--text-heading);
        font-family: var(--font-head);
        font-size: var(--text-xl);
        font-weight: var(--weight-bold);
        line-height: var(--leading-tight);
    }
    .app-h2 { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); color: var(--text-heading); font-size: var(--text-sm); font-weight: var(--weight-bold); }
    /* The app's buttons, drawn small. */
    .app-outline, .app-button {
        display: inline-block;
        width: fit-content;
        padding: var(--space-0) var(--space-2);
        border: var(--border-width) solid var(--border-strong);
        border-radius: var(--radius-md);
        background: var(--surface);
        color: var(--text-heading);
        font-size: var(--text-2xs);
        font-weight: var(--weight-semibold);
        white-space: nowrap;
    }
    .app-button { border-color: var(--primary-fill); background: var(--primary-fill); color: var(--on-primary); }
    /* A text field with its text in it (the day and week notes). */
    .app-field {
        display: block;
        padding: var(--space-1) var(--space-2);
        border: var(--border-width) solid var(--border-strong);
        border-radius: var(--radius-sm);
        background: var(--surface);
        color: var(--text);
    }
    .today { display: grid; grid-template-columns: minmax(0, 1fr) var(--replica-side); gap: var(--space-5); align-items: start; }
    .today-lessons { display: flex; flex-direction: column; gap: var(--space-2); min-width: 0; }

    /* The agenda: the time, then the lesson's card with the subject's edge;
     * «Jetzt» ringed in ink, an unprepared lesson dashed. */
    .agenda { display: grid; gap: var(--space-2); }
    .agenda-item { display: grid; grid-template-columns: var(--replica-time) minmax(0, 1fr); gap: var(--space-2); }
    .agenda-time { display: grid; align-content: start; padding-top: var(--space-2); font-variant-numeric: tabular-nums lining-nums; }
    .agenda-time b { color: var(--text-heading); }
    .agenda-time small { color: var(--text-muted); font-size: var(--text-2xs); }
    .agenda-card {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        justify-content: space-between;
        gap: var(--space-1) var(--space-3);
        min-width: 0;
        padding: var(--space-2) var(--space-3);
        border: var(--border-width) solid color-mix(in srgb, var(--subject) var(--tint-strong), var(--border));
        border-left: var(--border-thick) solid var(--subject);
        border-radius: var(--radius-md);
        background: var(--surface);
        box-shadow: var(--shadow-card);
    }
    .agenda-main { display: grid; min-width: 0; }
    .agenda-context { color: var(--text-muted); font-size: var(--text-2xs); font-weight: var(--weight-semibold); }
    .agenda-title { color: var(--text-heading); font-weight: var(--weight-semibold); }
    .agenda-side { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1) var(--space-2); color: var(--text-muted); font-size: var(--text-2xs); }
    .is-past .agenda-card { border-color: var(--border); border-left-color: color-mix(in srgb, var(--subject) var(--tint-edge), var(--border)); box-shadow: none; }
    .is-past :is(.agenda-title, .agenda-time b) { color: var(--text-muted); }
    .is-now .agenda-card { border-color: var(--primary); box-shadow: 0 0 0 var(--border-width) var(--primary); }
    .is-now .agenda-time b { color: var(--primary); }
    .is-unprepared .agenda-card { border-style: dashed; box-shadow: none; }
    .agenda-break {
        margin-left: calc(var(--replica-time) + var(--space-2));
        padding: var(--space-0);
        border-radius: var(--radius-md);
        background: color-mix(in srgb, var(--text-muted) var(--tint-hover), transparent);
        color: var(--text-muted);
        font-size: var(--text-2xs);
        text-align: center;
    }

    .today-side {
        display: flex;
        flex-direction: column;
        gap: var(--space-1);
        padding: var(--space-3);
        border: var(--border-width) solid var(--border);
        border-radius: var(--radius-md);
        background: var(--surface);
        box-shadow: var(--shadow-card);
    }
    .side-head { margin-top: var(--space-2); color: var(--text-heading); font-weight: var(--weight-bold); }
    .side-head:first-child { margin-top: 0; }
    .side-list { display: grid; gap: var(--space-0); }
    .side-list small { color: var(--text-muted); font-size: var(--text-2xs); }
    .side-link { color: var(--primary); text-decoration: underline; text-decoration-thickness: var(--border-width); }

    .phone-bar {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: var(--space-3) var(--space-3) var(--space-2);
        border-bottom: var(--border-width) solid var(--border);
        background: var(--nav-bg);
        color: var(--text-quiet);
    }
    .phone-body { display: flex; flex-direction: column; gap: var(--space-2); padding: var(--space-3); }
    .phone-body .app-eyebrow { margin-top: calc(var(--space-2) * -1); }
    .phone-tabs {
        display: grid;
        grid-template-columns: repeat(5, minmax(0, 1fr));
        padding: var(--space-2) var(--space-1) var(--space-3);
        border-top: var(--border-width) solid var(--border);
        background: var(--nav-bg);
        color: var(--text-quiet);
        font-size: var(--text-2xs);
        text-align: center;
    }
    .tab-current {
        justify-self: center;
        padding-inline: var(--space-1);
        border-radius: var(--radius-pill);
        background: var(--nav-current-bg);
        color: var(--nav-current-text);
        font-weight: var(--weight-bold);
    }
    /* After the rules above, so they win by source order. */
    @container (max-width: 39.99rem) {
        .app { grid-template-columns: minmax(0, 1fr); }
        .app-nav { display: none; }
    }
    @container (max-width: 29.99rem) {
        .today { grid-template-columns: minmax(0, 1fr); }
        .today-side { display: none; }
    }
    @container (min-width: 50rem) {
        .app { font-size: var(--text-sm); }
        .app-eyebrow { font-size: var(--text-xs); }
    }

    @media (max-width: 39.99rem) {
        /* No room for a margin line beside the text on a phone. */
        .hero { --hero-margin: none; padding-top: var(--space-8); }
        /* The phone replica alone, as on a phone; the laptop would be cut. */
        .devices { justify-content: center; padding-bottom: 0; }
        .laptop { display: none; }
        .phone { margin: 0; }
        .window { padding: var(--space-3); }
        .reg-tab { padding-inline: var(--space-2); }
    }
    @media (min-width: 64rem) {
        /* The price note sits in the margin beside the claim. */
        .hero-top { grid-template-columns: minmax(0, 1fr) var(--note-width); }
        .hero-note { margin-top: var(--space-9); }
    }

    /* ---------- 3 Ihr Arbeitstag: the times as large ink numerals ---------- */
    .moments {
        display: grid;
        gap: var(--space-7) var(--space-6);
        margin-bottom: var(--space-9);
    }
    .moment { padding-top: var(--space-4); border-top: var(--border-width) solid var(--margin-line); }
    .numeral {
        display: block;
        margin-bottom: var(--space-3);
        color: var(--primary);
        font-family: var(--font-head);
        font-size: var(--text-numeral);
        font-weight: var(--weight-bold);
        line-height: var(--leading-none);
        letter-spacing: var(--tracking-tight);
        font-variant-numeric: tabular-nums lining-nums;
    }
    .moment h3 { margin-bottom: var(--space-2); }
    @media (min-width: 40rem) {
        .moments { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    }
    @media (min-width: 64rem) {
        .moments { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    }

    /* Her week in the Journal, taped into the page like a printout. */
    .window {
        padding: var(--space-5) var(--space-4) var(--space-4);
        border: var(--border-width) solid var(--border);
        border-radius: var(--radius-sm);
        background: var(--bg);
        box-shadow: var(--photo-shadow);
    }
    .journal-figure figcaption { margin-top: var(--space-4); color: var(--primary); }
    .journal-toolbar {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: var(--space-2) var(--space-3);
        margin-bottom: var(--space-3);
        font-size: var(--text-sm);
    }
    .tb-button, .tb-seg {
        display: inline-flex;
        align-items: center;
        min-height: var(--control-h);
        padding: 0 var(--space-3);
        border: var(--border-width) solid var(--border-strong);
        border-radius: var(--radius-md);
        background: var(--surface);
        color: var(--text);
        font-weight: var(--weight-medium);
    }
    .tb-seg { gap: var(--space-2); padding: 0 var(--space-2); color: var(--text-muted); }
    .journal-week b { color: var(--text-heading); font-size: var(--text-lg); font-weight: var(--weight-bold); }
    .journal-week span { color: var(--text-muted); font-size: var(--text-lg); font-variant-numeric: tabular-nums; }
    .week-note { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3); margin-bottom: var(--space-4); font-size: var(--text-sm); }
    .week-note b { color: var(--text-heading); }
    .week-note .app-field { flex: 1 1 auto; }
    .table-scroll { overflow-x: auto; border-radius: var(--radius-sm); }
    .journal {
        width: 100%;
        min-width: var(--journal-min);
        table-layout: fixed;
        background: var(--surface);
        font-size: var(--text-sm);
        line-height: var(--leading-snug);
    }
    .journal th, .journal td {
        padding: var(--space-2);
        border: var(--border-width) solid var(--border);
        text-align: left;
        vertical-align: top;
    }
    .journal thead th {
        color: var(--text-heading);
        font-size: var(--text-xs);
        font-weight: var(--weight-bold);
        letter-spacing: var(--tracking-caps);
        text-transform: uppercase;
    }
    .journal thead small { display: block; margin-bottom: var(--space-1); font-size: var(--text-sm); letter-spacing: normal; text-transform: none; }
    .journal .col-period { width: var(--journal-period); }
    .journal tbody th { color: var(--text-muted); font-weight: var(--weight-regular); font-variant-numeric: tabular-nums; }
    .journal tbody th small { display: block; }
    .period { display: block; color: var(--text-heading); font-size: var(--text-xs); }
    /* Today: the yellow band across its column head. */
    .journal thead .day-today { background: var(--now-bg); color: var(--now-text); box-shadow: inset 0 var(--border-thick) 0 var(--now-edge); }
    .day-info, .day-due {
        display: block;
        width: fit-content;
        margin-top: var(--space-1);
        padding: var(--space-0) var(--space-1);
        border-radius: var(--radius-sm);
        background: var(--secondary-fill);
        color: var(--on-secondary);
        font-size: var(--text-2xs);
        font-weight: var(--weight-semibold);
        letter-spacing: normal;
        text-transform: none;
        white-space: normal;
    }
    .day-event { background: color-mix(in srgb, var(--primary) var(--tint-selected), var(--surface)); color: var(--primary); }
    .day-due { background: var(--marker-orange); color: var(--on-marker); }
    .tile {
        display: flex;
        flex-direction: column;
        gap: var(--space-0);
        padding: var(--space-1) var(--space-2);
        border-left: var(--border-thick) solid var(--subject);
        border-radius: var(--radius-sm);
        background: color-mix(in srgb, var(--subject) var(--tint-selected), var(--surface));
        color: var(--text-heading);
        font-weight: var(--weight-semibold);
        hyphens: auto;
        overflow-wrap: break-word;
    }
    .tile small { color: var(--text); font-weight: var(--weight-regular); }
    .tile.is-unprepared { background: var(--surface); outline: var(--border-width) dashed var(--text-muted); outline-offset: calc(var(--border-width) * -1); }
    .free { color: var(--text-muted); }
    .journal-break td { padding-block: var(--space-1); background: var(--surface-sunken); color: var(--text-muted); font-size: var(--text-xs); text-align: center; }
    @media (min-width: 40rem) {
        .window { padding: var(--space-6) var(--space-5) var(--space-5); }
    }

    /* ---------- 4 Was sich ändert: by hand, then typed ---------- */
    .compare { border-top: var(--border-width) solid var(--border); }
    .compare-row {
        display: grid;
        gap: var(--space-2) var(--space-6);
        padding-block: var(--space-5);
        border-bottom: var(--border-width) solid var(--border);
    }
    .compare dt { color: var(--text-heading); font-family: var(--font-head); font-size: var(--text-xl); font-weight: var(--weight-bold); }
    .compare-label {
        display: block;
        width: fit-content;
        margin-bottom: var(--space-1);
        color: var(--text-muted);
        font-size: var(--text-xs);
        font-weight: var(--weight-bold);
        letter-spacing: var(--tracking-caps);
        text-transform: uppercase;
    }
    .compare-before .hand { color: var(--pencil); }
    .compare-after .compare-label {
        padding: 0 var(--space-2);
        border-radius: var(--radius-marker);
        background: var(--marker-green);
        color: var(--on-marker);
    }
    .split-print .photo { aspect-ratio: var(--photo-ratio); }
    @media (min-width: 40rem) {
        .compare-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
        .compare dt { grid-column: 1 / -1; }
        .split-print .photo { aspect-ratio: var(--photo-wide); }
    }
    @media (min-width: 64rem) {
        .split-print { align-self: center; }
        .split-print .photo { aspect-ratio: var(--photo-ratio); }
    }

    /* ---------- 5 Für wen: a taped photo and two index cards ---------- */
    .audience { display: grid; gap: var(--space-7); align-items: start; }
    /* The 3:1 crop keeps the open notebook and pen, the planning cue, in the lower half. */
    .audience-print .photo { aspect-ratio: var(--photo-ratio); object-position: center 85%; }
    @media (min-width: 40rem) {
        .audience-print .photo { aspect-ratio: var(--band-ratio); }
    }
    @media (min-width: 64rem) {
        .audience { grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); gap: var(--space-8); }
        .audience-print { margin-top: var(--space-4); }
        .audience-print .photo { aspect-ratio: var(--photo-ratio); }
    }

    /* ---------- 6 Funktionen ---------- */
    .band-print { margin-bottom: var(--space-8); rotate: none; }
    .band { aspect-ratio: var(--band-ratio); object-position: center top; }
    .feature-groups { display: grid; gap: var(--space-8); }
    .feature-stack { display: grid; align-content: start; gap: var(--space-8); }
    .feature-group h3 {
        width: fit-content;
        margin-bottom: var(--space-2);
        padding-bottom: var(--space-1);
        border-bottom: var(--border-thick) solid var(--register);
        font-size: var(--text-xl);
    }
    .features { column-gap: var(--space-7); }
    .features > div { padding-block: var(--space-3); border-bottom: var(--border-width) solid var(--border); }
    .features dt { color: var(--text-heading); font-weight: var(--weight-bold); }
    /* «Täglich», the core, gets the wide column and its list in two. */
    @media (min-width: 40rem) {
        .feature-groups { grid-template-columns: repeat(2, minmax(0, 1fr)); }
        .feature-daily { grid-column: 1 / -1; }
        .feature-daily .features { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
    }
    @media (min-width: 64rem) {
        .feature-groups { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
        .feature-daily { grid-column: auto; }
        .feature-stack { grid-column: 1 / -1; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); column-gap: var(--space-8); }
        .feature-stack .features { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
        .feature-stack .feature-group + .feature-group .features { grid-template-columns: minmax(0, 1fr); }
    }

    /* ---------- 7 Lehrplan 21: 5 mm squared paper ---------- */
    .squared {
        background-color: var(--bg);
        background-image:
            linear-gradient(var(--grid-line) var(--border-width), transparent var(--border-width)),
            linear-gradient(90deg, var(--grid-line) var(--border-width), transparent var(--border-width));
        background-size: var(--grid-cell) var(--grid-cell);
    }
    .praktikum { margin-top: var(--space-9); }
    .praktikum > h3 { margin-bottom: var(--space-5); font-size: var(--text-xl); }

    /* ---------- 8 Vertrauen: the teacher's red ticks ---------- */
    .trust { display: grid; gap: var(--space-6) var(--space-7); }
    @media (min-width: 40rem) {
        /* Four points as two by two, kept under the title. */
        .trust { grid-template-columns: repeat(2, minmax(0, 1fr)); max-width: var(--measure); }
    }
    .trust li { display: flex; gap: var(--space-3); font-size: var(--text-md); }
    .tick { flex: none; width: var(--tick-size); height: var(--tick-size); margin-top: calc(var(--space-1) * -1); color: var(--accent); }
    .trust-more { margin-top: var(--space-7); }

    /* ---------- 9 Zugang und Preis ---------- */
    .price {
        color: var(--text-heading);
        font-family: var(--font-head);
        font-size: var(--text-price);
        font-weight: var(--weight-bold);
        line-height: var(--leading-none);
        letter-spacing: var(--tracking-tight);
    }
    .price-unit { color: var(--text-muted); font-family: var(--font-body); font-size: var(--text-base); font-weight: var(--weight-regular); letter-spacing: normal; }
    .sheet .price { margin-block: var(--space-6) var(--space-5); }
    .steps { display: grid; gap: var(--space-3); counter-reset: step; }
    .steps li { position: relative; counter-increment: step; }
    /* Step numbers by hand, in the margin, in the teacher's red. */
    .steps li::before {
        content: counter(step);
        position: absolute;
        top: calc(var(--space-2) * -1);
        right: calc(100% + var(--space-5) + var(--space-4));
        color: var(--accent-text);
        font-family: var(--font-hand);
        font-size: var(--text-hand-lg);
        font-weight: var(--weight-bold);
        line-height: var(--leading-snug);
    }
    .sheet .actions { margin-top: var(--space-6); }
    /* The photo, and the note stuck over its lower corner. */
    .zugang-aside { display: grid; align-content: center; }
    .zugang-aside .photo { aspect-ratio: var(--photo-ratio); }
    .zugang-note { position: relative; z-index: var(--z-raised); margin: calc(var(--space-8) * -1) 0 0 var(--space-6); }
    @media (max-width: 39.99rem) {
        .steps li::before { right: calc(100% + var(--space-5) + var(--space-2)); }
    }

    /* ---------- 10 Fragen und Antworten ---------- */
    .faq { border-top: var(--border-width) solid var(--border); }
    .faq details { border-bottom: var(--border-width) solid var(--border); }
    /* A block, not flex: the question stays inline, so its hover stroke
     * runs along each line; the chevron sits in the right padding. */
    .faq summary {
        display: block;
        position: relative;
        padding-block: var(--space-4);
        padding-right: calc(var(--icon-size) + var(--space-4));
        color: var(--text-heading);
        font-size: var(--text-md);
        font-weight: var(--weight-bold);
        cursor: pointer;
        list-style: none;
    }
    .faq summary::-webkit-details-marker { display: none; }
    .faq summary > span {
        background: linear-gradient(transparent var(--marker-hover-top), var(--register) var(--marker-hover-top),
            var(--register) var(--marker-hover-bottom), transparent var(--marker-hover-bottom)) 0 0 / 0% 100% no-repeat;
    }
    .faq summary:hover { color: var(--primary); }
    .faq summary:is(:hover, :focus-visible) > span { background-size: 100% 100%; }
    .faq summary .icon { position: absolute; top: calc(50% - var(--icon-size) / 2); right: 0; color: var(--text-muted); }
    .faq details[open] summary .icon { transform: rotate(180deg); }
    .faq details p { max-width: var(--measure); padding-bottom: var(--space-5); }

    /* ---------- Impressum, Datenschutz and the 404 page ---------- */
    main { flex: 1; }
    .page { padding-block: var(--space-9) var(--section-pad); }
    .page .sheet { max-width: calc(var(--measure) + var(--space-10)); }
    .page h1 { margin-bottom: var(--space-6); font-size: var(--text-h2); }
    .page h2 { margin-top: var(--space-8); font-size: var(--text-xl); }
    .page .sheet > ul { padding-left: var(--space-5); list-style: disc; }
    .page .meta { color: var(--text-muted); font-size: var(--text-sm); }

    /* ---------- Motion ---------- */
    /* Each motion shows a change of state, answers the pointer, or points
     * once to what matters. Only strokes and a ring are drawn in; no text is
     * hidden or moved before a motion runs, so with reduced motion the page
     * is the same, only still. No loops, no motion on scroll except the
     * section titles' strokes. */
    @media (prefers-reduced-motion: no-preference) {
        /* Anchor jumps glide; scroll-margin-top keeps the section's tab in view. */
        html { scroll-behavior: smooth; }

        /* Feedback: buttons lift and are pressed, the header's tabs rise out
         * of the binder (a shadow in their colour keeps them on the rule),
         * underlines grow, the arrow moves on. */
        .button, .outline {
            transition: translate var(--duration-normal) var(--ease-out),
                box-shadow var(--duration-normal) var(--ease-out),
                background-color var(--duration-fast) linear,
                border-color var(--duration-fast) linear,
                color var(--duration-fast) linear;
        }
        .button:hover, .outline:hover { translate: 0 var(--lift); box-shadow: var(--shadow-lift); }
        .button:active, .outline:active { translate: 0 var(--press); box-shadow: none; transition-duration: var(--duration-fast); }
        a.reg-tab { transition: translate var(--duration-normal) var(--ease-out), box-shadow var(--duration-normal) var(--ease-out); }
        a.reg-tab:is(:hover, :focus-visible) { translate: 0 var(--lift); box-shadow: 0 calc(var(--lift) * -1) 0 var(--register); }
        a { transition: text-decoration-thickness var(--duration-normal) var(--ease-out), color var(--duration-fast) linear; }
        .arrow-link { transition: background-size var(--duration-normal) var(--ease-out), color var(--duration-fast) linear; }
        .arrow-link .icon { transition: translate var(--duration-normal) var(--ease-out); }
        .arrow-link:hover .icon { translate: var(--nudge) 0; }

        /* FAQ: the answer's height grows from 0 to auto, the answer fades
         * and slides down a little, the chevron turns, the question's
         * stroke sweeps in. Without ::details-content or interpolate-size
         * the answer opens at once. */
        .faq { interpolate-size: allow-keywords; }
        .faq details::details-content {
            block-size: 0;
            overflow-y: clip;
            opacity: 0;
            translate: 0 var(--slide);
            transition: block-size var(--duration-open) var(--ease-out),
                opacity var(--duration-open) var(--ease-out),
                translate var(--duration-open) var(--ease-out),
                content-visibility var(--duration-open) allow-discrete;
        }
        .faq details[open]::details-content { block-size: auto; opacity: 1; translate: none; }
        .faq summary .icon { transition: transform var(--duration-open) var(--ease-out); }
        .faq summary > span { transition: background-size var(--duration-normal) var(--ease-out); }

        /* On load: the claim's stroke is drawn, then an ink ring closes
         * around the running lesson. */
        .is-now .agenda-card { animation: ring-close var(--duration-ring) var(--ease-out) var(--delay-now) backwards; }

        /* A highlighter stroke drawn left to right, line by line (the clone
         * break). At night the marked words turn dark ink, so the ink is
         * switched exactly where the stroke has reached: two text-clipped
         * layers, the marker's ink over the heading's. */
        @supports (background-clip: text) {
            .hero .hl { animation: stroke-draw var(--duration-draw) var(--ease-pen) var(--delay-claim) backwards; }
            /* The section titles' strokes are drawn as they scroll in; in
             * browsers without scroll timelines they are simply there. */
            @supports (animation-timeline: view()) {
                .section-title .hl {
                    animation: stroke-draw linear;
                    animation-timeline: view();
                    animation-range: var(--draw-range);
                }
            }
        }

        @keyframes stroke-draw {
            from, to {
                background-image: linear-gradient(var(--hl-text), var(--hl-text)),
                    linear-gradient(var(--text-heading), var(--text-heading)), var(--hl-stroke);
                background-repeat: no-repeat;
                background-clip: text, text, border-box;
                -webkit-text-fill-color: transparent;
            }
            from { background-size: 0% 100%, 100% 100%, 0% 100%; }
            to { background-size: 100% 100%, 100% 100%, 100% 100%; }
        }
        @keyframes ring-close {
            from { box-shadow: 0 0 0 var(--ring-from) transparent; }
        }
    }
}

@layer utilities {
    /* The three registers: colour and how far right the tab sits. */
    .reg-1 { --register: var(--marker-yellow); --tab-index: 0; }
    .reg-2 { --register: var(--marker-green); --tab-index: 1; }
    .reg-3 { --register: var(--marker-orange); --tab-index: 2; }

    /* Highlighter colours by meaning: yellow now or key, green done,
     * orange needs attention. */
    .hl-yellow { --hl: var(--marker-yellow); }
    .hl-green { --hl: var(--marker-green); }
    .hl-orange { --hl: var(--marker-orange); }

    /* The demo subjects' pencils (classes: the CSP forbids style attributes):
     * Mathematik blue, Deutsch red, Englisch teal, Französisch violet,
     * Natur und Technik green. */
    .subject-1 { --subject: var(--subject-1); }
    .subject-2 { --subject: var(--subject-2); }
    .subject-3 { --subject: var(--subject-3); }
    .subject-5 { --subject: var(--subject-5); }
    .subject-6 { --subject: var(--subject-6); }
}
