/* =========================================================================
   essali – Design-System
   Ein Stylesheet für beide Bereiche: „Raus“ (Finder) und „Daheim“ (Kochen).
   Kein Framework, kein Build-Schritt. Reines CSS mit Custom Properties.

   Aufbau:
     01 Tokens (Light)          07 Karten
     02 Tokens (Dark)           08 Aktionsleiste
     03 Reset & Basis           09 Formulare
     04 Layout & Topbar         10 Toast, Skeleton, Leerer Zustand, Einwilligung
     05 Buttons & Icons         11 Finder-Layout
     06 Chips, Badges, Pills    12 Prose & Tabellen  13 Utilities  14 Druck

   Klassennamen sind BEM-artig: .block, .block__element, .block--modifier.
   Zustände zusätzlich über .is-active / [aria-current] / [aria-disabled].
   Dokumentation mit HTML-Schnipseln: public/assets/css/README.md
   ========================================================================= */

/* == 01 Tokens (Light) =================================================== */

:root {
    color-scheme: light dark;

    /* -- Schrift: System-Stack, keine externen Fonts -- */
    --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue",
                 Arial, "Noto Sans", sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

    --fs-xs: 0.75rem;      /* 12px – Meta, Zähler        */
    --fs-sm: 0.875rem;     /* 14px – Meta-Zeilen, Labels */
    --fs-md: 1rem;         /* 16px – Fließtext           */
    --fs-lg: 1.125rem;     /* 18px – Kartentitel         */
    --fs-xl: 1.375rem;     /* 22px – h2                  */
    --fs-2xl: 1.75rem;     /* 28px – h1 klein            */
    --fs-3xl: clamp(1.75rem, 1.25rem + 2.2vw, 2.5rem); /* h1 */

    --fw-regular: 400;
    --fw-medium: 500;
    --fw-bold: 700;
    --fw-black: 800;

    --lh-tight: 1.2;
    --lh-base: 1.55;

    /* -- Abstände (4px-Raster) -- */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.5rem;
    --space-6: 2rem;
    --space-7: 3rem;
    --gutter: 1rem;              /* Seitenrand, mobil wie Desktop */

    /* -- Radien -- */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 18px;
    --radius-pill: 999px;

    /* -- Maße -- */
    --topbar-h: 64px;
    --tap: 44px;                 /* minimale Touch-Fläche */
    --content-max: 1120px;
    --sidebar-w: 400px;          /* Liste links ab 900px */
    --map-h: 45svh;              /* Karte oben auf dem Handy */

    /* -- Farben -- */
    --c-bg: #fffbf7;
    --c-bg-alt: #f7efe6;
    --c-surface: #ffffff;
    --c-surface-2: #fbf4ec;

    --c-text: #241812;
    --c-text-muted: #6e5a4e;
    --c-border: #e7dccf;
    --c-border-strong: #d6c4b1;

    --c-primary: #c1441a;        /* Terracotta */
    --c-primary-hover: #a5360f;
    --c-primary-soft: #fbeae1;
    --c-on-primary: #ffffff;

    --c-accent: #e8a33a;         /* Safran – dekorativ, Sterne, Highlights */
    --c-accent-text: #8a5a00;
    --c-accent-soft: #fdf3df;

    --c-success: #186a43;
    --c-success-soft: #e3f2e9;

    --c-danger: #a62b20;
    --c-danger-soft: #fbe6e3;
    --c-on-danger: #ffffff;

    --c-neutral-soft: #f1e8dc;
    --c-neutral-text: #5c4a3e;
    --c-unknown-soft: #f4eee7;
    --c-unknown-text: #6e5a4e;

    --c-focus: #8a2c06;
    --c-skeleton: #efe5da;
    --c-skeleton-shine: #f9f2ea;
    --c-overlay: rgba(36, 24, 18, 0.55);
    --c-map-placeholder-a: #ece3d6;
    --c-map-placeholder-b: #dfd2c0;

    --shadow-sm: 0 1px 2px rgba(60, 38, 22, 0.08);
    --shadow-md: 0 2px 8px rgba(60, 38, 22, 0.10);
    --shadow-lg: 0 8px 28px rgba(60, 38, 22, 0.18);

    /* -- Bewegung -- */
    --dur-fast: 120ms;
    --dur-base: 200ms;
    --ease: cubic-bezier(0.2, 0.6, 0.3, 1);
}

