/* Familienrezept – gemeinsames Stylesheet für App-Shell, Login und Einladung (AP 0.4).
   Mobil zuerst (360–430 px), Tippflächen min. 44 px, hell/dunkel über prefers-color-scheme.
   Keine Inline-Stile (CSP style-src 'self'): Zustände nur über Klassen und [hidden]. */
:root {
  --bg: #f6f5f2; --card: #fff; --text: #1d1d1b; --muted: #6b6b66; --line: #ddd9d0; --soft: #efece6;
  --accent: #b5502b; --accent-text: #fff; --accent-soft: #f6e4dc;
  --err: #b3261e; --err-soft: #fbe9e7; --ok: #2e7d4f; --ok-soft: #e3f2e8;
  --warn: #8a6100; --warn-soft: #fdf0c4; --pending: #6b6b66; --pending-soft: #ecebe7;
  --shadow: 0 8px 30px rgba(0, 0, 0, .18); --backdrop: rgba(0, 0, 0, .4);
  --radius: 12px; --radius-sm: 8px; --tap: 44px; --tabbar: 60px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161614; --card: #22221f; --text: #eceae4; --muted: #a3a199; --line: #3a3a35; --soft: #2c2c28;
    --accent: #e07a50; --accent-text: #161614; --accent-soft: #3a2a22;
    --err: #f2b8b5; --err-soft: #3b2220; --ok: #8fd4a8; --ok-soft: #1f3227;
    --warn: #f0c75e; --warn-soft: #3a3016; --pending: #a3a199; --pending-soft: #2c2c28;
    --shadow: 0 8px 30px rgba(0, 0, 0, .6); --backdrop: rgba(0, 0, 0, .6);
  }
}

