/* ===========================================================================
   Splitit – 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: #232f34 / #344955 / #4A6572 als Primärfamilie, #F9AA33 als Akzent.
   Alle Paarungen sind gegen WCAG geprüft; die Werte stehen als Kommentar an den
   Tokens. Zwei Fallen, die dabei aufgefallen sind:
     - #4A6572 erreicht auf #232f34 nur 2,2:1 -> ausschließlich Ränder, nie Text.
     - #F9AA33 erreicht auf Weiß nur 1,9:1 -> im hellen Theme braucht Akzenttext
       die abgedunkelte Variante; die Amber-Flä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:        #232f34;
    --bg-2:      #1A2429;   /* tiefer als bg: Vertiefungen, Eingabefelder */
    --surface:   #344955;   /* Karten, Listenzeilen */
    --surface-2: #3D5462;   /* gehobene Fläche, gedrückter Zustand */
    --border:    #4A6572;   /* NUR Ränder – als Text nur 2,2:1 */
    --text:      #F1F5F7;   /* 14,8:1 auf bg */
    --muted:     #9BAAB3;   /*  5,8:1 auf bg */

    --accent:      #F9AA33; /*  7,1:1 auf bg */
    --accent-fill: #F9AA33;
    --accent-ink:  #232f34; /* Schrift auf Amber-Flächen, 7,1:1 */
    --accent-soft: rgba(249, 170, 51, .16);

    --pos: #4ADE80;         /*  7,9:1 – Guthaben */
    --neg: #F87171;         /*  5,0:1 – Schulden */
    --pos-soft: rgba(74, 222, 128, .14);
    --neg-soft: rgba(248, 113, 113, .14);

    --scrim:  rgba(12, 18, 21, .62);
    --shadow:    0 8px 24px -10px rgba(0, 0, 0, .6);
    --shadow-lg: 0 24px 56px -20px rgba(0, 0, 0, .7);
    --ring: rgba(249, 170, 51, .45);
}

/* --- Hell --- */
:root[data-theme="light"] {
    --bg:        #F4F6F7;
    --bg-2:      #E8ECEE;
    --surface:   #FFFFFF;
    --surface-2: #F0F3F4;
    --border:    #D3DBDF;
    --text:      #232f34;   /* 14,4:1 auf bg */
    --muted:     #4A6572;   /*  6,2:1 auf Weiß */

    --accent:      #9A6100; /* 5,2:1 – Amber selbst schafft auf Weiß nur 1,9:1 */
    --accent-fill: #F9AA33;
    --accent-ink:  #232f34;
    --accent-soft: rgba(249, 170, 51, .22);

    --pos: #15803D;
    --neg: #B91C1C;
    --pos-soft: rgba(21, 128, 61, .12);
    --neg-soft: rgba(185, 28, 28, .12);

    --scrim:  rgba(35, 47, 52, .48);
    --shadow:    0 8px 24px -12px rgba(35, 47, 52, .28);
    --shadow-lg: 0 24px 56px -22px rgba(35, 47, 52, .34);
    --ring: rgba(154, 97, 0, .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-amber:  #F9AA33;
    --g-teal:   #2DD4BF;
    --g-rose:   #FB7185;
    --g-violet: #A78BFA;
    --g-sky:    #38BDF8;
    --g-lime:   #A3E635;
    --g-orange: #FB923C;
    --g-slate:  #94A3B8;
}

[data-color="amber"]  { --tile: var(--g-amber); }
[data-color="teal"]   { --tile: var(--g-teal); }
[data-color="rose"]   { --tile: var(--g-rose); }
[data-color="violet"] { --tile: var(--g-violet); }
[data-color="sky"]    { --tile: var(--g-sky); }
[data-color="lime"]   { --tile: var(--g-lime); }
[data-color="orange"] { --tile: var(--g-orange); }
[data-color="slate"]  { --tile: var(--g-slate); }

.group-tile {
    display: grid; place-items: center;
    width: 40px; height: 40px; flex: none;
    border-radius: var(--radius-sm);
    background: var(--tile, var(--g-amber));
    color: #232f34;                       /* fest, nicht themeabhängig: siehe oben */
}
.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-amber)); }
.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. */
/* padding: 0 ist Pflicht: Der Standard-Innenabstand des Buttons (~6 px je Seite)
   lässt dem Häkchen nur ~10 px Breite, es läuft dann nach rechts aus der Mitte. */
.check {
    display: grid; place-items: center;
    width: 26px; height: 26px; flex: none; padding: 0;
    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); }
