/* Alkohol-Tracker – Stylesheet. Hell/Dunkel folgt der Systemeinstellung. */

:root {
  color-scheme: light;
  --bg: #f3f5f8;
  --surface: #ffffff;
  --surface-2: #f5f7fa;
  --surface-3: #ffffff;
  --text: #0f1b2a;
  --text-muted: #5b6878;
  --border: #e1e6ed;
  --grid: #e9edf2;
  --navy: #0f2236;
  --accent: #e08e0b;
  --accent-strong: #f2a516;
  --accent-ink: #2a1a00;
  --accent-text: #9a5b00;
  --danger: #c92f2f;
  --danger-soft: #fdecec;
  --good: #0b7a2b;
  --good-soft: #e5f5ea;
  --bad: #b3261e;
  --bad-soft: #fdeceb;
  --glass: rgba(255, 255, 255, 0.65);
  --tile: #eef2f7;
  --icon-ink: #22374d;
  --warn: #8a5a00;
  --warn-soft: #fdf1d6;
  --status-good: #0ca30c;
  --status-warn: #fab219;
  --status-bad: #d03b3b;
  --limit: #6250d6;
  --chip-on-bg: #0f2236;
  --chip-on-fg: #ffffff;
  --series-1: #2a78d6;
  --series-1-fill: rgba(42, 120, 214, 0.16);
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --shadow: 0 1px 2px rgba(15, 27, 42, 0.06), 0 4px 16px rgba(15, 27, 42, 0.05);
  --radius: 16px;
  --radius-sm: 10px;
  --tabbar-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0b121b;
    --surface: #121c28;
    --surface-2: #172331;
    --surface-3: #1d2a3a;
    --text: #edf2f7;
    --text-muted: #9babbd;
    --border: #233245;
    --grid: #1c2939;
    --accent: #f2a516;
    --accent-text: #f7bd4f;
    --danger: #f06a6a;
    --danger-soft: #3a1717;
    --good: #5fd27e;
    --good-soft: #12301c;
    --bad: #ff8a80;
    --bad-soft: #3a1717;
    --glass: rgba(255, 255, 255, 0.14);
    --tile: #1a2738;
    --icon-ink: #c9d6e4;
    --warn: #f7c04a;
    --warn-soft: #3a2c0c;
    --limit: #9085e9;
    --chip-on-bg: #f2a516;
    --chip-on-fg: #2a1a00;
    --series-1: #3987e5;
    --series-1-fill: rgba(57, 135, 229, 0.22);
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  }
}

* { 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);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
body.has-sheet { overflow: hidden; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
button, input, select { font: inherit; color: inherit; }
a { color: inherit; }
.muted { color: var(--text-muted); }
.small { font-size: 0.82rem; }
.center { text-align: center; }
[hidden] { display: none !important; }

.ico { width: 22px; height: 22px; flex: none; }
.ico.inline { width: 1.1em; height: 1.1em; vertical-align: -0.2em; }

/* ---------- Bildschirme ---------- */
.shell, .auth, .splash { display: none; }
body[data-screen="app"] .shell { display: block; }
body[data-screen="auth"] .auth { display: flex; }
body[data-screen="loading"] .splash { display: grid; }
.splash { position: fixed; inset: 0; place-items: center; background: var(--bg); }
.splash img { border-radius: 16px; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.5; transform: scale(0.96); } }

