/* =========================================================================
   Kalorienrechner — Dark Mode, Mobile-first, Desktop zweispaltig
   Selbst-gehostet (keine externen Fonts/Requests → CSP 'self')
   ========================================================================= */
:root {
  --bg: #0B0E14;
  --card: #141A24;
  --card2: #1B2330;
  --line: #232C3B;
  --text: #EEF2F8;
  --muted: #8A97AB;
  --faint: #5C687B;
  --protein: #4ADE80;
  --carbs: #38BDF8;
  --fat: #FB923C;
  --accent: #5EEAD4;
  --warn: #FBBF24;
  --danger: #F87171;

  --r-card: 16px;
  --r-sm: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "SFMono-Regular", ui-monospace, "JetBrains Mono", "Fira Code", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background:
    radial-gradient(1200px 600px at 50% -10%, rgba(94, 234, 212, 0.06), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.5;
  padding: max(20px, env(safe-area-inset-top)) 14px calc(60px + env(safe-area-inset-bottom));
  min-height: 100vh;
}

.wrap { max-width: 1080px; margin: 0 auto; }

/* ── Kopf ─────────────────────────────────────────────────────────────────── */
.page-head { margin-bottom: 22px; }
.brand {
  display: inline-flex; align-items: center; gap: 8px;
  color: var(--muted); font-size: 13px; font-weight: 600; letter-spacing: 0.4px;
  text-transform: uppercase; margin-bottom: 10px;
}
.brand-dot {
  width: 9px; height: 9px; border-radius: 50%; background: var(--accent);
  box-shadow: 0 0 12px var(--accent);
}
h1 {
  margin: 0;
  font-size: clamp(26px, 6vw, 40px);
  font-weight: 700;
  letter-spacing: -0.6px;
}
.lead { margin: 6px 0 0; color: var(--muted); font-size: 14px; }

/* Experten-Schalter im Kopf */
.expert-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-top: 16px; padding: 12px 14px;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
}
.expert-label { display: flex; flex-direction: column; gap: 2px; font-weight: 600; font-size: 14px; }
.expert-sub { font-weight: 400; font-size: 12px; }

/* Kontextuelle Experten-Blöcke in den Karten */
.expert-block {
  margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--line);
}
.exp-title { margin: 0 0 10px; font-size: 13px; font-weight: 600; color: var(--accent); }
.tempo-readout { margin-top: 8px; font-size: 13px; color: var(--muted); font-family: var(--mono); }
.tempo-readout b { color: var(--text); }
.exp-presets { display: flex; flex-wrap: wrap; gap: 6px; }
.preset-btn {
  flex: 1 1 auto; min-width: 84px; padding: 8px 10px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--line); background: var(--card2); color: var(--muted);
  font-size: 13px; font-weight: 600; font-family: inherit; transition: border-color .15s, color .15s;
}
.preset-btn:hover { color: var(--text); border-color: var(--muted); }
.preset-btn[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); background: rgba(94,234,212,0.08); }
.exp-bmr { margin-top: 16px; display: flex; flex-direction: column; gap: 8px; }

/* ── Layout: mobil eine Spalte, Desktop zwei ──────────────────────────────── */
.layout { display: grid; gap: 14px; grid-template-columns: 1fr; }

@media (min-width: 880px) {
  .layout { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; gap: 18px; }
  .col-results { position: sticky; top: 18px; }
}

.col-inputs, .col-results { display: flex; flex-direction: column; gap: 14px; }