/* Kräftiger Strich, damit das dunkle Häkchen auf Amber auch klein gut lesbar ist. */
.check .icon {
    width: 16px; height: 16px;
    stroke-width: 3.5; stroke-linecap: round; stroke-linejoin: round;
}
/* 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.
   Das Feld liegt über der vergrößerten Trefferfläche des Kästchens (::after,
   inset:0) – sonst trifft jeder Tipp ins Feld das Kästchen und wählt die
   Person ab. Die Markiersperre von .list-row wird aufgehoben, weil iOS Felder
   darin sonst nicht beschreiben lässt. */
.split-input {
    position: relative; z-index: 1;
    -webkit-user-select: text; user-select: text;
    width: 68px; flex: none; min-height: 36px;
    padding: var(--sp-1) var(--sp-2);
    text-align: right; font-variant-numeric: tabular-nums;
}
/* Ungültig, leer oder Summe geht nicht auf – nur der Rahmen, kein Text: Was
   fehlt, steht in der Zeile über der Liste und auf dem Speichern-Knopf. */
.split-input[aria-invalid="true"] { border-color: var(--neg); }
.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; }
/* Stand der Aufteilung, über der Personenliste: Beim Tippen soll er im Blick
   bleiben, unter einer langen Liste verschwände er hinter der Tastatur. */
.split-summary { margin-bottom: var(--sp-2); font-size: .85rem; font-weight: 600; }
.split-summary:empty { display: none; }
.split-summary.is-error { color: var(--neg); }
.split-summary.is-ok { color: var(--pos); }

/* --- Posten: Aufteilung nach Beleg --- */

/* Bei Posten ergibt sich der Betrag – er ist Anzeige, kein Eingabefeld. */
.amount-input.is-derived { color: var(--muted); }

.items-editor { display: flex; flex-direction: column; gap: var(--sp-3); margin-bottom: var(--sp-3); }

.scan-preview {
    display: flex; align-items: flex-start; gap: var(--sp-3);
    padding: var(--sp-3);
    border-radius: var(--radius); background: var(--bg-2);
}
/* Vorschau: der gerade gezogene Bon, oben angeschnitten – dort steht, wo er herkommt. */
.scan-preview img, .scan-thumb {
    width: 72px; height: 96px; flex: none; object-fit: cover; object-position: top;
    border-radius: var(--radius-sm); background: var(--surface);
}
.scan-preview .stack { gap: var(--sp-2); }
.scan-preview .row   { gap: var(--sp-2); flex-wrap: wrap; }
.scan-status { font-size: .85rem; font-weight: 600; }
.scan-status.is-warn { color: var(--accent); }

/* Diagnose für Admins: wofür die Zeit draufging, was die Erkennung gesehen hat. */
.scan-details {
    padding: var(--sp-2) var(--sp-3);
    border-radius: var(--radius); background: var(--bg-2);
    font-size: .8rem;
}
.scan-details summary { cursor: pointer; font-weight: 600; }
.scan-details p { margin: var(--sp-3) 0 var(--sp-1); }
.scan-times {
    display: grid; grid-template-columns: 1fr auto; gap: 2px var(--sp-3);
    margin: var(--sp-2) 0 0;
}
.scan-times dt { color: var(--muted); }
.scan-times dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.scan-details img { display: block; max-width: 100%; max-height: 50vh; border-radius: var(--radius-sm); }
.scan-details pre {
    margin: 0; padding: var(--sp-2); max-height: 40vh; overflow: auto;
    border-radius: var(--radius-sm); background: var(--surface);
    font-size: .75rem; white-space: pre-wrap; overflow-wrap: anywhere;
}

/* Ecken-Editor: so groß, wie das Foto ins Blatt passt (Seitenverhältnis in --seiten). */
.corner-hint { margin: 0; font-size: .88rem; }
.corner-editor {
    position: relative; flex: none;
    width: min(100%, calc(60vh * var(--seiten)));
    aspect-ratio: var(--seiten);
    margin: 0 auto;
    user-select: none; -webkit-user-select: none;
}
.corner-editor img, .corner-editor svg {
    position: absolute; inset: 0; width: 100%; height: 100%;
    pointer-events: none;
}
.corner-editor img { display: block; object-fit: fill; border-radius: var(--radius-sm); }
.corner-editor svg { overflow: visible; }
.corner-editor polygon {
    fill: var(--accent-fill); fill-opacity: .15;
    stroke: var(--accent-fill); stroke-width: 2px; vector-effect: non-scaling-stroke;
}
/* Griff: Tippziel in voller Größe, sichtbar nur der Punkt in der Mitte. */
.corner-handle {
    position: absolute; width: var(--tap); height: var(--tap);
    margin: 0; padding: 0; border: 0; background: transparent;
    transform: translate(-50%, -50%);
    touch-action: none; cursor: grab;
}
.corner-handle::after {
    content: ''; position: absolute; inset: 11px;
    border: 2px solid #fff; border-radius: 50%;
    background: var(--accent-fill); box-shadow: 0 1px 4px rgba(0, 0, 0, .4);
}
.corner-handle:active { cursor: grabbing; }
.corner-handle:focus-visible { outline: none; }
.corner-handle:focus-visible::after { outline: 2px solid var(--accent); outline-offset: 3px; }

