/*
 * Erfolgsjournal – Designsystem (Kapitel 9)
 *
 * Leitgedanke: die digitale Fortsetzung eines Punktraster-Notizbuchs.
 * Punktraster, Tinte, Hairlines, Mono-Ziffern. Keine Karten mit Schatten,
 * keine Verläufe, keine Fortschrittsringe.
 *
 * Die App selbst hat keine Signalfarbe – der einzige Farbeindruck entsteht
 * durch die Gewohnheiten.
 */

/* ---------------------------------------------------------------- Schriften */
/*
 * IBM Plex, selbst gehostet, Subset Latin. Liegen die woff2-Dateien nicht
 * vor, greift die Fallback-Kette und die App sieht schlichter aus, bleibt
 * aber vollständig benutzbar. bin/fetch-fonts.php lädt sie nach.
 */
/* Plex Sans ist ein Variable Font: eine Datei deckt Regular und Semibold ab. */
@font-face {
    font-family: 'IBM Plex Sans';
    src: url('../fonts/ibm-plex-sans.woff2') format('woff2-variations'),
         url('../fonts/ibm-plex-sans.woff2') format('woff2');
    font-weight: 100 700; font-style: normal; font-display: swap;
}
@font-face {
    font-family: 'IBM Plex Mono';
    src: url('../fonts/ibm-plex-mono-400.woff2') format('woff2');
    font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
    font-family: 'IBM Plex Serif';
    src: url('../fonts/ibm-plex-serif-400.woff2') format('woff2');
    font-weight: 400; font-style: normal; font-display: swap;
}

/* ------------------------------------------------------------------ Tokens */
:root {
    --paper:     #F4F6F8;
    --surface:   #FFFFFF;
    --dot:       #C9D1D9;
    --hairline:  #E3E8ED;
    --ink:       #14181C;
    --ink-muted: #5B6570;

    /* Rot nur für Zerstörerisches – keine Signalfarbe im Alltag. */
    --danger:    #7A2E2E;

    /*
     * Rahmen von Bedienelementen: Eingabefelder, Knöpfe, klickbare Zellen.
     *
     * --dot aus Kapitel 9.1 erreicht gegen --paper nur 1,42:1. Für das
     * Punktraster und die Trennlinien ist das genau richtig – die sollen
     * kaum da sein. Für etwas, das man bedient, verlangt WCAG 1.4.11 aber
     * 3:1, sonst sieht man den Rand eines Eingabefelds schlicht nicht.
     * Deshalb ein eigener Wert, statt die Palette umzufärben: 3,02:1.
     */
    --rahmen:    #898F95;

    --font-sans:  'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    --font-mono:  'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    --font-serif: 'IBM Plex Serif', Georgia, 'Times New Roman', serif;

    /* Skala 12 / 14 / 16 / 20 / 28 / 40 */
    --text-xs: 12px;
    --text-sm: 14px;
    --text-md: 16px;
    --text-lg: 20px;
    --text-xl: 28px;
    --text-2xl: 40px;

    /* Spacing-Basis 4px */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-6: 24px;
    --space-10: 40px;

    --radius: 6px;
    --radius-cell: 2px;

    /* Der einzige Schatten im System, ausschließlich für Overlays. */
    --shadow-overlay: 0 12px 32px rgb(20 24 28 / 18%);

    --tap-min: 44px;

    /* Grundfarbe der Jahres-Heatmap. Die Stufen mischen sie mit --hairline. */
    --heat: #1B3A6B;

    /*
     * Sagt dem Browser, in welche Richtung er Formularelemente, Scrollbalken
     * und die Auswahlfarbe faerben soll. Ohne das bleibt ein Datumsfeld im
     * dunklen Modus hellgrau.
     */
    color-scheme: light;
}

/*
 * Dunkel auf zwei Wegen.
 *
 * Erstens, weil das Geraet es so eingestellt hat und in der Anwendung nichts
 * anderes gewaehlt wurde. Zweitens, weil in den Einstellungen ausdruecklich
 * Dunkel steht – dann auch auf einem Geraet, das hell laeuft.
 *
 * Ohne Build-Step laesst sich der Block nicht teilen: Das eine steht in einer
 * Media Query, das andere nicht, und CSS kann Selektoren ueber diese Grenze
 * hinweg nicht zusammenfassen. Er steht deshalb zweimal da. Wer einen Wert
 * aendert, muss beide aendern – tests/test-theme.php faellt sonst.
 */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="hell"]) {
        --paper:     #0F1317;
        --surface:   #171C21;
        --dot:       #2A3138;
        --hairline:  #232A31;
        --ink:       #E8ECEF;
        --ink-muted: #97A1AB;
        --danger:    #C77B7B;
        --rahmen:    #62686E;
        --heat:      #6E93C8;
        --shadow-overlay: 0 12px 32px rgb(0 0 0 / 50%);
        color-scheme: dark;
    }
}

:root[data-theme="dunkel"] {
        --paper:     #0F1317;
        --surface:   #171C21;
        --dot:       #2A3138;
        --hairline:  #232A31;
        --ink:       #E8ECEF;
        --ink-muted: #97A1AB;
        --danger:    #C77B7B;
        --rahmen:    #62686E;
        --heat:      #6E93C8;
        --shadow-overlay: 0 12px 32px rgb(0 0 0 / 50%);
        color-scheme: dark;
}

/* -------------------------------------------------------------- Grundlagen */
*, *::before, *::after { box-sizing: border-box; }

/*
 * Das hidden-Attribut muss auch gegen eine eigene display-Regel gewinnen.
 *
 * Der Browser setzt dafuer nur "display: none" mit der Spezifitaet eines
 * Elementselektors – jede Klasse mit eigenem display schlaegt das. Konkret:
 * .weekday-picker ist ein Flex-Container, und deshalb standen die Wochentage
 * auch dann da, wenn "Jeden Tag" gewaehlt war. Das sah aus wie sieben
 * ausgewaehlte Tage und war schlicht ein Anzeigefehler.
 */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: var(--font-sans);
    font-size: var(--text-md);
    line-height: 1.5;
    color: var(--ink);
    background-color: var(--paper);

    /* Das Punktraster: 24px Abstand, --dot bei 40 % Deckkraft.
       Das einzige dekorative Element, und es ist inhaltlich begründet. */
    background-image: radial-gradient(circle, color-mix(in srgb, var(--dot) 40%, transparent) 1px, transparent 1px);
    background-size: 24px 24px;
    background-position: 0 0;

    padding-bottom: calc(72px + env(safe-area-inset-bottom));
}

