/* =====================================================================
   Macros — "Ember on Graphite"  (Award-Edition)
   ---------------------------------------------------------------------
   Ein ruhiges, anthrazitfarbenes Graphit-Canvas mit einem einzigen,
   selbstbewussten Ember-Rot als Akzent. Praezisions-Instrument-Look:
   feine Haarlinien, tabellarische Ziffern, gestufte Tiefe, dezenter
   Kantenglanz, ruhige Mikro-Interaktionen.

   - Reines Vanilla-CSS, CSP-konform: nur System-Schriften, CSS-Gradients
     und -Formen, kein url(...) auf fremde Quellen, keine Daten-URIs,
     keine externen Fonts/CDNs, keine Emojis.
   - Nutzt die VORHANDENEN Klassennamen -> Drop-in fuer style.css.
   - Die Fortschritts-Farbe der Ringe kommt per Inline-`stroke` aus
     app.js und kann hier NICHT ueberschrieben werden. Ein optionaler
     JS-Patch (fuer Ring-Glow) steht in DESIGN_AWARD.md.
   - Optionale Komponenten (Makro-Balken, Rezept-Karten, Mahlzeit-Zeilen
     mit Icon) am Ende; HTML-Snippets in DESIGN_AWARD.md.
   ===================================================================== */

/* ===================================================================
   1. DESIGN-TOKENS
   =================================================================== */
:root {
  /* --- Graphit-Flaechen (anthrazit, mehrstufig, leicht kuehl) --- */
  --bg:         #0f1013;  /* App-Grund, tiefes Anthrazit            */
  --bg-2:       #16181d;  /* zweiter Verlaufston (Lichtquelle oben) */
  --surface:    #16181c;  /* Karten / Sektionen                     */
  --surface-2:  #1d2026;  /* erhabene Flaechen, Hover, Inputs       */
  --surface-3:  #262a31;  /* Track / Fuellungen / aktive Felder     */
  --line:       #2c313b;  /* Rahmen / Trennlinien                   */
  --line-soft:  #21252c;  /* leise Trennlinien innerhalb Karten     */

  /* --- Text --- */
  --text:       #f2f3f5;  /* Primaertext, warm-neutral              */
  --muted:      #a2a8b2;  /* Sekundaertext                          */
  --faint:      #6b7280;  /* Hinweise / Einheiten                   */

  /* --- Akzent: Ember-Rot --- */
  --accent:      #e5484d; /* Hauptakzent (Radix-Red-Familie)        */
  --accent-2:    #ff5b60; /* heller fuer Verlauf / Hover            */
  --accent-deep: #aa2127; /* gedeckt fuer Raender                   */
  --accent-soft: rgba(229, 72, 77, .12);  /* zarte Fuellung         */
  --accent-line: rgba(229, 72, 77, .30);  /* zarte Kontur           */
  --accent-glow: rgba(229, 72, 77, .42);  /* Schein hinter Akzent   */
  --on-accent:   #fff5f5; /* Text auf Rot                           */

  /* --- Makro-/Status-Farben (Spiegel der app.js-Inline-Farben) --- */
  --kcal:    #e5484d;     /* Kalorien   -> Akzent                   */
  --protein: #a78bfa;     /* Eiweiss    -> Violett                  */
  --carbs:   #38bdf8;     /* Kohlenhydr.-> Sky                      */
  --fat:     #fbbf24;     /* Fett       -> Amber                    */
  --water:   #22d3ee;     /* Wasser     -> Cyan                     */
  --good:    #34d399;     /* erreicht   -> Gruen                    */
  --over:    #fb923c;     /* ueberschritten -> Orange               */

  /* --- Form / Rhythmus --- */
  --r-xs:   8px;
  --r-sm:   12px;
  --r-md:   16px;
  --r-lg:   20px;
  --r-xl:   26px;
  --r-pill: 999px;

  --s-1: 4px;  --s-2: 8px;  --s-3: 12px; --s-4: 16px;
  --s-5: 20px; --s-6: 24px; --s-8: 32px; --s-10: 40px;

  /* --- Tiefe: gestufte Schatten + Kantenglanz --- */
  --edge:      inset 0 1px 0 rgba(255, 255, 255, .045);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .30);
  --shadow-md: 0 6px 18px -6px rgba(0, 0, 0, .50);
  --shadow-lg: 0 18px 44px -16px rgba(0, 0, 0, .62);
  --shadow-accent: 0 10px 26px -8px var(--accent-glow);

  /* --- Fokus-Ring (einheitlich, rot) --- */
  --focus: 0 0 0 3px rgba(229, 72, 77, .42);

  /* --- Bewegung --- */
  --ease: cubic-bezier(.32, .72, 0, 1);
  --fast: .14s;
  --med:  .26s;
}

/* ===================================================================
   2. RESET / GRUNDGERUEST
   =================================================================== */
* { box-sizing: border-box; }

/* CSP-sichere Sicherheits-Regel: hidden bleibt hidden, egal welches
   display spaeter gesetzt wird. */
[hidden] { display: none !important; }

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

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-size: 16px;
  line-height: 1.5;
  letter-spacing: -.003em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;

  display: flex;
  flex-direction: column;
  align-items: center;

  /* Geschichtetes Graphit-Canvas: warmer Akzent-Hauch oben,
     kuehler Lichtkegel, dann der tiefe Grund. */
  background:
    radial-gradient(1100px 520px at 50% -240px, rgba(229, 72, 77, .10), transparent 70%),
    radial-gradient(900px 600px at 50% -120px, var(--bg-2), transparent 62%),
    var(--bg);
  background-attachment: fixed;
}

main {
  width: 100%;
  max-width: 760px;
  padding: var(--s-5) var(--s-4) 112px;
}

/* Sanfter Auftritt beim View-Wechsel (per hidden-Toggle in app.js). */
.view:not([hidden]) {
  animation: viewIn var(--med) var(--ease) both;
}
@keyframes viewIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

/* ===================================================================
   3. TYPOGRAFIE
   =================================================================== */
h1 {
  margin: 0 0 var(--s-1);
  font-size: clamp(26px, 6vw, 30px);
  font-weight: 800;
  letter-spacing: -.022em;
  line-height: 1.1;
}
.sub {
  color: var(--muted);
  margin: 0 0 var(--s-2);
  font-size: 14px;
}