/* ---------- Kopfzeile & Tabs ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  padding: calc(var(--safe-t) + 10px) 16px 10px;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  max-width: 680px; margin: 0 auto;
}
.topbar h1 { font-size: 1.6rem; font-weight: 750; letter-spacing: -0.02em; flex: 1; }
.topbar-btn { background: var(--surface); box-shadow: var(--shadow); }
.offline-badge {
  display: inline-flex; align-items: center; gap: 4px; font-size: 0.75rem; font-weight: 600;
  padding: 4px 10px; border-radius: 99px; background: var(--surface-3); color: var(--text-muted); border: 1px solid var(--border);
}
.offline-badge .ico { width: 14px; height: 14px; }

.main {
  max-width: 680px; margin: 0 auto;
  padding: 4px 16px calc(var(--tabbar-h) + var(--safe-b) + 28px);
}
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(5, 1fr); align-items: center;
  height: calc(var(--tabbar-h) + var(--safe-b));
  padding: 0 max(8px, calc((100vw - 680px) / 2)) var(--safe-b);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(16px);
  -webkit-backdrop-filter: saturate(1.4) blur(16px);
  border-top: 1px solid var(--border);
}
.tab {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  text-decoration: none; color: var(--text-muted); font-size: 0.7rem; font-weight: 600;
  padding: 6px 0; border: 0; background: none;
}
.tab .ico { width: 24px; height: 24px; }
.tab.is-active { color: var(--text); }
.tab.is-active .ico { color: var(--accent); }
.tab-add { justify-self: center; }
.tab-add span {
  display: grid; place-items: center; width: 54px; height: 54px; margin-top: -22px;
  border-radius: 50%; background: var(--accent-strong); color: var(--accent-ink);
  box-shadow: 0 6px 18px rgba(224, 142, 11, 0.45), 0 0 0 5px var(--bg);
  transition: transform 0.15s;
}
.tab-add .ico { width: 28px; height: 28px; stroke-width: 2.6; }
.tab-add:active span { transform: scale(0.92); }

/* ---------- Grundbausteine ---------- */
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--border); }
.pad { padding: 16px; }
.section { margin-top: 26px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 0 2px 10px; }
.section-head h2 { font-size: 1.12rem; font-weight: 700; letter-spacing: -0.01em; }
.section-head + .card, .section-head + .chart-card { margin-bottom: 18px; }
.empty {
  padding: 22px 16px; text-align: center; color: var(--text-muted);
  border: 1.5px dashed var(--border); border-radius: var(--radius);
}
.banner {
  display: flex; gap: 8px; align-items: center; margin-top: 12px; padding: 10px 14px;
  border-radius: var(--radius-sm); background: var(--surface-3); border: 1px solid var(--border); font-size: 0.88rem;
}
.banner .ico { color: var(--accent-text); }

.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; flex: none;
  border-radius: 50%; border: 0; background: transparent; color: var(--text-muted); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn:disabled { opacity: 0.3; pointer-events: none; }