h1, h2, h3 { line-height: 1.2; font-weight: 600; margin: 0 0 var(--space-3); }
h1 { font-size: var(--text-xl); }
h2 { font-size: var(--text-lg); }
h3 { font-size: var(--text-md); }

p { margin: 0 0 var(--space-3); }

a { color: var(--ink); text-decoration-color: var(--dot); text-underline-offset: 3px; }
a:hover { text-decoration-color: currentColor; }

.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* Sichtbarer Fokusring auf allen interaktiven Elementen. */
:focus-visible {
    outline: 2px solid var(--ink);
    outline-offset: 2px;
    border-radius: var(--radius);
}

.skip-link {
    position: absolute;
    left: -9999px;
    top: var(--space-2);
    padding: var(--space-2) var(--space-3);
    background: var(--surface);
    border: 1px solid var(--ink);
    border-radius: var(--radius);
    z-index: 100;
}
.skip-link:focus { left: var(--space-2); }

/* ------------------------------------------------------------------ Layout */
.wrap {
    max-width: 1200px;
    margin: 0 auto;
    padding: var(--space-6) var(--space-4);
    padding-left: max(var(--space-4), env(safe-area-inset-left));
    padding-right: max(var(--space-4), env(safe-area-inset-right));
}

.page--narrow { max-width: 34rem; }

.page__head { margin-bottom: var(--space-6); }
.page__head--split {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
    align-items: flex-start;
    justify-content: space-between;
}

.eyebrow {
    font-size: var(--text-sm);
    color: var(--ink-muted);
    margin: 0 0 var(--space-1);
}

.lead { color: var(--ink-muted); }

.section {
    margin-top: var(--space-10);
    padding-top: var(--space-6);
    border-top: 1px solid var(--hairline);
}
.section__action { margin-top: var(--space-4); }

.hint {
    font-size: var(--text-sm);
    color: var(--ink-muted);
    margin: var(--space-1) 0 0;
}
.optional {
    font-weight: 400;
    font-size: var(--text-xs);
    color: var(--ink-muted);
}

/* Trennung durch Hairlines und Weißraum, nicht durch Karten und Schatten. */
.footer {
    max-width: 1200px;
    margin: var(--space-10) auto 0;
    padding: var(--space-4);
    border-top: 1px solid var(--hairline);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: var(--text-sm);
    color: var(--ink-muted);
}

/* -------------------------------------------------------------- Navigation */
/*
 * Eine Liste, zwei Platzierungen: unten fixiert auf dem iPhone
 * (Einhandbedienung), oben ab 600px.
 */
.nav {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: var(--surface);
    border-top: 1px solid var(--hairline);
    padding-bottom: env(safe-area-inset-bottom);
    z-index: 20;
}

.nav ul {
    display: flex;
    margin: 0;
    padding: 0;
    list-style: none;
    max-width: 1200px;
    margin-inline: auto;
}

.nav li { flex: 1; }

.nav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-height: var(--tap-min);
    padding: var(--space-2) var(--space-1);
    font-size: var(--text-xs);
    color: var(--ink-muted);
    text-decoration: none;
}

.nav a[aria-current="page"] { color: var(--ink); font-weight: 600; }
.nav svg { width: 22px; height: 22px; flex: 0 0 auto; }

/* Fünf Punkte auf einem schmalen iPhone: lieber kleiner setzen als umbrechen. */
.nav span {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
@media (max-width: 419px) {
    .nav span { font-size: 10px; }
}

@media (min-width: 600px) {
    .nav {
        position: static;
        border-top: 0;
        border-bottom: 1px solid var(--hairline);
        background: transparent;
    }
    .nav ul {
        justify-content: flex-start;
        gap: var(--space-2);
        padding: 0 var(--space-4);
    }
    .nav li { flex: 0 0 auto; }
    .nav a {
        flex-direction: row;
        gap: var(--space-2);
        font-size: var(--text-sm);
        padding: var(--space-3) var(--space-2);
        border-bottom: 2px solid transparent;
    }
    .nav a[aria-current="page"] { border-bottom-color: var(--ink); }
    body { padding-bottom: var(--space-10); }
}

/* --------------------------------------------------------------- Meldungen */
.notice {
    padding: var(--space-3) var(--space-4);
    border-left: 3px solid var(--dot);
    background: var(--surface);
    border-radius: 0 var(--radius) var(--radius) 0;
    margin-bottom: var(--space-4);
}
.notice--ok     { border-left-color: #3F6B4A; }
.notice--warn   { border-left-color: #8A6420; }
.notice--danger { border-left-color: var(--danger); }
.notice--info   { border-left-color: #1F5F6B; color: var(--ink-muted); }

.empty {
    padding: var(--space-10) var(--space-4);
    text-align: center;
    border: 1px dashed var(--dot);
    border-radius: var(--radius);
}
.empty__text { color: var(--ink-muted); margin-bottom: var(--space-4); }

/* --------------------------------------------------------------- Formulare */
.form { max-width: 34rem; }

.field { margin-bottom: var(--space-6); border: 0; padding: 0; }
.field--short { max-width: 12rem; }

.field-row {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-4);
    align-items: flex-start;
}
.field-row .field { margin-bottom: 0; }

/*
 * Feste Grundbreiten statt "so breit wie noetig".
 *
 * Ohne sie entscheidet die Mindestbreite, die der Browser einem Eingabefeld
 * zubilligt – und die faellt je Browser anders aus. Safari auf dem iPhone
 * liess Uhrzeit und Ort nebeneinander stehen und schob das Zeitfeld unter
 * das Ortsfeld. Mit einer Grundbreite bricht die Zeile ueberall an
 * derselben Stelle um.
 */
.field-row > .field { flex: 1 1 14rem; min-width: 0; }
.field-row > .field--short { flex: 0 1 12rem; }

/* Ein Eingabefeld darf nie breiter werden als das, worin es steht. */
input, select, textarea { max-width: 100%; }

label, legend {
    display: block;
    font-size: var(--text-sm);
    font-weight: 600;
    margin-bottom: var(--space-2);
    padding: 0;
}

input[type="text"], input[type="password"], input[type="date"],
input[type="time"], input[type="search"], input[type="url"],
textarea, select {
    width: 100%;
    min-height: var(--tap-min);
    padding: var(--space-2) var(--space-3);
    font: inherit;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--rahmen);
    border-radius: var(--radius);
    transition: border-color 120ms ease;
}

textarea { min-height: 0; resize: vertical; font-family: var(--font-serif); font-size: 18px; }

input:focus, textarea:focus { border-color: var(--ink); }

.input--emoji { font-size: var(--text-lg); text-align: center; }

.field--error input, .field--error textarea { border-color: var(--danger); }
.field__error {
    font-size: var(--text-sm);
    color: var(--danger);
    margin: var(--space-1) 0 0;
}

.form__actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
    align-items: center;
    margin-top: var(--space-6);
}

.radio-row {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    min-height: var(--tap-min);
    font-weight: 400;
    margin-bottom: 0;
    cursor: pointer;
}
.radio-row input { width: 20px; height: 20px; accent-color: var(--ink); }

/* Farbwahl aus der kuratierten Palette – keine freie Farbwahl. */
.color-picker {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(7.5rem, 1fr));
    gap: var(--space-2);
}