/* Tabellarische Ziffern fuer alle Mess-/Zahlenwerte. */
.val, .pct, .food-kcal, .totals, table.nutri,
.weekstrip .dot, .weight-input, .macrobar .num, .dayplan .big {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

/* ===================================================================
   4. BUTTONS
   =================================================================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: var(--s-2);
  padding: 12px 18px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--line);
  box-shadow: var(--edge);
  cursor: pointer;
  font-size: 15px; font-weight: 650;
  line-height: 1.1;
  letter-spacing: -.01em;
  transition: background var(--fast) var(--ease),
              border-color var(--fast) var(--ease),
              box-shadow var(--fast) var(--ease),
              transform var(--fast) var(--ease);
}
.btn:hover { background: var(--surface-3); border-color: #353b46; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--focus); }

.btn.primary {
  position: relative;
  width: 100%;
  margin-top: var(--s-3);
  color: var(--on-accent);
  border: 1px solid transparent;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .14), transparent 42%),
    linear-gradient(135deg, var(--accent-2), var(--accent));
  box-shadow: var(--shadow-accent), var(--edge);
}
.btn.primary:hover { filter: brightness(1.06) saturate(1.04); }
.btn.primary:active { filter: brightness(.98); }

.btn.ghost {
  background: transparent;
  border-color: var(--line);
  box-shadow: none;
  color: var(--muted);
}
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }

.btn.small { font-size: 13px; padding: 8px 13px; margin-top: var(--s-3); }
.btn:disabled { opacity: .42; cursor: not-allowed; box-shadow: none; filter: none; }

.controls { margin: var(--s-4) 0; }

/* Datei-Upload als Button (label.btn) */
label.btn { cursor: pointer; }
label.btn input[type="file"] { display: none; }

#preview {
  width: 100%; margin-top: var(--s-3);
  border-radius: var(--r-md);
  max-height: 360px; object-fit: cover;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-md);
}
.status { margin: var(--s-3) 0; min-height: 22px; color: var(--muted); font-size: 14px; }

/* ===================================================================
   5. KARTEN
   =================================================================== */
.card {
  position: relative;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .018), transparent 120px),
    var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--s-5);
  margin-top: var(--s-4);
  box-shadow: var(--shadow-md), var(--edge);
}
.card h2 { margin: 0 0 var(--s-3); font-size: 17px; font-weight: 750; letter-spacing: -.01em; }
.card h3 { margin: 0 0 var(--s-3); font-size: 16px; font-weight: 750; }

/* Dezente, gross gesperrte Sektions-Ueberschrift mit Akzent-Tick. */
.card-title {
  display: flex; align-items: center; gap: var(--s-2);
  margin: 0 0 var(--s-4);
  font-size: 12px; font-weight: 800;
  letter-spacing: .10em; text-transform: uppercase;
  color: var(--muted);
}
.card-title::before {
  content: ""; width: 3px; height: 13px;
  border-radius: var(--r-pill);
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  box-shadow: 0 0 10px var(--accent-glow);
}

/* ===================================================================
   6. RINGE  (Donut-Diagramme)
   =================================================================== */
.rings {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(88px, 1fr));
  gap: var(--s-3);
}
.rings.big { grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); }

.cell { text-align: center; }
.ringwrap {
  position: relative;
  width: var(--ring, 72px); height: var(--ring, 72px);
  margin: 0 auto;
}
.ringsvg { width: var(--ring, 72px); height: var(--ring, 72px); transform: rotate(-90deg); display: block; }
.ringsvg .track { fill: none; stroke: var(--surface-3); stroke-width: 6.5; }
.ringsvg .prog {
  fill: none; stroke-width: 6.5; stroke-linecap: round;
  transition: stroke-dashoffset .7s var(--ease);
}
.ringwrap .pct {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: var(--pct, 13px); color: var(--text); font-weight: 750;
  letter-spacing: -.02em;
}
.ringwrap.over .pct { color: var(--over); }

.cell .lbl { margin-top: var(--s-2); font-size: 13px; color: var(--text); font-weight: 650; }
.cell .val { font-size: 11px; color: var(--muted); margin-top: 1px; }

/* ===================================================================
   7. WASSER-BUTTONS
   =================================================================== */
.water-btns { display: flex; gap: var(--s-2); margin-top: var(--s-2); }
.water-btns .btn { flex: 1; padding-left: 0; padding-right: 0; }

/* ===================================================================
   8. MAHLZEITEN
   =================================================================== */
.meal {
  display: flex; justify-content: space-between; align-items: center;
  padding: 13px 0; border-bottom: 1px solid var(--line-soft);
  font-size: 14px;
}
.meal:last-child { border-bottom: none; }
.meal span { color: var(--text); }
.meal b { color: var(--text); font-variant-numeric: tabular-nums; }
.note { color: var(--muted); font-size: 14px; }

/* ===================================================================
   9. ANALYSE-ERGEBNIS
   =================================================================== */
.totals h2 { margin-bottom: var(--s-4); }
.totals .macros { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--s-2); }
.totals .macros div {
  position: relative; overflow: hidden;
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-sm);
  padding: 14px 8px;
  text-align: center;
}
/* Farbcodierte Kopfkante je Makro: kcal, Eiweiss, KH, Fett */
.totals .macros div::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px;
}
.totals .macros div:nth-child(1)::before { background: var(--kcal); }
.totals .macros div:nth-child(2)::before { background: var(--protein); }
.totals .macros div:nth-child(3)::before { background: var(--carbs); }
.totals .macros div:nth-child(4)::before { background: var(--fat); }
.totals .macros b { display: block; font-size: 18px; color: #fff; font-variant-numeric: tabular-nums; }
.totals .macros span { font-size: 11px; color: var(--muted); }

.grams { color: var(--muted); font-weight: 400; font-size: 14px; }
.conf { float: right; color: var(--faint); font-size: 12px; font-weight: 400; }

.weight {
  display: inline-flex; align-items: center; gap: var(--s-2);
  font-size: 13px; color: var(--muted); margin-bottom: var(--s-4);
}
.weight-input {
  width: 96px; padding: 9px 11px;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--r-xs);
  font-size: 16px;          /* >= 16px: kein iOS-Zoom */
}
.weight-input:focus-visible { outline: none; box-shadow: var(--focus); border-color: var(--accent); }

.ai-hint {
  display: inline-block; margin: 0 0 var(--s-4); padding: 4px 0;
  background: none; border: none; color: var(--accent-2);
  cursor: pointer; font-size: 12px; text-decoration: underline; text-underline-offset: 2px;
}
.ai-hint:hover { color: var(--accent); }

table.nutri { width: 100%; border-collapse: collapse; font-size: 13px; }
table.nutri th, table.nutri td { padding: 8px 6px; text-align: right; border-bottom: 1px solid var(--line-soft); }
table.nutri th { color: var(--muted); font-weight: 700; vertical-align: bottom; }
table.nutri th span { font-weight: 400; font-size: 11px; }
table.nutri td.name, table.nutri th:first-child { text-align: left; }
table.nutri tbody tr:hover td { background: rgba(255, 255, 255, .015); }
table.nutri .u { color: var(--faint); font-size: 11px; }
tr.grouprow td {
  text-align: left; font-weight: 800; color: var(--accent-2);
  padding-top: var(--s-4); border-bottom: none;
  font-size: 11px; letter-spacing: .07em; text-transform: uppercase;
}