.icon-btn .ico { width: 20px; height: 20px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 46px; padding: 0 18px; border-radius: 12px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  font-weight: 650; text-decoration: none; transition: transform 0.1s, opacity 0.15s;
}
.btn:active { transform: scale(0.98); }
.btn .ico { width: 18px; height: 18px; }
.btn-primary { background: var(--accent-strong); border-color: transparent; color: var(--accent-ink); }
.btn-danger { background: var(--danger); border-color: transparent; color: #fff; }
.btn-ghost { background: transparent; }
.btn-danger-text { color: var(--danger); }
.btn-small { min-height: 36px; padding: 0 12px; font-size: 0.88rem; border-radius: 10px; }
.btn-block { width: 100%; }
.btn.is-busy { opacity: 0.6; pointer-events: none; }
.btn-row { display: flex; gap: 10px; justify-content: flex-end; margin-top: 6px; }
.btn-row .btn-primary { flex: 1; }
.link-btn {
  display: inline-flex; align-items: center; gap: 2px; margin-top: 10px; padding: 6px 2px;
  border: 0; background: none; color: var(--accent-text); font-weight: 650; cursor: pointer;
}
.link-btn .ico { width: 16px; height: 16px; }

/* Formulare */
.form { display: grid; gap: 14px; }
.field { display: grid; gap: 6px; min-width: 0; }
.field > span { font-size: 0.82rem; font-weight: 600; color: var(--text-muted); }
.field em { font-weight: 400; font-style: normal; }
.field input:not([type=range]):not([type=radio]) {
  width: 100%; min-height: 46px; padding: 10px 12px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--surface-2); outline: none; font-size: 16px;
}
.field input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.field input[readonly] { opacity: 0.7; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.form-hint { margin: -4px 2px 0; font-size: 0.85rem; color: var(--text-muted); min-height: 1.2em; }
input[type=range] { width: 100%; accent-color: var(--accent); }
.range-scale { display: flex; justify-content: space-between; font-size: 0.72rem; color: var(--text-muted); }

.segmented {
  display: flex; gap: 4px; padding: 4px; border-radius: 12px; background: var(--surface-2);
  border: 1px solid var(--border); overflow-x: auto; scrollbar-width: none;
}
.segmented > * {
  flex: 1; min-height: 36px; display: grid; place-items: center; padding: 0 10px; white-space: nowrap;
  border-radius: 9px; border: 0; background: none; font-size: 0.9rem; font-weight: 600; color: var(--text-muted); cursor: pointer;
}
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented .is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.view-stats > .segmented { margin-bottom: 14px; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: -4px; }
.chip {
  padding: 6px 12px; border-radius: 99px; border: 1px solid var(--border); background: var(--surface);
  font-size: 0.85rem; font-weight: 600; cursor: pointer;
}
.chip:active { background: var(--surface-2); }

/* ---------- Getränkebilder ---------- */
.drink-img {
  display: grid; place-items: center; flex: none; overflow: hidden;
  width: 48px; height: 48px; border-radius: 12px; background: var(--tile); color: var(--icon-ink);
}
.drink-img img { width: 100%; height: 100%; object-fit: cover; }
.drink-img.sm { width: 40px; height: 40px; border-radius: 10px; }
.drink-img.lg { width: 100%; height: auto; aspect-ratio: 1; border-radius: 14px; }
.drink-svg { width: 82%; height: 82%; --glass: var(--glass); }
.drink-img.is-plus { background: transparent; border: 1.5px dashed var(--border); color: var(--text-muted); }

/* ---------- Hero (aktueller Wert) ---------- */
.hero {
  margin-top: 6px; padding: 20px 20px 18px; color: #fff; border: 0;
  background: radial-gradient(120% 140% at 100% 0%, #1d4a75 0%, #10263d 55%, #0b1a2b 100%);
  box-shadow: 0 10px 30px rgba(11, 26, 43, 0.25);
}
.hero-label { font-size: 0.82rem; font-weight: 600; opacity: 0.75; letter-spacing: 0.02em; }
.hero-value {
  font-size: 4rem; font-weight: 750; letter-spacing: -0.04em; line-height: 1.05; margin: 4px 0 8px;
  font-variant-numeric: tabular-nums;
}
.hero-value[data-level="some"] { color: #ffd27a; }
.hero-value[data-level="high"] { color: #ff9d8a; }
.hero-unit { font-size: 1.6rem; font-weight: 600; margin-left: 6px; opacity: 0.8; }
.hero-line { font-size: 0.95rem; opacity: 0.95; }
.hero-line strong { font-weight: 700; }
.hero-dim { opacity: 0.7; }
.hero-note { margin-top: 8px; font-size: 0.74rem; opacity: 0.65; }
.hero-hint {
  display: flex; align-items: center; gap: 6px; margin-top: 12px; padding: 8px 10px; width: 100%;
  border: 0; border-radius: 10px; background: rgba(255, 255, 255, 0.1); color: #fff; font-size: 0.82rem; text-align: left; cursor: pointer;
}
.hero-hint .ico { width: 16px; height: 16px; }

/* ---------- Schnellerfassung ---------- */
.quick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 10px; }
.quick {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 12px 6px 10px;
  border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); box-shadow: var(--shadow);
  cursor: pointer; text-align: center; transition: transform 0.12s; min-width: 0;
}
.quick:active { transform: scale(0.96); }
.quick .drink-img { width: 56px; height: 56px; border-radius: 14px; margin-bottom: 4px; }
.quick-name { font-weight: 650; font-size: 0.9rem; line-height: 1.2; max-width: 100%; overflow-wrap: anywhere; hyphens: auto; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.quick-meta { font-size: 0.72rem; color: var(--text-muted); }
.quick.is-tapped { animation: tap 0.4s ease; }
@keyframes tap { 30% { transform: scale(0.93); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 45%, transparent); } }
.quick-more { background: transparent; box-shadow: none; border-style: dashed; }
.quick-today {
  margin-top: 2px; padding: 1px 8px; border-radius: 99px;
  font-size: 0.68rem; font-weight: 700; background: color-mix(in srgb, var(--accent) 16%, var(--surface)); color: var(--accent-text);
}

/* ---------- Einträge ---------- */
.entry-list { list-style: none; margin: 12px 0 0; padding: 0; background: var(--surface); border-radius: var(--radius); border: 1px solid var(--border); box-shadow: var(--shadow); }
.entry { display: flex; align-items: center; gap: 12px; padding: 10px 6px 10px 12px; }
.entry + .entry { border-top: 1px solid var(--border); }
.entry-main { flex: 1; min-width: 0; }
.entry-title { font-weight: 650; display: flex; align-items: center; gap: 8px; }
.entry-meta { font-size: 0.82rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.entry-grams { font-weight: 700; font-variant-numeric: tabular-nums; font-size: 0.92rem; }
.entry.is-pending { opacity: 0.85; }
.tag { display: inline-flex; align-items: center; gap: 3px; font-size: 0.7rem; font-weight: 600; padding: 1px 7px; border-radius: 99px; background: var(--surface-2); color: var(--accent-text); border: 1px solid var(--border); }
.tag .ico { width: 12px; height: 12px; }

/* ---------- Diagramme ---------- */
.chart-card { padding: 12px 10px 8px 4px; }
.chart-box { position: relative; height: 200px; }

/* ---------- Verlauf ---------- */
.day-nav { display: flex; align-items: center; gap: 4px; padding: 6px; margin-top: 6px; }
.day-picker { position: relative; flex: 1; text-align: center; cursor: pointer; padding: 4px 0; }
.day-picker-label { display: block; font-weight: 700; font-size: 1.05rem; }
.day-picker-sub { display: block; font-size: 0.74rem; color: var(--text-muted); }
.day-picker input { position: absolute; inset: 0; opacity: 0; width: 100%; cursor: pointer; }
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 12px 0; }
.kpis.kpis-4 { grid-template-columns: repeat(2, 1fr); }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; box-shadow: var(--shadow); min-width: 0; }
.kpi-label { font-size: 0.75rem; font-weight: 600; color: var(--text-muted); }
.kpi-value { font-size: 1.3rem; font-weight: 750; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.kpi-small { font-size: 1.05rem; padding-top: 3px; }
.kpi-sub { font-size: 0.74rem; color: var(--text-muted); min-height: 1em; }
.view-history .chart-card { margin-top: 0; }

.day-list { list-style: none; margin: 0; padding: 0; background: var(--surface); border-radius: var(--radius); border: 1px solid var(--border); overflow: hidden; }
.day-list li + li { border-top: 1px solid var(--border); }
.day-row {
  display: grid; grid-template-columns: 8.4rem 1fr 3.6rem 2.2rem; align-items: center; gap: 10px;
  width: 100%; padding: 11px 14px; border: 0; background: none; text-align: left; cursor: pointer; font-size: 0.9rem;
}
.day-row.is-active { background: var(--surface-2); }
.day-row-date { font-weight: 600; white-space: nowrap; }
.day-row-bar { height: 8px; border-radius: 4px; background: var(--grid); overflow: hidden; }
.day-row-bar span { display: block; height: 100%; border-radius: 4px; background: var(--series-1); }
.day-row-val { text-align: right; font-weight: 650; font-variant-numeric: tabular-nums; }
.day-row-count { text-align: right; color: var(--text-muted); font-size: 0.8rem; }
.view-history .btn-block { margin-top: 10px; }

/* ---------- Monatskalender (Verlauf) ---------- */
.cal { margin-top: 12px; padding: 8px 10px 12px; }
.cal-head { display: flex; align-items: center; gap: 4px; }
.cal-title { flex: 1; text-align: center; font-weight: 700; }
.cal-title span { display: block; font-size: 0.74rem; font-weight: 500; color: var(--text-muted); }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-top: 6px; }
.cal-wd { text-align: center; font-size: 0.7rem; font-weight: 600; color: var(--text-muted); padding-bottom: 2px; }
.cal-cell {
  aspect-ratio: 1; display: grid; place-items: center; border: 0; border-radius: 10px; background: var(--surface-2);
  font: inherit; font-size: 0.85rem; font-variant-numeric: tabular-nums; color: var(--text); cursor: pointer; padding: 0;
}
.cal-cell.is-blank { background: none; }
.cal-cell:disabled { opacity: 0.35; cursor: default; }
.cal-cell.is-under { background: var(--status-warn); color: #2b1d00; font-weight: 700; }
.cal-cell.is-over { background: var(--status-bad); color: #fff; font-weight: 700; }
.cal-cell.is-today { box-shadow: inset 0 0 0 2px var(--text-muted); }
.cal-cell.is-selected { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--text); }
.cal-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; justify-content: center; margin-top: 10px; font-size: 0.78rem; }
.cal-legend span { display: inline-flex; align-items: center; gap: 6px; }
.cal-swatch { width: 12px; height: 12px; border-radius: 4px; display: inline-block; }
.cal-swatch.is-under { background: var(--status-warn); }
.cal-swatch.is-over { background: var(--status-bad); }
.cal-cell.is-with { outline: 3px solid var(--series-1); outline-offset: -3px; }
.cal-swatch.is-with { background: transparent; box-shadow: inset 0 0 0 3px var(--series-1); }
.cal-person { display: flex; align-items: center; gap: 8px; margin: 6px 4px 2px; color: var(--text-muted); }
.cal-person .ico { width: 18px; height: 18px; }
.cal-person select {
  flex: 1; min-height: 38px; padding: 6px 10px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text); font-size: 16px;
}
.chart-note { margin: -4px 2px 8px; }