.color-swatch {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    min-height: var(--tap-min);
    padding: var(--space-2);
    font-weight: 400;
    font-size: var(--text-sm);
    border: 1px solid var(--hairline);
    border-radius: var(--radius);
    cursor: pointer;
    margin-bottom: 0;
}
.color-swatch input {
    position: absolute;
    opacity: 0;
    width: 1px; height: 1px;
}
.color-swatch__dot {
    width: 18px; height: 18px;
    border-radius: var(--radius-cell);
    background: var(--habit-color);
    flex: 0 0 auto;
}
.color-swatch:has(input:checked) { border-color: var(--ink); background: var(--surface); }
.color-swatch:has(input:focus-visible) { outline: 2px solid var(--ink); outline-offset: 2px; }

/* Zahlenfeld fuer "n-mal pro Woche" – schmal, es sind nur die Ziffern 1 bis 7. */
.woche-picker { margin-top: var(--space-3); max-width: 9rem; }
.woche-picker label { font-size: var(--text-xs); font-weight: 400; color: var(--ink-muted); }

.weekday-picker {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    margin-top: var(--space-2);
}
.weekday {
    margin-bottom: 0;
    font-weight: 400;
}
.weekday input {
    position: absolute;
    opacity: 0;
    width: 1px; height: 1px;
}
.weekday span {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: var(--tap-min);
    min-height: var(--tap-min);
    font-family: var(--font-mono);
    border: 1px solid var(--rahmen);
    border-radius: var(--radius);
    cursor: pointer;
}
.weekday:has(input:checked) span {
    background: var(--ink);
    color: var(--paper);
    border-color: var(--ink);
}
.weekday:has(input:focus-visible) span { outline: 2px solid var(--ink); outline-offset: 2px; }

/* ----------------------------------------------------------------- Buttons */
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: var(--tap-min);
    padding: var(--space-2) var(--space-4);
    font: inherit;
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--rahmen);
    border-radius: var(--radius);
    text-decoration: none;
    cursor: pointer;
    transition: border-color 120ms ease, background-color 120ms ease;
}
.button:hover { border-color: var(--ink); }

.button--primary {
    background: var(--ink);
    color: var(--paper);
    border-color: var(--ink);
}
.button--primary:hover { opacity: 0.9; }

.button--quiet { border-color: transparent; color: var(--ink-muted); }
.button--quiet:hover { border-color: var(--dot); color: var(--ink); }

.button--danger {
    background: var(--danger);
    border-color: var(--danger);
    color: #FFF;
}
.button--danger-quiet { border-color: transparent; color: var(--danger); }
.button--danger-quiet:hover { border-color: var(--danger); }

.button:disabled, .icon-button:disabled { opacity: 0.35; cursor: default; }

.icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--tap-min);
    height: var(--tap-min);
    font: inherit;
    font-size: var(--text-md);
    color: var(--ink-muted);
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius);
    cursor: pointer;
}
.icon-button:hover:not(:disabled) { border-color: var(--dot); color: var(--ink); }

/*
 * Sieht aus wie ein Textlink, ist aber ein Knopf – und damit ein Tap-Ziel.
 * Kapitel 8.2 verlangt 44px, gemessen waren es 37. Die Höhe kommt über
 * min-height und zentrierte Ausrichtung, nicht über mehr Polsterung: sonst
 * rückt der Text in der Fußzeile sichtbar von der Linie ab.
 */
.link-button {
    display: inline-flex;
    align-items: center;
    min-height: var(--tap-min);
    font: inherit;
    font-size: var(--text-sm);
    color: var(--ink-muted);
    background: none;
    border: 0;
    padding: 0 var(--space-2);
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 3px;
}
.link-button:hover { color: var(--ink); }

.inline { display: inline-flex; gap: var(--space-1); margin: 0; }

.badge {
    display: inline-block;
    font-size: var(--text-xs);
    font-weight: 400;
    color: var(--ink-muted);
    border: 1px solid var(--dot);
    border-radius: var(--radius);
    padding: 0 var(--space-2);
    vertical-align: middle;
}

.stimmung__wahl span,
.tag-chip { border-color: var(--rahmen); }

/* ------------------------------------------------- Palette der Gewohnheiten */
/*
 * Acht Füllfederhalter-Tinten, leicht entsättigt und in der Helligkeit
 * ähnlich, damit keine Gewohnheit optisch dominiert und der Kontrast im
 * Dark Mode nicht kippt.
 *
 * Als Klassen statt als style-Attribut, damit die Content-Security-Policy
 * ohne 'unsafe-inline' auskommt.
 */