/* == 02 Tokens (Dark) ====================================================
   Zwei Blöcke mit identischem Inhalt: Systemeinstellung und manueller
   Umschalter (html[data-theme]). Wer hier etwas ändert, ändert es zweimal. */

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        color-scheme: dark;

        --c-bg: #16100c;
        --c-bg-alt: #1c150f;
        --c-surface: #211911;
        --c-surface-2: #2a2019;

        --c-text: #f6ede3;
        --c-text-muted: #bca99a;
        --c-border: #38291f;
        --c-border-strong: #4b382b;

        --c-primary: #ff9057;
        --c-primary-hover: #ffa877;
        --c-primary-soft: #35211a;
        --c-on-primary: #2a1206;

        --c-accent: #f2c15c;
        --c-accent-text: #f2c15c;
        --c-accent-soft: #33260f;

        --c-success: #79d9a4;
        --c-success-soft: #16301f;

        --c-danger: #ff9a90;
        --c-danger-soft: #3a1a16;
        --c-on-danger: #2a0d0a;

        --c-neutral-soft: #2c2219;
        --c-neutral-text: #d6c6b8;
        --c-unknown-soft: #241c15;
        --c-unknown-text: #b8a697;

        --c-focus: #ffb081;
        --c-skeleton: #2a2019;
        --c-skeleton-shine: #362a20;
        --c-overlay: rgba(8, 5, 3, 0.65);
        --c-map-placeholder-a: #241c15;
        --c-map-placeholder-b: #2f251c;

        --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.5);
        --shadow-md: 0 2px 10px rgba(0, 0, 0, 0.55);
        --shadow-lg: 0 8px 28px rgba(0, 0, 0, 0.65);
    }
}

:root[data-theme="dark"] {
    color-scheme: dark;

    --c-bg: #16100c;
    --c-bg-alt: #1c150f;
    --c-surface: #211911;
    --c-surface-2: #2a2019;

    --c-text: #f6ede3;
    --c-text-muted: #bca99a;
    --c-border: #38291f;
    --c-border-strong: #4b382b;

    --c-primary: #ff9057;
    --c-primary-hover: #ffa877;
    --c-primary-soft: #35211a;
    --c-on-primary: #2a1206;

    --c-accent: #f2c15c;
    --c-accent-text: #f2c15c;
    --c-accent-soft: #33260f;

    --c-success: #79d9a4;
    --c-success-soft: #16301f;

    --c-danger: #ff9a90;
    --c-danger-soft: #3a1a16;
    --c-on-danger: #2a0d0a;

    --c-neutral-soft: #2c2219;
    --c-neutral-text: #d6c6b8;
    --c-unknown-soft: #241c15;
    --c-unknown-text: #b8a697;

    --c-focus: #ffb081;
    --c-skeleton: #2a2019;
    --c-skeleton-shine: #362a20;
    --c-overlay: rgba(8, 5, 3, 0.65);
    --c-map-placeholder-a: #241c15;
    --c-map-placeholder-b: #2f251c;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.5);
    --shadow-md: 0 2px 10px rgba(0, 0, 0, 0.55);
    --shadow-lg: 0 8px 28px rgba(0, 0, 0, 0.65);
}

:root[data-theme="light"] {
    color-scheme: light;
}

/* == 03 Reset & Basis ==================================================== */

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

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

body {
    margin: 0;
    min-height: 100svh;
    background: var(--c-bg);            /* immer explizit */
    color: var(--c-text);
    font-family: var(--font-sans);
    font-size: var(--fs-md);
    line-height: var(--lh-base);
    -webkit-font-smoothing: antialiased;
    overflow-wrap: break-word;
}

h1, h2, h3, h4 {
    margin: 0 0 var(--space-3);
    line-height: var(--lh-tight);
    font-weight: var(--fw-black);
    letter-spacing: -0.01em;
}

h1 { font-size: var(--fs-3xl); }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-lg); }
h4 { font-size: var(--fs-md); }

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

a {
    color: var(--c-primary);
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
}

a:hover { color: var(--c-primary-hover); }

img, svg, video {
    max-width: 100%;
    height: auto;
}

ul, ol { padding-left: 1.25em; }

hr {
    border: 0;
    border-top: 1px solid var(--c-border);
    margin: var(--space-5) 0;
}

code, kbd, samp {
    font-family: var(--font-mono);
    font-size: 0.9em;
    background: var(--c-surface-2);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-sm);
    padding: 0.1em 0.35em;
}

/* Fokus: immer sichtbar, nie wegoptimiert. */
:focus-visible {
    outline: 3px solid var(--c-focus);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

::selection {
    background: var(--c-primary-soft);
    color: var(--c-text);
}

/* Nur für Screenreader */
.visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

.skip-link {
    position: absolute;
    left: var(--gutter);
    top: -100px;
    z-index: 200;
    padding: var(--space-3) var(--space-4);
    background: var(--c-primary);
    color: var(--c-on-primary);
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    font-weight: var(--fw-bold);
    text-decoration: none;
}

.skip-link:focus {
    top: 0;
    color: var(--c-on-primary);
}

/* == 04 Layout & Topbar ================================================== */

.topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    /* Feste Höhe statt min-height: die Filterleiste des Finders klebt exakt darunter –
       weicht die echte Höhe ab, schiebt sie sich beim Scrollen unter die Leiste (Flackern). */
    height: calc(var(--topbar-h) + env(safe-area-inset-top, 0px));
    padding: 0 var(--gutter);
    padding-top: env(safe-area-inset-top, 0px);
    background: var(--c-bg);
    border-bottom: 1px solid var(--c-border);
    /* Eigene Compositor-Ebene: verhindert Flackern der klebenden Leiste beim Scrollen
       (Handy-Browser, GPU-Karte darunter). */
    transform: translateZ(0);
    backface-visibility: hidden;
    isolation: isolate;
}