.disclaimer { color: var(--muted); font-size: 12px; margin-top: var(--s-5); line-height: 1.55; }

/* ===================================================================
   10. FORMULARE
   =================================================================== */
main.auth { max-width: 420px; }

form label { display: block; font-size: 13px; color: var(--muted); margin-bottom: var(--s-3); }
form input[type="email"],
form input[type="password"],
form input[type="text"],
form input[type="number"],
form textarea,
form select {
  display: block; width: 100%; margin-top: var(--s-1);
  padding: 12px 13px;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--r-xs);
  font-size: 16px;          /* >= 16px: kein iOS-Zoom */
  transition: border-color var(--fast) var(--ease), box-shadow var(--fast) var(--ease), background var(--fast) var(--ease);
}
form textarea { font: inherit; font-size: 16px; line-height: 1.5; resize: vertical; min-height: 120px; }
form input:hover, form textarea:hover, form select:hover { border-color: #353b46; }
form input:focus-visible, form textarea:focus-visible, form select:focus-visible {
  outline: none; box-shadow: var(--focus); border-color: var(--accent); background: var(--surface);
}
form input::placeholder, form textarea::placeholder { color: var(--faint); }

form label.check { display: flex; align-items: center; gap: var(--s-2); cursor: pointer; }
form label.check input { width: auto; margin: 0; }
input[type="checkbox"] { accent-color: var(--accent); width: 16px; height: 16px; }

/* Eigener Select-Pfeil als CSS-Form (kein externes Bild). */
form select {
  appearance: none; -webkit-appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) calc(50% - 2px),
    calc(100% - 13px) calc(50% - 2px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 38px;
}

/* Segmentierter Umschalter (Login/Registrieren) */
.seg {
  display: flex; gap: 3px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-md); padding: 4px;
  margin: var(--s-5) 0; box-shadow: var(--edge);
}
.seg button {
  flex: 1; background: none; border: none; color: var(--muted);
  padding: 11px; cursor: pointer; font-size: 15px; font-weight: 650;
  border-radius: var(--r-sm);
  transition: color var(--fast) var(--ease), background var(--fast) var(--ease);
}
.seg button:hover { color: var(--text); }
.seg button.active {
  color: var(--on-accent);
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  box-shadow: var(--shadow-accent);
}

/* Gefahren-Bereiche */
.card.danger, details.sect.danger { border-color: var(--accent-deep); }
.btn.danger-btn {
  background: linear-gradient(135deg, #d23b3f, #a01f24);
  border-color: transparent; color: #fff;
  box-shadow: 0 8px 22px -10px rgba(178, 38, 43, .7), var(--edge);
}
.btn.danger-btn:hover { filter: brightness(1.07); }

/* ===================================================================
   11. TAB-LEISTE  (oben, sticky, Glas)
   =================================================================== */
/* Globaler Header: Markenzeile oben + Pillen-Navigation darunter */
.apphead {
  position: sticky; top: 0; z-index: 20; width: 100%;
  background: rgba(15, 16, 19, .82);
  -webkit-backdrop-filter: saturate(160%) blur(16px);
  backdrop-filter: saturate(160%) blur(16px);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
}
.apphead-top {
  display: flex; align-items: baseline; gap: var(--s-3);
  padding: 12px 16px 8px;
  max-width: 760px; margin: 0 auto;
}
.apphead .brand {
  background: none; border: none; cursor: pointer; padding: 0;
  font-weight: 800; font-size: 26px; line-height: 1; letter-spacing: -.045em;
  color: var(--text);
  align-self: baseline;
}
.apphead .brand-dot { color: var(--accent); text-shadow: 0 2px 16px var(--accent-glow); }
/* Datum auf die Grundlinie des Logos: Baseline-Ausrichtung des Containers reicht
   bei Buttons nicht zuverlässig, daher zusätzlich an der Textgrundlinie ausrichten. */
.apphead .brand-date { color: var(--muted); font-size: 13px; font-weight: 500; line-height: 1; align-self: baseline; }

/* Icon-Tabs */
.tabbar.fab {
  display: flex; align-items: center; justify-content: space-between;
  gap: 2px; padding: 6px 12px 12px;
  max-width: 760px; margin: 0 auto;
}
.tabbar.fab button {
  flex: 1 1 0; display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: none; border: none; color: var(--muted); cursor: pointer;
  padding: 6px 2px; position: relative;
  transition: color var(--fast) var(--ease);
}
.tabbar.fab button span { font-size: 11px; font-weight: 650; letter-spacing: -.01em; }
.tabbar.fab .tabicon {
  width: 23px; height: 23px; display: block;
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.tabbar.fab button:hover { color: var(--text); }
.tabbar.fab button:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--r-sm); }
.tabbar.fab button.active { color: var(--accent); }
.tabbar.fab button.active .tabicon { filter: drop-shadow(0 0 6px var(--accent-glow)); }

/* "Hinzufügen"-Tab nur am Desktop (mobil übernimmt der schwebende +-Button) */
.tabbar.fab button.tab-desktop { display: none; }

/* Desktop: Logo + Tabs als zusammenhängende Gruppe zentriert, größere Schrift */
@media (min-width: 620px) {
  .apphead-inner {
    display: flex; align-items: center; justify-content: center; gap: var(--s-6);
    max-width: 1000px; margin: 0 auto; padding: 0 16px;
  }
  .apphead-top { padding: 0; margin: 0; flex: 0 0 auto; align-items: center; }
  .apphead .brand { font-size: 30px; }
  .apphead .brand-date { font-size: 14px; }
  .tabbar.fab {
    flex: 0 1 auto; justify-content: center; gap: 10px;
    max-width: none; margin: 0; padding: 8px 0 10px;
  }
  .tabbar.fab button { flex: 0 0 auto; min-width: 80px; padding: 4px 6px; }
  .tabbar.fab button span { font-size: 13px; }
  .tabbar.fab .tabicon { width: 24px; height: 24px; }
}

/* Schwebender Aktions-Button "+": unten mittig, sticky */
.fab-float {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(28px + env(safe-area-inset-bottom));
  z-index: 30; width: 60px; height: 60px; border-radius: 50%;
  border: none; cursor: pointer; color: var(--on-accent);
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  box-shadow: var(--shadow-accent), 0 6px 20px rgba(0,0,0,.45), 0 0 0 4px var(--bg);
  transition: transform var(--fast) var(--ease), filter var(--fast) var(--ease);
}
.fab-float svg {
  width: 30px; height: 30px; fill: none; stroke: currentColor;
  stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round;
}
.fab-float:hover { filter: brightness(1.06); transform: translateX(-50%) translateY(-2px); }
.fab-float:active { transform: translateX(-50%); }
.fab-float:focus-visible { outline: none; box-shadow: var(--focus), 0 0 0 4px var(--bg); }
.fab-float.active { filter: brightness(1.04); }
/* Erst auf großen Schirmen: schwebenden Button durch Header-Tab ersetzen */
@media (min-width: 900px) {
  .fab-float { display: none; }
  .tabbar.fab button.tab-desktop { display: flex; }
}