.farbe-nachtblau  { --habit-color: #1B3A6B; }
.farbe-petrol     { --habit-color: #1F5F6B; }
.farbe-moos       { --habit-color: #3F6B4A; }
.farbe-ocker      { --habit-color: #8A6420; }
.farbe-rost       { --habit-color: #9A4E20; }
.farbe-ochsenblut { --habit-color: #7A2E2E; }
.farbe-pflaume    { --habit-color: #5E3A6B; }
.farbe-graphit    { --habit-color: #4A5158; }

/* ------------------------------------------------------------ Gewohnheiten */
.habit-list { list-style: none; margin: 0; padding: 0; }

.habit-row, .habit-card {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) 0;
    border-bottom: 1px solid var(--hairline);
}

.habit-dot {
    width: 12px; height: 12px;
    flex: 0 0 auto;
    border-radius: var(--radius-cell);
    background: var(--habit-color);
}

.habit-icon { margin-right: var(--space-1); }

.habit-row__name { flex: 1; }
.habit-row__cue { font-size: var(--text-sm); color: var(--ink-muted); }

/*
 * Der Textblock darf schrumpfen, aber nicht auf Null.
 *
 * Mit flex: 1 und min-width: 0 gab er bis zum letzten Pixel nach, waehrend
 * die Knoepfe daneben nicht unter ihre Beschriftung koennen – auf dem iPhone
 * stand der Text dann einwortig untereinander und die Knoepfe lagen darueber.
 * Eine Grundbreite von 12rem sorgt dafuer, dass stattdessen die Knopfleiste
 * in die naechste Zeile rutscht. Ohne Breakpoint: Es entscheidet, was
 * tatsaechlich hineinpasst, nicht eine geratene Geraetebreite.
 */
.habit-card__body { flex: 1 1 12rem; min-width: 0; }
.habit-card__name { margin: 0; font-weight: 600; }
.habit-card__meta {
    margin: 0;
    font-size: var(--text-xs);
    color: var(--ink-muted);
}
.habit-card__cue {
    margin: var(--space-1) 0 0;
    font-size: var(--text-sm);
    color: var(--ink-muted);
}

.habit-card__actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-1);

    /*
     * Die Leiste rutscht als Ganzes in die naechste Zeile, statt sich
     * zwischen den Text zu schieben. Dort darf sie schrumpfen – dann
     * greift ihr eigenes flex-wrap und die Knoepfe brechen um. Mit
     * flex: 0 0 auto taeten sie das nicht und "Loeschen" stuende
     * ausserhalb des Bildschirms.
     */
    flex: 0 1 auto;
}

.habit-card--muted .habit-card__name { color: var(--ink-muted); font-weight: 400; }

/* Der Griff ist nur auf Zeigergeräten sinnvoll – Touch bekommt die Pfeile. */
.habit-card__grip {
    display: none;
    color: var(--dot);
    cursor: grab;
    user-select: none;
    font-size: var(--text-sm);
    letter-spacing: -2px;
}
.habit-card.is-dragging { opacity: 0.5; }
.habit-card.is-drop-target { border-top: 2px solid var(--ink); }

.hint--sortable { display: none; }

@media (hover: hover) and (pointer: fine) {
    .habit-card__grip { display: block; }
    .hint--sortable { display: block; margin-top: var(--space-3); }
    /* Mit Drag & Drop sind die Pfeile Redundanz, bleiben aber für die Tastatur. */
}

/* ---------------------------------------------------------------- Geräte */
.device-list { list-style: none; margin: 0; padding: 0; }

.device {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-3);
    padding: var(--space-4) 0;
    border-bottom: 1px solid var(--hairline);
}
.device__body { min-width: 0; }
.device__name { margin: 0 0 var(--space-1); font-weight: 600; }
.device__meta { margin: 0; font-size: var(--text-xs); color: var(--ink-muted); }
.device__ua {
    margin: var(--space-1) 0 0;
    font-size: var(--text-xs);
    color: var(--ink-muted);
    overflow-wrap: anywhere;
}
.device--current .device__name { color: var(--ink); }

.facts {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: var(--space-2) var(--space-4);
    margin: 0;
}
.facts dt { font-size: var(--text-sm); color: var(--ink-muted); }
.facts dd { margin: 0; font-size: var(--text-sm); }

/* --------------------------------------------------------------- Bewegung */
/*
 * Sparsam und an einer Stelle konzentriert. prefers-reduced-motion schaltet
 * alles ab – ohne Ausnahme.
 */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ------------------------------------------------------------ Breakpoints */
@media (min-width: 1024px) {
    .wrap { padding: var(--space-10) var(--space-6); }
}

/* ============================================================================
   Tagesansicht
   ========================================================================= */

.tag-kopf {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin-bottom: var(--space-4);
}
.tag-kopf__mitte { flex: 1; text-align: center; min-width: 0; }
.tag-kopf__mitte h1 { font-size: var(--text-lg); margin: 0; }
.tag-kopf__mitte .eyebrow { margin: 0; min-height: 1.2em; }

.tag-zurueck { text-align: center; font-size: var(--text-sm); margin-bottom: var(--space-4); }
.tag-fuss { margin-top: var(--space-10); font-size: var(--text-sm); }

.fortschritt {
    font-size: var(--text-sm);
    color: var(--ink-muted);
    margin-bottom: var(--space-2);
}

.tagesliste { list-style: none; margin: 0; padding: 0; }

.tageszeile { border-bottom: 1px solid var(--hairline); }

.tageszeile__form {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin: 0;
    padding: var(--space-2) 0;
}

.tageszeile__text { flex: 1; min-width: 0; }
.tageszeile__name { display: block; }
.tageszeile__meta {
    display: block;
    font-size: var(--text-xs);
    color: var(--ink-muted);
}
.tageszeile__meta > * + *::before { content: " · "; }
.serie:empty, .tageszeile__zeit:empty, .woche:empty, .menge:empty { display: none; }

/* Der Minusknopf sitzt neben dem Aussetzen-Knopf und ist genauso ruhig. */
.icon-button.minus { font-size: var(--text-md); }
.icon-button.minus:disabled { opacity: 0.35; cursor: default; }

/*
 * Der Haken. Bewusst ein großes Ziel: auf dem iPhone wird hier einhändig
 * getippt, und ein Fehltap kostet einen zweiten Tap zum Zurücknehmen.
 */
.haken {
    flex: 0 0 auto;
    width: var(--tap-min);
    height: var(--tap-min);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    background: none;
    border: 0;
    cursor: pointer;
}

.haken__feld {
    width: 26px;
    height: 26px;
    border: 1.5px solid var(--rahmen);
    border-radius: var(--radius-cell);
    background: transparent;
    position: relative;
    transition: border-color 120ms ease;
}
.haken:hover:not(:disabled) .haken__feld { border-color: var(--habit-color, var(--ink)); }

/*
 * Die Füllung läuft aus der Mitte nach außen – 140ms, die einzige Stelle im
 * System, an der etwas mehr als ein Zustandswechsel passiert (Kapitel 9.5).
 */
.haken__feld::after {
    content: "";
    position: absolute;
    inset: 0;
    background: var(--habit-color, var(--ink));
    border-radius: 1px;
    transform: scale(0);
    transition: transform 140ms cubic-bezier(0.2, 0, 0.2, 1);
}

.tageszeile[data-status="done"] .haken__feld { border-color: var(--habit-color, var(--ink)); }
.tageszeile[data-status="done"] .haken__feld::after { transform: scale(1); }

/*
 * Angefangen, aber das Tagesziel noch nicht erreicht.
 *
 * Dieselbe Sprache wie im Monatsraster: blass genug, um nicht mit einem
 * erledigten Tag verwechselt zu werden, kraeftig genug, um zu zeigen, dass
 * hier schon etwas passiert ist. Die Zahl daneben sagt, wie viel fehlt.
 */
.tageszeile[data-status="partial"] .haken__feld {
    border-color: color-mix(in srgb, var(--habit-color, var(--ink)) 60%, var(--rahmen));
}
.tageszeile[data-status="partial"] .haken__feld::after {
    transform: scale(1);
    opacity: 0.32;
}

/* Ausgesetzt: gestreift statt gefüllt – sichtbar anders als erledigt. */
.tageszeile[data-status="skipped"] .haken__feld {
    border-color: var(--habit-color, var(--ink));
    border-style: dashed;
}
.tageszeile[data-status="skipped"] .haken__feld::after {
    transform: scale(1);
    opacity: 0.28;
    background: repeating-linear-gradient(
        -45deg,
        var(--habit-color, var(--ink)) 0 3px,
        transparent 3px 6px
    );
}

.tageszeile[data-status="done"] .tageszeile__name { color: var(--ink-muted); }

.aussetzen { font-family: var(--font-mono); }
.aussetzen[aria-pressed="true"] {
    color: var(--habit-color, var(--ink));
    border-color: var(--dot);
}

.haken:disabled, .aussetzen:disabled { opacity: 0.35; cursor: default; }

/* Tastenkürzel nur zeigen, wo es eine Tastatur gibt. */
.kuerzel {
    display: none;
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    color: var(--ink-muted);
    border: 1px solid var(--hairline);
    border-radius: 4px;
    padding: 0 5px;
    line-height: 1.6;
}
@media (min-width: 1024px) and (hover: hover) {
    .kuerzel { display: inline-block; }
}

/* ============================================================================
   Monatsraster – die Signatur der App
   ========================================================================= */

.page--breit { max-width: none; }

.monat-kopf {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin-bottom: var(--space-3);
}
.monat-kopf h1 { flex: 1; text-align: center; font-size: var(--text-lg); margin: 0; }

.monat-wahl {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    align-items: center;
    margin-bottom: var(--space-6);
}
.monat-wahl select { width: auto; min-width: 12rem; }

.raster-form { margin: 0; }

/* Auf dem iPhone waagerecht scrollbar, die Namensspalte bleibt stehen. */
.raster-rolle {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 calc(-1 * var(--space-4));
    padding: 0 var(--space-4);
}

/*
 * Die Tabelle ist exakt so breit wie ihr Inhalt – kein min-width: 100%.
 * Sonst streckt der Browser die Spalten über die Fensterbreite, zwischen die
 * Zellen kommt Luft, und aus der Kette werden einzelne Punkte.
 */
.raster {
    border-collapse: separate;
    border-spacing: 0;
    width: max-content;
}

.raster th, .raster td { padding: 0; }

.raster__name {
    position: sticky;
    left: 0;
    z-index: 2;
    background: var(--paper);
    text-align: left;
    font-weight: 400;
    font-size: var(--text-sm);
    padding: var(--space-1) var(--space-3) var(--space-1) 0;
    white-space: nowrap;
    max-width: 11rem;
    overflow: hidden;
    text-overflow: ellipsis;
}
thead .raster__name { font-size: var(--text-xs); color: var(--ink-muted); }

.raster__name .habit-dot { display: inline-block; vertical-align: middle; margin-right: var(--space-2); }
.raster__name-text { vertical-align: middle; }

.raster__tag {
    font-weight: 400;
    font-size: var(--text-xs);
    color: var(--ink-muted);
    text-align: center;
    padding-bottom: var(--space-2);
    width: 20px;
}
.raster__wochentag { display: block; font-size: 9px; opacity: 0.7; }
.raster__tag--wochenende { color: var(--ink-muted); opacity: 0.6; }

.raster__summe {
    text-align: right;
    font-size: var(--text-xs);
    color: var(--ink-muted);
    padding-left: var(--space-4);
    min-width: 3.5rem;
    white-space: nowrap;
}
thead .raster__summe { padding-bottom: var(--space-2); }

/*
 * Die Kette.
 *
 * Zellen stehen ohne Abstand nebeneinander. Eine einzelne erledigte Zelle ist
 * ein Quadrat mit runden Ecken; grenzt links oder rechts eine gefüllte Zelle
 * an, werden die Ecken dort eckig – aus zwei Kästchen wird ein Strich, aus
 * zehn eine lange Linie. Reine border-radius-Arbeit, kein Extra-Markup,
 * keine Grafik.
 */
/* Zellen stehen bündig nebeneinander – die Kette braucht die Nulllücke. */
.raster__zelle { width: 20px; padding: 1px 0; }

.zelle {
    display: block;
    width: 20px;
    height: 20px;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: inset 0 0 0 1px var(--rahmen);
    border-radius: var(--radius-cell);
    cursor: pointer;
    transition: background-color 120ms ease, box-shadow 120ms ease;
}

/* Nicht bedienbare Zellen dürfen zurücktreten – sie sind reine Grafik. */
.zelle--gesperrt:not(.zelle--erledigt):not(.zelle--ausgesetzt) {
    box-shadow: inset 0 0 0 1px var(--hairline);
}

.zelle:hover:not(.zelle--gesperrt) { box-shadow: inset 0 0 0 1px var(--ink); }

.zelle--erledigt {
    background: var(--habit-color);
    box-shadow: none;
    border-radius: 9px;
}

/*
 * Angefangen, aber das Tagesziel nicht erreicht.
 *
 * Blass genug, um nicht mit einem erledigten Tag verwechselt zu werden, und
 * kraeftig genug, um ueberhaupt aufzufallen. Bewusst ohne Kettenradius: Die
 * Kette verbindet nur volle Tage, sonst behauptet das Raster eine Serie, die
 * die Rechnung nicht kennt.
 */
.zelle--angefangen {
    background: color-mix(in srgb, var(--habit-color) 32%, transparent);
    box-shadow: none;
    border-radius: 9px;
}

.zelle--ausgesetzt {
    box-shadow: none;
    border-radius: 9px;
    background: repeating-linear-gradient(
        -45deg,
        var(--habit-color) 0 3px,
        transparent 3px 6px
    );
}

/* Nachbarschaft: an der angrenzenden Seite verschwindet die Rundung. */
.kette-links  { border-start-start-radius: 0; border-end-start-radius: 0; }
.kette-rechts { border-start-end-radius: 0; border-end-end-radius: 0; }

/* Ein halbes Pixel Überlappung nach rechts deckt den Haarriss ab, den
   Subpixel-Rundung sonst mitten in einen Balken zeichnet. */
.zelle--erledigt.kette-rechts,
.zelle--ausgesetzt.kette-rechts { width: 21px; }

.zelle--heute { box-shadow: inset 0 0 0 1.5px var(--ink); }
.zelle--heute.zelle--erledigt,
.zelle--heute.zelle--ausgesetzt { box-shadow: 0 0 0 1.5px var(--ink); }

.zelle--inaktiv {
    box-shadow: none;
    background: transparent;
    cursor: default;
}
.zelle--inaktiv::after {
    content: "";
    display: block;
    width: 3px;
    height: 3px;
    margin: 8px auto;
    border-radius: 50%;
    background: var(--dot);
    opacity: 0.5;
}

.zelle--gesperrt { cursor: default; }

/* Ab Tablet passt der volle Monat ohne Scrollen – dann dürfen die Zellen größer sein. */
@media (min-width: 768px) {
    .zelle { width: 24px; height: 24px; border-radius: var(--radius-cell); }
    .zelle--erledigt, .zelle--ausgesetzt { border-radius: 11px; }
    .zelle--erledigt.kette-rechts,
    .zelle--ausgesetzt.kette-rechts { width: 25px; }
    .raster__tag, .raster__zelle { width: 24px; }
    .raster__name { max-width: 16rem; }
}

/* ============================================================================
   Tastaturhilfe
   ========================================================================= */

.visuell-versteckt {
    position: absolute;
    width: 1px; height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* Der einzige Schatten im gesamten System, ausschließlich für Overlays. */
.overlay {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-4);
    background: rgb(20 24 28 / 40%);
    z-index: 50;
}

.overlay__inhalt {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-overlay);
    padding: var(--space-6);
    max-width: 26rem;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
}

.kuerzel-liste {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: var(--space-2) var(--space-4);
    margin: 0 0 var(--space-4);
    font-size: var(--text-sm);
}
.kuerzel-liste dt { font-family: var(--font-mono); color: var(--ink-muted); }
.kuerzel-liste dd { margin: 0; }

/* ============================================================================
   NFC-Tags
   ========================================================================= */

.frisch {
    border: 1px solid var(--dot);
    border-radius: var(--radius);
    padding: var(--space-4);
    margin-bottom: var(--space-6);
    background: var(--surface);
}
.frisch h2 { margin-top: 0; }

.kopierfeld { margin-bottom: var(--space-4); }
.kopierfeld__reihe {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    align-items: stretch;
}
.kopierfeld__reihe input {
    /* Grundbreite statt "so schmal wie noetig": Auf 320px rutscht sonst der
       Knopf aus dem Bild, statt eine Zeile tiefer zu gehen. */
    flex: 1 1 11rem;
    min-width: 0;
    font-size: var(--text-sm);
}
.kopierfeld__reihe .button { flex: 0 0 auto; }

/*
 * Eine beschriftete Zeile zum Kopieren, innerhalb der Anleitung.
 *
 * Alles, was sonst in die Kurzbefehle-App abgetippt werden muesste, steht
 * hier zum Antippen: Schluessel, Wert, Feldname. Der Token allein hat 64
 * Zeichen, und ein Zeichen daneben heisst "unbekannt, abgewiesen".
 */
.kopierzeile { margin-top: var(--space-3); }
.kopierzeile label {
    font-size: var(--text-xs);
    font-weight: 400;
    color: var(--ink-muted);
    margin-bottom: var(--space-1);
}

.anleitung-block { font-size: var(--text-sm); }
.anleitung-block h3 { margin-top: var(--space-6); }

.schritt-liste { padding-left: var(--space-6); margin: 0 0 var(--space-4); }
.schritt-liste li { margin-bottom: var(--space-3); }
.schritt-liste .kopierfeld__reihe { margin-top: var(--space-2); }

.tag-liste { list-style: none; margin: 0; padding: 0; }

.tag {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    padding: var(--space-3) 0;
    border-bottom: 1px solid var(--hairline);
}
.tag__body { flex: 1; min-width: 0; }
.tag__name { margin: 0 0 var(--space-1); font-weight: 600; }
.tag__meta { margin: 0; font-size: var(--text-xs); color: var(--ink-muted); }
.tag--widerrufen .tag__name a { color: var(--ink-muted); }
.tag--widerrufen .habit-dot { opacity: 0.4; }

.protokoll-liste {
    list-style: none;
    margin: 0 0 var(--space-3);
    padding: 0;
    font-size: var(--text-sm);
}
.protokoll-liste li {
    display: flex;
    gap: var(--space-4);
    padding: var(--space-1) 0;
    border-bottom: 1px solid var(--hairline);
}
.protokoll-liste li span:first-child { color: var(--ink-muted); flex: 0 0 8.5rem; }

/* ============================================================================
   Tagebuch
   ========================================================================= */

/*
 * Das Schreibfeld sieht bewusst anders aus als der Rest der App: Serif,
 * 18px, viel Raum. Es soll sich beim Tippen wie Schreiben anfühlen, nicht
 * wie Formularausfüllen (Kapitel 9.2).
 */
.tagebuch {
    margin-top: var(--space-10);
    padding-top: var(--space-6);
    border-top: 1px solid var(--hairline);
}
.tagebuch__titel { font-size: var(--text-md); margin-bottom: var(--space-3); }
.tagebuch__form { margin: 0; }

.tagebuch textarea {
    font-family: var(--font-serif);
    font-size: 18px;
    line-height: 1.6;
    padding: var(--space-3);
    border-color: var(--hairline);
    background: var(--surface);
}
.tagebuch textarea:focus { border-color: var(--dot); }
.tagebuch textarea::placeholder { color: var(--ink-muted); opacity: 0.7; }

.tagebuch__fuss {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    margin-top: var(--space-2);
}
.tagebuch__status {
    font-size: var(--text-xs);
    color: var(--ink-muted);
    min-height: 1.2em;
}

.an-diesem-tag {
    margin-top: var(--space-10);
    padding-top: var(--space-6);
    border-top: 1px solid var(--hairline);
}
.an-diesem-tag h2 { font-size: var(--text-md); }

.rueckblick { list-style: none; margin: 0; padding: 0; }
.rueckblick li {
    display: flex;
    gap: var(--space-3);
    align-items: baseline;
    padding: var(--space-2) 0;
    border-bottom: 1px solid var(--hairline);
}
.rueckblick__jahr {
    flex: 0 0 auto;
    font-size: var(--text-sm);
    color: var(--ink-muted);
    text-decoration: none;
}
.rueckblick__jahr:hover { color: var(--ink); }
.rueckblick__text { font-family: var(--font-serif); }

.tagebuch-monat { margin-bottom: var(--space-10); }
.tagebuch-monat__titel {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--space-3);
    font-size: var(--text-md);
    padding-bottom: var(--space-2);
    border-bottom: 1px solid var(--hairline);
}
.tagebuch-monat__anzahl { font-size: var(--text-xs); color: var(--ink-muted); font-weight: 400; }

.tagebuch-liste { list-style: none; margin: 0; padding: 0; }

.tagebuch-zeile {
    display: flex;
    gap: var(--space-4);
    align-items: baseline;
    padding: var(--space-3) 0;
    border-bottom: 1px solid var(--hairline);
}

.tagebuch-zeile__datum {
    flex: 0 0 3rem;
    text-decoration: none;
    color: var(--ink-muted);
    text-align: right;
}
.tagebuch-zeile__datum:hover { color: var(--ink); }
.tagebuch-zeile__tag { font-size: var(--text-md); }
.tagebuch-zeile__wochentag { display: block; font-size: 10px; }

.tagebuch-zeile__text {
    margin: 0;
    font-family: var(--font-serif);
    font-size: 18px;
    line-height: 1.5;
}

.export-knoepfe {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
}

/* ============================================================================
   Updater
   ========================================================================= */

.schritt-fortschritt {
    list-style: none;
    margin: var(--space-6) 0;
    padding: 0;
    font-size: var(--text-sm);
}
.schritt-fortschritt li {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) 0;
    color: var(--ink-muted);
}
.schritt-fortschritt__zeichen {
    flex: 0 0 auto;
    width: 18px;
    height: 18px;
    border: 1.5px solid var(--dot);
    border-radius: 50%;
    position: relative;
}
.schritt-fortschritt .erledigt { color: var(--ink); }
.schritt-fortschritt .erledigt .schritt-fortschritt__zeichen {
    border-color: #3F6B4A;
    background: #3F6B4A;
}
.schritt-fortschritt .erledigt .schritt-fortschritt__zeichen::after {
    content: "";
    position: absolute;
    left: 5px; top: 2px;
    width: 4px; height: 8px;
    border: solid #FFF;
    border-width: 0 1.5px 1.5px 0;
    transform: rotate(45deg);
}
.schritt-fortschritt .aktiv { color: var(--ink); font-weight: 600; }
.schritt-fortschritt .aktiv .schritt-fortschritt__zeichen { border-color: var(--ink); }
.schritt-fortschritt .laeuft .schritt-fortschritt__zeichen {
    border-color: var(--ink);
    border-right-color: transparent;
    animation: dreht 900ms linear infinite;
}
@keyframes dreht { to { transform: rotate(360deg); } }

.dateiliste { margin-bottom: var(--space-3); font-size: var(--text-sm); }
.dateiliste summary { cursor: pointer; color: var(--ink-muted); padding: var(--space-1) 0; }
.dateiliste summary:hover { color: var(--ink); }
.dateiliste ul {
    margin: var(--space-2) 0 0;
    padding-left: var(--space-6);
    font-size: var(--text-xs);
    max-height: 16rem;
    overflow-y: auto;
}

.protokoll {
    list-style: none;
    margin: 0 0 var(--space-4);
    padding: var(--space-3) var(--space-4);
    background: var(--surface);
    border: 1px solid var(--hairline);
    border-radius: var(--radius);
    font-size: var(--text-sm);
}
.protokoll:empty { display: none; }
.protokoll li { padding: 2px 0; }
.protokoll li::before { content: "· "; color: var(--ink-muted); }

input[type="file"] {
    width: 100%;
    padding: var(--space-2);
    font: inherit;
    font-size: var(--text-sm);
    border: 1px dashed var(--dot);
    border-radius: var(--radius);
    background: var(--surface);
}

/* ============================================================================
   Notizen
   ========================================================================= */

.suchleiste {
    display: flex;
    gap: var(--space-2);
    margin-bottom: var(--space-6);
}
.suchleiste input { flex: 1; min-width: 0; }

.tag-wolke {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    margin-bottom: var(--space-6);
}

.tag-chip {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: 2px var(--space-2);
    font-size: var(--text-xs);
    color: var(--ink-muted);
    border: 1px solid var(--hairline);
    border-radius: var(--radius);
    text-decoration: none;
}
.tag-chip:hover { border-color: var(--dot); color: var(--ink); }
.tag-chip--aktiv { border-color: var(--ink); color: var(--ink); }
.tag-chip--klein { margin-left: var(--space-1); }

.notiz-liste { list-style: none; margin: 0; padding: 0; }

.notiz {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    padding: var(--space-3) 0;
    border-bottom: 1px solid var(--hairline);
}
.notiz__body { flex: 1; min-width: 0; }
.notiz__titel { margin: 0 0 var(--space-1); font-weight: 600; }
.notiz__titel a { text-decoration: none; }
.notiz__titel a:hover { text-decoration: underline; }
.notiz__pin { color: var(--ink-muted); font-size: var(--text-xs); }
.notiz__vorschau {
    margin: 0 0 var(--space-1);
    font-family: var(--font-serif);
    color: var(--ink-muted);
    font-size: var(--text-sm);
}
.notiz__meta { margin: 0; font-size: var(--text-xs); color: var(--ink-muted); }
.notiz--gepinnt .notiz__titel { color: var(--ink); }

/* Der gerenderte Markdown-Text – Serif wie das Tagebuch, aus demselben Grund. */
.notiz-inhalt {
    font-family: var(--font-serif);
    font-size: 18px;
    line-height: 1.6;
}
.notiz-inhalt h1, .notiz-inhalt h2, .notiz-inhalt h3 {
    font-family: var(--font-sans);
    margin-top: var(--space-6);
}
.notiz-inhalt h1 { font-size: var(--text-lg); }
.notiz-inhalt h2 { font-size: var(--text-md); }
.notiz-inhalt h3 { font-size: var(--text-sm); text-transform: uppercase; letter-spacing: 0.04em; }
.notiz-inhalt code {
    font-family: var(--font-mono);
    font-size: 0.85em;
    background: var(--surface);
    border: 1px solid var(--hairline);
    border-radius: 4px;
    padding: 1px 4px;
}
.notiz-inhalt pre {
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    background: var(--surface);
    border: 1px solid var(--hairline);
    border-radius: var(--radius);
    padding: var(--space-3);
    overflow-x: auto;
}
.notiz-inhalt pre code { border: 0; padding: 0; background: none; }
.notiz-inhalt blockquote {
    margin: var(--space-4) 0;
    padding-left: var(--space-4);
    border-left: 3px solid var(--dot);
    color: var(--ink-muted);
}
.notiz-inhalt table { border-collapse: collapse; width: 100%; font-family: var(--font-sans); font-size: var(--text-sm); }
.notiz-inhalt th, .notiz-inhalt td { text-align: left; padding: var(--space-2); border-bottom: 1px solid var(--hairline); }
.notiz-inhalt hr { border: 0; border-top: 1px solid var(--hairline); margin: var(--space-6) 0; }

/* ============================================================================
   Statistik
   ========================================================================= */

.section--ohne-linie { border-top: 0; padding-top: 0; }

.statistik-block h2 {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--text-md);
}