.topbar__brand {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--fs-xl);
    font-weight: var(--fw-black);
    letter-spacing: -0.02em;
    color: var(--c-primary);
    text-decoration: none;
    flex: 0 0 auto;
}

.topbar__logo {
    width: 28px;
    height: 28px;
    flex: 0 0 auto;
}

.topbar__actions {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

/* -- Segmented Control „Raus | Daheim“ -- */
.segmented {
    display: inline-flex;
    gap: 2px;
    padding: 4px;
    background: var(--c-surface-2);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-pill);
}

.segmented__item {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    min-height: 44px;
    padding: 0 var(--space-4);
    border: 0;
    border-radius: var(--radius-pill);
    background: transparent;
    color: var(--c-text);
    font: inherit;
    font-size: var(--fs-sm);
    font-weight: var(--fw-bold);
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}

.segmented__item:hover {
    background: var(--c-primary-soft);
    color: var(--c-text);
}

.segmented__item[aria-current="page"],
.segmented__item.is-active {
    background: var(--c-primary);
    color: var(--c-on-primary);
    box-shadow: var(--shadow-sm);
}

.segmented__item[aria-current="page"]:hover,
.segmented__item.is-active:hover {
    background: var(--c-primary-hover);
    color: var(--c-on-primary);
}

/* -- Hauptbereich -- */
.main {
    width: 100%;
    max-width: var(--content-max);
    margin: 0 auto;
    padding: var(--space-5) var(--gutter) var(--space-7);
}

/* Randlos: Finder-Karte füllt die Fläche selbst.
   Entweder body-Klasse „flush“ setzen (View-Variable $body_class)
   oder .main--flush verwenden. */
.main--flush,
body.flush .main,
.main:has(> .finder) {
    max-width: none;
    padding: 0;
}

.footer {
    padding: var(--space-5) var(--gutter) calc(var(--space-5) + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--c-border);
    background: var(--c-bg-alt);
    color: var(--c-text-muted);
    font-size: var(--fs-sm);
    text-align: center;
}

.footer a { color: inherit; }

.footer__nav {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--space-2) var(--space-4);
    margin-bottom: var(--space-2);
}

.footer__attribution { margin: 0; }

/* Allgemeine Bausteine */
.container {
    width: 100%;
    max-width: var(--content-max);
    margin: 0 auto;
    padding-inline: var(--gutter);
}

.stack > * + * { margin-top: var(--space-4); }
.stack--tight > * + * { margin-top: var(--space-2); }
.stack--loose > * + * { margin-top: var(--space-6); }

.section-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--space-3);
    margin-bottom: var(--space-4);
}

.section-head h2 { margin: 0; }

/* Karten-Raster (Rezepte, Listen) */
.grid {
    display: grid;
    gap: var(--space-4);
    grid-template-columns: 1fr;
}

