/* ===========================================================================
   RecipeVault – Design-System

   Mobile first und app-artig: Die Seite selbst scrollt NIE. Die Hülle ist ein
   100dvh-Raster aus Kopf / Inhalt / Tab-Leiste; gescrollt wird ausschließlich
   innerhalb der Inhaltsfläche. Deshalb steht hier overflow:hidden am <body> –
   das ist Absicht, kein Versehen.

   Farben: warmes Dunkeloliv (#14180f / #202718 / #2b3320) als Grundfamilie,
   Basilikumgrün #8FCB5E als Akzent, Terrakotta #E2725B für Warnungen. Grün ist
   die eine Farbe, die neben fast jedem Essensfoto nicht streitet – und die
   Kachelwand dieser App besteht aus Essensfotos.

   Alle Paarungen sind gegen WCAG geprüft; die Werte stehen als Kommentar an den
   Tokens. Zwei Fallen, die dabei aufgefallen sind:
     - #3c4630 erreicht auf #14180f nur 1,8:1 -> ausschließlich Ränder, nie Text.
     - #8FCB5E erreicht auf Weiß nur 1,9:1 -> im hellen Theme braucht Akzenttext
       die abgedunkelte Variante; die Grünfläche bleibt mit dunkler Schrift.
   =========================================================================== */

@import url('../fonts/inter.css');

:root {
    /* --- Maße und Rhythmus (4/8-Raster) --- */
    --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px; --sp-4: 16px;
    --sp-5: 20px; --sp-6: 24px; --sp-8: 32px; --sp-12: 48px;

    --radius-sm: 10px;
    --radius:    14px;
    --radius-lg: 20px;
    --radius-xl: 28px;

    --tap: 44px;                       /* Mindestgröße für Tippziele */
    --tabbar-h: 60px;
    --topbar-h: 56px;

    --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;

    /* Bewegung: 150–300 ms mit plattformnaher Kurve. */
    --ease: cubic-bezier(.2, .8, .3, 1);
    --dur-fast: 140ms;
    --dur:      220ms;

    --z-sheet: 100;
    --z-toast: 200;
}

/* --- Dunkel (Standard) --- */
:root, :root[data-theme="dark"] {
    --bg:        #14180f;
    --bg-2:      #0d1009;   /* tiefer als bg: Vertiefungen, Eingabefelder */
    --surface:   #202718;   /* Karten, Listenzeilen, Rezeptkacheln */
    --surface-2: #2b3320;   /* gehobene Fläche, gedrückter Zustand */
    --border:    #3c4630;   /* NUR Ränder – als Text nur 1,8:1 */
    --text:      #F2F5EC;   /* 16,3:1 auf bg */
    --muted:     #A3AE96;   /*  7,8:1 auf bg */

    --accent:      #8FCB5E; /*  9,3:1 auf bg */
    --accent-fill: #8FCB5E;
    --accent-ink:  #14180f; /* Schrift auf Basilikumflächen, 9,3:1 */
    --accent-soft: rgba(143, 203, 94, .16);

    /* Erfolg ist hier derselbe Grünton wie der Akzent: Anders als bei einer
       Finanz-App gibt es nichts, was mit "gut" verwechselt werden könnte. */
    --pos: #8FCB5E;         /*  9,3:1 */
    --neg: #E2725B;         /*  5,8:1 – Terrakotta */
    --pos-soft: rgba(143, 203, 94, .14);
    --neg-soft: rgba(226, 114, 91, .14);

    --scrim:  rgba(8, 11, 6, .64);
    --shadow:    0 8px 24px -10px rgba(0, 0, 0, .6);
    --shadow-lg: 0 24px 56px -20px rgba(0, 0, 0, .7);
    --ring: rgba(143, 203, 94, .45);
}

/* --- Hell --- */
:root[data-theme="light"] {
    --bg:        #F7F8F3;
    --bg-2:      #ECEEE4;
    --surface:   #FFFFFF;
    --surface-2: #F2F4EC;
    --border:    #D8DCCC;
    --text:      #232a1c;   /* 13,9:1 auf bg */
    --muted:     #5C6652;   /*  5,7:1 auf bg */

    --accent:      #3F6D1F; /* 5,8:1 – Basilikum selbst schafft auf Weiß nur 1,9:1 */
    --accent-fill: #8FCB5E;
    --accent-ink:  #14180f;
    --accent-soft: rgba(143, 203, 94, .24);

    --pos: #3F6D1F;
    --neg: #A33B26;
    --pos-soft: rgba(63, 109, 31, .12);
    --neg-soft: rgba(163, 59, 38, .12);

    --scrim:  rgba(35, 42, 28, .48);
    --shadow:    0 8px 24px -12px rgba(35, 42, 28, .28);
    --shadow-lg: 0 24px 56px -22px rgba(35, 42, 28, .34);
    --ring: rgba(63, 109, 31, .35);
}

/* ===========================================================================
   Grundlagen
   =========================================================================== */

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

html {
    height: 100%;
    -webkit-tap-highlight-color: transparent;  /* kein blaues Tap-Blinken */
}

body {
    height: 100dvh;
    margin: 0;
    overflow: hidden;              /* die SEITE scrollt nie – nur Inhaltsflächen */
    overscroll-behavior: none;     /* kein Gummiband, das den Hintergrund freilegt */
    font-family: var(--font);
    font-size: 16px;               /* unter 16px zoomt iOS beim Fokus in ein Feld */
    line-height: 1.5;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}

/* Bedienelemente sind nicht markierbar (keine iOS-Lupe beim Halten);
   Fließtext und Beträge bleiben markierbar. */
.topbar, .tabbar, .btn, .icon-btn, .seg, .list-row, .fab {
    -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}

h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: -.02em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p  { margin: 0 0 1em; }
a  { color: var(--accent); text-decoration: none; }

.hidden { display: none !important; }
.muted  { color: var(--muted); }
.grow   { flex: 1 1 auto; min-width: 0; }
.row    { display: flex; align-items: center; gap: var(--sp-3); }
.stack  { display: flex; flex-direction: column; gap: var(--sp-3); }
.center { text-align: center; }

/* Text, der nicht umbrechen darf (Namen in Zeilen) */
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Nur für Screenreader */
.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;
}

/* Tastaturfokus immer sichtbar – aber nicht bei Maus/Touch. */
:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

/* ===========================================================================
   Beträge

   Tabellenziffern sind hier kein Detail, sondern der Grund, warum eine
   Betragsspalte überhaupt lesbar ist: Ohne sie sind die Ziffern verschieden
   breit und die Kommas stehen versetzt untereinander.
   =========================================================================== */