/* ---------- Grundlagen ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.45 var(--font);
       overflow-wrap: anywhere; }
h1 { margin: 0 0 12px; font-size: 1.6rem; line-height: 1.2; }
h2 { margin: 0 0 4px; font-size: 1.2rem; line-height: 1.25; }
h3 { margin: 0 0 4px; font-size: 1rem; }
p { margin: 0 0 8px; }
a { color: var(--accent); }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.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; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Formularfelder ---------- */
label { display: block; margin: 12px 0 4px; color: var(--muted); font-size: .9rem; }
label:first-child { margin-top: 0; }
input, select, textarea { width: 100%; min-height: var(--tap); padding: 8px 12px; font: inherit; color: var(--text);
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-sm); }
textarea { min-height: 88px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
input[readonly] { background: var(--soft); }
.check { display: flex; align-items: center; gap: 10px; min-height: var(--tap); margin: 8px 0 0; color: var(--text);
         font-size: 1rem; cursor: pointer; }
.check input { width: 22px; min-height: 22px; height: 22px; margin: 0; accent-color: var(--accent); }
.field-hint { margin: 4px 0 0; color: var(--muted); font-size: .85rem; }
.err { min-height: 1.4em; margin-top: 8px; color: var(--err); }
.err:empty { min-height: 0; margin: 0; }

/* ---------- Knöpfe ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: var(--tap);
       padding: 8px 16px; font: inherit; font-weight: 600; text-decoration: none; border: 1px solid transparent;
       border-radius: var(--radius-sm); background: var(--accent); color: var(--accent-text); cursor: pointer; }
.btn:disabled { opacity: .6; cursor: default; }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--line); }
.btn-danger { background: transparent; color: var(--err); border-color: var(--err); }
.btn-block { width: 100%; margin-top: 16px; }
.btn-sm { min-height: 36px; padding: 4px 12px; font-size: .9rem; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.btn-row .btn { flex: 1 1 auto; }
.link-btn { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); cursor: pointer;
            text-decoration: underline; }

/* ---------- Karten, Listen, Chips ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px;
        margin-bottom: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.card-head h2 { margin: 0; }
.card h3 { margin-top: 16px; }
.list { list-style: none; margin: 0; padding: 0; }
.list > li { border-top: 1px solid var(--line); }
.list > li:first-child { border-top: 0; }
.row { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 56px; padding: 8px 0; color: inherit;
       font: inherit; text-align: left; background: none; border: 0; }
button.row { cursor: pointer; }
.row-main { flex: 1 1 auto; min-width: 0; }
.row-title { font-weight: 600; }
.row-sub { color: var(--muted); font-size: .875rem; }
.row-chev { color: var(--muted); flex: 0 0 auto; }
.chip { display: inline-flex; align-items: center; min-height: 28px; padding: 2px 10px; margin: 2px 4px 2px 0;
        font: inherit; font-size: .8rem; color: var(--text); background: var(--soft); border: 1px solid var(--line);
        border-radius: 99px; white-space: nowrap; }
button.chip { min-height: 36px; cursor: pointer; }
.chip.on, .chip-accent { background: var(--accent-soft); border-color: var(--accent); color: var(--text); }
.chip-off { color: var(--muted); }
.notice { padding: 12px 14px; border-radius: var(--radius-sm); background: var(--accent-soft); margin-bottom: 16px; }
.notice-ok { background: var(--ok-soft); }
.steps { margin: 8px 0 0; padding-left: 1.3em; }
.steps li { margin: 4px 0; }
.steps .done { color: var(--muted); text-decoration: line-through; }
.empty { padding: 32px 8px; text-align: center; color: var(--muted); }
.empty .empty-icon { display: block; font-size: 2.2rem; margin-bottom: 8px; }
.copy-row { display: flex; gap: 8px; margin-top: 8px; }
.copy-row input { flex: 1 1 auto; min-width: 0; font-size: .85rem; }

/* ---------- App-Shell ---------- */
.app-header { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: var(--bg);
  border-bottom: 1px solid var(--line); }
.app-header h1 { margin: 0; font-size: 1.25rem; }
.app-header .who { color: var(--muted); font-size: .85rem; text-align: right; min-width: 0; overflow: hidden;
                   text-overflow: ellipsis; white-space: nowrap; }
.view { max-width: 720px; margin: 0 auto;
        padding: 16px 16px calc(var(--tabbar) + 24px + env(safe-area-inset-bottom)); }
.view:focus { outline: none; }
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; justify-content: space-around;
  height: calc(var(--tabbar) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: var(--card); border-top: 1px solid var(--line); }
.tab { flex: 1 1 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
       min-width: 0; color: var(--muted); text-decoration: none; font-size: .75rem; font-weight: 600; }
.tab-icon { font-size: 1.3rem; line-height: 1; }
.tab[aria-current="page"] { color: var(--accent); }
.loading { padding: 32px 0; text-align: center; color: var(--muted); }

/* ---------- Sheet (unten aufgehend) ---------- */
.sheet-backdrop { position: fixed; inset: 0; z-index: 40; background: var(--backdrop); display: flex;
                  align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 560px; max-height: 88vh; overflow-y: auto; background: var(--card);
         border-radius: 16px 16px 0 0; padding: 8px 16px calc(20px + env(safe-area-inset-bottom));
         box-shadow: var(--shadow); animation: sheet-in .18s ease-out; }
.sheet-grip { width: 40px; height: 5px; margin: 4px auto 12px; border-radius: 3px; background: var(--line); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.sheet-head h2 { margin: 0; }
.sheet-close { min-width: var(--tap); min-height: var(--tap); font-size: 1.4rem; line-height: 1; color: var(--muted);
               background: none; border: 0; cursor: pointer; }
.sheet .actions { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.sheet .actions .btn { width: 100%; }
@keyframes sheet-in { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (min-width: 600px) {
  .sheet-backdrop { align-items: center; }
  .sheet { border-radius: 16px; }
}
@media (prefers-reduced-motion: reduce) { .sheet { animation: none; } }
body.no-scroll { overflow: hidden; }

/* ---------- Toast ---------- */
.toasts { position: fixed; left: 0; right: 0; z-index: 60; bottom: calc(var(--tabbar) + 12px + env(safe-area-inset-bottom));
          display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 0 16px; pointer-events: none; }
.toast { max-width: 480px; width: 100%; padding: 12px 16px; border-radius: var(--radius-sm); background: var(--text);
         color: var(--bg); box-shadow: var(--shadow); pointer-events: auto; }
.toast-err { background: var(--err); color: #fff; }
@media (prefers-color-scheme: dark) { .toast-err { color: #161614; } }

/* ---------- Login / Einladung ---------- */
.login { max-width: 380px; margin: 12vh auto 0; padding: 0 16px 32px; }
.login .card { margin-bottom: 12px; }
.help { margin-top: 8px; }
.help summary { min-height: var(--tap); display: flex; align-items: center; color: var(--accent); cursor: pointer; }
.help p { margin: 0 0 8px; color: var(--muted); }

/* ---------- Breite Bildschirme ---------- */
@media (min-width: 900px) {
  .view { max-width: 960px; }
  .grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
  .grid-2 > .card { margin-bottom: 0; }
  .grid-2 + .card, .grid-2 + .grid-2 { margin-top: 16px; }
}

/* ---------- Tag-Farben (recipes.TAG_COLORS, Klassen statt Inline-Stil) ---------- */
.tc-standard { background: var(--accent-soft); color: var(--accent); }
.tc-rot { background: #e5534b; color: #fff; }
.tc-orange { background: #ef8a3a; color: #fff; }
.tc-gelb { background: #e8c547; color: #3b3000; }
.tc-gruen { background: #4f9d5d; color: #fff; }
.tc-tuerkis { background: #2aa198; color: #fff; }
.tc-blau { background: #4a7fd0; color: #fff; }
.tc-lila { background: #8b62c9; color: #fff; }
.tc-rosa { background: #e27aa8; color: #fff; }
.tc-grau { background: #8d8b84; color: #fff; }
.tag-dot { display: inline-block; flex: 0 0 auto; width: 10px; height: 10px; margin-right: 6px; border-radius: 50%; }
.tag-dot.tc-standard { background: var(--accent); }
.tag-dot-lg { width: 16px; height: 16px; margin: 0; }
.chip-tag { gap: 0; }
.chip-add { color: var(--accent); border-style: dashed; background: transparent; }
.chip-row { display: flex; flex-wrap: wrap; gap: 4px; margin: 8px 0 12px; }
.chip-row .chip { margin: 0; }
.color-pick { display: flex; flex-wrap: wrap; gap: 8px; }
.color-opt { position: relative; margin: 0; cursor: pointer; }
.color-opt input { position: absolute; opacity: 0; width: 1px; height: 1px; min-height: 0; }
.color-swatch { display: block; width: 40px; height: 40px; border-radius: 50%; border: 3px solid transparent; }
.color-swatch.tc-standard { background: var(--accent-soft); border-color: var(--line); }
.color-opt input:checked + .color-swatch { border-color: var(--text); box-shadow: 0 0 0 2px var(--card) inset; }
.color-opt input:focus-visible + .color-swatch { outline: 2px solid var(--accent); outline-offset: 2px; }
.label-like { margin: 12px 0 4px; color: var(--muted); font-size: .9rem; }

/* ---------- Rezeptliste ---------- */
.btn-main { flex: 0 0 auto; }
.list-head { display: flex; gap: 8px; align-items: center; }
.search-wrap { flex: 1 1 auto; min-width: 0; }
.tiles { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.tile { display: flex; gap: 12px; align-items: center; padding: 10px 12px; min-height: 72px; color: inherit;
        text-decoration: none; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.tile:hover { border-color: var(--accent); }
.tile-badge { flex: 0 0 auto; display: flex; align-items: center; justify-content: center; width: 52px; height: 52px;
              border-radius: 10px; font-size: 1.5rem; font-weight: 700; }
.tile-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.tile-title { font-weight: 600; }
.tile-meta { color: var(--muted); font-size: .85rem; }
.tile-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.tile-tags .chip { margin: 0; min-height: 22px; font-size: .75rem; padding: 0 8px; }
.center { text-align: center; }
.pre { white-space: pre-line; }
@media (min-width: 700px) { .tiles { grid-template-columns: 1fr 1fr; } }

/* ---------- Rezept-Detail ---------- */
.back { display: inline-flex; align-items: center; min-height: var(--tap); margin: -8px 0 4px; text-decoration: none; }
.recipe-title { font-size: 1.5rem; margin-bottom: 8px; }
.recipe .tile-tags { margin-bottom: 8px; }
.stepper { display: flex; align-items: center; justify-content: center; gap: 16px; margin: 4px 0 4px; }
.stepper-btn { width: 48px; height: 48px; font: inherit; font-size: 1.5rem; line-height: 1; color: var(--accent);
               background: var(--accent-soft); border: 1px solid var(--accent); border-radius: 50%; cursor: pointer; }
.stepper-btn:disabled { opacity: .4; cursor: default; }
.stepper-value { min-width: 120px; text-align: center; font-weight: 600; font-size: 1.1rem; }
.ing-section { margin: 16px 0 4px; font-size: .95rem; color: var(--muted); }
.ing { list-style: none; margin: 8px 0 0; padding: 0; }
.ing li { display: flex; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); }
.ing li:first-child { border-top: 0; }
.ing-qty { flex: 0 0 6.5em; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.ing-name { flex: 1 1 auto; min-width: 0; }

/* ---------- Editor ---------- */
.field-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-pair label { margin-top: 12px; }
.lines { list-style: none; margin: 8px 0 0; padding: 0; }
.lines-section { margin: 12px 0 0; font-weight: 600; color: var(--muted); font-size: .9rem; }
.lines-empty { padding: 8px 0; }
.ln { padding: 10px 0; border-top: 1px solid var(--line); }
.ln:first-child, .lines-section + .ln { border-top: 0; }
.ln-top { display: flex; align-items: center; gap: 8px; }
.ln-fields { display: grid; grid-template-columns: 4.5em 6.5em minmax(0, 1fr); gap: 6px; margin-top: 6px; }
.ln-fields input, .ln-fields select { min-height: 40px; padding: 6px 8px; }
.ln-amount.invalid { border-color: var(--err); }
.ln-del { flex: 0 0 auto; width: var(--tap); height: var(--tap); font-size: 1.4rem; line-height: 1; color: var(--muted);
          background: none; border: 0; cursor: pointer; }
.ing-chip { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 6px; min-height: var(--tap);
            padding: 6px 12px; font: inherit; font-weight: 600; text-align: left; border-radius: 99px; cursor: pointer;
            border: 1px solid var(--line); background: var(--soft); color: var(--text); }
.ing-chip.st-ok { background: var(--ok-soft); border-color: var(--ok); }
.ing-chip.st-pending { background: var(--pending-soft); border-color: var(--pending); border-style: dashed; }
.ing-chip.st-ask { background: var(--warn-soft); border-color: var(--warn); }
.chip-flag { margin-left: auto; padding: 0 6px; font-size: .75rem; font-weight: 600; border-radius: 99px;
             background: var(--card); color: var(--muted); }
.ask-box { margin-top: 8px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--warn-soft);
           border: 1px solid var(--warn); }
.ask-box p { margin: 0 0 8px; }
.ask-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.ask-actions .btn { flex: 1 1 auto; }
.ask-actions .btn-ghost { background: var(--card); }
.quick-add { display: flex; gap: 8px; margin-top: 12px; }
.quick-add input { flex: 1 1 auto; min-width: 0; }
.quick-add .btn { flex: 0 0 var(--tap); padding: 0; font-size: 1.4rem; }
.pick-list { margin-top: 8px; }
.pick-head { padding: 8px 0 4px; }
.savebar { position: sticky; bottom: calc(var(--tabbar) + 8px + env(safe-area-inset-bottom)); z-index: 5;
           display: flex; align-items: center; gap: 12px; padding: 10px 12px; background: var(--card);
           border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.savebar-info { flex: 1 1 auto; min-width: 0; }
.savebar-status { color: var(--warn); font-weight: 600; text-align: left; }
.savebar .err { margin-top: 0; }
.savebar .btn { flex: 0 0 auto; }

/* ---------- Zutatensuche (AP 1.6) und Basics (AP 1.9) ---------- */
.btn-pantry { margin-top: 8px; width: 100%; white-space: normal; text-align: center; }
.picker .pick-list:empty { display: none; }
.chip-remove { gap: 6px; }
.chip-x { font-size: 1.1rem; line-height: 1; color: var(--muted); }
.stage { margin-top: 16px; }
.stage-title { font-size: 1rem; margin: 0 0 8px; }
.tile-missing { color: var(--muted); font-size: .85rem; overflow-wrap: anywhere; }
.basic-list .row-title { overflow-wrap: anywhere; }

/* ---------- Verwaltung (AP 1.7) ---------- */
.admin-item { padding: 12px 0; }
.admin-item .row-title { overflow-wrap: anywhere; }
.admin-item .notice { margin: 8px 0 0; }
.admin-item .chip-row { align-items: center; margin: 6px 0 0; }
.admin-actions { margin-top: 8px; }
.admin-actions .btn { flex: 0 1 auto; }

/* ---------- Teilen (AP 1.8) ---------- */
.tile-static:hover { border-color: var(--line); }
.shared-action { margin: 12px 0 16px; }
.shared-action .btn-block { margin-top: 0; }
.shared-action .notice .btn { margin-top: 4px; }