@media (min-width: 560px) {
    .grid--cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 900px) {
    .grid--cards { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* == 05 Buttons & Icons ================================================== */

.icon {
    width: 1.25em;
    height: 1.25em;
    flex: 0 0 auto;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.75;
    stroke-linecap: round;
    stroke-linejoin: round;
    vertical-align: -0.2em;
}

.icon--sm { width: 1em; height: 1em; }
.icon--lg { width: 1.75em; height: 1.75em; }
.icon--solid { fill: currentColor; stroke: none; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    min-height: var(--tap);
    padding: var(--space-2) var(--space-4);
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    background: var(--c-primary);
    color: var(--c-on-primary);
    font: inherit;
    font-size: var(--fs-sm);
    font-weight: var(--fw-bold);
    line-height: 1.2;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    transition: background var(--dur-fast) var(--ease),
                border-color var(--dur-fast) var(--ease),
                transform var(--dur-fast) var(--ease);
}

.btn:hover {
    background: var(--c-primary-hover);
    color: var(--c-on-primary);
}

.btn:active { transform: translateY(1px); }

/* Sekundär: Fläche mit Rand */
.btn--secondary {
    background: var(--c-surface);
    color: var(--c-text);
    border-color: var(--c-border-strong);
}

.btn--secondary:hover {
    background: var(--c-surface-2);
    color: var(--c-text);
    border-color: var(--c-primary);
}

/* Ghost: nur Text */
.btn--ghost {
    background: transparent;
    color: var(--c-text);
    border-color: transparent;
}

.btn--ghost:hover {
    background: var(--c-surface-2);
    color: var(--c-text);
}

.btn--danger {
    background: var(--c-danger);
    color: var(--c-on-danger);
}

.btn--danger:hover {
    background: var(--c-danger);
    color: var(--c-on-danger);
    filter: brightness(0.92);
}

.btn--sm {
    min-height: 36px;
    padding: var(--space-1) var(--space-3);
    font-size: var(--fs-xs);
    border-radius: var(--radius-sm);
}

.btn--block { width: 100%; }

/* Icon-Button (quadratisch, Text im aria-label) */
.btn--icon {
    min-width: var(--tap);
    padding: var(--space-2);
    border-radius: var(--radius-pill);
}

.btn--icon.btn--sm {
    min-width: 36px;
    min-height: 36px;
}

/* Deaktiviert: nie verstecken, immer erkennbar */
.btn:disabled,
.btn[aria-disabled="true"] {
    background: var(--c-surface-2);
    color: var(--c-text-muted);
    border-color: var(--c-border);
    cursor: not-allowed;
    opacity: 0.75;
    box-shadow: none;
    pointer-events: none;   /* Links mit aria-disabled bleiben fokussierbar */
    transform: none;
    filter: none;
}

.btn-row {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
}

/* == 06 Chips, Badges, Pills ============================================= */

/* Filter-Chips: auf dem Handy horizontal scrollbar */
.chips {
    display: flex;
    gap: var(--space-2);
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: var(--space-2) 0;
    list-style: none;
    margin: 0;
}

.chips::-webkit-scrollbar { display: none; }

/* Bis an den Bildschirmrand scrollen, wenn der Eltern-Container Rand hat */
.chips--bleed {
    margin-inline: calc(var(--gutter) * -1);
    padding-inline: var(--gutter);
}

.chips--wrap {
    flex-wrap: wrap;
    overflow-x: visible;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    flex: 0 0 auto;
    scroll-snap-align: start;
    min-height: var(--tap);
    padding: var(--space-2) var(--space-4);
    border: 1px solid var(--c-border-strong);
    border-radius: var(--radius-pill);
    background: var(--c-surface);
    color: var(--c-text);
    font: inherit;
    font-size: var(--fs-sm);
    font-weight: var(--fw-medium);
    white-space: nowrap;
    text-decoration: none;
    cursor: pointer;
    transition: background var(--dur-fast) var(--ease),
                border-color var(--dur-fast) var(--ease);
}

.chip:hover {
    background: var(--c-primary-soft);
    color: var(--c-text);
    border-color: var(--c-primary);
}

.chip__emoji {
    font-size: 1.1em;
    line-height: 1;
}

.chip__count {
    display: inline-block;
    min-width: 1.5em;
    padding: 0 0.4em;
    border-radius: var(--radius-pill);
    background: var(--c-neutral-soft);
    color: var(--c-neutral-text);
    font-size: var(--fs-xs);
    font-weight: var(--fw-bold);
    text-align: center;
}

.chip[aria-pressed="true"],
.chip.is-active {
    background: var(--c-primary);
    border-color: var(--c-primary);
    color: var(--c-on-primary);
    font-weight: var(--fw-bold);
}

.chip[aria-pressed="true"] .chip__count,
.chip.is-active .chip__count {
    background: rgba(255, 255, 255, 0.28);
    color: var(--c-on-primary);
}

.chip[aria-disabled="true"],
.chip:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    pointer-events: none;
}

/* Badges: Status und Kennzeichnung */
.badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: 0.2em 0.65em;
    border-radius: var(--radius-pill);
    background: var(--c-neutral-soft);
    color: var(--c-neutral-text);
    font-size: var(--fs-xs);
    font-weight: var(--fw-bold);
    line-height: 1.6;
    white-space: nowrap;
}

.badge::before {
    content: "";
    width: 0.5em;
    height: 0.5em;
    border-radius: 50%;
    background: currentColor;
    flex: 0 0 auto;
}

.badge--open {                     /* „offen bis 22:00“ */
    background: var(--c-success-soft);
    color: var(--c-success);
}

.badge--soon {                     /* „öffnet um 17:00“ */
    background: var(--c-neutral-soft);
    color: var(--c-neutral-text);
}

.badge--unknown {                  /* „Zeiten unbekannt“ */
    background: var(--c-unknown-soft);
    color: var(--c-unknown-text);
}

.badge--unknown::before { opacity: 0.5; }

.badge--closed {                   /* „geschlossen“ */
    background: var(--c-danger-soft);
    color: var(--c-danger);
}

.badge--accent {
    background: var(--c-accent-soft);
    color: var(--c-accent-text);
}

.badge--plain::before { display: none; }