/* ── Karten ───────────────────────────────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  padding: 18px;
}

.label {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 12px; letter-spacing: 1.2px; text-transform: uppercase; font-weight: 600;
}
.label-tight { margin-bottom: 4px; }
.spacer { height: 20px; }
.muted { color: var(--muted); }
.hidden { display: none !important; }

/* ── Segment-Buttons ──────────────────────────────────────────────────────── */
.segment {
  display: flex; gap: 6px; background: var(--card2); padding: 5px; border-radius: 12px;
}
.seg-btn {
  flex: 1; padding: 11px 8px; border-radius: 8px; border: none; cursor: pointer;
  font-size: 14px; font-weight: 600; color: var(--muted); background: transparent;
  transition: background .15s ease, color .15s ease, transform .1s ease;
  font-family: inherit;
}
.seg-btn:hover { color: var(--text); }
.seg-btn[aria-checked="true"] { color: #0B0E14; }
.seg-btn.is-protein[aria-checked="true"] { background: var(--protein); }
.seg-btn.is-carbs[aria-checked="true"]   { background: var(--carbs); }
.seg-btn.is-fat[aria-checked="true"]     { background: var(--fat); }
.seg-btn.is-accent[aria-checked="true"]  { background: var(--accent); }
.seg-btn:active { transform: scale(.98); }

/* ── Felder mit Slider + Zahleneingabe ────────────────────────────────────── */
.field { margin-bottom: 18px; }
.field:last-child { margin-bottom: 0; }
.field-head {
  display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; gap: 10px;
}
.field-label { color: var(--muted); font-size: 13px; }
.num { display: inline-flex; align-items: baseline; gap: 3px; }
.num-input {
  width: 64px; text-align: right;
  background: var(--card2); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 6px 8px;
  font-family: var(--mono); font-size: 16px; font-weight: 600; /* 16px → kein iOS-Zoom */
  font-variant-numeric: tabular-nums;
}
.num-input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
.num-input::-webkit-outer-spin-button,
.num-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.num-input[type="number"] { -moz-appearance: textfield; }
.num-unit { color: var(--faint); font-size: 13px; }

/* Range-Slider */
.range {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 6px; border-radius: 99px; background: var(--card2); outline: none;
  margin: 0; cursor: pointer;
}
.range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 22px; height: 22px; border-radius: 50%; background: var(--accent);
  cursor: pointer; border: 3px solid var(--bg); box-shadow: 0 0 0 1px var(--accent);
}
.range::-moz-range-thumb {
  width: 18px; height: 18px; border-radius: 50%; background: var(--accent);
  cursor: pointer; border: 3px solid var(--bg);
}
.range:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 4px rgba(94,234,212,.35); }
.range:focus-visible::-moz-range-thumb { box-shadow: 0 0 0 4px rgba(94,234,212,.35); }

.hint { color: var(--faint); font-size: 12px; margin: 8px 0 0; }