/* ===================================================================
   12. HOME / TAGES-DASHBOARD
   =================================================================== */
.home-head { margin-bottom: var(--s-2); }
.home-head h1 { margin-top: var(--s-2); }

/* Makro-Hero: Kalorien gross, Makros darunter, weicher Akzent-Schein. */
.card.hero {
  overflow: hidden;
  background:
    radial-gradient(520px 240px at 50% -60px, var(--accent-soft), transparent 72%),
    linear-gradient(180deg, var(--surface-2), var(--surface));
  border-color: var(--line);
}
.rings.macros { grid-template-columns: repeat(3, 1fr); gap: var(--s-3); row-gap: var(--s-5); }
.rings.macros .cell:first-child {
  position: relative;
  grid-column: 1 / -1;
  --ring: 138px; --pct: 30px;
  padding-bottom: var(--s-5);
  border-bottom: 1px solid var(--line-soft);
}
/* Schein hinter dem grossen Kalorienring (CSP-sicher, reiner Gradient). */
.rings.macros .cell:first-child .ringwrap::before {
  content: ""; position: absolute; inset: -22px;
  border-radius: 50%; z-index: -1;
  background: radial-gradient(circle, var(--accent-glow), transparent 68%);
  opacity: .55; filter: blur(6px);
}
.rings.macros .cell:first-child .lbl { margin-top: var(--s-3); font-size: 15px; font-weight: 750; }
.rings.macros .cell:first-child .val { font-size: 13px; }

/* Wasser */
.rings.water { --ring: 104px; margin-bottom: var(--s-3); }

/* Mikronaehrstoffe: kompaktes Raster */
.rings.compact {
  --ring: 56px; --pct: 11px;
  gap: var(--s-4) var(--s-2);
  grid-template-columns: repeat(auto-fit, minmax(66px, 1fr));
}
.rings.compact .lbl { margin-top: var(--s-1); font-size: 12px; }
.rings.compact .val { font-size: 10px; }

/* Zweispaltiges, einklappbares Raster (Masonry-artig). */
.home-cols { margin-top: var(--s-4); }
@media (min-width: 720px) {
  .home-cols { column-count: 2; column-gap: var(--s-4); }
}

details.sect {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .015), transparent 90px),
    var(--surface);
  border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 0 var(--s-5); margin: 0 0 var(--s-4);
  break-inside: avoid;
  box-shadow: var(--shadow-md), var(--edge);
  transition: border-color var(--med) var(--ease);
}
details.sect[open] { border-color: #343a45; }
details.sect summary {
  cursor: pointer; list-style: none; padding: 16px 0;
  font-size: 12px; font-weight: 800; letter-spacing: .10em;
  text-transform: uppercase; color: var(--muted);
  display: flex; justify-content: space-between; align-items: center;
  transition: color var(--fast) var(--ease);
}
details.sect summary:hover { color: var(--text); }
details.sect summary::-webkit-details-marker { display: none; }
/* Chevron als reine CSS-Form (Borders), kein Glyph/Emoji. */
details.sect summary::after {
  content: ""; width: 7px; height: 7px; margin-right: 3px;
  border-right: 2px solid var(--accent); border-bottom: 2px solid var(--accent);
  transform: rotate(-45deg); transition: transform var(--med) var(--ease);
}
details.sect[open] summary::after { transform: rotate(45deg); }
details.sect > *:last-child { padding-bottom: var(--s-5); }
details.sect.danger summary { color: #d98a8d; }
details.sect.danger summary::after { border-color: var(--accent); }

/* ===================================================================
   13. ZUTATENSUCHE / SCAN
   =================================================================== */
.search-row { display: flex; gap: var(--s-2); align-items: center; }
.search-row input[type="text"], .search-row input[type="number"] {
  min-width: 0; padding: 12px 13px;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--r-xs);
  font-size: 16px;          /* >= 16px: kein iOS-Zoom */
  transition: border-color var(--fast) var(--ease), box-shadow var(--fast) var(--ease);
}
.search-row input:focus-visible { outline: none; box-shadow: var(--focus); border-color: var(--accent); }
.search-row input[type="text"] { flex: 1; }
.search-row input[type="number"] { flex: 0 0 84px; }
.search-row .btn { white-space: nowrap; }

#food-results { margin-top: var(--s-2); }
.food-res { padding: 13px 0; border-bottom: 1px solid var(--line-soft); }
.food-res:last-child { border-bottom: none; }
.food-res-head { display: flex; justify-content: space-between; gap: var(--s-3); margin-bottom: var(--s-2); font-size: 14px; }
.food-name { color: var(--text); font-weight: 650; }
.food-name small { color: var(--faint); font-weight: 400; }
.food-macros { color: var(--muted); font-size: 12px; }
.food-kcal { color: var(--muted); font-size: 12px; white-space: nowrap; }

/* ===================================================================
   14. BARCODE-SCANNER-OVERLAY
   =================================================================== */
.scanner {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(8, 9, 11, .94);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center; padding: var(--s-4);
  animation: viewIn var(--med) var(--ease) both;
}
.scanner[hidden] { display: none !important; }
.scanner-box { width: 100%; max-width: 480px; text-align: center; }
#scanner-video {
  width: 100%; max-height: 70vh; border-radius: var(--r-md);
  background: #000; border: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
}
/* Ziel-Rahmen-Ecken als reine CSS-Form, dezent ueber dem Video. */
.scanner-box .note { color: var(--muted); margin: var(--s-4) 0 0; font-size: 14px; }
.scanner-box .btn { margin-top: var(--s-4); }

/* ===================================================================
   15. ADMIN
   =================================================================== */
#admin-stats { margin-bottom: var(--s-4); }
#admin-users .meal b { white-space: nowrap; }

/* ===================================================================
   16. CHIPS  (vorhandene/optionale Klassen)
   =================================================================== */