.progress { height: 6px; overflow: hidden; border-radius: 999px; background: var(--surface); }
.progress > span {
    display: block; height: 100%; border-radius: inherit;
    background: var(--accent-fill); transition: width var(--dur) var(--ease);
}
/* Laden ohne Prozentangabe: ein wandernder Balken statt eines stehenden. */
.progress.is-indeterminate > span { width: 30% !important; animation: fortschritt-wandert 1.2s var(--ease) infinite; }
@keyframes fortschritt-wandert { from { transform: translateX(-100%); } to { transform: translateX(340%); } }

/* Personen-Leiste: gewählt ist, wem ein Tipp auf einen Posten gilt. */
.person-chip { padding-left: var(--sp-1); }
.avatar-xs { width: 24px; height: 24px; font-size: .62rem; }
.chip-count {
    display: inline-grid; place-items: center;
    min-width: 20px; height: 20px; padding: 0 5px; border-radius: 999px;
    background: var(--surface); color: var(--text); font-size: .72rem;
}
.person-chip[aria-pressed="true"] .chip-count { background: var(--accent-fill); color: var(--accent-ink); }

.items-list { display: flex; flex-direction: column; gap: var(--sp-2); }
.item-row {
    display: flex; flex-direction: column; gap: var(--sp-2);
    padding: var(--sp-2) var(--sp-3);
    border: 1.5px solid transparent; border-radius: var(--radius);
    background: var(--surface);
}
/* Offen = niemandem zugewiesen. Rot, weil Speichern daran scheitert. */
.item-row.is-open  { border-color: var(--neg); background: var(--neg-soft); }
.item-row.is-extra { background: var(--bg-2); }

.item-fields { display: flex; gap: var(--sp-2); }
.item-fields .item-name { flex: 1 1 auto; min-width: 0; }
.item-name, .item-amount { min-height: 38px; padding: var(--sp-1) var(--sp-2); }
.item-amount {
    width: 96px; flex: none;
    text-align: right; font-variant-numeric: tabular-nums;
}
/* Vom Scan unsicher gelesen – bis jemand das Feld anfasst. Vor aria-invalid,
   damit ein ungültiger Preis rot bleibt. */
.item-name.is-unsure, .item-amount.is-unsure { border-color: var(--accent); background: var(--accent-soft); }
.item-amount[aria-invalid="true"] { border-color: var(--neg); }

.item-assign-row { display: flex; align-items: center; gap: var(--sp-2); }
/* Die große Tippfläche: schaltet die gewählte Person für diesen Posten um. */
.item-assign {
    display: flex; align-items: center; gap: var(--sp-2);
    flex: 1 1 auto; min-width: 0; min-height: var(--tap);
    padding: 0 var(--sp-2);
    border: 1.5px dashed var(--border); border-radius: var(--radius-sm);
    background: transparent; color: var(--text);
    font: inherit; font-size: .88rem; text-align: left; cursor: pointer;
}
.item-row.is-open .item-assign { border-color: var(--neg); color: var(--neg); }
.item-assign:disabled { border-color: transparent; padding-left: 0; cursor: default; }
.item-hint { font-size: .75rem; color: var(--muted); }

.avatar-stack { display: inline-flex; flex: none; }
.avatar-stack > .avatar + .avatar { margin-left: -8px; box-shadow: 0 0 0 2px var(--surface); }

.items-total { display: flex; align-items: center; gap: var(--sp-3); }
.items-total label { flex: 1; margin: 0; }
.items-status { margin: 0; font-size: .82rem; color: var(--muted); }
.items-status:empty { display: none; }
.items-status.is-warn { color: var(--accent); font-weight: 600; }

/* Detailblatt: die eigenen Posten sind markiert. */
.item-detail.is-mine { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent-fill); }
.item-detail.is-extra .list-title { color: var(--muted); }
.items-legend {
    display: flex; align-items: center; gap: var(--sp-2);
    margin: 0 0 var(--sp-2); font-size: .78rem; color: var(--muted);
}
.legend-mine {
    width: 12px; height: 12px; border-radius: 3px;
    background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent-fill);
}

/* --- 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)); }

/* Unter einer Liste mit Plus-Knopf Platz lassen – sonst läge er auf der letzten
   Zeile oder auf „Ältere anzeigen". */
.has-fab { padding-bottom: calc(56px + var(--sp-6)); }