.kennzahlen {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(6rem, 1fr));
    gap: var(--space-4);
    margin-bottom: var(--space-6);
}
.kennzahl { display: flex; flex-direction: column; gap: 2px; }
.kennzahl__wert { font-size: var(--text-xl); line-height: 1; }
.kennzahl__name { font-size: var(--text-xs); color: var(--ink-muted); }

/*
 * Die Balkenhöhe steht in Pixeln, nicht in Prozent: In einer Flex-Spalte
 * mit zwei Textzeilen darunter löst sich eine Prozenthöhe gegen die falsche
 * Bezugsgröße auf, und dann sehen 18 und 23 gleich aus.
 */
.wochentage {
    display: flex;
    gap: var(--space-2);
    align-items: flex-end;
}
.wochentag {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    gap: 2px;
}
.wochentag__balken {
    width: 100%;
    background: var(--habit-color, var(--ink));
    border-radius: var(--radius-cell) var(--radius-cell) 0 0;
    opacity: 0.85;
}
.balken--0  { height: 2px; opacity: 0.25; }
.balken--1  { height: 8px; }
.balken--2  { height: 16px; }
.balken--3  { height: 24px; }
.balken--4  { height: 32px; }
.balken--5  { height: 40px; }
.balken--6  { height: 48px; }
.balken--7  { height: 56px; }
.balken--8  { height: 64px; }
.balken--9  { height: 72px; }
.balken--10 { height: 80px; }
.wochentag__zahl { font-size: var(--text-xs); color: var(--ink-muted); }
.wochentag__name { font-size: var(--text-xs); color: var(--ink-muted); }