/* Pills: Tags ohne Zustand (Rezept-Tags, Küchen) */
.pill {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: 0.25em 0.7em;
    border: 1px solid var(--c-border);
    border-radius: var(--radius-pill);
    background: var(--c-surface-2);
    color: var(--c-text-muted);
    font-size: var(--fs-xs);
    font-weight: var(--fw-medium);
    text-decoration: none;
    white-space: nowrap;
}

a.pill:hover {
    border-color: var(--c-primary);
    color: var(--c-primary);
}

.pills {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    margin: 0;
    padding: 0;
    list-style: none;
}

/* == 07 Karten =========================================================== */

.card {
    position: relative;
    container-type: inline-size;   /* für die Aktionsleiste, siehe @container weiter unten */
    container-name: card;
    display: flex;
    flex-direction: column;
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.card__body {
    padding: var(--space-4);
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    flex: 1 1 auto;
}

.card__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-3);
}

.card__title {
    margin: 0;
    font-size: var(--fs-lg);
    font-weight: var(--fw-bold);
    line-height: var(--lh-tight);
    letter-spacing: -0.01em;
}

.card__title a {
    color: inherit;
    text-decoration: none;
}

.card__title a:hover { text-decoration: underline; }

/* Meta-Zeile: Punkte zwischen den Angaben, umbruchfähig */
.card__meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-1) var(--space-2);
    margin: 0;
    padding: 0;
    list-style: none;
    color: var(--c-text-muted);
    font-size: var(--fs-sm);
}

.card__meta > * + *::before {
    content: "·";
    margin-right: var(--space-2);
    color: var(--c-border-strong);
}

.card__note {
    margin: 0;
    color: var(--c-text-muted);
    font-size: var(--fs-sm);
}

.card__foot {
    padding: 0 var(--space-4) var(--space-4);
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

/* Bild 4:3, mit Verlauf als Platzhalter */
.card__media {
    position: relative;
    aspect-ratio: 4 / 3;
    background: linear-gradient(135deg, var(--c-accent-soft), var(--c-primary-soft) 55%, var(--c-bg-alt));
    overflow: hidden;
}

.card__media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.card__media--placeholder::after {
    content: "🍽";
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    opacity: 0.55;
}

.card__media-label {         /* z. B. „KI-Bild“ */
    position: absolute;
    left: var(--space-2);
    bottom: var(--space-2);
    padding: 0.15em 0.55em;
    border-radius: var(--radius-pill);
    background: var(--c-overlay);
    color: #fff;
    font-size: var(--fs-xs);
    font-weight: var(--fw-medium);
}

.card--recipe .card__body { gap: var(--space-2); }

/* Ausgegraute/geschlossene Läden bleiben sichtbar */
.card--muted {
    background: var(--c-bg-alt);
}

.card--muted .card__title { color: var(--c-text-muted); }

/* Hervorgehobene Karte (aktiver Marker auf der Karte) */
.card.is-selected {
    border-color: var(--c-primary);
    box-shadow: 0 0 0 2px var(--c-primary) inset, var(--shadow-md);
}

/* Horizontale Variante für die Finder-Liste auf breiten Schirmen */
.card--row .card__media {
    aspect-ratio: 1 / 1;
    width: 96px;
    flex: 0 0 96px;
    border-radius: var(--radius-md);
}

/* == 08 Aktionsleiste ====================================================
   Immer drei gleich große Flächen: Route · Anrufen · Bestellen.
   Nicht verfügbar = aria-disabled, ausgegraut, niemals versteckt. */

.card__actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--space-2);
}

.card__actions .btn {
    padding-inline: var(--space-2);
    min-height: var(--tap);
}