.bf-info {
  margin-top: 12px; padding: 10px 12px; border-radius: var(--r-sm);
  background: var(--card2); color: var(--muted); font-size: 13px; line-height: 1.5;
}
.bf-info b { color: var(--text); font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* ── Toggle / Switch ──────────────────────────────────────────────────────── */
.toggle-row {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 18px; gap: 12px;
}
.toggle-text { color: var(--muted); font-size: 13px; }
.switch {
  width: 46px; height: 26px; border-radius: 99px; border: none; cursor: pointer;
  position: relative; background: var(--card2); transition: background .15s; flex-shrink: 0;
}
.switch[aria-checked="true"] { background: var(--accent); }
.switch-knob {
  position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: var(--faint); transition: left .15s, background .15s;
}
.switch[aria-checked="true"] .switch-knob { left: 23px; background: #0B0E14; }
#bf-field { margin-top: 16px; }

/* ── Aktivitätsliste ──────────────────────────────────────────────────────── */
.activity-list { display: flex; flex-direction: column; gap: 8px; }
.act-btn {
  text-align: left; padding: 12px 14px; border-radius: var(--r-sm); cursor: pointer;
  border: 1px solid var(--line); background: var(--card2);
  transition: border-color .15s, background .15s; font-family: inherit; color: var(--text);
}
.act-btn:hover { border-color: var(--muted); }
.act-btn[aria-checked="true"] { border-color: var(--accent); background: rgba(94,234,212,0.08); }
.act-top { display: flex; justify-content: space-between; align-items: center; }
.act-name { font-weight: 600; font-size: 14px; }
.act-btn[aria-checked="true"] .act-name { color: var(--accent); }
.act-factor { color: var(--faint); font-size: 12px; font-family: var(--mono); }
.act-desc { color: var(--muted); font-size: 12px; margin-top: 3px; }

/* ── Warnung Minderjährige ────────────────────────────────────────────────── */
.warn {
  background: rgba(251,191,36,0.10); border: 1px solid var(--warn); border-radius: 14px;
  padding: 16px; display: flex; gap: 10px; align-items: flex-start;
}
.warn-icon { font-size: 18px; line-height: 1; }
.warn-text { font-size: 13px; line-height: 1.5; color: var(--text); }
.warn-text strong { color: var(--warn); }

/* ── Ergebnis: Kalorien ───────────────────────────────────────────────────── */
.result-card { text-align: center; padding: 26px 18px; }
.result-cap { color: var(--muted); font-size: 13px; letter-spacing: 1px; text-transform: uppercase; }
.result-kcal {
  font-family: var(--mono); font-variant-numeric: tabular-nums;
  font-size: clamp(46px, 13vw, 64px); font-weight: 700; line-height: 1.05;
  margin: 6px 0 2px; letter-spacing: -1px;
  text-shadow: 0 0 30px rgba(94,234,212,0.25);
}
.result-unit { font-size: 20px; color: var(--muted); font-weight: 500; margin-left: 6px; }
.result-sub { color: var(--faint); font-size: 13px; min-height: 18px; }
.result-stats { display: flex; justify-content: center; gap: 28px; margin-top: 20px; }
.stat { text-align: center; }
.stat-label { color: var(--muted); font-size: 12px; }
.stat-val { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 24px; font-weight: 700; margin: 2px 0; }
.stat-sub { color: var(--faint); font-size: 11px; }
.stat-div { width: 1px; background: var(--line); align-self: stretch; }

/* ── Makros ───────────────────────────────────────────────────────────────── */
.macros { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.donut-wrap { position: relative; flex-shrink: 0; margin: 0 auto; width: 168px; height: 168px; }
.donut { display: block; }
.donut circle { transition: stroke-dasharray .4s ease, stroke-dashoffset .4s ease; }
#seg-protein { stroke: var(--protein); }
#seg-carbs   { stroke: var(--carbs); }
#seg-fat     { stroke: var(--fat); }
.donut-center {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; pointer-events: none;
}
.donut-kcal { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 22px; font-weight: 700; }
.donut-unit { font-size: 11px; color: var(--muted); }

.bars { flex: 1; min-width: 220px; }
.bar { margin-bottom: 14px; }
.bar-head { display: flex; justify-content: space-between; margin-bottom: 6px; font-size: 14px; }
.bar-name { color: var(--text); display: flex; align-items: center; gap: 8px; }
.bar-val { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.bar-val b { color: var(--text); font-weight: 600; }
.bar-val span { color: var(--faint); margin-left: 8px; }
.dot { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }
.dot-protein { background: var(--protein); }
.dot-carbs { background: var(--carbs); }
.dot-fat { background: var(--fat); }
.bar-track { height: 8px; background: var(--card2); border-radius: 99px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 99px; width: 0; transition: width .4s ease; }
.bar-protein { background: var(--protein); }
.bar-carbs { background: var(--carbs); }
.bar-fat { background: var(--fat); }
.fiber-row {
  margin-top: 4px; padding-top: 12px; border-top: 1px solid var(--line);
  display: flex; justify-content: space-between; font-size: 13px;
}
.fiber-row b { font-family: var(--mono); }

/* ── BMI ──────────────────────────────────────────────────────────────────── */
.bmi-card { display: flex; justify-content: space-between; align-items: center; gap: 14px; }
.bmi-val { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 30px; font-weight: 700; margin-top: 4px; }
.bmi-right { text-align: right; max-width: 230px; }
.badge { color: #0B0E14; padding: 4px 12px; border-radius: 99px; font-size: 13px; font-weight: 700; background: var(--muted); }
.bmi-note { color: var(--muted); font-size: 12px; margin-top: 8px; line-height: 1.4; }
.bmi-disclaimer {
  margin: 14px 0 0; padding-top: 14px; border-top: 1px solid var(--line);
  color: var(--muted); font-size: 12.5px; line-height: 1.55;
}
.bmi-disclaimer strong { color: var(--text); font-weight: 600; }

/* ── Aktionen ─────────────────────────────────────────────────────────────── */
.actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.btn {
  padding: 11px 16px; border-radius: var(--r-sm); border: 1px solid var(--accent);
  background: rgba(94,234,212,0.10); color: var(--accent); font-weight: 600; font-size: 14px;
  cursor: pointer; font-family: inherit; transition: background .15s, transform .1s;
}
.btn:hover { background: rgba(94,234,212,0.18); }
.btn:active { transform: scale(.98); }
.btn-ghost { border-color: var(--line); background: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--text); border-color: var(--muted); background: transparent; }
.copied { color: var(--protein); font-size: 13px; font-weight: 600; }

/* ── SEO-Text ─────────────────────────────────────────────────────────────── */
.seo { margin-top: 22px; }
.seo h2 { margin: 0 0 10px; font-size: 20px; letter-spacing: -0.3px; }
.seo h3 { margin: 18px 0 8px; font-size: 15px; color: var(--muted); }
.seo p { margin: 0 0 10px; color: var(--muted); font-size: 14px; max-width: 70ch; }
.seo strong { color: var(--text); font-weight: 600; }
.seo details { border-top: 1px solid var(--line); padding: 10px 0; }
.seo summary { cursor: pointer; font-size: 14px; color: var(--text); font-weight: 600; }
.seo summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.seo details p { margin: 8px 0 0; }

/* ── Disclaimer ───────────────────────────────────────────────────────────── */
.disclaimer {
  color: var(--faint); font-size: 12px; line-height: 1.55; text-align: center;
  margin: 18px auto 0; max-width: 60ch;
}

/* ── Globale Fokus-Sichtbarkeit & Reduced Motion ──────────────────────────── */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button:focus-visible { border-radius: 8px; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