/* Herunterziehen zum Neuladen (refresh.js). Wartet verdeckt hinter der
   Kopfzeile, folgt dem Finger und dreht sich, bis die Ansicht neu steht. */
.ptr {
    position: absolute; left: 50%; top: calc(var(--topbar-h) + env(safe-area-inset-top));
    z-index: 20;
    display: grid; place-items: center;
    width: 36px; height: 36px; margin: -36px 0 0 -18px;
    border-radius: 50%;
    background: var(--surface); color: var(--muted);
    border: 1px solid var(--border); box-shadow: var(--shadow-lg);
    opacity: 0; pointer-events: none;
    transform: translateY(var(--ptr-y, 0px)) rotate(var(--ptr-drehung, 0deg));
}
.ptr .icon { width: 18px; height: 18px; }
.ptr.is-pulling { opacity: 1; }
/* Losgelassen: sanft zurück statt zu springen. Beim Ziehen folgt es dem Finger. */
.ptr:not(.is-pulling) { transition: transform var(--dur) var(--ease), opacity var(--dur) var(--ease); }
.ptr.is-ready   { color: var(--accent); }
.ptr.is-loading .icon { animation: spin .8s linear infinite; }

/* ===========================================================================
   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; }

/* ===========================================================================
   Bezahlen und Bezahlwege
   =========================================================================== */

/* Kleines Abzeichen hinter einem Titel („bevorzugt"). */
.pill {
    display: inline-block; vertical-align: middle;
    margin-left: var(--sp-1); padding: 1px var(--sp-2);
    border-radius: 999px;
    background: var(--accent-soft); color: var(--accent);
    font-size: .68rem; font-weight: 700; letter-spacing: .02em;
}

/* GiroCode: immer Schwarz auf Weiß, auch im dunklen Theme. Eine eingefärbte
   oder invertierte Fassung lesen nicht alle Banking-Apps. */
.girocode {
    display: grid; place-items: center;
    width: min(240px, 100%); aspect-ratio: 1;
    margin: 0 auto var(--sp-2);
    padding: var(--sp-2);
    border-radius: var(--radius);
    background: #fff;
}
.girocode svg { display: block; width: 100%; height: 100%; }
.girocode .spinner { border-color: rgba(0, 0, 0, .15); border-top-color: #344955; }

/* Kopierzeile: Bezeichnung klein oben, Wert groß darunter. */
.copy-row .list-sub { font-size: .72rem; }
.copy-row .list-title { word-break: break-all; }
.copy-row > .icon:last-child { color: var(--accent); }

.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: .02em; }

/* Die Zahlung, zu der eine Benachrichtigung geführt hat. */
.list-row.is-highlight { box-shadow: inset 0 0 0 2px var(--accent); }

/* Hinweis an den Gläubiger, Bezahldaten zu hinterlegen. */
.pay-hint { align-items: flex-start; margin: 0 0 var(--sp-3); font-weight: 500; }
.pay-hint > .icon { margin-top: 2px; color: var(--accent); }
.pay-hint .link-btn { display: inline; margin-left: var(--sp-1); }
.pay-hint .icon-btn { margin: calc(var(--sp-2) * -1) calc(var(--sp-2) * -1) 0 0; }

/* Eingabefeld mit festem Vorsatz („paypal.me/"). */
.prefix-field {
    display: flex; align-items: center;
    background: var(--bg-2);
    border: 1.5px solid transparent; border-radius: var(--radius-sm);
    transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.prefix-field:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
.prefix-field > span { padding-left: var(--sp-3); color: var(--muted); white-space: nowrap; }
.prefix-field input { padding-left: 2px; background: transparent; border: 0; }
.prefix-field input:focus { box-shadow: none; border-color: transparent; }

/* ===========================================================================
   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);
    /* Ausgeblendet bleibt der Toast im DOM. Ohne das finge er Taps auf die
       Liste darunter ab – und ein unsichtbares „Rückgängig" ließe sich treffen. */
    pointer-events: none;
}
.toast.show  { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast.error { border-color: var(--neg); color: var(--neg); }
.toast.has-action {
    display: flex; align-items: center; gap: var(--sp-3);
    padding-right: var(--sp-2);
}
.toast-action {
    flex: none; min-height: 36px; padding: 0 var(--sp-3);
    border: 0; border-radius: 999px;
    background: transparent; color: var(--accent);
    font: inherit; font-weight: 700; cursor: pointer;
}
.toast-action:active { background: var(--bg-2); }

.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: 260px; 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;
    /* Der Blattrumpf ist eine Flex-Spalte: Ohne das schrumpft die Vorschau bei
       langem Inhalt (Postenliste) auf einen Strich zusammen. */
    flex: none;
    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; }