.card__actions .btn__label {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.card__links {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
    font-size: var(--fs-sm);
}

.link-google {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    min-height: 32px;
    color: var(--c-text-muted);
    text-decoration: none;
    font-weight: var(--fw-medium);
}

.link-google:hover {
    color: var(--c-primary);
    text-decoration: underline;
}

.link-google__star { color: var(--c-accent); }

/* Schmale Karte (Handy oder 400px-Spalte am Desktop): Icon über den Text stellen,
   damit „Bestellen“ in eine Zeile passt. Die Fläche bleibt über 44 px hoch.
   Container-Query: es zählt die Breite der Karte, nicht die des Fensters. */
@container card (max-width: 420px) {
    .card__actions .btn {
        flex-direction: column;
        gap: 2px;
        padding: var(--space-1);
        font-size: var(--fs-xs);
        line-height: 1.15;
    }

    .card__actions .btn .icon {
        width: 1.15rem;
        height: 1.15rem;
        vertical-align: baseline;
    }
}

/* Rückfall für Browser ohne Container-Queries */
@supports not (container-type: inline-size) {
    @media (max-width: 420px) {
        .card__actions .btn {
            flex-direction: column;
            gap: 2px;
            padding: var(--space-1);
            font-size: var(--fs-xs);
            line-height: 1.15;
        }

        .card__actions .btn .icon {
            width: 1.15rem;
            height: 1.15rem;
            vertical-align: baseline;
        }
    }
}

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

.form {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

.form-row {
    display: grid;
    gap: var(--space-4);
    grid-template-columns: 1fr;
}

@media (min-width: 640px) {
    .form-row--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .form-row--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.field {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    min-width: 0;
}

.field__label {
    font-size: var(--fs-sm);
    font-weight: var(--fw-bold);
    color: var(--c-text);
}

.field__hint {
    font-size: var(--fs-xs);
    color: var(--c-text-muted);
}

.field__error {
    font-size: var(--fs-xs);
    font-weight: var(--fw-bold);
    color: var(--c-danger);
}

.input,
.select,
.textarea {
    width: 100%;
    min-height: var(--tap);
    padding: var(--space-2) var(--space-3);
    border: 1px solid var(--c-border-strong);
    border-radius: var(--radius-md);
    background: var(--c-surface);
    color: var(--c-text);
    font: inherit;
    font-size: var(--fs-md);      /* 16px: iOS zoomt sonst beim Fokus */
    line-height: 1.4;
    transition: border-color var(--dur-fast) var(--ease);
}

.input::placeholder,
.textarea::placeholder { color: var(--c-text-muted); opacity: 1; }

.input:hover,
.select:hover,
.textarea:hover { border-color: var(--c-primary); }

.input:focus,
.select:focus,
.textarea:focus { border-color: var(--c-primary); }

.textarea {
    min-height: 120px;
    resize: vertical;
}

.select {
    appearance: none;
    padding-right: var(--space-6);
    background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
                      linear-gradient(135deg, currentColor 50%, transparent 50%);
    background-position: right var(--space-4) center, right calc(var(--space-4) - 5px) center;
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
}

.input[aria-invalid="true"],
.select[aria-invalid="true"],
.textarea[aria-invalid="true"] { border-color: var(--c-danger); }

.input:disabled,
.select:disabled,
.textarea:disabled {
    background: var(--c-surface-2);
    color: var(--c-text-muted);
    cursor: not-allowed;
}

/* Suchfeld mit Icon */
.search {
    position: relative;
    display: flex;
    align-items: center;
}

.search .icon {
    position: absolute;
    left: var(--space-3);
    color: var(--c-text-muted);
    pointer-events: none;
}

.search .input { padding-left: calc(var(--space-4) + 1.4em); }

/* Checkbox und Radio */
.check {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    min-height: var(--tap);
    padding: var(--space-1) 0;
    cursor: pointer;
}

.check__input {
    appearance: none;
    flex: 0 0 auto;
    width: 22px;
    height: 22px;
    margin: 0;
    margin-top: 0.15em;
    border: 2px solid var(--c-border-strong);
    border-radius: var(--radius-sm);
    background: var(--c-surface);
    cursor: pointer;
    display: grid;
    place-content: center;
    transition: background var(--dur-fast) var(--ease),
                border-color var(--dur-fast) var(--ease);
}

.check__input[type="radio"] { border-radius: 50%; }

.check__input::before {
    content: "";
    width: 12px;
    height: 12px;
    transform: scale(0);
    transition: transform var(--dur-fast) var(--ease);
    box-shadow: inset 1em 1em var(--c-on-primary);
    clip-path: polygon(14% 44%, 0 65%, 43% 100%, 100% 16%, 80% 0%, 40% 62%);
}

.check__input[type="radio"]::before {
    border-radius: 50%;
    clip-path: none;
    width: 10px;
    height: 10px;
}

.check__input:checked {
    background: var(--c-primary);
    border-color: var(--c-primary);
}

.check__input:checked::before { transform: scale(1); }

.check__input:disabled {
    background: var(--c-surface-2);
    border-color: var(--c-border);
    cursor: not-allowed;
}

.check__label { font-size: var(--fs-md); }

.check__label small {
    display: block;
    color: var(--c-text-muted);
    font-size: var(--fs-xs);
}

.check.is-done .check__label {
    text-decoration: line-through;
    color: var(--c-text-muted);
}

/* Gruppe aus Checkboxen/Radios */
.fieldset {
    border: 1px solid var(--c-border);
    border-radius: var(--radius-md);
    padding: var(--space-4);
    margin: 0;
}

.fieldset > legend {
    padding: 0 var(--space-2);
    font-size: var(--fs-sm);
    font-weight: var(--fw-bold);
}

/* == 10 Toast, Skeleton, Leerer Zustand, Einwilligung ==================== */

/* Toast-Bereich: einmal ins Layout, gefüllt von essali.toast() */
.toasts {
    position: fixed;
    left: 50%;
    bottom: calc(var(--space-4) + env(safe-area-inset-bottom, 0px));
    z-index: 300;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-2);
    width: min(420px, calc(100vw - 2 * var(--gutter)));
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    width: 100%;
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md);
    background: var(--c-text);
    color: var(--c-bg);
    box-shadow: var(--shadow-lg);
    font-size: var(--fs-sm);
    font-weight: var(--fw-medium);
    pointer-events: auto;
    animation: toast-in var(--dur-base) var(--ease);
}

.toast--success { background: var(--c-success); color: #fff; }
.toast--error { background: var(--c-danger); color: var(--c-on-danger); }

.toast__action {
    margin-left: auto;
    background: none;
    border: 0;
    color: inherit;
    font: inherit;
    font-weight: var(--fw-bold);
    text-decoration: underline;
    cursor: pointer;
    min-height: 32px;
}

.toast.is-leaving { animation: toast-out var(--dur-base) var(--ease) forwards; }

@keyframes toast-in {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: none; }
}

@keyframes toast-out {
    to { opacity: 0; transform: translateY(12px); }
}

/* Skeleton-Loader */
.skeleton {
    position: relative;
    background: var(--c-skeleton);
    border-radius: var(--radius-sm);
    overflow: hidden;
    color: transparent;
}

.skeleton::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, var(--c-skeleton-shine), transparent);
    transform: translateX(-100%);
    animation: skeleton-shine 1.4s infinite;
}