.chips {
  display: flex; gap: var(--s-2); overflow-x: auto;
  padding-bottom: var(--s-1); margin-bottom: var(--s-4);
  -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; padding: 8px 14px; border-radius: var(--r-pill);
  background: var(--surface-2); border: 1px solid var(--line); color: var(--muted);
  font-size: 13px; font-weight: 650; cursor: pointer; white-space: nowrap;
  transition: color var(--fast) var(--ease), background var(--fast) var(--ease), border-color var(--fast) var(--ease);
}
.chip:hover { color: var(--text); border-color: #353b46; }
.chip.active {
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  border-color: transparent; color: var(--on-accent);
  box-shadow: var(--shadow-accent);
}

/* ===================================================================
   17. OPTIONALE KOMPONENTEN  (HTML-Snippets in DESIGN_AWARD.md)
   =================================================================== */

/* ---- Wochentags-Leiste (MO–SO) ---- */
.weekstrip {
  display: flex; gap: var(--s-2); justify-content: space-between;
  margin: var(--s-1) 0 var(--s-4); overflow-x: auto;
  padding-bottom: 2px; -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.weekstrip::-webkit-scrollbar { display: none; }
.weekstrip .day {
  flex: 1 1 0; min-width: 42px;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  background: none; border: none; cursor: pointer;
  color: var(--muted); font-weight: 700;
}
.weekstrip .day .dot {
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--surface-2); border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; color: var(--text);
  transition: transform var(--fast) var(--ease), background var(--fast) var(--ease), box-shadow var(--fast) var(--ease);
}
.weekstrip .day .name { font-size: 11px; letter-spacing: .05em; text-transform: uppercase; }
.weekstrip .day:hover .dot { background: var(--surface-3); transform: translateY(-1px); }
/* Ausgewählter Tag (nicht heute): Blau */
.weekstrip .day.active { color: var(--carbs); }
.weekstrip .day.active .dot {
  background: linear-gradient(135deg, #7dd3fc, var(--carbs));
  border-color: transparent; color: #06283d;
  box-shadow: 0 10px 26px -8px rgba(56, 189, 248, .5);
  transform: translateY(-1px);
}
/* Heute: bleibt immer rot (auch wenn ein anderer Tag ausgewählt ist) */
.weekstrip .day.today { color: var(--accent); }
.weekstrip .day.today .dot {
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  border-color: transparent; color: var(--on-accent);
  box-shadow: var(--shadow-accent);
  transform: translateY(-1px);
}

/* ---- Tages-Uebersicht: Ring zwischen zwei Zahlen ---- */
.dayplan { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: var(--s-3); }
.dayplan .stat { text-align: center; }
.dayplan .stat .big { font-size: 22px; font-weight: 800; color: var(--text); }
.dayplan .stat .cap { font-size: 12px; color: var(--muted); margin-top: 2px; }
.dayplan .center { --ring: 138px; --pct: 28px; }
.dayplan .center .ringwrap .pct { flex-direction: column; line-height: 1.1; }
.dayplan .center .ringwrap .pct small { font-size: 12px; color: var(--muted); font-weight: 650; }

/* ---- Makro-Fortschritts-BALKEN ---- */
.macrobars { display: grid; gap: var(--s-4); margin-top: var(--s-1); }
.macrobar .top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 7px; font-size: 13px; }
.macrobar .top .name { color: var(--text); font-weight: 700; }
.macrobar .top .num { color: var(--muted); font-size: 12px; }
.macrobar .track { height: 9px; border-radius: var(--r-pill); background: var(--surface-3); overflow: hidden; box-shadow: inset 0 1px 2px rgba(0, 0, 0, .35); }
.macrobar .fill {
  height: 100%; border-radius: var(--r-pill); width: var(--val, 0%);
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width .7s var(--ease);
}
.macrobar.carbs   .fill { background: linear-gradient(90deg, #1f93d6, var(--carbs)); }
.macrobar.protein .fill { background: linear-gradient(90deg, #7c5cf0, var(--protein)); }
.macrobar.fat     .fill { background: linear-gradient(90deg, #d99413, var(--fat)); }
.macrobar.over    .fill { background: linear-gradient(90deg, var(--accent-deep), var(--over)); }

/* ---- Mahlzeiten-Zeile mit Initial-Icon + "+"-Button ---- */
.mealrow { display: flex; align-items: center; gap: var(--s-3); padding: 13px 0; border-bottom: 1px solid var(--line-soft); }
.mealrow:last-child { border-bottom: none; }
.mealrow .ic {
  width: 38px; height: 38px; border-radius: var(--r-sm); flex: none;
  background: var(--accent-soft); border: 1px solid var(--accent-line); color: var(--accent);
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 15px;
}
.mealrow .body { flex: 1; min-width: 0; }
.mealrow .body .t { font-weight: 700; color: var(--text); }
.mealrow .body .d { font-size: 12px; color: var(--muted); margin-top: 2px; }
.mealrow .add {
  width: 34px; height: 34px; flex: none; border-radius: 50%;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--accent);
  font-size: 22px; line-height: 1; cursor: pointer; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  transition: background var(--fast) var(--ease), color var(--fast) var(--ease), border-color var(--fast) var(--ease);
}
.mealrow .add:hover { background: linear-gradient(135deg, var(--accent-2), var(--accent)); border-color: transparent; color: var(--on-accent); }
.mealrow .add:focus-visible { outline: none; box-shadow: var(--focus); }

/* ---- Such-Pillenfeld + Rezept-Karten ---- */
.searchbar { position: relative; margin: var(--s-1) 0 var(--s-4); }
.searchbar input {
  width: 100%; padding: 12px 16px; border-radius: var(--r-pill);
  background: var(--surface-2); color: var(--text); border: 1px solid var(--line); font-size: 16px;
}
.searchbar input:focus-visible { outline: none; box-shadow: var(--focus); border-color: var(--accent); }
.searchbar input::placeholder { color: var(--faint); }

.recipes { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: var(--s-4); }
.recipe {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  overflow: hidden; box-shadow: var(--shadow-md), var(--edge); cursor: pointer;
  transition: transform var(--fast) var(--ease), border-color var(--fast) var(--ease), box-shadow var(--fast) var(--ease);
}
.recipe:hover { transform: translateY(-3px); border-color: var(--accent-line); box-shadow: var(--shadow-lg); }
.recipe .thumb { aspect-ratio: 16 / 10; width: 100%; background: linear-gradient(135deg, var(--surface-2), var(--surface-3)); position: relative; }
.recipe .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.recipe .tag {
  position: absolute; top: var(--s-2); left: var(--s-2);
  background: var(--accent); color: var(--on-accent);
  font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: var(--r-pill);
}
.recipe .info { padding: var(--s-3); }
.recipe .info .t { font-weight: 700; font-size: 14px; color: var(--text); }
.recipe .info .meta { display: flex; gap: var(--s-3); margin-top: 6px; font-size: 12px; color: var(--muted); }
.recipe .info .meta b { color: var(--accent-2); font-weight: 700; }

/* ===================================================================
   18. ZUGAENGLICHKEIT / FEINSCHLIFF
   =================================================================== */
::selection { background: var(--accent-line); color: #fff; }

/* Dezenter, themenkonformer Scrollbar-Stil (WebKit). */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: var(--r-pill); border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: #313742; }

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

/* ===================================================================
   19. PROJEKT-ERGAENZUNGEN  (mobil-first, grosse Tap-Flaechen)
   =================================================================== */

/* Wasser: einzelner Ring zentriert */
.rings.water { display: flex; justify-content: center; }

/* Wasser-Schnelltasten: grosse, gleich breite Touch-Ziele */
.water-btns { display: flex; gap: var(--s-2); margin-top: var(--s-3); }
.water-btns .btn { flex: 1; padding: 14px 8px; }

/* Freie Wassereingabe */
.water-custom { margin-top: var(--s-2); }
.water-custom input { flex: 1; }

/* Such-/Scan-Treffer: Makro-Zeile */
.food-macros { margin: 4px 0 10px; }
.food-macros small { color: var(--faint); }

/* Mahlzeiten-Zeile mit Loeschen */
.meal-right { display: inline-flex; align-items: center; gap: var(--s-3); }
.meal-del {
  width: 32px; height: 32px; flex: none; border-radius: 50%;
  background: none; border: 1px solid var(--line); color: var(--muted);
  font-size: 18px; line-height: 1; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: color var(--fast) var(--ease), border-color var(--fast) var(--ease);
}
.meal-del:hover { color: var(--accent); border-color: var(--accent-line); }

/* Touch: bequeme Hoehen fuer Such-/Mengenfelder auf dem Handy */
@media (max-width: 560px) {
  .search-row input, .search-row .btn { padding-top: 13px; padding-bottom: 13px; }
}

/* ---- Marken-Schriftzug "macros." ---- */
.home-head { margin-bottom: var(--s-4); }
.brandrow { display: flex; align-items: baseline; gap: var(--s-3); flex-wrap: wrap; }
.brand {
  font-weight: 800; font-size: clamp(28px, 8vw, 38px); line-height: 1;
  letter-spacing: -.045em; color: var(--text);
}
.brand-dot { color: var(--accent); text-shadow: 0 2px 16px var(--accent-glow); }
.brand-date { color: var(--muted); font-size: 14px; font-weight: 500; }

/* Login: Marke + Slogan zentriert */
.brandhead { text-align: center; margin: var(--s-6) 0 var(--s-5); }
.brandhead .brand { font-size: clamp(38px, 12vw, 52px); }
.slogan { color: var(--muted); margin: var(--s-2) 0 0; font-size: 15px; font-style: italic; }

/* Honeypot-Feld: für Menschen unsichtbar, aber kein display:none (Bots füllen es) */
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* Trenner „oder" zwischen Passwort- und Google-Login */
.or-sep { display: flex; align-items: center; gap: var(--s-3); color: var(--faint); margin: var(--s-4) 0; font-size: 13px; }
.or-sep::before, .or-sep::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* Google-Button */
.google-btn {
  display: flex; align-items: center; justify-content: center; gap: var(--s-2);
  width: 100%; background: var(--surface-2); color: var(--text);
  border: 1px solid var(--line); text-decoration: none;
}
.google-btn:hover { background: var(--surface-3); }

/* Login-Fußzeile mit Rechtslinks */
.auth-foot { display: flex; justify-content: center; gap: var(--s-4); margin-top: var(--s-5); }
.auth-foot a { color: var(--muted); font-size: 13px; text-decoration: none; }
.auth-foot a:hover { color: var(--text); text-decoration: underline; }
.lang-link { background: none; border: none; cursor: pointer; color: var(--muted); font-size: 13px; padding: 0; }
.lang-link:hover { color: var(--text); }
.lang-link.active { color: var(--accent-2); font-weight: 650; }

/* Rechtstexte (Impressum / Datenschutz / AGB) */
.legal { max-width: 760px; margin: 0 auto; padding: var(--s-5) var(--s-4) var(--s-6); }
.legal h1 { margin: 0 0 var(--s-4); }
.legal h2 { font-size: 18px; margin: var(--s-5) 0 var(--s-2); color: var(--text); }
.legal p, .legal li { color: var(--muted); line-height: 1.6; font-size: 15px; }
.legal ul { padding-left: 1.2em; margin: var(--s-2) 0; }
.legal a { color: var(--accent-2); }
.legal .back { display: inline-block; margin-bottom: var(--s-4); color: var(--muted); text-decoration: none; font-size: 14px; }
.legal .back:hover { color: var(--text); }
.legal .updated { color: var(--faint); font-size: 13px; margin-top: var(--s-5); }
.legal .placeholder { color: var(--accent-2); font-weight: 600; }

/* ---- Wochen-Navigation (vor/zurück) ---- */
.daynav { margin-bottom: var(--s-4); }
.daynav .weeknav { margin-top: 0; }
.weeknav { display: flex; align-items: stretch; gap: var(--s-2); margin-top: var(--s-2); }
.weeknav .weekstrip { flex: 1; margin: 0; }
.weeknav-btn {
  flex: none; width: 38px; border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--surface-2); color: var(--muted); cursor: pointer;
  font-size: 22px; line-height: 1; box-shadow: var(--edge);
  transition: background var(--fast) var(--ease), color var(--fast) var(--ease);
}
.weeknav-btn:hover { background: var(--surface-3); color: var(--text); }
.weeknav-btn:focus-visible { outline: none; box-shadow: var(--focus); }

/* ---- Toasts (Benachrichtigungen) ---- */
.toast-wrap {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(env(safe-area-inset-bottom, 0px) + 84px);
  z-index: 1000; display: flex; flex-direction: column-reverse; gap: 10px;
  width: max-content; max-width: min(92vw, 420px); pointer-events: none;
}
.toast {
  pointer-events: auto; cursor: pointer; display: flex; align-items: center; gap: 11px;
  padding: 12px 16px 12px 13px; border-radius: 14px;
  background: rgba(28, 30, 36, .92); color: var(--text);
  border: 1px solid var(--line); border-left: 3px solid var(--muted);
  box-shadow: 0 12px 34px -10px rgba(0,0,0,.65), var(--edge);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  font-size: 14.5px; line-height: 1.35; font-weight: 550;
  opacity: 0; transform: translateY(14px) scale(.97);
  transition: opacity .26s var(--ease), transform .26s var(--ease);
}
.toast.show { opacity: 1; transform: translateY(0) scale(1); }
.toast.hide { opacity: 0; transform: translateY(8px) scale(.98); }
.toast-ico { flex: none; width: 22px; height: 22px; display: grid; place-items: center; }
.toast-ico svg { width: 22px; height: 22px; fill: none; stroke-width: 2.2;
  stroke-linecap: round; stroke-linejoin: round; }
.toast-txt { min-width: 0; }
/* Typ-Farben (Rand, Icon, Glow) */
.toast-success { border-left-color: #34d399; box-shadow: 0 12px 34px -10px rgba(0,0,0,.65), 0 0 0 1px rgba(52,211,153,.15); }
.toast-success .toast-ico svg { stroke: #34d399; }
.toast-error { border-left-color: var(--accent); box-shadow: 0 12px 34px -10px rgba(0,0,0,.65), 0 0 0 1px var(--accent-line); }
.toast-error .toast-ico svg { stroke: var(--accent-2); }
.toast-info { border-left-color: var(--carbs); }
.toast-info .toast-ico svg { stroke: var(--carbs); }
@media (max-width: 620px) {
  .toast-wrap { bottom: calc(env(safe-area-inset-bottom, 0px) + 78px); max-width: 92vw; }
}

/* ---- Bestätigungsdialog (ersetzt natives confirm) ---- */
.modal-back {
  position: fixed; inset: 0; z-index: 1100;
  display: grid; place-items: center; padding: 24px;
  background: rgba(8, 9, 11, .58);
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  opacity: 0; transition: opacity .22s var(--ease);
}
.modal-back.show { opacity: 1; }
.modal-back.hide { opacity: 0; }
.modal {
  width: min(92vw, 380px);
  padding: 20px 20px 16px;
  border-radius: 16px;
  background: rgba(28, 30, 36, .96);
  border: 1px solid var(--line); border-top: 3px solid var(--muted);
  box-shadow: 0 24px 60px -16px rgba(0,0,0,.7), var(--edge);
  transform: translateY(12px) scale(.97);
  transition: transform .26s var(--ease);
}
.modal-back.show .modal { transform: translateY(0) scale(1); }
.modal-danger { border-top-color: var(--accent); }
.modal-title { margin: 0 0 6px; font-size: 16px; font-weight: 700; letter-spacing: -.01em; }
.modal-txt { margin: 0; color: var(--text); font-size: 14.5px; line-height: 1.45; }
.modal-actions { display: flex; gap: 10px; margin-top: 18px; }
.modal-actions .btn { flex: 1; width: auto; margin-top: 0; }

/* Datenschutzhinweis im Tagebuch (verschlüsselt, privat) */
.note-privacy {
  display: flex; align-items: flex-start; gap: 8px;
  margin: calc(var(--s-3) * -1) 0 var(--s-4); padding: 9px 12px;
  background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--r-sm);
  color: var(--muted); font-size: 12.5px; line-height: 1.5;
}
.note-privacy::before {
  content: ""; flex: none; width: 15px; height: 15px; margin-top: 1px;
  background: no-repeat center / contain
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a2a8b2' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='11' width='18' height='11' rx='2'/%3E%3Cpath d='M7 11V7a5 5 0 0 1 10 0v4'/%3E%3C/svg%3E");
}

/* Erklärtext über dem Ziele-Formular */
.goals-intro { margin: 0 0 var(--s-4); line-height: 1.55; }

/* Hinweis im Tagesüberblick: Soll-Werte sind einstellbar */
.goals-hint {
  display: flex; align-items: center; gap: 7px; width: 100%;
  margin-top: var(--s-3); padding: 9px 12px;
  background: none; border: 1px dashed var(--line); border-radius: var(--r-sm);
  color: var(--muted); font-size: 13px; font-weight: 550; cursor: pointer;
  transition: color var(--fast) var(--ease), border-color var(--fast) var(--ease), background var(--fast) var(--ease);
}
.goals-hint::before { content: "⚙"; flex: none; font-size: 14px; line-height: 1; }
.goals-hint::after { content: "›"; margin-left: auto; font-size: 17px; line-height: 1; }
.goals-hint:hover { color: var(--text); border-color: var(--accent-line); background: var(--surface-2); }

/* App-Version (Konto-Fußzeile) */
.app-version { color: var(--faint); font-size: 12px; text-align: center; margin-top: var(--s-5); }

/* Scanner-Status-Punkt (Vision-Modell über Tunnel erreichbar?) */
.scan-status { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--muted); margin: 0 0 var(--s-3); }
.scan-status .dot {
  width: 9px; height: 9px; border-radius: 50%; background: var(--faint);
  transition: background var(--fast) var(--ease), box-shadow var(--fast) var(--ease);
}
.scan-status[data-state="on"] { color: var(--text); }
.scan-status[data-state="on"] .dot { background: #34d399; box-shadow: 0 0 8px rgba(52, 211, 153, .7); }

/* Quellen-Label an Suchtreffern (Open Food Facts / USDA) */
.src-tag {
  display: inline-block; margin-left: 6px; padding: 1px 7px;
  border-radius: 999px; font-size: 11px; font-weight: 600;
  background: var(--surface-3); color: var(--muted); border: 1px solid var(--line);
  vertical-align: middle;
}

/* Utility-Klassen (ersetzen Inline-Styles wegen strikter CSP) */
.mt-2 { margin-top: 8px; }
.flex-1 { flex: 1; }

/* Gewicht: einzelne Tagesmessungen als kleine, löschbare Chips */
.wmeas {
  display: inline-flex; align-items: center; gap: 2px; margin-left: 6px;
  padding: 2px 6px; border-radius: var(--r-sm);
  background: var(--surface-2); border: 1px solid var(--line);
  font-size: 12px; color: var(--muted);
}
.wmeas .meal-del { font-size: 13px; }

/* ---- Tagebuch / Notizen ---- */
.md-toolbar { display: flex; gap: var(--s-2); margin-bottom: var(--s-3); flex-wrap: wrap; }
.md-btn {
  min-width: 38px; height: 34px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--surface-2); color: var(--muted); cursor: pointer;
  font-size: 14px; line-height: 1;
  transition: background var(--fast) var(--ease), color var(--fast) var(--ease);
}
.md-btn:hover { background: var(--surface-3); color: var(--text); }
.md-btn:focus-visible { outline: none; box-shadow: var(--focus); }
#note-text {
  display: block; width: 100%; resize: vertical; min-height: 140px;
  padding: 12px 13px; background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--r-xs);
  font: inherit; font-size: 16px; line-height: 1.5;
  transition: border-color var(--fast) var(--ease), box-shadow var(--fast) var(--ease), background var(--fast) var(--ease);
}
#note-text:hover { border-color: #353b46; }
#note-text:focus-visible { outline: none; box-shadow: var(--focus); border-color: var(--accent); background: var(--surface); }
#note-text::placeholder { color: var(--faint); }
.note-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); margin-bottom: var(--s-3); }
.note-head .card-title { margin: 0; }
.note-foot { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); margin-top: var(--s-3); }
.note-actions { display: flex; gap: var(--s-2); }
.md-preview { color: var(--text); font-size: 15px; line-height: 1.55; }
.md-preview .empty { color: var(--faint); font-size: 13px; }
.md-preview p { margin: 0 0 var(--s-2); }
.md-preview h4, .md-preview h5, .md-preview h6 { margin: var(--s-2) 0 var(--s-1); color: var(--text); }
.md-preview ul { margin: 0 0 var(--s-2); padding-left: 1.2em; }
.md-preview li { margin: 2px 0; }
.md-preview strong { color: var(--text); }

/* ---- Karte mit seitlichen Tabs (Wasser / Mineralstoffe / Vitamine) ---- */
.panel { display: flex; gap: var(--s-4); padding: var(--s-4); align-items: stretch; }
.vtabs { display: flex; flex-direction: column; gap: var(--s-2); flex: 0 0 108px; }
.vtab {
  text-align: left; padding: 12px 12px; border-radius: var(--r-sm);
  background: transparent; border: 1px solid transparent; color: var(--muted);
  cursor: pointer; font-size: 13px; font-weight: 700; line-height: 1.15;
  hyphens: auto; transition: background var(--fast) var(--ease), color var(--fast) var(--ease), border-color var(--fast) var(--ease);
}
.vtab:hover { color: var(--text); background: var(--surface-2); }
.vtab.active {
  color: var(--accent); background: var(--accent-soft); border-color: var(--accent-line);
}
.vpanels { flex: 1; min-width: 0; display: flex; align-items: center; }
.vpanel { width: 100%; }
.vpanel[hidden] { display: none; }

/* ---- Wasser-Tab: Liste links, Ring rechts ---- */
.water-main { display: flex; align-items: center; gap: var(--s-4); }
.water-main .water-log { flex: 1; min-width: 0; margin-top: 0; border-top: none; max-height: 180px; overflow-y: auto; }
.water-main .rings.water { flex: none; }

/* ---- Wasser-Liste (was wann hinzugefügt) ---- */
.water-log { margin-top: var(--s-3); border-top: 1px solid var(--line-soft); }
.water-log .wl {
  display: flex; justify-content: space-between; align-items: center;
  padding: 9px 0; border-bottom: 1px solid var(--line-soft); font-size: 13px;
}
.water-log .wl:last-child { border-bottom: none; }
.water-log .wl .t { color: var(--muted); font-variant-numeric: tabular-nums; }
.water-log .wl .v { font-weight: 650; font-variant-numeric: tabular-nums; }
.water-log .wl .x {
  background: none; border: none; color: var(--faint); cursor: pointer;
  font-size: 16px; padding: 0 4px; margin-left: var(--s-2);
}
.water-log .wl .x:hover { color: var(--accent); }
.water-log .empty { color: var(--faint); font-size: 13px; padding: 10px 0 2px; }

/* Auf schmalen Phones: seitliche Tabs etwas schmaler */
@media (max-width: 560px) {
  .vtabs { flex-basis: 92px; }
  .panel { gap: var(--s-3); }
}

/* Eingebettete (innere) einklappbare Sektion, z. B. Wasser-Verlauf */
details.sect.inner { margin: var(--s-3) 0 0; }
details.sect.inner .water-log { margin-top: 0; border-top: none; }

/* Hilfetext unter Formularfeldern (z. B. Aktivität) */
.fieldhelp {
  list-style: none; margin: -6px 0 16px; padding: 12px 14px;
  background: var(--surface-2); border: 1px solid var(--line-soft); border-radius: var(--r-sm);
  font-size: 12px; color: var(--muted); line-height: 1.6;
}
.fieldhelp b { color: var(--text); font-weight: 650; }
details.sect.inner .fieldhelp { margin: 0; padding: 0 0 4px; background: none; border: none; }

/* ---- Vorrat: Bearbeiten/Einheiten ---- */
.saved-actions { float: right; display: inline-flex; gap: 6px; }
.iconbtn {
  width: 32px; height: 32px; border-radius: 50%;
  background: none; border: 1px solid var(--line); color: var(--muted);
  cursor: pointer; font-size: 14px; display: inline-flex; align-items: center; justify-content: center;
}
.iconbtn:hover { color: var(--accent); border-color: var(--accent-line); }
.unit-label { color: var(--muted); font-size: 14px; }
.saved-edit { margin-top: var(--s-3); }
.edit-form { background: var(--surface-2); border: 1px solid var(--line-soft); border-radius: var(--r-sm); padding: var(--s-3); }
.edit-form label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 10px; }
.edit-form input { display: block; width: 100%; margin-top: 4px; padding: 9px 10px; font-size: 16px;
  background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 8px; }