/* Jahres-Heatmap: dieselbe Idee wie das Monatsraster, nur aus der Entfernung. */
.heatmap {
    display: grid;
    grid-template-rows: repeat(7, 11px);
    grid-auto-flow: column;
    grid-auto-columns: 11px;
    gap: 2px;
    width: max-content;
    padding-bottom: var(--space-2);
}
.heat {
    width: 11px;
    height: 11px;
    border-radius: var(--radius-cell);
    background: var(--hairline);
    display: block;
}
.heat--leer { background: transparent; }
.heat--0 { background: var(--hairline); }
.heat--1 { background: color-mix(in srgb, var(--heat) 25%, var(--hairline)); }
.heat--2 { background: color-mix(in srgb, var(--heat) 50%, var(--hairline)); }
.heat--3 { background: color-mix(in srgb, var(--heat) 75%, var(--hairline)); }
.heat--4 { background: var(--heat); }

.heat-legende {
    display: flex;
    align-items: center;
    gap: 3px;
    font-size: var(--text-xs);
    color: var(--ink-muted);
}
.heat-legende .heat { display: inline-block; }

/* ============================================================================
   Stimmung und Sammelseite
   ========================================================================= */

.stimmung {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-1);
    border: 0;
    padding: 0;
    margin: var(--space-2) 0 0;
}
.stimmung__wahl { margin: 0; font-weight: 400; }
.stimmung__wahl input {
    position: absolute;
    opacity: 0;
    width: 1px; height: 1px;
}
.stimmung__wahl span {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    font-size: var(--text-sm);
    color: var(--ink-muted);
    border: 1px solid var(--hairline);
    border-radius: var(--radius);
    cursor: pointer;
}
.stimmung__wahl:has(input:checked) span {
    background: var(--ink);
    color: var(--paper);
    border-color: var(--ink);
}
.stimmung__wahl:has(input:focus-visible) span { outline: 2px solid var(--ink); outline-offset: 2px; }
.stimmung__hinweis { margin-left: var(--space-2); }

.mehr-liste { list-style: none; margin: 0; padding: 0; }
.mehr-liste li { border-bottom: 1px solid var(--hairline); }
.mehr-liste a {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: var(--space-4) 0;
    min-height: var(--tap-min);
    text-decoration: none;
}
.mehr-liste a:hover .mehr-liste__titel { text-decoration: underline; }
.mehr-liste__titel { font-weight: 600; }
.mehr-liste__meta { font-size: var(--text-sm); color: var(--ink-muted); }