@keyframes skeleton-shine {
    to { transform: translateX(100%); }
}

.skeleton__line { height: 0.8em; margin-bottom: var(--space-2); }
.skeleton__line--title { height: 1.2em; width: 60%; }
.skeleton__line--short { width: 40%; }
.skeleton__block { aspect-ratio: 4 / 3; border-radius: 0; }

.skeleton-card {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-lg);
    padding: var(--space-4);
    overflow: hidden;
}

/* Leerer Zustand */
.empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: var(--space-2);
    padding: var(--space-7) var(--space-4);
    border: 1px dashed var(--c-border-strong);
    border-radius: var(--radius-lg);
    background: var(--c-surface-2);
}

.empty__icon {
    font-size: 2.5rem;
    line-height: 1;
}

.empty__title {
    margin: 0;
    font-size: var(--fs-lg);
    font-weight: var(--fw-bold);
}

.empty__text {
    margin: 0;
    max-width: 42ch;
    color: var(--c-text-muted);
    font-size: var(--fs-sm);
}

/* Einwilligungs-Box für Google-Inhalte */
.consent {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    padding: var(--space-4);
    border: 1px solid var(--c-border-strong);
    border-radius: var(--radius-lg);
    background: var(--c-surface-2);
}

.consent__title {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin: 0;
    font-size: var(--fs-md);
    font-weight: var(--fw-bold);
}

.consent__text {
    margin: 0;
    color: var(--c-text-muted);
    font-size: var(--fs-sm);
}

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

.consent__actions .btn { flex: 1 1 160px; }

/* == 11 Finder-Layout ====================================================
   Handy: Karte oben (~45 % Höhe), darunter die scrollbare Liste.
   Ab 900px: Liste links (400px), Karte rechts, beide auf voller Höhe. */

.finder {
    display: flex;
    flex-direction: column;
    min-height: calc(100svh - var(--topbar-h));
}

.finder__map {
    position: relative;
    height: var(--map-h);
    min-height: 200px;
    background: repeating-linear-gradient(
            45deg,
            var(--c-map-placeholder-a) 0 12px,
            var(--c-map-placeholder-b) 12px 24px);
    border-bottom: 1px solid var(--c-border);
    isolation: isolate;
}

/* Der MapLibre-Container selbst – wird von Agent „Karte“ befüllt */
.finder__map > #map,
.map-canvas {
    position: absolute;
    inset: 0;
}

.finder__map-note {
    position: absolute;
    right: var(--space-2);
    bottom: var(--space-2);
    z-index: 2;
    padding: 0.15em 0.55em;
    border-radius: var(--radius-pill);
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    color: var(--c-text-muted);
    font-size: var(--fs-xs);
}

.finder__map-note a { color: inherit; }

.finder__panel {
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: var(--c-bg);
}

.finder__filters {
    position: sticky;
    top: calc(var(--topbar-h) + env(safe-area-inset-top, 0px));
    z-index: 20;
    padding: var(--space-2) var(--gutter);
    background: var(--c-bg);
    border-bottom: 1px solid var(--c-border);
}

.finder__list {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    padding: var(--space-4) var(--gutter) var(--space-6);
    margin: 0;
    list-style: none;
    min-width: 0;
}

.finder__count {
    color: var(--c-text-muted);
    font-size: var(--fs-sm);
    padding: 0 var(--gutter);
}

@media (min-width: 900px) {
    .finder {
        display: grid;
        grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
        height: calc(100svh - var(--topbar-h));
        min-height: 0;
    }

    .finder__panel {
        grid-column: 1;
        grid-row: 1;
        overflow-y: auto;
        overscroll-behavior: contain;
        border-right: 1px solid var(--c-border);
    }

    .finder__map {
        grid-column: 2;
        grid-row: 1;
        height: 100%;
        border-bottom: 0;
    }

    .finder__filters { top: 0; }
}