/* ---------- Mittrinkende ---------- */
.cmp-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: -2px 2px 12px; }
.cmp-label { font-size: 0.85rem; font-weight: 600; color: var(--text-muted); margin-right: 2px; }
.cmp-chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 4px 6px 4px 10px; border-radius: 99px;
  background: color-mix(in srgb, var(--series-1) 14%, var(--surface)); border: 1px solid color-mix(in srgb, var(--series-1) 35%, var(--border));
  font-size: 0.88rem; font-weight: 600;
}
.cmp-chip.is-static { padding: 4px 10px 4px 8px; }
.cmp-chip .cmp-ico { width: 14px; height: 14px; color: var(--series-1); }
.cmp-chip button { display: grid; place-items: center; width: 22px; height: 22px; border: 0; border-radius: 50%; background: transparent; color: var(--text-muted); cursor: pointer; padding: 0; }
.cmp-chip button .ico { width: 14px; height: 14px; }
.chip.cmp-edit { display: inline-flex; align-items: center; gap: 4px; }
.chip.cmp-edit .ico { width: 14px; height: 14px; }
.cmp-editor { display: grid; gap: 10px; }
.cmp-chips { display: flex; flex-wrap: wrap; gap: 6px; min-height: 30px; align-items: center; }
.cmp-input { display: flex; gap: 8px; }
.cmp-input input { flex: 1; min-width: 0; min-height: 44px; padding: 8px 12px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-2); font-size: 16px; }
.cmp-suggest { display: flex; flex-wrap: wrap; gap: 6px; }
.cmp-suggest:empty { display: none; }
.sheet .cmp-editor + .btn, .sheet [data-editor] + .btn { margin-top: 16px; }