.edit-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }

/* ---- "Mehr"-Menü ---- */
.more-menu { display: flex; flex-direction: column; gap: var(--s-2); }
.more-item {
  text-align: left; padding: 16px; border-radius: var(--r-sm);
  background: var(--surface-2); border: 1px solid var(--line); color: var(--text);
  font-size: 16px; font-weight: 650; cursor: pointer; text-decoration: none;
}
.more-item:hover { background: var(--surface-3); }
.more-item.danger { color: var(--accent); border-color: var(--accent-line); }

/* Sprachumschalter: Label links, Segment-Toggle rechts */
.lang-card { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); }
.lang-label { color: var(--muted); font-size: 14px; font-weight: 600; }
.lang-seg {
  display: inline-flex; padding: 3px; gap: 2px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 999px;
}
.lang-opt {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 14px; border: none; border-radius: 999px; cursor: pointer;
  background: none; color: var(--muted); font-size: 14px; font-weight: 600;
  transition: color var(--fast) var(--ease), background var(--fast) var(--ease);
}
.lang-opt .flag {
  font-size: 10px; font-weight: 800; letter-spacing: .04em;
  padding: 2px 5px; border-radius: 5px; background: var(--surface-3); color: var(--muted);
  transition: background var(--fast) var(--ease), color var(--fast) var(--ease);
}
.lang-opt:hover { color: var(--text); }
.lang-opt.active {
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  color: var(--on-accent); box-shadow: var(--shadow-accent);
}
.lang-opt.active .flag { background: rgba(255,255,255,.22); color: #fff; }

/* Dropdowns außerhalb von Formularen (Gains-Auswahl) */
.search-row select {
  flex: 1; min-width: 0; padding: 11px 12px; font-size: 16px;
  background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 10px;
}
.search-row select:focus-visible { outline: none; box-shadow: var(--focus); border-color: var(--accent); }

/* ---- ChewScale / Gewicht ---- */
.weight-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--s-2); margin-bottom: var(--s-4); }
.wstat { background: var(--surface-2); border: 1px solid var(--line-soft); border-radius: var(--r-sm); padding: 10px 8px; text-align: center; }
.wstat b { display: block; font-size: 16px; color: var(--text); font-variant-numeric: tabular-nums; }
.wstat span { font-size: 11px; color: var(--muted); }
.weight-chart { width: 100%; }
.wchart { width: 100%; height: auto; display: block; }
@media (max-width: 560px) {
  .weight-stats { grid-template-columns: repeat(2, 1fr); }
}

/* Zahlenfeld-Spinner (hoch/runter-Pfeile) ueberall entfernen */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type="number"] { -moz-appearance: textfield; appearance: textfield; }

/* iPhone Safe-Area: Home-Indikator unten (Header-Notch ist in .apphead gelöst) */
main {
  padding-left: max(var(--s-4), env(safe-area-inset-left));
  padding-right: max(var(--s-4), env(safe-area-inset-right));
  padding-bottom: calc(104px + env(safe-area-inset-bottom));
}

/* Mobile-first: Mindest-Tap-Flaeche fuer Buttons */
@media (max-width: 560px) {
  .btn { min-height: 46px; }
  .weekstrip .day .dot { width: 46px; height: 46px; }
}