/* == 12 Prose & Tabellen ================================================= */

.prose {
    max-width: 68ch;
    font-size: var(--fs-md);
}

.prose > * + * { margin-top: var(--space-4); }

.prose h2 { margin-top: var(--space-6); }
.prose h3 { margin-top: var(--space-5); }

.prose ul,
.prose ol { padding-left: 1.4em; }

.prose li + li { margin-top: var(--space-1); }

.prose blockquote {
    margin: 0;
    padding: var(--space-3) var(--space-4);
    border-left: 4px solid var(--c-primary);
    background: var(--c-surface-2);
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    color: var(--c-text-muted);
}

.prose img { border-radius: var(--radius-md); }

.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--fs-sm);
}

.table th,
.table td {
    padding: var(--space-2) var(--space-3);
    text-align: left;
    border-bottom: 1px solid var(--c-border);
    vertical-align: top;
}

.table th {
    font-weight: var(--fw-bold);
    color: var(--c-text);
    background: var(--c-surface-2);
    white-space: nowrap;
}

.table tbody tr:hover { background: var(--c-surface-2); }

.table td.is-numeric,
.table th.is-numeric { text-align: right; font-variant-numeric: tabular-nums; }

/* Einkaufszettel: Liste mit Abteilungen */
.basket__group + .basket__group { margin-top: var(--space-5); }

.basket__group-title {
    margin: 0 0 var(--space-2);
    font-size: var(--fs-sm);
    font-weight: var(--fw-black);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--c-text-muted);
}

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

.basket__item {
    border-bottom: 1px solid var(--c-border);
}

.basket__amount {
    color: var(--c-text-muted);
    font-variant-numeric: tabular-nums;
}

/* == 13 Utilities ======================================================== */

.text-muted { color: var(--c-text-muted); }
.text-sm { font-size: var(--fs-sm); }
.text-xs { font-size: var(--fs-xs); }
.text-center { text-align: center; }
.text-bold { font-weight: var(--fw-bold); }
.nowrap { white-space: nowrap; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.mt-4 { margin-top: var(--space-4); }
.mb-4 { margin-bottom: var(--space-4); }
.flex-between {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
}

.divider {
    height: 1px;
    background: var(--c-border);
    border: 0;
    margin: var(--space-4) 0;
}

.print-only { display: none; }

/* Weniger Bewegung, wenn gewünscht */
@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }

    *,
    *::before,
    *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }

    .skeleton::after { display: none; }
}

/* Höherer Kontrast, wenn das System ihn verlangt */
@media (prefers-contrast: more) {
    :root {
        --c-border: var(--c-border-strong);
        --c-text-muted: var(--c-text);
    }
}

/* == 14 Druck: Einkaufszettel ============================================
   Gedruckt wird die Liste – sonst nichts. */

@media print {
    :root {
        --c-bg: #fff;
        --c-surface: #fff;
        --c-surface-2: #fff;
        --c-text: #000;
        --c-text-muted: #333;
        --c-border: #999;
        --c-border-strong: #666;
        --shadow-sm: none;
        --shadow-md: none;
        --shadow-lg: none;
    }

    body {
        background: #fff !important;
        color: #000 !important;
        font-size: 11pt;
    }

    .topbar,
    .footer,
    .toasts,
    .chips,
    .finder__map,
    .card__actions,
    .consent,
    .segmented,
    .btn,
    .skip-link,
    .no-print {
        display: none !important;
    }

    .print-only { display: block; }

    .main {
        max-width: none;
        padding: 0;
    }

    .card,
    .skeleton-card {
        border: 1px solid #999;
        box-shadow: none;
        break-inside: avoid;
    }

    /* Checkboxen als echte Kästchen zum Abhaken */
    .check {
        min-height: 0;
        padding: 2pt 0;
        break-inside: avoid;
    }

    .check__input,
    .check__input:checked {
        appearance: none;
        width: 12pt;
        height: 12pt;
        border: 1pt solid #000 !important;
        border-radius: 2pt;
        background: #fff !important;
        margin-top: 2pt;
        print-color-adjust: exact;
        -webkit-print-color-adjust: exact;
    }

    .check__input::before { display: none; }

    .basket__group-title {
        color: #000;
        border-bottom: 1pt solid #000;
        padding-bottom: 2pt;
        break-after: avoid;
    }

    .basket__item { border-bottom: 0.5pt dotted #999; }

    a { color: #000; text-decoration: none; }

    a[href^="http"]::after {
        content: " (" attr(href) ")";
        font-size: 8pt;
        color: #555;
    }

    .basket a[href]::after { content: ""; }

    h1 { font-size: 18pt; }
    h2 { font-size: 14pt; }
}
