/* Eierzähler – Legebuch
   Schriften: Fraunces & Atkinson Hyperlegible (beide SIL Open Font License), lokal eingebunden. */

@font-face {
    font-family: 'Fraunces';
    src: url('fonts/fraunces.woff2') format('woff2');
    font-weight: 100 900;
    font-display: swap;
}
@font-face {
    font-family: 'Atkinson';
    src: url('fonts/atkinson-400.woff2') format('woff2');
    font-weight: 400;
    font-display: swap;
}
@font-face {
    font-family: 'Atkinson';
    src: url('fonts/atkinson-700.woff2') format('woff2');
    font-weight: 700;
    font-display: swap;
}

/* ---------- Farben & Grundwerte ---------- */

:root {
    color-scheme: light;

    --papier: #f3ecdd;
    --karte: #fffaf1;
    --karte-2: #f7efe0;
    --tinte: #2a241b;
    --tinte-2: #6c604e;
    --tinte-3: #9b8e78;
    --linie: #e6dac4;
    --linie-stark: #cdbc9d;

    --dotter: #f2aa1f;
    --dotter-kante: #c98608;
    --dotter-hell: #fcebc0;
    --dotter-text: #8a5600;
    --kamm: #b53b25;
    --kamm-hell: #f8e1d8;
    --gruen: #4a6a31;

    --karton: #dcc9a6;
    --karton-mulde: #c9b28a;
    --karton-tief: #b29973;
    --karton-kante: #c3ab83;

    --stufe-0: #e9dfcb;
    --stufe-1: #f8dfa0;
    --stufe-2: #f3c35a;
    --stufe-3: #e39c14;
    --stufe-4: #a66300;

    --schatten: 0 1px 0 rgb(80 55 20 / 0.05), 0 10px 30px -18px rgb(80 55 20 / 0.45);
    --radius: 20px;

    --serif: 'Fraunces', 'Iowan Old Style', Georgia, serif;
    --sans: 'Atkinson', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --mono: ui-monospace, 'SF Mono', Consolas, 'Courier New', monospace;
}

@media (prefers-color-scheme: dark) {
    :root {
        color-scheme: dark;

        --papier: #1b1813;
        --karte: #25211a;
        --karte-2: #2e2920;
        --tinte: #f3eadb;
        --tinte-2: #bdb098;
        --tinte-3: #8b7f6a;
        --linie: #3a3329;
        --linie-stark: #51473a;

        --dotter: #f5b42e;
        --dotter-kante: #b57a0c;
        --dotter-hell: #3f3218;
        --dotter-text: #f6c45c;
        --kamm: #ec735c;
        --kamm-hell: #3b221b;
        --gruen: #9cc174;

        --karton: #5d4f3c;
        --karton-mulde: #4b4031;
        --karton-tief: #3b3227;
        --karton-kante: #6a5b46;

        --stufe-0: #3a3329;
        --stufe-1: #5b4518;
        --stufe-2: #8e6614;
        --stufe-3: #cc8f17;
        --stufe-4: #f7bb3a;

        --schatten: 0 1px 0 rgb(0 0 0 / 0.2), 0 12px 30px -18px rgb(0 0 0 / 0.8);
    }
}

/* ---------- Grundlagen ---------- */

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

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

body {
    margin: 0;
    background-color: var(--papier);
    /* feines Papierkorn */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .45 0 0 0 0 .33 0 0 0 0 .15 0 0 0 .07 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    color: var(--tinte);
    font: 400 1.0625rem/1.5 var(--sans);
    -webkit-font-smoothing: antialiased;
}

button, input, textarea, select { font: inherit; color: inherit; }
button { -webkit-tap-highlight-color: transparent; }

:focus-visible {
    outline: 3px solid var(--dotter);
    outline-offset: 2px;
}

.sr-only {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0);
    white-space: nowrap; border: 0;
}

.leise { color: var(--tinte-2); font-size: 0.9rem; }

[hidden] { display: none !important; }

/* ---------- Seitengerüst ---------- */

.seite {
    max-width: 1180px;
    margin: 0 auto;
    padding: max(12px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) calc(40px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}

.kopf {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 2px 14px;
    margin-bottom: 20px;
    border-bottom: 4px double var(--tinte);
}

.kicker {
    margin: 0 0 8px;
    font-weight: 700;
    font-size: 0.78rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--dotter-text);
}