.amount {
    font-variant-numeric: tabular-nums;
    font-feature-settings: 'tnum' 1, 'cv05' 1;
    font-weight: 700;
    letter-spacing: -.01em;
}
.amount-lg  { font-size: 1.5rem; }
.amount-xl  { font-size: 2.25rem; font-weight: 800; }
.amount-pos { color: var(--pos); }
.amount-neg { color: var(--neg); }
/* Die Originalwährung unter dem umgerechneten Betrag. */
.amount-original { font-size: .78rem; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ===========================================================================
   Icons
   =========================================================================== */

.icon { width: 22px; height: 22px; flex: none; stroke: currentColor; fill: none; }
.icon-sm { width: 18px; height: 18px; }
.icon-lg { width: 28px; height: 28px; }

/* ===========================================================================
   Schaltflächen
   =========================================================================== */

.btn {
    display: inline-flex; align-items: center; justify-content: center;
    gap: var(--sp-2);
    min-height: var(--tap); padding: 0 var(--sp-5);
    border: 0; border-radius: var(--radius);
    font: inherit; font-weight: 600; font-size: .95rem;
    color: var(--text); background: var(--surface-2);
    cursor: pointer;
    /* Gedrückt wird über Farbe/Deckkraft angezeigt, nicht über Größe – ein
       Transform würde die Nachbarn verschieben und wirkt auf Listen unruhig. */
    transition: background var(--dur-fast) var(--ease), opacity var(--dur-fast) var(--ease);
}
.btn:active   { opacity: .72; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn-primary  { background: var(--accent-fill); color: var(--accent-ink); }
.btn-ghost    { background: transparent; border: 1.5px solid var(--border); }
.btn-danger   { background: var(--neg); color: #fff; }
.btn-block    { width: 100%; }
.btn-sm       { min-height: 36px; padding: 0 var(--sp-3); font-size: .85rem; border-radius: var(--radius-sm); }

.icon-btn {
    display: grid; place-items: center;
    width: var(--tap); height: var(--tap);
    border: 0; border-radius: var(--radius-sm);
    background: transparent; color: var(--text); cursor: pointer;
    transition: background var(--dur-fast) var(--ease);
}
.icon-btn:active { background: var(--surface-2); }

/* Schwebende Hauptaktion – sitzt über der Tab-Leiste, nie darunter. */
.fab {
    position: absolute; right: var(--sp-4);
    bottom: calc(var(--sp-4) + var(--tabbar-h) + var(--offline-bar-h) + env(safe-area-inset-bottom));
    display: grid; place-items: center;
    width: 56px; height: 56px; border: 0; border-radius: 50%;
    background: var(--accent-fill); color: var(--accent-ink);
    box-shadow: var(--shadow-lg); cursor: pointer; z-index: 30;
    transition: opacity var(--dur-fast) var(--ease);
}
.fab:active { opacity: .8; }
.fab .icon  { width: 26px; height: 26px; stroke-width: 2.5; }

/* ===========================================================================
   App-Hülle
   =========================================================================== */

.app {
    display: grid;
    /* Kopf / Inhalt / Tab-Leiste. Nur die mittlere Zeile ist flexibel und
       scrollt; minmax(0,1fr) ist nötig, damit sie überhaupt schrumpfen darf. */
    grid-template-rows: auto minmax(0, 1fr) auto;
    height: 100dvh;
    position: relative;
}

.topbar {
    display: flex; align-items: center; gap: var(--sp-2);
    min-height: var(--topbar-h);
    /* Oben zieht die Kopffarbe unter Notch/Statusleiste, seitlich die Insets
       im Querformat. */
    padding: env(safe-area-inset-top) max(var(--sp-4), env(safe-area-inset-right))
             0 max(var(--sp-4), env(safe-area-inset-left));
    background: var(--bg);
    border-bottom: 1px solid var(--border);
}
.topbar > .title { font-size: 1.25rem; font-weight: 700; letter-spacing: -.02em; }
/* Sitzt der Titel neben einem Zurück-Knopf, gleicht das den Randabstand aus. */
.topbar .icon-btn:first-child { margin-left: calc(var(--sp-2) * -1); }

.content {
    overflow-y: auto;
    overscroll-behavior: contain;   /* kein Durchscrollen auf die Seite dahinter */
    -webkit-overflow-scrolling: touch;
    padding: var(--sp-4) max(var(--sp-4), env(safe-area-inset-right))
             var(--sp-4) max(var(--sp-4), env(safe-area-inset-left));
}
/* Ohne Tab-Leiste (Detailansichten) den Home-Indicator selbst freihalten. */
.app[data-chrome="none"] .content { padding-bottom: calc(var(--sp-4) + env(safe-area-inset-bottom)); }

.tabbar {
    display: flex;
    background: var(--bg);
    border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a {
    position: relative; flex: 1;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 2px; min-height: var(--tabbar-h); padding: var(--sp-2) var(--sp-1) var(--sp-1);
    color: var(--muted); font-size: .68rem; font-weight: 600;
    transition: color var(--dur-fast) var(--ease);
}
.tabbar a.active { color: var(--accent); }
/* Aktiv-Markierung als Balken – Farbe allein darf nie das einzige Signal sein. */
.tabbar a::before {
    content: ""; position: absolute; top: 0; left: 50%;
    width: 28px; height: 3px; border-radius: 0 0 3px 3px;
    background: var(--accent);
    transform: translateX(-50%) scaleX(0);
    transition: transform var(--dur) var(--ease);
}
.tabbar a.active::before { transform: translateX(-50%) scaleX(1); }
.tabbar .badge {
    position: absolute; top: 6px; left: 50%; margin-left: 6px;
    min-width: 16px; height: 16px; padding: 0 4px; border-radius: 999px;
    background: var(--accent-fill); color: var(--accent-ink);
    font-size: .62rem; font-weight: 800; display: grid; place-items: center;
}

/* Tab-Leiste in Detailansichten ausblenden (Gruppe, Ausgabe). */
.app[data-chrome="none"] .tabbar { display: none; }

/* ===========================================================================
   Karten und Listen
   =========================================================================== */

.card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: var(--sp-4);
}

.list { display: flex; flex-direction: column; gap: var(--sp-2); }

.list-row {
    display: flex; align-items: center; gap: var(--sp-3);
    min-height: var(--tap);
    padding: var(--sp-3) var(--sp-4);
    background: var(--surface);
    border-radius: var(--radius);
    cursor: pointer;
    /* Auch als <a>: Die ganze Zeile ist die Schaltfläche, der Text bleibt
       normale Schrift. Amber ist der Aktionsfarbe vorbehalten – eine Liste
       komplett in Akzentfarbe hat keine Hierarchie mehr. */
    color: var(--text);
    transition: background var(--dur-fast) var(--ease);
}
.list-row:active { background: var(--surface-2); }
/* Auch als <button> verwendet (Menüs, Auswahl) – die Browser-Vorgaben für
   Schaltflächen müssen dann weg, sonst steht der Text mittig in halber Breite. */
button.list-row {
    width: 100%; border: 0; text-align: left; font: inherit;
}
/* Die beiden Textzeilen sind Spans in einem Flex-Kind: ohne display:block
   stünden sie nebeneinander statt untereinander. */
.list-row .list-title,
.list-row .list-sub { display: block; }
.list-row .list-title { font-weight: 600; }
.list-row .list-sub   { font-size: .8rem; color: var(--muted); }
.list-row .list-sub:empty { display: none; }
/* Führendes Symbol und der Pfeil rechts treten zurück. */
.list-row > .icon:first-child,
.list-row > .icon:last-child { color: var(--muted); }

/* Rundes Symbolfeld links in einer Zeile (Kategorie, Gruppe). */
.badge-icon {
    display: grid; place-items: center;
    width: 40px; height: 40px; flex: none;
    border-radius: var(--radius-sm);
    background: var(--accent-soft); color: var(--accent);
}

.avatar {
    width: 36px; height: 36px; flex: none; border-radius: 50%;
    object-fit: cover; background: var(--surface-2);
    display: grid; place-items: center;
    font-size: .8rem; font-weight: 700; color: var(--text);
}
.avatar-sm { width: 28px; height: 28px; font-size: .7rem; }
.avatar-lg { width: 64px; height: 64px; font-size: 1.3rem; }

/* ===========================================================================
   Gruppenfarben

   Acht Töne, alle hell genug, um mit dunkler Schrift (--accent-ink) über 5:1 zu
   kommen. Deshalb ist die Kachel in BEIDEN Themes gleich: farbige Fläche,
   dunkles Symbol. Ein zweites Set fürs helle Theme wäre nicht nur Aufwand,
   sondern hieße auch, dass dieselbe Gruppe je nach Einstellung anders aussieht.
   =========================================================================== */

:root {
    --g-basil:      #8FCB5E;
    --g-terracotta: #E2895B;
    --g-amber:      #F2C14E;
    --g-plum:       #C79BE0;
    --g-sky:        #6FC5F0;
    --g-lime:       #C3E657;
    --g-paprika:    #F08A7A;
    --g-stone:      #B4BCA8;
}

[data-color="basil"]      { --tile: var(--g-basil); }
[data-color="terracotta"] { --tile: var(--g-terracotta); }
[data-color="amber"]      { --tile: var(--g-amber); }
[data-color="plum"]       { --tile: var(--g-plum); }
[data-color="sky"]        { --tile: var(--g-sky); }
[data-color="lime"]       { --tile: var(--g-lime); }
[data-color="paprika"]    { --tile: var(--g-paprika); }
[data-color="stone"]      { --tile: var(--g-stone); }

.group-tile {
    display: grid; place-items: center;
    width: 40px; height: 40px; flex: none;
    border-radius: var(--radius-sm);
    background: var(--tile, var(--g-basil));
    color: #14180f;                       /* fest, nicht themeabhängig: 6,8:1 auf der dunkelsten Kachel */
}
.group-tile-lg { width: 56px; height: 56px; border-radius: var(--radius); }
.group-tile-lg .icon { width: 28px; height: 28px; }

/* ===========================================================================
   Gruppenkopf und Reiter
   =========================================================================== */

.group-head {
    display: flex; align-items: center; gap: var(--sp-4);
    padding: var(--sp-2) 0 var(--sp-5);
}

/* Textzeile, die sich wie ein Link verhält (Mitgliederzahl -> Mitgliederliste) */
.link-row {
    display: inline-flex; align-items: center; gap: var(--sp-1);
    margin-top: var(--sp-1); padding: 0;
    background: none; border: 0; cursor: pointer;
    font: inherit; font-size: .82rem; color: var(--muted);
}
.link-row .icon { color: var(--muted); }

.tab-panel { margin-top: var(--sp-4); }

.section-title {
    margin: var(--sp-6) 0 var(--sp-2);
    font-size: .8rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: .06em; color: var(--muted);
}

/* Hinweisstreifen, z. B. „Archiviert – nur noch lesbar" */
.banner {
    display: flex; align-items: center; gap: var(--sp-2);
    padding: var(--sp-3) var(--sp-4); margin-bottom: var(--sp-4);
    border-radius: var(--radius);
    background: var(--surface-2); color: var(--muted);
    font-size: .85rem; font-weight: 600;
}

/* ===========================================================================
   Archiv-Klappe in der Gruppenliste
   =========================================================================== */

.archive { margin-top: var(--sp-6); }
.archive > summary {
    display: flex; align-items: center; gap: var(--sp-2);
    min-height: var(--tap); padding: 0 var(--sp-2);
    cursor: pointer; list-style: none;
    color: var(--muted); font-size: .85rem; font-weight: 600;
}
.archive > summary::-webkit-details-marker { display: none; }
.archive > summary .count {
    margin-left: auto; padding: 2px var(--sp-2);
    border-radius: 999px; background: var(--surface-2); font-size: .75rem;
}
.archive[open] > summary { margin-bottom: var(--sp-2); }
.archive .list-row { opacity: .72; }

/* ===========================================================================
   Betragsspalte in Listenzeilen
   =========================================================================== */

.list-amount {
    display: flex; flex-direction: column; align-items: flex-end;
    flex: none; text-align: right;
}
.list-amount .list-sub { font-size: .72rem; }
.list-row.is-muted { opacity: .6; }
.text-danger { color: var(--neg); }

/* ===========================================================================
   Auswahlreihen (Symbol und Farbe beim Anlegen einer Gruppe)
   =========================================================================== */

/* Vier Spalten statt Umbruch nach Platz: Acht Einträge ergeben zwei volle
   Reihen. Ein freier Umbruch ließe je nach Gerätebreite einen einzelnen Knopf
   in der zweiten Zeile stehen. */
.picker {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--sp-2);
}
.picker-item {
    display: grid; place-items: center;
    min-height: var(--tap);
    border: 2px solid transparent; border-radius: var(--radius-sm);
    background: var(--bg-2); color: var(--text); cursor: pointer;
    transition: border-color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}
.picker-item[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }

/* Die Farbfläche IST die Information – sie darf im gewählten Zustand nicht vom
   Akzent-Hintergrund überdeckt werden. Deshalb steht sie hier nach der
   aria-pressed-Regel und gewinnt zusätzlich über die höhere Spezifität.
   Die Markierung übernimmt ein innen liegender Ring in Hintergrundfarbe. */
.picker-color,
.picker-color[aria-pressed="true"] { background: var(--tile, var(--g-basil)); }
.picker-color[aria-pressed="true"] { box-shadow: inset 0 0 0 3px var(--bg); }

/* ===========================================================================
   Chips (ausgewählte Personen)
   =========================================================================== */

.chips { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.chip {
    display: inline-flex; align-items: center; gap: var(--sp-1);
    min-height: 34px; padding: 0 var(--sp-3);
    border: 0; border-radius: 999px;
    background: var(--accent-soft); color: var(--accent);
    font: inherit; font-size: .85rem; font-weight: 600; cursor: pointer;
}

.mt    { margin-top: var(--sp-4); }
.mt-sm { margin-top: var(--sp-2); }

/* ===========================================================================
   Segmented Control (Ausgaben / Schulden / Log)
   =========================================================================== */

.seg {
    display: flex; gap: var(--sp-1);
    padding: var(--sp-1);
    background: var(--bg-2);
    border-radius: var(--radius);
}
.seg button {
    flex: 1; min-height: 38px; border: 0; border-radius: var(--radius-sm);
    background: transparent; color: var(--muted);
    font: inherit; font-size: .88rem; font-weight: 600; cursor: pointer;
    transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.seg button[aria-selected="true"] { background: var(--surface); color: var(--text); }

/* ===========================================================================
   Formulare
   =========================================================================== */

label { display: block; font-size: .82rem; font-weight: 600; color: var(--muted); margin-bottom: var(--sp-1); }

input, select, textarea {
    width: 100%;
    min-height: var(--tap);
    padding: var(--sp-3);
    font: inherit; font-size: 1rem;   /* 16px, sonst zoomt iOS beim Fokus */
    color: var(--text);
    background: var(--bg-2);
    border: 1.5px solid transparent;
    border-radius: var(--radius-sm);
    outline: none;
    transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
input:focus, select:focus, textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--ring);
}
/* Native Options-Popups erben den dunklen Hintergrund nicht zuverlässig. */
select option { background: var(--surface); color: var(--text); }
textarea { min-height: 88px; resize: vertical; }

/* Das Betragsfeld ist das meistgenutzte Element der App und darum groß. */
.amount-input {
    font-size: 2.25rem; font-weight: 800; text-align: center;
    font-variant-numeric: tabular-nums;
    background: transparent; border: 0; padding: var(--sp-2) 0;
}
.amount-input:focus { box-shadow: none; border-color: transparent; }

.field-error { margin-top: var(--sp-1); font-size: .8rem; color: var(--neg); }

/* ===========================================================================
   Ausgaben
   =========================================================================== */

/* Das Betragsfeld ist groß, mittig und trägt die Währung rechts daneben. */
.amount-field {
    display: flex; align-items: baseline; justify-content: center; gap: var(--sp-2);
    padding: var(--sp-2) 0;
}
.amount-field .amount-input { width: auto; max-width: 62%; min-height: 0; }

/* Die Währung ist eine Schaltfläche, kein Etikett – sie öffnet die Auswahl. */
.amount-currency {
    display: inline-flex; align-items: center; gap: var(--sp-1);
    min-height: 36px; padding: 0 var(--sp-2);
    border: 1.5px solid var(--border); border-radius: var(--radius-sm);
    background: transparent; color: var(--muted);
    font: inherit; font-size: 1rem; font-weight: 700; cursor: pointer;
    transition: border-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.amount-currency:active { border-color: var(--accent); color: var(--accent); }

/* --- Umrechnung --- */
.rate-row {
    display: flex; align-items: center; gap: var(--sp-2);
    padding: var(--sp-2) var(--sp-3);
    border-radius: var(--radius-sm);
    background: var(--bg-2);
    font-size: .82rem; color: var(--muted);
}
.rate-row.is-warn { color: var(--accent); }
.rate-manual { margin-top: var(--sp-2); }

.currency-code {
    flex: none; min-width: 48px;
    font-weight: 700; font-variant-numeric: tabular-nums;
}

/* Waagerecht scrollende Reihe (Kategorien). Wichtig: Sie scrollt in sich,
   nicht die Seite – deshalb overflow-x auf DIESEM Element. */
.strip {
    display: flex; gap: var(--sp-2);
    overflow-x: auto; overscroll-behavior-x: contain;
    padding-bottom: var(--sp-1);
    scrollbar-width: none;
}
.strip::-webkit-scrollbar { display: none; }

.chip-cat {
    display: inline-flex; align-items: center; gap: var(--sp-2);
    flex: none; min-height: 38px; padding: 0 var(--sp-3);
    border: 1.5px solid transparent; border-radius: 999px;
    background: var(--bg-2); color: var(--muted);
    font: inherit; font-size: .85rem; font-weight: 600; white-space: nowrap;
    cursor: pointer;
    transition: border-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.chip-cat[aria-pressed="true"] {
    border-color: var(--accent); color: var(--accent); background: var(--accent-soft);
}

/* --- Beteiligtenliste im Formular --- */
.participants { gap: var(--sp-1); }
.participant { padding: var(--sp-2) var(--sp-3); background: transparent; }
.participant.is-off { opacity: .5; }

/* Eigenes Kästchen statt <input type=checkbox>: Die native Variante lässt sich
   nicht zuverlässig auf 44 px vergrößern und nicht einfärben. */
.check {
    display: grid; place-items: center;
    width: 26px; height: 26px; flex: none;
    border: 2px solid var(--border); border-radius: 8px;
    background: transparent; color: var(--accent-ink); cursor: pointer;
    transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.check[aria-pressed="true"] { background: var(--accent-fill); border-color: var(--accent-fill); }
/* Das Tippziel ist die ganze Zeile; das Kästchen darf deshalb klein bleiben,
   bekommt aber eine vergrößerte Trefferfläche. */
.participant .check::after {
    content: ""; position: absolute; inset: 0;
}
.participant { position: relative; }

/* Eingabe und Ergebnis so schmal wie vertretbar: In der Zeile konkurrieren
   Kästchen, Bild, Name, Eingabe und Betrag um 342 px – jedes gesparte Pixel
   geht an den Namen, der sonst abschneidet. */
.split-input {
    width: 68px; flex: none; min-height: 36px;
    padding: var(--sp-1) var(--sp-2);
    text-align: right; font-variant-numeric: tabular-nums;
}
.amount-share {
    min-width: 66px; flex: none; text-align: right;
    font-size: .85rem; color: var(--muted);
}
/* Bei aktiver Eingabe tritt das Bild zurück – der Name braucht den Platz mehr. */
.participant:has(.split-input) .avatar { display: none; }
.split-hint { font-size: .78rem; margin: var(--sp-2) 0; }
.split-summary { margin-top: var(--sp-2); font-size: .85rem; font-weight: 600; }
.split-summary.is-error { color: var(--neg); }

/* --- Detailblatt --- */
.detail-head { display: flex; align-items: center; gap: var(--sp-4); }
.badge-icon-lg { width: 56px; height: 56px; border-radius: var(--radius); }
.badge-icon-lg .icon { width: 28px; height: 28px; }
.note { white-space: pre-wrap; font-size: .9rem; color: var(--muted); }

/* Die zusammengesetzte Regel `.list-row .list-sub` (Spezifität 0,2,0) schlägt
   eine einzelne Klasse – deshalb hier ausdrücklich mitgeführt, sonst bliebe der
   Saldo in einer Listenzeile grau statt grün oder rot. */
.text-pos, .list-row .list-sub.text-pos { color: var(--pos); }
.text-neg, .list-row .list-sub.text-neg { color: var(--neg); }

/* In Detailansichten fehlt die Tab-Leiste – die schwebende Schaltfläche rückt
   entsprechend nach unten. */
.fab-detail { bottom: calc(var(--sp-4) + var(--offline-bar-h) + env(safe-area-inset-bottom)); }

/* ===========================================================================
   Offline, Aktualisierung, Installation
   =========================================================================== */

/* Streifen ganz unten, über der Tab-Leiste.
 *
 * Er ÜBERLAGERT nicht: Solange er sichtbar ist, rücken die schwebende
 * Schaltfläche, der Toast und der untere Rand der Liste um seine Höhe nach oben.
 * Sonst läge er genau auf dem Plus-Knopf, mit dem man die Ausgabe eintragen
 * will, die er ankündigt. */
.offline-bar {
    position: fixed; left: 0; right: 0; z-index: 60;
    bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
    display: flex; align-items: center; justify-content: center; gap: var(--sp-2);
    padding: var(--sp-2) var(--sp-4);
    background: var(--surface-2); color: var(--muted);
    border-top: 1px solid var(--border);
    font-size: .82rem; font-weight: 600;
}
/* In Detailansichten fehlt die Tab-Leiste. */
.app[data-chrome="none"] ~ .offline-bar { bottom: env(safe-area-inset-bottom); }
.offline-bar.is-sending { color: var(--accent); }
.offline-bar.is-sending .icon { animation: spin 1.2s linear infinite; }

/* Wird von offline.js gesetzt, solange der Streifen steht. */
:root { --offline-bar-h: 0px; }
body.has-offline-bar { --offline-bar-h: 38px; }
body.has-offline-bar .content { padding-bottom: calc(var(--sp-4) + var(--offline-bar-h)); }

/* Handlungsstreifen (Aktualisierung) – schwebt über allem außer Blättern, damit
   er ein offenes Formular nicht überdeckt. */
.action-banner {
    position: fixed; left: 50%; z-index: 70;
    bottom: calc(var(--sp-4) + var(--tabbar-h) + var(--offline-bar-h) + env(safe-area-inset-bottom));
    transform: translateX(-50%);
    display: flex; align-items: center; gap: var(--sp-2);
    width: min(92vw, 460px);
    padding: var(--sp-2) var(--sp-2) var(--sp-2) var(--sp-4);
    border-radius: var(--radius);
    background: var(--surface); border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    font-size: .85rem; font-weight: 600;
    animation: sheet-up var(--dur) var(--ease);
}

/* Schalter (Push an/aus). Kein <input type=checkbox>: Der lässt sich nicht
   zuverlässig einfärben und nicht auf Fingergröße bringen. */
.switch {
    position: relative; flex: none;
    width: 44px; height: 26px; border-radius: 999px;
    background: var(--border);
    transition: background var(--dur) var(--ease);
}
.switch::after {
    content: ""; position: absolute; top: 3px; left: 3px;
    width: 20px; height: 20px; border-radius: 50%;
    background: var(--surface);
    transition: transform var(--dur) var(--ease);
}
.switch.is-on { background: var(--accent-fill); }
.switch.is-on::after { transform: translateX(18px); }

button.list-row:disabled { cursor: default; }
button.list-row.is-muted { opacity: .6; }

/* ===========================================================================
   Glocke und Benachrichtigungen
   =========================================================================== */

.bell { position: relative; }
.bell-badge {
    position: absolute; top: 6px; right: 6px;
    min-width: 17px; height: 17px; padding: 0 4px;
    border-radius: 999px;
    background: var(--accent-fill); color: var(--accent-ink);
    font-size: .62rem; font-weight: 800; line-height: 17px; text-align: center;
}

/* Gelesene Meldungen treten zurück, verschwinden aber nicht – man sucht auch
   mal etwas, das man schon gesehen hat. */
.list-row.is-read { opacity: .62; }
.list-row .dot {
    width: 8px; height: 8px; flex: none;
    border-radius: 50%; background: var(--accent);
}

/* ===========================================================================
   Protokoll
   =========================================================================== */

.log-row { align-items: flex-start; }
.log-row .badge-icon { width: 32px; height: 32px; border-radius: 8px; }
.log-row .badge-icon .icon { width: 18px; height: 18px; }
/* Uhrzeit rechts: schmal, tabellarisch, damit die Spalte nicht zappelt. */
.log-time {
    flex: none; font-variant-numeric: tabular-nums;
    padding-top: 2px;
}

/* ===========================================================================
   Salden und Ausgleich
   =========================================================================== */

/* Vorschlagszeile: zwei Bilder mit Pfeil, Betrag, Abhaken-Knopf. Bei knapper
   Breite bricht der Knopf in eine zweite Reihe, statt den Betrag zu quetschen. */
.settle-row { flex-wrap: wrap; row-gap: var(--sp-2); }
.settle-people { display: flex; flex-direction: column; gap: var(--sp-1); min-width: 0; }
.settle-people .icon { color: var(--muted); }
.settle-row .btn-sm { margin-left: auto; }

/* Widerrufene Zahlung: durchgestrichen, nicht nur blass – Ausgrauen allein
   liest sich wie „inaktiv", nicht wie „gilt nicht mehr". */
.strike { text-decoration: line-through; }

.balance-total { text-align: center; }
.balance-total .amount-xl { margin: var(--sp-1) 0; }

/* ===========================================================================
   Formularreihen
   =========================================================================== */

.field-row { display: flex; gap: var(--sp-3); }
.field-row > * { min-width: 0; }
.spread { justify-content: space-between; }

.link-btn {
    padding: 0; border: 0; background: none; cursor: pointer;
    font: inherit; font-size: .85rem; font-weight: 600; color: var(--accent);
}

/* ===========================================================================
   Sheet (Ausgabe erfassen)

   Kopf und Fußleiste stehen fest, nur der Rumpf scrollt. Dadurch bleibt die
   Speichern-Schaltfläche über der Tastatur erreichbar.
   =========================================================================== */

.sheet-scrim {
    position: fixed; inset: 0; z-index: var(--z-sheet);
    background: var(--scrim);
    animation: fade var(--dur) var(--ease);
}
.sheet {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: var(--z-sheet);
    display: grid; grid-template-rows: auto minmax(0, 1fr) auto;
    max-height: 92dvh;
    background: var(--bg);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    box-shadow: var(--shadow-lg);
    animation: sheet-up var(--dur) var(--ease);
}
.sheet-head {
    display: flex; align-items: center; gap: var(--sp-2);
    padding: var(--sp-3) var(--sp-4);
    border-bottom: 1px solid var(--border);
}
.sheet-body {
    overflow-y: auto; overscroll-behavior: contain;
    padding: var(--sp-4);
    display: flex; flex-direction: column; gap: var(--sp-4);
}
.sheet-foot {
    padding: var(--sp-3) var(--sp-4) calc(var(--sp-3) + env(safe-area-inset-bottom));
    border-top: 1px solid var(--border);
    background: var(--bg);
}

@keyframes fade     { from { opacity: 0; } }
@keyframes sheet-up { from { transform: translateY(100%); } }

/* ===========================================================================
   Rückmeldungen
   =========================================================================== */

.toast {
    position: fixed; left: 50%; z-index: var(--z-toast);
    bottom: calc(var(--sp-4) + var(--tabbar-h) + var(--offline-bar-h) + env(safe-area-inset-bottom));
    max-width: min(92vw, 420px);
    padding: var(--sp-3) var(--sp-5);
    border-radius: 999px;
    background: var(--surface-2); color: var(--text);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    font-size: .9rem; font-weight: 600;
    transform: translate(-50%, 16px); opacity: 0;
    transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.toast.show  { opacity: 1; transform: translate(-50%, 0); }
.toast.error { border-color: var(--neg); color: var(--neg); }

.empty {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: var(--sp-3); padding: var(--sp-12) var(--sp-4);
    color: var(--muted); text-align: center;
}
.empty .icon { width: 40px; height: 40px; opacity: .5; }

.loading { display: grid; place-items: center; padding: var(--sp-12); color: var(--muted); }
.spinner {
    width: 26px; height: 26px; border-radius: 50%;
    border: 2.5px solid var(--border); border-top-color: var(--accent);
    animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.error-box {
    padding: var(--sp-4); border-radius: var(--radius);
    background: var(--neg-soft); color: var(--neg);
    font-size: .9rem; font-weight: 600;
}

/* ===========================================================================
   Anmeldung

   Das Formular steht hier, geprüft wird am Hub. Die Ansicht muss zwei sehr
   unterschiedliche Zustände tragen: eine einzelne Zeile ("Anmeldung wird
   geprüft") und ein vierfeldriges Registrierungsformular. Deshalb zentriert
   der Rahmen, aber die Karte wächst nach unten.
   =========================================================================== */

.auth {
    display: flex; align-items: center; justify-content: center;
    min-height: 100dvh; padding: var(--sp-6);
    text-align: center;
}
/* width + max-width statt Auto-Breite: Ein zentriertes Grid-/Flex-Kind wird
   sonst so breit wie sein längster Satz und schiebt auf schmalen Geräten über
   den Rand hinaus. */
.auth-card { width: 100%; max-width: 340px; }
.auth .brand {
    display: flex; justify-content: center;
    margin-bottom: var(--sp-5);
}
/* Die Wortmarke bringt den Schriftzug mit, deshalb stehen hier weder Schriftgrad
   noch Laufweite. Die Höhe ergibt sich aus dem Seitenverhältnis der viewBox –
   sie festzuschreiben würde das SVG stauchen. */
.auth .brand .wordmark {
    width: 100%; max-width: 340px; height: auto;
}
.auth .btn { margin-top: var(--sp-6); min-width: 220px; }

.auth-lead { color: var(--muted); font-size: .95rem; }
/* Hinweise, die keine Fehler sind: abgemeldet, Sitzung abgelaufen, Link ist
   unterwegs. Farblich abgesetzt, aber nicht alarmierend. */
.auth-note {
    margin-top: var(--sp-4); padding: var(--sp-3);
    border-radius: var(--radius-sm);
    background: var(--bg-2); color: var(--text);
    font-size: .88rem;
}
.auth .error-box { margin-top: var(--sp-4); text-align: left; }

.auth-form { margin-top: var(--sp-5); display: flex; flex-direction: column; gap: var(--sp-4); }
/* Beschriftung und Feldfehler linksbündig – die Karte selbst bleibt zentriert. */
.auth-field { text-align: left; }
.auth-form .btn { margin-top: var(--sp-2); }

/* Das Auge sitzt IM Feld, nicht daneben: Ein Knopf neben der Eingabe würde
   ihre Breite verkürzen und auf schmalen Geräten den Text abschneiden. */
.auth-input-group { position: relative; }
.auth-input-group input { padding-right: calc(var(--tap) + var(--sp-1)); }
.auth-reveal {
    position: absolute; inset-block: 0; right: 0;
    display: grid; place-items: center;
    width: var(--tap); border: 0; background: transparent;
    color: var(--muted); cursor: pointer;
}
.auth-reveal:hover { color: var(--text); }

.auth-switch { margin-top: var(--sp-4); font-size: .88rem; color: var(--muted); }
.auth-switch a { color: var(--accent); font-weight: 600; }

/* ===========================================================================
   Größere Bildschirme

   Die App bleibt eine Telefon-App; auf einem Desktop wird sie nur mittig
   begrenzt, statt die Zeilen quer über den Bildschirm zu ziehen.
   =========================================================================== */

@media (min-width: 720px) {
    .app { max-width: 560px; margin: 0 auto; border-inline: 1px solid var(--border); }
    .sheet { left: 50%; transform: translateX(-50%); width: min(560px, 100%); }
    .fab { right: max(var(--sp-4), calc(50vw - 280px + var(--sp-4))); }
}

/* ===========================================================================
   Bewegung reduzieren
   =========================================================================== */

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}

/* --- Belege --------------------------------------------------------------- */

/* Kleines Symbol mitten im Fließtext, etwa hinter „Ich hat bezahlt". Es steht
   nie allein, sondern immer neben Text – deshalb braucht es keine Beschriftung. */
.inline-icon {
    vertical-align: -.15em;
    opacity: .7;
}

/* Die Vorschau ist bewusst breit und flach: Ein Kassenbon ist hochkant, würde
   also ungeschnitten die halbe Blatthöhe fressen. Der Ausschnitt zeigt den
   oberen Teil (dort steht, wo man war), das volle Bild ist einen Tipp entfernt. */
.receipt-preview {
    position: relative;
    display: block;
    width: 100%;
    height: 140px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-2);
    overflow: hidden;
    cursor: pointer;
}

.receipt-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top;
    display: block;
}

.receipt-preview .loading,
.receipt-preview .muted {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .85rem;
}

/* Die Lupe sitzt in der Ecke und sagt, dass es größer geht. */
.receipt-preview img + .zoom-hint { display: none; }
.receipt-preview:has(img)::after {
    content: "";
    position: absolute;
    inset-inline-end: 8px;
    inset-block-end: 8px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgb(0 0 0 / .55) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%23fff' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='7' cy='7' r='5'/%3E%3Cpath d='M11 11l4 4'/%3E%3C/svg%3E") center / 16px no-repeat;
}

/* Patchnotes: Fließtext, kein Datenblatt. Etwas mehr Zeilenabstand, weil der
   Text am Stück gelesen wird und nicht überflogen. */
.patchnotes p {
    margin: 0 0 var(--sp-3);
    line-height: 1.6;
}
.patchnotes p:last-child { margin-bottom: 0; }

/* Installationshinweis: Nutzen als Aufzählung, Anleitung als nummerierte Folge.
   Beide ohne eigene Farben – die Tokens erledigen hell und dunkel bereits. */
.install-benefits,
.install-steps {
    list-style: none;
    display: flex; flex-direction: column; gap: var(--sp-3);
    margin: 0; padding: 0;
    counter-reset: schritt;
}
.install-benefits li,
.install-steps li {
    display: flex; align-items: flex-start; gap: var(--sp-3);
    line-height: 1.45;
}
/* Das Symbol soll auf der ersten Zeile sitzen bleiben, auch wenn der Text
   umbricht – deshalb keine vertikale Zentrierung, sondern ein fester Versatz. */
.install-benefits > li > .icon,
.install-steps > li > .icon {
    flex: none; margin-top: 2px; color: var(--muted);
}

/* Die Ziffer steht vor dem Symbol: Erst die Reihenfolge, dann wonach man sucht. */
.install-steps > li::before {
    counter-increment: schritt;
    content: counter(schritt);
    flex: none;
    width: 22px; height: 22px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 50%;
    background: var(--surface-2);
    font-size: .78rem; font-weight: 700;
}

/* Das Blatt bekommt den Fokus nur als Parkplatz, wenn es kein Eingabefeld gibt
   (siehe ui.js). Es ist kein Bedienelement – ein Ring um den halben Bildschirm
   sähe aus wie ein Fehler und sagt nichts, was der Dialog nicht schon zeigt. */
.sheet:focus,
.sheet:focus-visible { outline: none; }

/* ===========================================================================
   Rezeptliste – Kacheln und Zeilen
   ===========================================================================
   Zwei Darstellungen derselben Daten. Standard sind Bildkacheln: Bei Rezepten
   ist das Foto das Erkennungsmerkmal. Ab ein paar Dutzend Einträgen will man
   aber scrollen statt wischen – dafür die kompakte Zeilenform.

   Beide Layouts teilen sich die Karte (.recipe-card); nur Richtung und Größen
   unterscheiden sich. Zwei getrennte Kartendefinitionen liefen auseinander. */

.filterbar {
    display: flex; gap: var(--sp-2);
    margin-bottom: var(--sp-4);
    padding-bottom: var(--sp-1);
    overflow-x: auto;
    /* Die Leiste scrollt seitlich und darf dabei keine Bildlaufleiste zeigen –
       auf dem Telefon nimmt sie sonst Höhe weg, die der Liste fehlt. */
    scrollbar-width: none;
}
.filterbar::-webkit-scrollbar { display: none; }

.list-head {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: var(--sp-2);
    font-size: .85rem;
}

.recipe-tiles {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--sp-3);
}
.recipe-rows { display: flex; flex-direction: column; gap: var(--sp-2); }

.recipe-card {
    display: flex; flex-direction: column;
    background: var(--surface);
    border-radius: var(--radius);
    overflow: hidden;
    color: inherit; text-decoration: none;
}
.recipe-card:active { opacity: .8; }

.recipe-rows .recipe-card { flex-direction: row; align-items: center; gap: var(--sp-3); }

.tile-img {
    aspect-ratio: 4 / 3;
    background: var(--surface-2) center / cover no-repeat;
    /* Bis das Bild da ist, steht die Fläche schon in der richtigen Größe –
       ohne aspect-ratio ruckelte die ganze Liste beim Nachladen zurecht. */
    display: grid; place-items: center;
}
.recipe-rows .tile-img { width: 72px; aspect-ratio: 1; flex: none; border-radius: var(--radius-sm); }

/* Rezepte ohne Bild: farbige Fläche mit Initiale statt eines grauen Lochs.
   Die Farbe folgt dem Titel (siehe modules/recipes.js) und bleibt dadurch
   gleich – sie wird zum Wiedererkennungsmerkmal. */
.tile-img-leer span {
    font-size: 1.6rem; font-weight: 800;
    color: var(--accent-ink);
}
.tile-img-leer[data-farbe="basil"]      { background: var(--g-basil); }
.tile-img-leer[data-farbe="terracotta"] { background: var(--g-terracotta); }
.tile-img-leer[data-farbe="amber"]      { background: var(--g-amber); }
.tile-img-leer[data-farbe="plum"]       { background: var(--g-plum); }
.tile-img-leer[data-farbe="sky"]        { background: var(--g-sky); }
.tile-img-leer[data-farbe="lime"]       { background: var(--g-lime); }
.tile-img-leer[data-farbe="paprika"]    { background: var(--g-paprika); }
.tile-img-leer[data-farbe="stone"]      { background: var(--g-stone); }

.tile-body { display: flex; flex-direction: column; gap: var(--sp-1); padding: var(--sp-3); min-width: 0; }
.tile-title {
    font-weight: 600; line-height: 1.3;
    /* Zwei Zeilen, dann Auslassung: Ein dritter Titelabsatz schöbe die
       Meta-Zeile aus der Kachel und die Reihe stünde ungleich hoch. */
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    overflow: hidden;
}
.tile-meta {
    display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap;
    font-size: .78rem; color: var(--muted);
}
.tile-meta > span { display: inline-flex; align-items: center; gap: 4px; }
.tile-rating { font-variant-numeric: tabular-nums; }
.icon-sm { width: 14px; height: 14px; }
.is-fav { color: var(--neg); fill: currentColor; }

.chip-xs { min-height: 22px; padding: 0 var(--sp-2); font-size: .72rem; }

/* ===========================================================================
   Rezept ansehen
   ===========================================================================
   Zum LESEN gebaut, nicht zum Verwalten. Wer kocht, hält das Telefon mit einer
   nicht ganz sauberen Hand – Zeilen sind deshalb hoch und weit auseinander. */

.recipe-hero {
    /* Bewusst randlos über die volle Breite: Das Bild ist die Überschrift.
       Die 16:9-Fläche steht schon vor dem Laden, damit nichts springt. */
    margin: calc(var(--sp-4) * -1) calc(var(--sp-4) * -1) var(--sp-4);
    aspect-ratio: 16 / 9;
    background: var(--surface-2) center / cover no-repeat;
}

.recipe-head h1 { margin: 0 0 var(--sp-2); font-size: 1.5rem; line-height: 1.25; }
.recipe-block   { margin-top: var(--sp-8); }
.recipe-block h2 { margin: 0 0 var(--sp-3); font-size: 1.05rem; }

.facts { display: flex; flex-wrap: wrap; gap: var(--sp-4); margin: var(--sp-4) 0; }
.fact  { display: inline-flex; align-items: center; gap: var(--sp-2); font-size: .9rem; }
.fact .icon { color: var(--muted); }

.recipe-actions {
    display: flex; align-items: center; justify-content: space-between;
    gap: var(--sp-3); flex-wrap: wrap;
    margin: var(--sp-4) 0;
}

.origin {
    display: flex; align-items: center; gap: var(--sp-2);
    margin-top: var(--sp-3);
    font-size: .8rem; color: var(--muted);
}

.chips { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-top: var(--sp-3); }

/* --- Bewertung --- */
.rating { display: inline-flex; align-items: center; gap: var(--sp-1); }
.star {
    display: grid; place-items: center;
    width: 36px; height: 36px;
    border: 0; background: transparent; color: var(--border);
    cursor: pointer;
}
.star-on { color: var(--accent); }
.star-on .icon { fill: currentColor; }
.rating .muted { margin-left: var(--sp-2); font-size: .8rem; }

/* --- Zutaten und Schritte --- */
.abschnitt { margin: var(--sp-5) 0 var(--sp-2); font-size: .85rem; color: var(--muted); }

.zutaten, .schritte { list-style: none; margin: 0; padding: 0; }

.zutat {
    display: flex; gap: var(--sp-3);
    padding: var(--sp-3) 0;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
}
.zutat-menge {
    flex: none; min-width: 72px;
    font-weight: 600; font-variant-numeric: tabular-nums;
}
.zutat-name { min-width: 0; }

.schritt { display: flex; gap: var(--sp-3); padding: var(--sp-4) 0; cursor: pointer; }
.schritt + .schritt { border-top: 1px solid var(--border); }
.schritt p { margin: 0; }
.schritt-nr {
    flex: none;
    width: 28px; height: 28px;
    display: grid; place-items: center;
    border-radius: 50%;
    background: var(--accent-soft); color: var(--accent);
    font-size: .85rem; font-weight: 700;
}
.schritt-bild {
    margin-top: var(--sp-3);
    aspect-ratio: 4 / 3; max-width: 320px;
    border-radius: var(--radius-sm);
    background: var(--surface-2) center / cover no-repeat;
}

/* Abgehakt beim Kochen. Gilt nur für diesen Kochvorgang und wird nirgends
   gespeichert – ein Häkchen von vor drei Wochen wäre nur verwirrend. */
.erledigt { opacity: .45; text-decoration: line-through; }

/* --- Nährwerte --- */
.naehrwerte { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--sp-3); }
.naehrwert {
    display: flex; align-items: baseline; justify-content: space-between;
    gap: var(--sp-2);
    padding: var(--sp-3);
    background: var(--surface); border-radius: var(--radius-sm);
    font-size: .9rem;
}
.naehrwert strong { font-variant-numeric: tabular-nums; }

/* ===========================================================================
   Rezeptformular
   =========================================================================== */

.form { display: flex; flex-direction: column; gap: var(--sp-5); padding-bottom: var(--sp-12); }

/* .feld trägt den Feldnamen als <span> und muss deshalb die label-Regel
   zurücknehmen – sonst erbte das Eingabefeld darin die kleine graue Schrift. */
.feld { display: block; font-size: 1rem; font-weight: 400; color: var(--text); margin-bottom: 0; }
.feld > span:first-child {
    display: block; margin-bottom: var(--sp-1);
    font-size: .82rem; font-weight: 600; color: var(--muted);
}
.feld .muted { margin: 0 0 var(--sp-2); }

.small { font-size: .8rem; }
.pre   { white-space: pre-wrap; }
.trenner { border: 0; border-top: 1px solid var(--border); margin: 0; }

.input-suche { min-height: 38px; padding: 0 var(--sp-3); }
.input-schritte { min-height: 180px; line-height: 1.6; }

.aufklapp summary {
    padding: var(--sp-3) 0;
    font-size: .9rem; font-weight: 600; color: var(--accent);
    cursor: pointer;
}
.aufklapp[open] summary { margin-bottom: var(--sp-3); }
.aufklapp > *:not(summary) { margin-bottom: var(--sp-4); }

/* --- Zutatenzeilen ---
   Menge und Einheit schmal, die Bezeichnung nimmt den Rest. Auf einem schmalen
   Gerät bricht die Zeile lieber um, als dass das Namensfeld unbenutzbar wird. */
.zeilen { display: flex; flex-direction: column; gap: var(--sp-2); margin-bottom: var(--sp-2); }
.zeile  { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.zeile-abschnitt {
    flex-basis: 100%;
    font-size: .78rem; font-weight: 600; color: var(--muted);
}
.input-mini { width: 68px; flex: none; padding: var(--sp-2); text-align: center; }
.zeile .grow { flex: 1 1 120px; min-width: 0; }

/* --- Bilder im Formular --- */
.bilder { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-bottom: var(--sp-2); }
.bild {
    position: relative;
    width: 96px; aspect-ratio: 1;
    border-radius: var(--radius-sm);
    background: var(--surface-2) center / cover no-repeat;
}
.bild-weg {
    position: absolute; top: -6px; right: -6px;
    width: 28px; height: 28px; min-height: 28px;
    border-radius: 50%;
    background: var(--bg); color: var(--text);
    box-shadow: var(--shadow);
}
.bild-fehlt { opacity: .4; }

/* Der Speichern-Knopf bleibt am unteren Rand stehen: Das Formular ist lang, und
   wer oben den Titel ändert, soll nicht erst ans Ende scrollen müssen. */
.sticky-footer {
    position: sticky; bottom: 0;
    margin-top: var(--sp-4);
    padding: var(--sp-3) 0 calc(var(--sp-3) + env(safe-area-inset-bottom));
    background: linear-gradient(to bottom, transparent, var(--bg) 24%);
}

/* Ab Tablettbreite drei Kacheln nebeneinander – zwei sähen dort verloren aus. */
@media (min-width: 640px) {
    .recipe-tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .naehrwerte   { grid-template-columns: repeat(4, 1fr); }
}

/* ===========================================================================
   Gruppen
   =========================================================================== */

.group-head {
    display: flex; align-items: center; gap: var(--sp-4);
    margin-bottom: var(--sp-5);
}
.group-head h1 { margin: 0 0 2px; font-size: 1.35rem; line-height: 1.2; }
.group-head p  { margin: 0; font-size: .85rem; }

/* Der Hinweisstreifen einer archivierten Gruppe. Zurückhaltend gehalten: Es ist
   kein Fehler, sondern ein Zustand – rot wäre eine Fehlmeldung. */
.hinweis {
    display: flex; align-items: center; gap: var(--sp-2);
    margin: 0 0 var(--sp-4);
    padding: var(--sp-3);
    border-radius: var(--radius-sm);
    background: var(--surface);
    font-size: .85rem; color: var(--muted);
}
.hinweis .icon { flex: none; }

/* Der Reiterblock in der Gruppe braucht Luft nach unten – er sitzt zwischen
   Kopf und Inhalt und klebte sonst am ersten Listeneintrag. */
.group-head + .seg { margin-bottom: var(--sp-5); }

/* --- Auswahl von Symbol und Farbe beim Anlegen --- */
.picker { display: flex; flex-wrap: wrap; gap: var(--sp-2); }

.picker-icon {
    display: grid; place-items: center;
    width: var(--tap); height: var(--tap);
    border: 1.5px solid transparent; border-radius: var(--radius-sm);
    background: var(--bg-2); color: var(--muted);
    cursor: pointer;
}
.picker-icon[aria-pressed="true"] {
    border-color: var(--accent); color: var(--accent); background: var(--accent-soft);
}

.picker-color {
    width: var(--tap); height: var(--tap);
    border: 3px solid transparent; border-radius: 50%;
    background: var(--tile, var(--g-basil));
    cursor: pointer;
}
/* Der Ring liegt AUSSERHALB des Kreises (box-shadow statt border), damit die
   Farbfläche beim Auswählen nicht kleiner wird und die Reihe nicht springt. */
.picker-color[aria-pressed="true"] {
    box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--accent);
}

/* --- Zugeschickte Rezepte --- */
.share-row { gap: var(--sp-2); }
.share-row .btn-sm { flex: none; }

/* ===========================================================================
   Verlauf
   ===========================================================================
   Eine Zeitleiste mit durchgehender Linie: Die Einträge gehören zusammen und
   stehen in einer Reihenfolge – einzelne Karten würden das zerschneiden. */

.log { position: relative; padding-left: var(--sp-5); }

/* Die Linie liegt hinter den Punkten und endet am letzten Eintrag, nicht am
   Rand des Blocks. */
.log::before {
    content: '';
    position: absolute; left: 5px; top: 8px; bottom: 8px;
    width: 2px;
    background: var(--border);
}

.log-row {
    position: relative;
    display: flex; gap: var(--sp-3);
    padding: var(--sp-3) 0;
}
.log-row p { margin: 0 0 2px; font-size: .9rem; }

.log-punkt {
    position: absolute; left: calc(var(--sp-5) * -1 + 1px); top: calc(var(--sp-3) + 6px);
    width: 10px; height: 10px;
    border-radius: 50%;
    background: var(--surface-2);
    box-shadow: 0 0 0 3px var(--bg);
}

/* ===========================================================================
   Schalterzeile
   ===========================================================================
   Beschriftung links, Schalter rechts – und die ganze Zeile ist antippbar,
   nicht nur das Kästchen. Ein 16-Pixel-Ziel trifft am Telefon niemand. */

.schalter {
    display: flex; align-items: center; gap: var(--sp-3);
    padding: var(--sp-3) 0;
    margin: 0;
    font-size: 1rem; font-weight: 400; color: var(--text);
    cursor: pointer;
}
.schalter + .schalter { border-top: 1px solid var(--border); }
.schalter input {
    width: 20px; height: 20px; min-height: 0;
    flex: none; order: 2; margin-left: auto;
    accent-color: var(--accent-fill);
}
.schalter span { order: 1; }

/* ===========================================================================
   Portionsregler
   ===========================================================================
   Sitzt über der Zutatenliste, weil er sie verändert – darunter müsste man ihn
   suchen, nachdem man schon gelesen hat. */

.portionen {
    display: flex; align-items: center; gap: var(--sp-3);
    margin-bottom: var(--sp-4);
    padding: var(--sp-2);
    background: var(--surface); border-radius: var(--radius);
}
.portionen-wert {
    display: flex; align-items: baseline; gap: var(--sp-2);
    min-width: 96px; justify-content: center;
}
.portionen-wert strong { font-size: 1.2rem; font-variant-numeric: tabular-nums; }
.portionen [data-portionen="reset"] { margin-left: auto; }

/* ===========================================================================
   Kochmodus
   ===========================================================================
   Eine eigene Ebene über allem. Die Maße sind hier bewusst großzügiger als im
   Rest der App: Man steht ein bis zwei Meter entfernt, hat eine Hand frei, und
   die ist nicht sauber. */

/* Solange der Kochmodus offen ist, scrollt darunter nichts mehr. */
body.kochen { overflow: hidden; }

.kochmodus {
    position: fixed; inset: 0;
    z-index: 300;   /* über Blättern (100) und Meldungen (200) */
    display: grid;
    grid-template-rows: auto auto 1fr auto;
    background: var(--bg);
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
}

.kochkopf {
    display: flex; align-items: center; gap: var(--sp-2);
    padding: var(--sp-2) var(--sp-3);
    border-bottom: 1px solid var(--border);
}
.kochtitel { flex: 1; font-weight: 600; }

/* Ein Punkt je Schritt: Man sieht auf einen Blick, wie weit man ist und wie
   viel noch kommt. Eine Prozentleiste sagte weniger – die Schritte sind
   unterschiedlich lang, aber gleich viele. */
.kochfortschritt {
    display: flex; gap: var(--sp-1); justify-content: center;
    padding: var(--sp-3) var(--sp-4) 0;
    flex-wrap: wrap;
}
.kochpunkt {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--border);
    transition: background var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.kochpunkt.ist-fertig { background: var(--muted); }
.kochpunkt.ist-hier   { background: var(--accent); transform: scale(1.5); }

.kochinhalt {
    display: flex; flex-direction: column; gap: var(--sp-4);
    padding: var(--sp-6) var(--sp-5);
    overflow-y: auto;
    justify-content: center;
}
.kochnummer   { font-size: .85rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.kochabschnitt { font-size: .9rem; color: var(--accent); font-weight: 600; }

/* Der eigentliche Text. Groß genug, um ihn vom Herd aus zu lesen; die
   Zeilenlänge ist begrenzt, weil lange Zeilen aus zwei Metern Entfernung
   schwer zu verfolgen sind. */
.kochtext {
    margin: 0;
    max-width: 34ch;
    font-size: clamp(1.35rem, 5vw, 1.9rem);
    line-height: 1.45;
}

.kochtimer { display: flex; flex-wrap: wrap; gap: var(--sp-2); }

.kochfuss {
    display: flex; gap: var(--sp-3);
    padding: var(--sp-4) var(--sp-4) var(--sp-5);
    border-top: 1px solid var(--border);
}
/* Beide Knöpfe hoch genug, um sie ohne Hinsehen zu treffen. */
.kochfuss .btn { min-height: 56px; font-size: 1rem; }

/* --- Die Zutaten als Blatt über dem Schritt --- */
.kochzutaten {
    position: absolute; inset: auto 0 0 0;
    max-height: 70%;
    display: flex; flex-direction: column;
    background: var(--surface);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    box-shadow: var(--shadow-lg);
    padding: var(--sp-4) var(--sp-5) calc(var(--sp-5) + env(safe-area-inset-bottom));
    overflow-y: auto;
}
.kochzutaten-kopf {
    display: flex; align-items: center; gap: var(--sp-3);
    margin-bottom: var(--sp-2);
    font-weight: 600;
}
.kochzutaten-kopf .icon-btn { margin-left: auto; }
.kochzutaten .zutat { font-size: 1.05rem; padding: var(--sp-4) 0; }

/* ===========================================================================
   Küchenwecker
   ===========================================================================
   Gestapelt am unteren Rand, über allem – auch über dem Kochmodus. Ein Wecker,
   den man nicht sieht, ist kein Wecker. */

.timer-leiste {
    position: fixed; left: 0; right: 0;
    bottom: calc(env(safe-area-inset-bottom) + var(--sp-3));
    z-index: 310;
    display: flex; flex-direction: column-reverse; gap: var(--sp-2);
    align-items: center;
    pointer-events: none;   /* die Leiste selbst fängt keine Tipper ab */
}
.timer {
    pointer-events: auto;
    display: flex; align-items: center; gap: var(--sp-3);
    padding: var(--sp-2) var(--sp-2) var(--sp-2) var(--sp-4);
    border-radius: 999px;
    background: var(--surface-2); color: var(--text);
    box-shadow: var(--shadow);
    font-size: .9rem;
}
.timer-rest {
    font-variant-numeric: tabular-nums; font-weight: 700;
    color: var(--accent);
    min-width: 4ch; text-align: right;
}

/* ===========================================================================
   Druckansicht
   ===========================================================================
   Papier ist die älteste Kochbuchtechnik und schlägt jedes Tablet, wenn Mehl
   im Spiel ist. Gedruckt wird nur das Rezept – ohne Hülle, ohne Bedienelemente,
   ohne die Farben des Themes. */

@media print {
    /* Die App ist ein 100dvh-Raster mit eigenem Scrollbereich. Für den Druck
       muss das aufgelöst werden, sonst landet nur die erste Bildschirmseite
       auf dem Papier. */
    html, body {
        height: auto; overflow: visible;
        background: #fff; color: #000;
    }
    .app { display: block; height: auto; }
    .content { overflow: visible; padding: 0; }

    .topbar, .tabbar, .recipe-actions, .portionen, .sticky-footer,
    .filterbar, .list-head, .seg, #timer-leiste, .kochmodus,
    .sheet, .scrim, .toast, [data-kochen] { display: none !important; }

    /* Das Titelbild wird als Hintergrundbild geladen (Blob-URL) und druckt in
       den meisten Browsern ohnehin nicht mit – es hier auszublenden spart die
       leere Fläche. */
    .recipe-hero, .schritt-bild { display: none; }

    .recipe { max-width: none; }
    .recipe-head h1 { font-size: 20pt; }
    .recipe-block   { margin-top: 16pt; }
    .recipe-block h2 { font-size: 13pt; }

    /* Zutaten und Schritte sollen nicht mitten in einer Zeile umbrechen. */
    .zutat, .schritt, .naehrwert { break-inside: avoid; page-break-inside: avoid; }
    .recipe-block   { break-inside: auto; }
    .recipe-block h2 { break-after: avoid; page-break-after: avoid; }

    .zutat { border-bottom: 1px solid #ccc; padding: 4pt 0; }
    .schritt { padding: 6pt 0; }
    .schritt-nr {
        background: none; color: #000;
        border: 1px solid #000;
    }
    .erledigt { opacity: 1; text-decoration: none; }

    /* Die Quelle als ausgeschriebene Adresse: Auf Papier nützt ein Link nichts,
       wenn nicht dabeisteht, wohin er führt. */
    .recipe-block a[href^="http"]::after {
        content: " (" attr(href) ")";
        font-size: 9pt; word-break: break-all;
    }
}

/* ===========================================================================
   Konfliktdialog
   ===========================================================================
   Zwei Fassungen nebeneinander, Feld für Feld. Nicht als Diff mit farbigen
   Zeilen: Das liest sich auf einem Telefon nicht, und die Frage ist ohnehin
   nicht "welches Zeichen", sondern "wessen Fassung". */

.konflikt { display: flex; flex-direction: column; gap: var(--sp-3); margin-top: var(--sp-4); }

.konflikt-feld {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--sp-2);
    padding: var(--sp-3);
    background: var(--bg-2); border-radius: var(--radius-sm);
}
.konflikt-name {
    grid-column: 1 / -1;
    font-size: .78rem; font-weight: 600; color: var(--muted);
}
.konflikt-seite { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.konflikt-seite > span:last-child { overflow-wrap: anywhere; }

/* Die eigene Fassung links und hervorgehoben: Sie ist der Grund, warum hier
   überhaupt gefragt wird. */
.konflikt-seite:nth-of-type(2) { border-left: 2px solid var(--accent); padding-left: var(--sp-2); }