/* ---------- Trinkkumpanen (Statistik) ---------- */
.buddy-years { margin-bottom: 10px; }
.buddy-sort { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0 2px 12px; }
.chip.is-active { background: var(--chip-on-bg); color: var(--chip-on-fg); border-color: var(--chip-on-bg); }
.buddy-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.buddy { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 14px; text-align: left; cursor: pointer; }
.buddy-rank { width: 28px; height: 28px; flex: none; display: grid; place-items: center; border-radius: 50%; background: var(--surface-2); font-weight: 700; font-size: 0.85rem; color: var(--text-muted); }
.buddy-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.buddy-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.buddy-meta { font-size: 0.8rem; color: var(--text-muted); }
.buddy-meta2 { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; font-size: 0.78rem; color: var(--text-muted); }
.buddy-over { width: 46px; height: 6px; border-radius: 3px; background: var(--grid); overflow: hidden; display: inline-block; }
.buddy-over i { display: block; height: 100%; background: var(--status-bad); border-radius: 3px; }
.buddy-fav { display: inline-flex; align-items: center; gap: 5px; }
.drink-img.xs { width: 22px; height: 22px; border-radius: 6px; }
.buddy-value { flex: none; text-align: right; font-weight: 750; font-size: 1.15rem; font-variant-numeric: tabular-nums; line-height: 1.1; }
.buddy-value small { display: block; font-size: 0.68rem; font-weight: 600; color: var(--text-muted); }
.buddy-detail { margin: 0 0 14px; display: grid; gap: 2px; }
.buddy-detail div { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.buddy-detail dt { color: var(--text-muted); }
.buddy-detail dd { margin: 0; font-weight: 700; text-align: right; }
.buddy-rename { margin-top: 18px; }

/* ---------- Statistik ---------- */
.stat-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat-card { padding: 14px; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.stat-card:nth-child(-n+2) { grid-column: 1 / -1; }
.stat-label { font-size: 0.8rem; font-weight: 600; color: var(--text-muted); }
.stat-value { font-size: 1.7rem; font-weight: 750; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat-of { font-size: 1rem; font-weight: 600; color: var(--text-muted); }
.stat-sub { font-size: 0.85rem; color: var(--text-muted); }
.stat-sub strong { color: var(--text); }
.progress { position: relative; height: 10px; border-radius: 5px; background: var(--grid); overflow: hidden; }
.progress span { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 5px; }
.progress-val { background: var(--series-1); }
.progress-proj { background: repeating-linear-gradient(45deg, var(--series-1-fill) 0 4px, transparent 4px 8px); border: 1px dashed var(--series-1); }
.progress-mark { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: var(--surface); opacity: 0.9; }
.progress.is-good .progress-val { background: var(--status-good); }
.progress.is-warn .progress-val { background: var(--status-warn); }
.progress.is-bad .progress-val { background: var(--status-bad); }
.progress.is-good .progress-proj { border-color: var(--status-good); background: repeating-linear-gradient(45deg, var(--good-soft) 0 4px, transparent 4px 8px); }
.progress.is-warn .progress-proj { border-color: var(--status-warn); background: repeating-linear-gradient(45deg, var(--warn-soft) 0 4px, transparent 4px 8px); }
.progress.is-bad .progress-proj { border-color: var(--status-bad); background: repeating-linear-gradient(45deg, var(--bad-soft) 0 4px, transparent 4px 8px); }
.stat-card.is-good { border-top: 4px solid var(--status-good); }
.stat-card.is-warn { border-top: 4px solid var(--status-warn); }
.stat-card.is-bad { border-top: 4px solid var(--status-bad); }
.badge { align-self: flex-start; font-size: 0.8rem; font-weight: 650; padding: 4px 10px; border-radius: 10px; line-height: 1.3; }
.badge.is-good { color: var(--good); background: var(--good-soft); }
.badge.is-warn { color: var(--warn); background: var(--warn-soft); }
.badge.is-bad { color: var(--bad); background: var(--bad-soft); }
.status-legend { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 4px; }
.liters { margin: 2px 0 0; display: grid; gap: 4px; }
.liters div { display: flex; justify-content: space-between; font-size: 0.88rem; }
.liters dt { display: flex; align-items: center; gap: 6px; color: var(--text-muted); }
.liters dd { margin: 0; font-weight: 650; font-variant-numeric: tabular-nums; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: 0.85rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table th, .table td { padding: 9px 10px; text-align: right; border-bottom: 1px solid var(--border); }
.table thead th { font-size: 0.75rem; color: var(--text-muted); font-weight: 600; background: var(--surface-2); }
.table th:first-child { text-align: left; position: sticky; left: 0; background: var(--surface); }
.table thead th:first-child { background: var(--surface-2); }
.table tbody tr:last-child > * { border-bottom: 0; }
.table td.cell-good, .table td.cell-warn, .table td.cell-bad { font-weight: 700; }
.table td.cell-good { color: var(--good); background: var(--good-soft); }
.table td.cell-warn { color: var(--warn); background: var(--warn-soft); }
.table td.cell-bad { color: var(--bad); background: var(--bad-soft); }
.cell-icon { display: inline-block; margin-right: 5px; font-size: 0.75rem; }
.cell-proj { display: block; font-size: 0.75rem; font-weight: 600; opacity: 0.85; }

.target-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.target { display: flex; align-items: center; gap: 14px; padding: 10px 6px 10px 16px; }
.target-year { font-size: 1.2rem; font-weight: 750; }
.target-vals { flex: 1; display: flex; flex-direction: column; font-size: 0.88rem; }
.target-vals span:last-child { color: var(--text-muted); }

/* ---------- Getränke ---------- */
.drink-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.drink-card { display: flex; flex-direction: column; gap: 2px; padding: 10px; text-align: left; cursor: pointer; min-width: 0; }
.drink-card .drink-img { margin-bottom: 8px; }
.drink-card .drink-svg { width: 70%; height: 70%; }
.drink-card-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drink-card-meta { font-size: 0.82rem; }
.drink-card-cat { font-size: 0.75rem; color: var(--text-muted); }

.img-edit { display: flex; gap: 14px; align-items: center; }
.img-preview { width: 96px; height: 96px; border-radius: 18px; overflow: hidden; background: var(--tile); color: var(--icon-ink); display: grid; place-items: center; flex: none; }
.img-preview img { width: 100%; height: 100%; object-fit: cover; }
.img-preview .is-icon { display: grid; place-items: center; width: 100%; height: 100%; }
.img-preview .drink-svg { width: 78%; height: 78%; }
.img-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.search-panel { display: grid; gap: 10px; padding: 12px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--border); }
.search-bar { display: flex; gap: 8px; }
.search-bar input { flex: 1; min-width: 0; min-height: 40px; padding: 8px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); font-size: 16px; }
.search-results { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; max-height: 300px; overflow-y: auto; }
.result { display: flex; flex-direction: column; gap: 4px; padding: 4px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; min-width: 0; }
.result img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 7px; background: #fff; }
.result span { font-size: 0.7rem; line-height: 1.2; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result:hover, .result:focus-visible { border-color: var(--accent); }

/* ---------- Erfassen-Sheet: Getränkeauswahl ---------- */
.picker { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 6px; margin: 0 -2px; scroll-snap-type: x proximity; scrollbar-width: none; }
.pick {
  flex: none; width: 84px; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 4px;
  border-radius: 14px; border: 1.5px solid var(--border); background: var(--surface); cursor: pointer; scroll-snap-align: center;
}
.pick span:last-child { font-size: 0.75rem; font-weight: 600; text-align: center; line-height: 1.15; max-width: 100%; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.pick.is-active { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--surface)); }

/* ---------- Profil ---------- */
.prose p { margin: 0 0 10px; }
.prose ol { margin: 0 0 10px; padding-left: 1.2em; display: grid; gap: 4px; font-size: 0.92rem; }
.prose p:last-child { margin-bottom: 0; }
.account { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

/* ---------- Listen-Karten (Profil) ---------- */
.list-card { overflow: hidden; }
.list-row {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 14px 12px 14px 16px;
  border: 0; background: none; text-align: left; cursor: pointer; font-weight: 600;
}
.list-row + .list-row { border-top: 1px solid var(--border); }
.list-row span { flex: 1; }
.list-row .ico { width: 20px; height: 20px; color: var(--text-muted); }
.list-row:active { background: var(--surface-2); }
.list-row.is-danger, .list-row.is-danger .ico { color: var(--danger); }
.view-profile .section > .muted.small { margin: 8px 4px 0; }

.check { display: flex; gap: 10px; align-items: flex-start; font-size: 0.92rem; text-align: left; cursor: pointer; }
.check input { width: 20px; height: 20px; margin: 1px 0 0; flex: none; accent-color: var(--accent); }

/* ---------- Verschlüsselung: Code, Hinweise ---------- */
.recovery-code {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 14px 0 10px; padding: 14px;
  border-radius: 14px; background: var(--surface-2); border: 1.5px dashed var(--border);
}
.recovery-code span {
  font: 700 1.1rem/1.4 ui-monospace, "SF Mono", Menlo, Consolas, monospace; letter-spacing: 0.08em; text-align: center;
  padding: 6px 0; border-radius: 8px; background: var(--surface); user-select: all;
}
.center-row { justify-content: center; margin: 0 0 14px; }
.center-row .btn { flex: none; }
.callout {
  padding: 12px 14px; border-radius: 12px; background: var(--warn-soft); color: var(--warn);
  font-size: 0.9rem; text-align: left; margin: 12px 0;
}
.auth-icon { display: grid; place-items: center; width: 64px; height: 64px; margin: 0 auto; border-radius: 18px; background: var(--navy); color: #ffcb4f; }
.auth-icon .ico { width: 30px; height: 30px; }
.auth-card .check { margin: 16px 0; }
.auth-links { display: flex; flex-direction: column; align-items: center; gap: 2px; margin-top: 8px; }
.spinner { width: 36px; height: 36px; margin: 24px auto 8px; border-radius: 50%; border: 4px solid var(--border); border-top-color: var(--accent); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Bottom-Sheet ---------- */
.sheet-wrap { position: fixed; inset: 0; z-index: 50; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(5, 10, 18, 0.45); opacity: 0; transition: opacity 0.2s; }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; margin: 0 auto; max-width: 600px; max-height: 92vh;
  display: flex; flex-direction: column;
  background: var(--surface); border-radius: 22px 22px 0 0; box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.2);
  transform: translateY(100%); transition: transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.sheet-wrap.is-open .sheet-backdrop { opacity: 1; }
.sheet-wrap.is-open .sheet { transform: none; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 12px 6px 20px; }
.sheet-head h2 { font-size: 1.15rem; }
.sheet-body { padding: 8px 20px calc(20px + var(--safe-b)); overflow-y: auto; overscroll-behavior: contain; }
@media (min-width: 640px) {
  .sheet { bottom: auto; top: 50%; border-radius: 22px; transform: translateY(-40%) scale(0.98); opacity: 0; transition: transform 0.2s, opacity 0.2s; }
  .sheet-wrap.is-open .sheet { transform: translateY(-50%); opacity: 1; }
}

/* ---------- Toast ---------- */
.toast-root { position: fixed; left: 0; right: 0; bottom: calc(var(--tabbar-h) + var(--safe-b) + 14px); z-index: 60; display: flex; justify-content: center; pointer-events: none; padding: 0 16px; }
.toast {
  display: flex; align-items: center; gap: 14px; max-width: 560px; padding: 12px 12px 12px 16px;
  border-radius: 14px; background: #16212e; color: #fff; box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
  font-size: 0.92rem; pointer-events: auto; transform: translateY(16px); opacity: 0; transition: 0.2s;
}
.toast.is-visible { transform: none; opacity: 1; }
.toast.is-error { background: #8f1d1d; }
.toast-action { border: 0; background: rgba(255, 255, 255, 0.14); color: #ffd27a; font-weight: 700; padding: 6px 12px; border-radius: 9px; cursor: pointer; white-space: nowrap; }
body[data-screen="auth"] .toast-root { bottom: 24px; }

/* ---------- Anmeldung ---------- */
.auth { min-height: 100vh; min-height: 100dvh; align-items: center; justify-content: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 380px; text-align: center; }
.auth-card h1 { font-size: 1.7rem; margin: 14px 0 6px; letter-spacing: -0.02em; }
.auth-card .form { text-align: left; margin-top: 22px; }
.auth-logo { border-radius: 18px; box-shadow: 0 8px 24px rgba(15, 34, 54, 0.3); }

@media (max-width: 380px) {
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .grid-3 > :first-child { grid-column: 1 / -1; }
  .hero-value { font-size: 3.4rem; }
  .day-row { grid-template-columns: 7.8rem 1fr 3.2rem 2rem; gap: 8px; padding: 10px 12px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