h1 {
    margin: 0;
    font-family: var(--serif);
    font-weight: 800;
    font-size: clamp(2.7rem, 11vw, 4.6rem);
    line-height: 0.9;
    letter-spacing: -0.025em;
    font-variation-settings: "SOFT" 100, "WONK" 1, "opsz" 144;
}

.kopf-datum {
    margin: 10px 0 0;
    color: var(--tinte-2);
}

/* Huhn im Kopf */
.huhn {
    flex: none;
    width: clamp(88px, 24vw, 140px);
    height: auto;
    margin-bottom: -6px;
    overflow: visible;
}
.huhn-koerper { fill: #b9652c; }
.huhn-fluegel { fill: #8f4419; }
.huhn-schwanz { fill: #5d2a12; }
.huhn-kamm, .huhn-kehllappen { fill: #cf3b24; }
.huhn-schnabel { fill: var(--dotter); }
.huhn-auge { fill: #1d140b; }
.huhn-bein { fill: none; stroke: #d89a2b; stroke-width: 4; stroke-linecap: round; }

@media (prefers-reduced-motion: no-preference) {
    .huhn { transform-origin: 60% 95%; animation: picken 7s ease-in-out infinite; }
}
@keyframes picken {
    0%, 82%, 100% { transform: rotate(0deg); }
    86% { transform: rotate(6deg); }
    90% { transform: rotate(0deg); }
    94% { transform: rotate(6deg); }
}

.raster { display: grid; gap: 16px; }
.spalte { display: grid; gap: 16px; align-content: start; min-width: 0; }

@media (min-width: 960px) {
    .raster {
        grid-template-columns: minmax(360px, 420px) minmax(0, 1fr);
        gap: 24px;
        align-items: start;
    }
    .spalte { gap: 24px; }
}

.fuss {
    margin-top: 32px;
    text-align: center;
    font-size: 0.85rem;
}
.fuss a { color: var(--tinte-3); text-decoration: none; }
.fuss a:hover { color: var(--tinte); }

/* ---------- Karten ---------- */

.karte {
    min-width: 0;
    background: var(--karte);
    border: 1px solid var(--linie);
    border-radius: var(--radius);
    box-shadow: var(--schatten);
    padding: 20px;
}
@media (max-width: 420px) {
    .karte { padding: 16px; }
}

.karten-kopf {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px 12px;
    margin-bottom: 14px;
}

.titel {
    margin: 0;
    font-family: var(--serif);
    font-weight: 650;
    font-size: 1.5rem;
    line-height: 1.1;
    letter-spacing: -0.01em;
    font-variation-settings: "SOFT" 60, "opsz" 48;
}
section > .titel { margin-bottom: 14px; }

/* ---------- Knöpfe & Felder ---------- */

.knopf {
    appearance: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 48px;
    padding: 12px 18px;
    border: 1.5px solid var(--tinte);
    border-radius: 14px;
    background: transparent;
    color: var(--tinte);
    font-weight: 700;
    font-size: 1rem;
    line-height: 1.1;
    text-decoration: none;
    cursor: pointer;
    touch-action: manipulation;
    transition: transform 0.08s ease, background-color 0.15s ease;
}
.knopf:hover { background: var(--karte-2); }
.knopf:active { transform: translateY(1px); }
.knopf:disabled { opacity: 0.45; cursor: not-allowed; }

.knopf-haupt {
    width: 100%;
    min-height: 60px;
    border: 0;
    background: var(--dotter);
    color: #2b1c03;
    font-size: 1.15rem;
    box-shadow: 0 3px 0 var(--dotter-kante);
}
.knopf-haupt:hover { background: #f5b434; }
.knopf-haupt:active { transform: translateY(3px); box-shadow: 0 0 0 var(--dotter-kante); }
.knopf-haupt[aria-busy="true"] { opacity: 0.7; }

.knopf-leise {
    border-color: var(--linie-stark);
    color: var(--tinte);
}

.knopf-gefahr {
    background: var(--kamm);
    border-color: var(--kamm);
    color: #fff;
}
.knopf-gefahr:hover { background: var(--kamm); filter: brightness(1.08); }

.knopf-gefahr-leise {
    border-color: transparent;
    color: var(--kamm);
}
.knopf-gefahr-leise:hover { background: var(--kamm-hell); }

.textknopf {
    appearance: none;
    padding: 0;
    border: 0;
    background: none;
    color: var(--dotter-text);
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 3px;
    cursor: pointer;
}

.chip {
    appearance: none;
    display: inline-flex;
    align-items: center;
    min-height: 42px;
    padding: 8px 14px;
    border: 1.5px solid var(--linie-stark);
    border-radius: 999px;
    background: transparent;
    color: var(--tinte);
    font-weight: 700;
    font-size: 0.95rem;
    line-height: 1.1;
    cursor: pointer;
    touch-action: manipulation;
}
.chip:hover { border-color: var(--tinte-2); }
.chip[aria-pressed="true"], .chip.aktiv {
    background: var(--tinte);
    border-color: var(--tinte);
    color: var(--karte);
}
.chip-klein {
    min-height: 34px;
    padding: 5px 11px;
    font-size: 0.85rem;
    font-weight: 400;
}

textarea,
.feld input,
.einst-form input,
.loeschen-form input,
#pin-eingabe {
    width: 100%;
    padding: 12px 14px;
    border: 1.5px solid var(--linie-stark);
    border-radius: 12px;
    background: var(--karte);
    color: var(--tinte);
}
textarea { resize: vertical; min-height: 64px; }
textarea:focus, input:focus { border-color: var(--tinte-2); }

input[type="number"] { -moz-appearance: textfield; appearance: textfield; }
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

.feld { display: grid; gap: 6px; }
.feld > span { font-weight: 700; font-size: 0.9rem; color: var(--tinte-2); }

/* ---------- Heute / Eintragen ---------- */

.stempel {
    padding: 5px 8px 4px;
    border: 2px solid currentColor;
    border-radius: 6px;
    color: var(--kamm);
    font: 700 0.85rem/1 var(--mono);
    letter-spacing: 0.08em;
    transform: rotate(-5deg);
    opacity: 0.85;
}

.karton-buehne {
    display: grid;
    justify-items: center;
    gap: 6px;
    margin: 2px 0 0;
}
.karton { display: block; width: 100%; max-width: 340px; height: auto; }
.karton-rest {
    font-family: var(--serif);
    font-weight: 700;
    color: var(--tinte-2);
}

.karton .tablett { fill: var(--karton); }
.karton .rand { fill: none; stroke: var(--karton-kante); stroke-width: 2; }
.karton .mulde { fill: var(--karton-mulde); }
.karton .mulde-tief { fill: var(--karton-tief); }
.karton .zapfen { fill: var(--karton); stroke: var(--karton-kante); stroke-width: 1.5; }
.karton .ei-glanz { fill: #fff; opacity: 0.55; }
.karton .ei-schatten { fill: #000; opacity: 0.12; }
.karton .ei-geist {
    fill: var(--karte);
    fill-opacity: 0.45;
    stroke: var(--tinte-2);
    stroke-width: 2;
    stroke-dasharray: 4 4;
}

@media (prefers-reduced-motion: no-preference) {
    .karton .ei.neu {
        transform-box: fill-box;
        transform-origin: 50% 80%;
        animation: ei-rein 0.5s cubic-bezier(.3, 1.6, .5, 1) both;
    }
    .karton .ei-geist { animation: geist-puls 1.6s ease-in-out infinite; }
}
@keyframes ei-rein {
    from { transform: translateY(-26px) scale(0.6); opacity: 0; }
    to { transform: none; opacity: 1; }
}
@keyframes geist-puls {
    50% { fill-opacity: 0.15; }
}

.tages-summe {
    margin: 4px 0 18px;
    text-align: center;
    color: var(--tinte-2);
}
.tages-summe strong {
    font-family: var(--serif);
    font-size: 1.7rem;
    font-weight: 700;
    color: var(--tinte);
    font-variation-settings: "opsz" 72;
}

.tag-wahl {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 14px;
}
.chip-datum {
    flex: 1 1 140px;
    padding: 0 6px 0 12px;
    cursor: pointer;
}
.chip-datum input {
    width: 100%;
    min-height: 38px;
    border: 0;
    background: transparent;
    color: inherit;
    font-weight: 700;
    cursor: pointer;
}
.chip-datum input::-webkit-calendar-picker-indicator { cursor: pointer; opacity: 0.6; }
.chip-datum.aktiv input::-webkit-calendar-picker-indicator { filter: invert(1); }
@media (prefers-color-scheme: dark) {
    .chip-datum input::-webkit-calendar-picker-indicator { filter: invert(1); }
    .chip-datum.aktiv input::-webkit-calendar-picker-indicator { filter: none; }
}

.stepper {
    display: grid;
    grid-template-columns: 68px minmax(0, 1fr) 68px;
    align-items: center;
    gap: 8px;
    padding: 8px;
    border: 1px solid var(--linie);
    border-radius: 22px;
    background: var(--karte-2);
}
.stepper-knopf {
    appearance: none;
    width: 68px;
    height: 68px;
    border: 0;
    border-radius: 16px;
    background: var(--karte);
    box-shadow: inset 0 0 0 1.5px var(--linie-stark), 0 2px 0 var(--linie-stark);
    color: var(--tinte);
    font: 500 2.2rem/1 var(--serif);
    cursor: pointer;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
}
.stepper-knopf:active {
    transform: translateY(2px);
    box-shadow: inset 0 0 0 1.5px var(--dotter-kante);
    background: var(--dotter-hell);
}
.stepper-wert {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 6px;
    min-width: 0;
    cursor: text;
}
.stepper-wert input {
    width: 2.6ch;
    min-width: 0;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--tinte);
    text-align: right;
    font: 700 3.1rem/1 var(--serif);
    font-variation-settings: "opsz" 144, "SOFT" 100;
    font-variant-numeric: lining-nums tabular-nums;
}
.stepper-wert input:focus { outline: none; }
.stepper:focus-within { border-color: var(--tinte-2); }
.stepper-einheit { color: var(--tinte-2); font-weight: 700; }

.schon-da {
    margin: 10px 4px 0;
    color: var(--tinte-2);
    font-size: 0.92rem;
}

.notiz { margin: 14px 0 16px; }
.notiz summary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
    color: var(--tinte-2);
    font-weight: 700;
    cursor: pointer;
    list-style: none;
}
.notiz summary::-webkit-details-marker { display: none; }
.notiz summary::before {
    content: "+";
    display: grid;
    place-items: center;
    width: 22px;
    height: 22px;
    border: 1.5px solid var(--linie-stark);
    border-radius: 50%;
    font-size: 1rem;
    line-height: 1;
}
.notiz[open] summary::before { content: "–"; }
.notiz textarea { margin-top: 8px; }
.notiz-vorschlaege {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.luecken {
    margin-top: 16px;
    padding: 12px 14px;
    border-radius: 14px;
    background: var(--dotter-hell);
    font-size: 0.95rem;
}
.luecken p { margin: 0 0 8px; }
.luecken-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.luecken .chip { background: var(--karte); border-color: transparent; min-height: 36px; padding: 6px 12px; font-size: 0.88rem; }

/* ---------- Bilanz ---------- */

.bilanz-liste { margin: 0; }
.bilanz-zeile {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: baseline;
    column-gap: 10px;
    padding: 9px 0;
}
.bilanz-zeile dt {
    display: flex;
    align-items: baseline;
    gap: 10px;
    min-width: 0;
    font-weight: 700;
}
.bilanz-zeile dt::after {
    content: "";
    flex: 1;
    min-width: 12px;
    border-bottom: 2px dotted var(--linie-stark);
    transform: translateY(-5px);
}
.bilanz-zeile .wert {
    margin: 0;
    font: 700 1.65rem/1 var(--serif);
    font-variant-numeric: lining-nums tabular-nums;
    font-variation-settings: "opsz" 72;
}
.bilanz-zeile .vergleich {
    grid-column: 1 / -1;
    margin: 3px 0 0;
    color: var(--tinte-2);
    font-size: 0.86rem;
}
.vergleich .mehr { color: var(--gruen); font-weight: 700; }
.vergleich .weniger { color: var(--tinte-2); font-weight: 700; }

.kennzahlen {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin-top: 14px;
    border: 1px solid var(--linie);
    border-radius: 14px;
    background: var(--karte-2);
    overflow: hidden;
}
.kennzahl {
    padding: 12px 12px 11px;
    min-width: 0;
}
.kennzahl + .kennzahl { border-left: 1px solid var(--linie); }
.kennzahl b {
    display: block;
    font: 700 clamp(1.15rem, 5vw, 1.4rem)/1.1 var(--serif);
    font-variant-numeric: lining-nums;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.kennzahl span {
    display: block;
    margin-top: 3px;
    color: var(--tinte-2);
    font-size: 0.78rem;
    line-height: 1.25;
}
.kennzahl .textknopf { font-size: 0.85rem; }

/* ---------- Rekorde ---------- */

.rekord-liste { list-style: none; margin: 0; padding: 0; }
.rekord {
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    padding: 11px 0;
}
.rekord + .rekord { border-top: 1px solid var(--linie); }
.rekord-symbol {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: var(--dotter-hell);
    color: var(--dotter-text);
}
.rekord-symbol svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.rekord-text { min-width: 0; }
.rekord-text b { display: block; }
.rekord-text span { display: block; color: var(--tinte-2); font-size: 0.88rem; }
.rekord-wert {
    font: 700 1.45rem/1 var(--serif);
    font-variant-numeric: lining-nums;
    text-align: right;
}
.rekord-wert small { font: 400 0.8rem var(--sans); color: var(--tinte-2); margin-left: 2px; }

.leer-hinweis { margin: 0; color: var(--tinte-2); }

/* ---------- Verlauf ---------- */

.umschalter {
    display: inline-flex;
    padding: 3px;
    border: 1px solid var(--linie);
    border-radius: 12px;
    background: var(--karte-2);
}
.umschalter button {
    appearance: none;
    padding: 7px 11px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: var(--tinte-2);
    font-weight: 700;
    font-size: 0.85rem;
    line-height: 1.1;
    cursor: pointer;
}
.umschalter button[aria-pressed="true"] {
    background: var(--karte);
    color: var(--tinte);
    box-shadow: 0 1px 2px rgb(0 0 0 / 0.14), inset 0 0 0 1px var(--linie);
}

.diagramm {
    position: relative;
    height: 240px;
    touch-action: pan-y;
    user-select: none;
    -webkit-user-select: none;
}
.diagramm svg { display: block; overflow: visible; }
.diagramm .gitter { stroke: var(--linie); stroke-width: 1; }
.diagramm .grundlinie { stroke: var(--linie-stark); stroke-width: 1.5; }
.diagramm .achse { fill: var(--tinte-3); font: 400 11.5px var(--sans); }
.diagramm .balken { fill: var(--dotter); transition: fill 0.12s ease; }
.diagramm .balken.aktuell { fill: var(--stufe-3); }
.diagramm .balken.null { fill: var(--tinte-3); }
.diagramm .geist { fill: none; stroke: var(--tinte-3); stroke-width: 1.5; stroke-dasharray: 3 3; }
.diagramm .schnitt { fill: none; stroke: var(--tinte); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.diagramm .markiert .balken { fill: var(--dotter-kante); }
.diagramm .markierung { fill: var(--tinte); opacity: 0.06; }

.tooltip {
    position: absolute;
    z-index: 2;
    padding: 6px 10px;
    border-radius: 8px;
    background: var(--tinte);
    color: var(--karte);
    font-size: 0.85rem;
    line-height: 1.3;
    white-space: nowrap;
    pointer-events: none;
    transform: translate(-50%, calc(-100% - 8px));
}
.tooltip b { font-weight: 700; }

.diagramm-legende {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 16px;
    margin: 10px 0 0;
    color: var(--tinte-2);
    font-size: 0.85rem;
}
.diagramm-legende .muster {
    display: inline-block;
    width: 12px;
    height: 12px;
    margin-right: 6px;
    border-radius: 3px;
    vertical-align: -1px;
}
.muster.balken { background: var(--dotter); }
.muster.linie { height: 3px; border-radius: 2px; background: var(--tinte); vertical-align: 3px; }
.muster.geist { border: 1.5px dashed var(--tinte-3); }
.diagramm-legende .summe { margin-left: auto; color: var(--tinte); font-weight: 700; }

/* ---------- Legekalender ---------- */

.jahr-wahl {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-family: var(--serif);
    font-weight: 700;
    font-size: 1.1rem;
}
.pfeil {
    appearance: none;
    width: 36px;
    height: 36px;
    border: 1.5px solid var(--linie-stark);
    border-radius: 10px;
    background: transparent;
    color: var(--tinte);
    font-size: 1.3rem;
    line-height: 1;
    cursor: pointer;
}
.pfeil:disabled { opacity: 0.3; cursor: default; }

.kalender-raster {
    display: grid;
    grid-template-columns: 2.3em repeat(31, minmax(0, 1fr));
    gap: 2px;
    font-size: 0.72rem;
    touch-action: pan-y;
    user-select: none;
    -webkit-user-select: none;
}
@media (min-width: 600px) {
    .kalender-raster { gap: 3px; }
}
.kal-zahl {
    color: var(--tinte-3);
    text-align: center;
    font-size: 0.66rem;
    line-height: 1.6;
}
.kal-monat {
    align-self: center;
    color: var(--tinte-2);
    font-weight: 700;
    line-height: 1;
}
.kal-tag {
    aspect-ratio: 1;
    border-radius: 3px;
    background: transparent;
}
.kal-tag.leer { box-shadow: inset 0 0 0 1px var(--linie-stark); opacity: 0.7; }
.kal-tag.zukunft { box-shadow: inset 0 0 0 1px var(--linie); opacity: 0.45; }
.kal-tag.s0 { background: var(--stufe-0); }
.kal-tag.s1 { background: var(--stufe-1); }
.kal-tag.s2 { background: var(--stufe-2); }
.kal-tag.s3 { background: var(--stufe-3); }
.kal-tag.s4 { background: var(--stufe-4); }
.kal-tag.heute { box-shadow: 0 0 0 2px var(--tinte); }
.kal-tag.gewaehlt { box-shadow: 0 0 0 2px var(--kamm); opacity: 1; }
.kal-tag:not(.nix):not(.zukunft) { cursor: pointer; }

.kalender-fuss {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px 16px;
    margin-top: 14px;
}
.kalender-info {
    margin: 0;
    min-height: 1.5em;
    color: var(--tinte-2);
    font-size: 0.92rem;
}
.kalender-info b { color: var(--tinte); }
.kalender-info .textknopf { margin-left: 6px; }
.skala {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    color: var(--tinte-3);
    font-size: 0.78rem;
}
.skala span { margin: 0 4px; }
.skala i { width: 12px; height: 12px; border-radius: 3px; }
.skala .s0 { background: var(--stufe-0); }
.skala .s1 { background: var(--stufe-1); }
.skala .s2 { background: var(--stufe-2); }
.skala .s3 { background: var(--stufe-3); }
.skala .s4 { background: var(--stufe-4); }

/* ---------- Einträge ---------- */

.eintrag-liste { margin-top: -4px; }
.monat-kopf {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin: 18px 0 2px;
    padding-bottom: 6px;
    border-bottom: 2px solid var(--tinte);
    font-family: var(--serif);
    font-weight: 700;
    font-size: 1.1rem;
}
.monat-kopf:first-child { margin-top: 0; }
.monat-kopf span { font: 400 0.88rem var(--sans); color: var(--tinte-2); }

.eintrag-zeile {
    appearance: none;
    display: grid;
    grid-template-columns: 3.1em minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 10px 6px;
    border: 0;
    border-bottom: 1px solid var(--linie);
    background: none;
    color: inherit;
    text-align: left;
    cursor: pointer;
}
.eintrag-zeile:hover { background: var(--karte-2); }
.eintrag-zeile:disabled { cursor: default; }
.eintrag-tag {
    display: grid;
    justify-items: center;
    line-height: 1;
}
.eintrag-tag small {
    color: var(--tinte-2);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}
.eintrag-tag b {
    margin-top: 3px;
    font: 700 1.35rem/1 var(--serif);
    font-variant-numeric: lining-nums;
}
.eintrag-mitte { min-width: 0; }
.eintrag-notiz {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.eintrag-meta { display: block; color: var(--tinte-2); font-size: 0.84rem; }
.eintrag-anzahl {
    font: 700 1.3rem/1 var(--serif);
    font-variant-numeric: lining-nums;
    white-space: nowrap;
}
.eintrag-anzahl small { font: 400 0.82rem var(--sans); color: var(--tinte-2); margin-left: 3px; }
.abzeichen {
    display: inline-block;
    margin-left: 6px;
    padding: 2px 7px;
    border-radius: 999px;
    background: var(--kamm-hell);
    color: var(--kamm);
    font-size: 0.72rem;
    font-weight: 700;
    vertical-align: 1px;
}
#mehr-knopf { width: 100%; margin-top: 14px; }

/* ---------- Einstellungen ---------- */

.einstellungen > details > summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    cursor: pointer;
    list-style: none;
}
.einstellungen > details > summary::-webkit-details-marker { display: none; }
.einstellungen > details > summary::after {
    content: "";
    flex: none;
    width: 10px;
    height: 10px;
    border-right: 2px solid var(--tinte-2);
    border-bottom: 2px solid var(--tinte-2);
    transform: rotate(45deg) translateY(-3px);
    transition: transform 0.2s ease;
}
.einstellungen > details[open] > summary::after { transform: rotate(-135deg) translateY(-3px); }

.einst-form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px;
    margin-top: 18px;
    align-items: end;
}
.einst-form label { display: grid; gap: 6px; }
.einst-form label > span { font-weight: 700; }
.einst-form small { color: var(--tinte-2); font-size: 0.82rem; }
.einst-form .knopf { grid-column: 1 / -1; justify-self: start; }

.export, .gefahr {
    margin-top: 22px;
    padding-top: 18px;
    border-top: 1px solid var(--linie);
}
.export h3, .gefahr h3 {
    margin: 0 0 4px;
    font-family: var(--serif);
    font-size: 1.1rem;
}
.export p, .gefahr p { margin: 0 0 12px; color: var(--tinte-2); font-size: 0.95rem; }
.gefahr {
    padding: 16px;
    border: 1.5px dashed var(--kamm);
    border-radius: 14px;
    background: var(--kamm-hell);
}
.gefahr h3 { color: var(--kamm); }
.loeschen-form { display: flex; flex-wrap: wrap; gap: 10px; }
.loeschen-form input { flex: 1 1 160px; width: auto; letter-spacing: 0.1em; }

/* ---------- Dialoge ---------- */

dialog.blatt {
    width: min(480px, 100%);
    max-width: 100%;
    max-height: 92vh;
    margin: auto auto 0;
    padding: 0;
    border: 0;
    border-radius: 24px 24px 0 0;
    background: var(--karte);
    color: var(--tinte);
    box-shadow: 0 -12px 40px rgb(0 0 0 / 0.25);
}
@media (min-width: 600px) {
    dialog.blatt { margin: auto; border-radius: 24px; }
}
dialog.blatt::backdrop {
    background: rgb(30 22 10 / 0.5);
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
}
dialog.blatt form {
    display: grid;
    gap: 14px;
    padding: 20px 20px calc(20px + env(safe-area-inset-bottom));
}
dialog.blatt p { margin: 0; }
.blatt-klein { width: min(380px, 100%); }
.blatt-kopf {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.schliessen {
    appearance: none;
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 50%;
    background: var(--karte-2);
    color: var(--tinte-2);
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
}
.blatt-knoepfe {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 10px;
    margin-top: 4px;
}
.blatt-knoepfe .knopf-haupt { min-height: 52px; }
.fehler { color: var(--kamm); font-weight: 700; }

@media (prefers-reduced-motion: no-preference) {
    dialog.blatt[open] { animation: blatt-hoch 0.22s ease-out; }
}
@keyframes blatt-hoch {
    from { transform: translateY(24px); opacity: 0; }
}

/* ---------- Toast ---------- */

.toast {
    position: fixed;
    left: 16px;
    right: 16px;
    bottom: calc(18px + env(safe-area-inset-bottom));
    z-index: 50;
    display: flex;
    align-items: center;
    gap: 14px;
    width: fit-content;
    max-width: 560px;
    margin: 0 auto;
    padding: 12px 12px 12px 18px;
    border-radius: 14px;
    background: var(--tinte);
    color: var(--karte);
    box-shadow: 0 12px 30px rgb(0 0 0 / 0.28);
    transition: transform 0.25s ease, opacity 0.25s ease;
}
.toast.weg { opacity: 0; transform: translateY(20px); }
.toast button {
    flex: none;
    padding: 6px 10px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--dotter);
    font-weight: 700;
    cursor: pointer;
}
.toast button:hover { background: rgb(255 255 255 / 0.08); }
