:root {
  color-scheme: light;
  --bg: #f5f6f4;
  --surface: #ffffff;
  --surface-2: #eef1ee;
  --border: #dde2dd;
  --text: #121614;
  --text-2: #4b5450;
  --muted: #6b736f;
  --accent: #0f766e;
  --accent-ink: #ffffff;
  --accent-soft: #d8f0ec;
  --lift: #2a78d6;
  --run: #d95926;
  --danger: #c0352b;
  --done: #1f8a4c;
  --series-1: #2a78d6;
  --grid: #e6e9e6;
  --shadow: 0 1px 2px rgba(0, 0, 0, .05), 0 2px 8px rgba(0, 0, 0, .04);
  --radius: 14px;
  --nav-h: 64px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0b1210;
    --surface: #141c1a;
    --surface-2: #1b2522;
    --border: #2a3632;
    --text: #eef3f1;
    --text-2: #c3ccc8;
    --muted: #93a09b;
    --accent: #2bb3a3;
    --accent-ink: #04211d;
    --accent-soft: #123a35;
    --lift: #5b9cf0;
    --run: #f07a45;
    --danger: #ef6b5f;
    --done: #3fbf74;
    --series-1: #3987e5;
    --grid: #24302c;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b1210; --surface: #141c1a; --surface-2: #1b2522; --border: #2a3632; --text: #eef3f1; --text-2: #c3ccc8; --muted: #93a09b;
  --accent: #2bb3a3; --accent-ink: #04211d; --accent-soft: #123a35; --lift: #5b9cf0; --run: #f07a45; --danger: #ef6b5f; --done: #3fbf74; --series-1: #3987e5; --grid: #24302c; --shadow: none;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { line-height: 1.2; margin: 0; }
h1 { font-size: 1.6rem; letter-spacing: -.01em; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { margin: 0; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ---------- Layout ---------- */
.app { min-height: 100vh; }
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); font-weight: 700; }
.main { max-width: 980px; margin: 0 auto; padding: 20px 16px calc(var(--nav-h) + 40px + env(safe-area-inset-bottom)); }

.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(6, 1fr);
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface); border-top: 1px solid var(--border);
}
.nav a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--muted); text-decoration: none; font-size: .72rem; font-weight: 600;
}
.nav a svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav a.active { color: var(--accent); }

@media (min-width: 860px) {
  .topbar { background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); }
  .nav { position: static; display: flex; height: auto; padding: 0; background: none; border: 0; gap: 4px; }
  .nav a { flex-direction: row; gap: 8px; padding: 8px 14px; border-radius: 999px; font-size: .9rem; }
  .nav a svg { width: 18px; height: 18px; }
  .nav a.active { background: var(--accent-soft); }
  .main { padding-bottom: 60px; }
  .rest { bottom: 24px !important; }
}

.stack { display: flex; flex-direction: column; gap: 14px; }
.narrow { max-width: 680px; margin: 0 auto; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.row.between { justify-content: space-between; }
.small-gap { gap: 6px; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.eyebrow { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.section-title { margin-top: 12px; font-size: .95rem; color: var(--text-2); }
.link { font-size: .9rem; text-decoration: none; font-weight: 600; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow);
}
.card.soft { background: var(--surface-2); box-shadow: none; }
.card.highlight { border-color: var(--accent); background: linear-gradient(0deg, var(--surface), var(--surface)) padding-box; box-shadow: 0 0 0 1px var(--accent) inset, var(--shadow); }
.card.hero { padding: 24px; }
.card.hero p { margin: 8px 0 16px; color: var(--text-2); }
.card h2 + p, .card h3 + p { margin-top: 6px; }

.plan-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.progress { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; border: 1px solid var(--border); }
.progress span { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width .3s; }

.day-card h2 { margin: 4px 0 10px; }
.items { list-style: none; padding: 0; margin: 0 0 14px; display: flex; flex-direction: column; gap: 8px; }
.items.compact { margin: 4px 0 0; gap: 2px; font-size: .9rem; }
.items li { overflow-wrap: anywhere; }
.ex { font-weight: 600; margin-right: 6px; }
.ex::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; vertical-align: 1px; }
.ex.lift::before { background: var(--lift); }
.ex.run::before { background: var(--run); border-radius: 50%; }
.desc { font-size: .85rem; color: var(--text-2); margin: 2px 0 0 14px; }
.summary { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; color: var(--text-2); }

.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat-row.four { grid-template-columns: repeat(2, 1fr); }
@media (min-width: 640px) { .stat-row.four { grid-template-columns: repeat(4, 1fr); } }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; }
.stat-v { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-l { font-size: .78rem; color: var(--muted); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 10px 16px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font-weight: 600; text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); }
.btn.danger:hover { border-color: var(--danger); }
.btn.big { min-height: 52px; font-size: 1.05rem; width: 100%; }
.row .btn.big { width: auto; }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: .88rem; }
.icon-btn { border: 0; background: none; color: var(--muted); cursor: pointer; width: 36px; height: 36px; border-radius: 8px; font-size: 1rem; }
.icon-btn:hover { background: var(--surface-2); color: var(--danger); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1px solid var(--border); background: var(--surface); padding: 6px 14px; border-radius: 99px; cursor: pointer; font-weight: 600; font-size: .9rem; min-height: 36px; }
.chip.small { padding: 4px 12px; font-size: .82rem; min-height: 32px; }
.chip.active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.card .chips { margin: 10px 0; }

.badge { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: .75rem; font-weight: 700; text-transform: capitalize; background: var(--surface-2); color: var(--text-2); }
.badge.styrka { background: color-mix(in srgb, var(--lift) 16%, transparent); color: var(--lift); }
.badge.löpning { background: color-mix(in srgb, var(--run) 16%, transparent); color: var(--run); }
.badge.kombination { background: var(--accent-soft); color: var(--accent); }
.tag { font-size: .7rem; font-weight: 600; background: var(--surface-2); color: var(--muted); padding: 2px 8px; border-radius: 99px; vertical-align: 2px; }

/* ---------- Program library ---------- */
.grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 640px) { .grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 900px) { .grid { grid-template-columns: repeat(3, 1fr); } }
.tpl { display: flex; flex-direction: column; gap: 6px; text-decoration: none; color: var(--text); transition: border-color .15s, transform .15s; }
.tpl:hover { border-color: var(--accent); transform: translateY(-1px); }
.tpl p { color: var(--text-2); flex: 1; }
.tpl-top { display: flex; justify-content: space-between; align-items: center; }

.weeks { display: flex; flex-direction: column; gap: 8px; }
details.card { padding: 0; }
details.card > summary { padding: 14px 16px; cursor: pointer; display: flex; justify-content: space-between; gap: 10px; align-items: center; list-style: none; }
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary::after { content: "▾"; color: var(--muted); margin-left: auto; }
details.card[open] > summary::after { content: "▴"; }
details.card > summary .muted { margin-left: auto; }
details.card > :not(summary) { margin: 0 16px 14px; }
.day-row { display: flex; gap: 12px; align-items: flex-start; padding: 12px 0; border-top: 1px solid var(--border); }
.day-row.done { opacity: .65; }
.day-row.next { background: var(--accent-soft); margin: 0 -16px !important; padding: 12px 16px; }
.day-status { flex: none; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); font-weight: 700; font-size: .85rem; color: var(--muted); }
.day-row.done .day-status { background: var(--done); color: #fff; }
.day-actions { display: flex; flex-direction: column; gap: 6px; }
@media (max-width: 520px) {
  .day-row { flex-wrap: wrap; }
  .day-actions { flex-direction: row; width: 100%; padding-left: 42px; }
}

/* ---------- Forms ---------- */
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
legend { font-weight: 700; padding: 0; margin-bottom: 10px; font-size: 1.02rem; }
fieldset.card legend { float: left; width: 100%; }
fieldset.card legend + * { clear: both; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: .85rem; color: var(--text-2); min-width: 0; }
.field > span { font-weight: 600; }
input, select, textarea {
  width: 100%; min-height: 44px; padding: 10px 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  font-size: 16px; /* prevents zoom on iOS */
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { resize: vertical; }
.max-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 600px) { .max-grid { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); } }
.opts { display: grid; gap: 8px; grid-template-columns: 1fr; }
@media (min-width: 560px) { .opts { grid-template-columns: repeat(2, 1fr); } .opts.three { grid-template-columns: repeat(3, 1fr); } }
.opt { position: relative; cursor: pointer; }
.opt input { position: absolute; opacity: 0; width: 1px; height: 1px; min-height: 0; }
.opt span { display: flex; flex-direction: column; padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px; height: 100%; }
.opt small { color: var(--muted); font-size: .82rem; }
.opt input:checked + span { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 1px var(--accent) inset; }
.opt input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
#gen-setup .card { gap: 16px; }
#setup fieldset, #gen-setup fieldset { display: flex; flex-direction: column; gap: 8px; }
.big-out { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- Workout ---------- */
.title-input { border: 0; padding: 0; min-height: 0; font-size: 1.5rem; font-weight: 700; background: transparent; }
.title-input:focus { box-shadow: none; border-bottom: 2px solid var(--accent); border-radius: 0; }
.date-input { width: auto; min-height: 40px; padding: 6px 10px; }
.session .plan-head { align-items: center; }
.ex-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.ex-card > p { margin-top: 2px; }
.set-grid { margin: 12px 0 10px; display: flex; flex-direction: column; gap: 6px; }
.set-row { display: grid; grid-template-columns: 48px 1fr 1fr 48px; gap: 8px; align-items: center; border-radius: 10px; transition: background .15s; }
.set-row.head { font-size: .75rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.set-row input { text-align: center; font-variant-numeric: tabular-nums; }
.set-n { font-weight: 700; text-align: center; display: flex; flex-direction: column; line-height: 1.1; }
.set-n small { font-weight: 500; font-size: .65rem; color: var(--muted); }
.set-n sup { color: var(--accent); }
.check {
  width: 48px; height: 44px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2);
  color: var(--muted); font-size: 1.2rem; font-weight: 700; cursor: pointer;
}
.set-row.done { background: color-mix(in srgb, var(--done) 12%, transparent); }
.set-row.done .check { background: var(--done); border-color: var(--done); color: #fff; }
.run-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0; }
.run-grid .field:last-child { grid-column: 1 / -1; }
@media (min-width: 560px) { .run-grid { grid-template-columns: 1fr 1fr 1fr; } .run-grid .field:last-child { grid-column: auto; } }
.pace { font-size: 1.3rem; font-weight: 700; min-height: 44px; display: flex; align-items: center; font-variant-numeric: tabular-nums; color: var(--text); }
.run-card.done { border-color: var(--done); }
.add-ex .row input { flex: 1 1 200px; width: auto; }
.sticky-actions {
  position: sticky; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 8px);
  background: var(--bg); padding: 10px 0; flex-wrap: nowrap;
}
@media (min-width: 860px) { .sticky-actions { bottom: 0; } }

.rest {
  position: fixed; right: 16px; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 80px); z-index: 30;
  background: var(--text); color: var(--bg); border: 0; border-radius: 99px; padding: 10px 18px;
  font-weight: 700; font-size: 1rem; cursor: pointer; box-shadow: 0 4px 16px rgba(0, 0, 0, .2);
}
.rest span { font-variant-numeric: tabular-nums; margin-left: 4px; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); top: calc(env(safe-area-inset-top) + 70px); z-index: 40;
  background: var(--text); color: var(--bg); padding: 12px 18px; border-radius: 12px; max-width: min(92vw, 460px);
  box-shadow: 0 6px 24px rgba(0, 0, 0, .25); font-weight: 500; font-size: .95rem;
}

/* ---------- History ---------- */
.log-card { padding: 12px 16px; }
.log-head { display: flex; justify-content: space-between; align-items: center; width: 100%; border: 0; background: none; padding: 0; text-align: left; cursor: pointer; }
.chev { color: var(--muted); }
.log-detail { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }
.notes { font-style: italic; color: var(--text-2); }
.detail-ex .muted { font-size: .88rem; font-variant-numeric: tabular-nums; }

/* ---------- Charts ---------- */
.chart-wrap { position: relative; margin-top: 8px; }
.chart-wrap svg { width: 100%; height: auto; display: block; touch-action: pan-y; }
.chart-wrap .grid { stroke: var(--grid); stroke-width: 1; }
.chart-wrap .axis { stroke: var(--border); stroke-width: 1; }
.chart-wrap .tick { fill: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.chart-wrap .line { fill: none; stroke: var(--series-1); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart-wrap .pt { fill: var(--series-1); stroke: var(--surface); stroke-width: 2; }
.chart-wrap .hover-dot { fill: var(--series-1); stroke: var(--surface); stroke-width: 2; pointer-events: none; }
.chart-wrap .cross { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; pointer-events: none; }
.chart-wrap .bar { fill: var(--series-1); }
.chart-wrap .bar.active { filter: brightness(1.15); }
.chart-tip {
  position: absolute; transform: translate(-50%, -100%); pointer-events: none;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px;
  font-size: .82rem; box-shadow: var(--shadow); white-space: nowrap; color: var(--text);
}
.empty { padding: 24px 0; text-align: center; }

/* ---------- Combine ---------- */
.check-row { display: flex; gap: 10px; align-items: center; cursor: pointer; font-size: .95rem; min-height: 36px; }
.check-row input { width: 20px; height: 20px; min-height: 0; accent-color: var(--accent); flex: none; }
.combine-card { border-style: dashed; border-color: var(--accent); background: var(--accent-soft); }
.combine-card p { color: var(--text-2); }

/* ---------- Pros and cons ---------- */
.pc-grid { display: grid; gap: 12px; }
@media (min-width: 600px) { .pc-grid { grid-template-columns: 1fr 1fr; } }
.pc { margin: 6px 0 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; font-size: .92rem; color: var(--text-2); }
.pc.pro li::marker { content: "✓  "; color: var(--done); }
.pc.con li::marker { content: "–  "; color: var(--danger); }
.info details summary { cursor: pointer; padding: 6px 0; }
.info-compact { margin-top: -4px; font-size: .9rem; }
.info-compact summary { cursor: pointer; color: var(--accent); font-weight: 600; padding: 4px 0; }
.info-compact > *:not(summary) { margin-top: 8px; }
.concurrent h3 { margin-top: 12px; }

/* ---------- Nutrition ---------- */
.date-nav { display: flex; align-items: center; gap: 4px; }
.date-nav .icon-btn { font-size: 1.4rem; }
.date-nav .icon-btn:disabled { opacity: .3; cursor: default; }
.kcal-top { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 10px; }
.kcal-top .right { text-align: right; }
.stat-v.over { color: var(--danger); }
.macro-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 14px; }
.macro-l { display: flex; flex-direction: column; font-size: .82rem; font-weight: 600; margin-bottom: 4px; }
.macro-l .muted { font-weight: 500; font-variant-numeric: tabular-nums; }
.progress.thin { height: 6px; }
.progress.protein_g span { background: var(--lift); }
.progress.carbs_g span { background: #eda100; }
.progress.fat_g span { background: var(--run); }
.photo-pick { display: flex; align-items: center; gap: 14px; padding: 18px; border: 2px dashed var(--border); border-radius: var(--radius); cursor: pointer; background: var(--surface-2); }
.photo-pick:hover { border-color: var(--accent); }
.photo-pick:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.photo-pick.has-img { padding: 0; border-style: solid; overflow: hidden; }
.photo-pick img, .meal-preview { width: 100%; max-height: 320px; object-fit: cover; display: block; border-radius: var(--radius); }
.photo-icon { font-size: 2rem; }
.notice { background: var(--accent-soft); border-radius: 10px; padding: 10px 14px; font-size: .9rem; }
.notice.error { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--text); }
.spinner { width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; display: inline-block; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.4s; } }
.food-table { display: flex; flex-direction: column; gap: 6px; }
.food-row { display: grid; grid-template-columns: 1fr 64px 52px 44px 44px 44px 30px; gap: 4px; align-items: center; }
.food-row input { padding: 8px 6px; min-height: 40px; font-size: 15px; }
.food-row input[inputmode="decimal"] { text-align: center; font-variant-numeric: tabular-nums; }
.food-row.head { font-size: .72rem; color: var(--muted); font-weight: 600; text-transform: uppercase; }
.food-row.head span:nth-child(n+3), .food-row.total span:nth-child(n+3) { text-align: center; }
.food-row.total { font-weight: 700; border-top: 1px solid var(--border); padding-top: 8px; font-variant-numeric: tabular-nums; }
.food-row .icon-btn { width: 30px; }
@media (max-width: 480px) {
  .food-row { grid-template-columns: 1fr 1fr 1fr 1fr 30px; }
  .food-row > :nth-child(1) { grid-column: 1 / 3; } .food-row > :nth-child(2) { grid-column: 3 / 6; }
  .food-row:not(.head):not(.total) { padding-bottom: 8px; border-bottom: 1px solid var(--border); }
  .food-row.total > :nth-child(2) { display: none; }
  .food-row.total > :nth-child(1) { grid-column: 1 / 6; }
}
.badge.conf-hög { background: color-mix(in srgb, var(--done) 18%, transparent); color: var(--done); }
.badge.conf-medel { background: color-mix(in srgb, #eda100 20%, transparent); color: var(--text); }
.badge.conf-låg { background: color-mix(in srgb, var(--danger) 16%, transparent); color: var(--danger); }
.meal-card { padding: 12px 14px; }
.meal-head { display: flex; gap: 12px; align-items: center; width: 100%; border: 0; background: none; padding: 0; text-align: left; cursor: pointer; }
.meal-head .grow { display: flex; flex-direction: column; }
.thumb { width: 52px; height: 52px; border-radius: 10px; object-fit: cover; flex: none; }
.thumb.ph { display: grid; place-items: center; background: var(--surface-2); font-size: 1.4rem; }
.center { text-align: center; }
.kost-mini { text-decoration: none; color: var(--text); display: flex; flex-direction: column; gap: 8px; }
.kost-mini:hover { border-color: var(--accent); }
.meal-preview { max-height: 180px; }

/* ---------- Goals ---------- */
.notice.warn { background: color-mix(in srgb, #eda100 18%, transparent); color: var(--text); }
.badge.st-good { background: color-mix(in srgb, var(--done) 18%, transparent); color: var(--done); }
.badge.st-warn { background: color-mix(in srgb, #eda100 22%, transparent); color: var(--text); }
.badge.st-bad { background: color-mix(in srgb, var(--danger) 16%, transparent); color: var(--danger); }
.goal-row { padding: 10px 0; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 4px; }
.goal-row:first-of-type { border-top: 0; }
.rec { border: 1px solid var(--border); border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.rec.top { border-color: var(--accent); background: var(--accent-soft); }
.rec .badge { align-self: flex-start; }
.goals details h3 { margin-top: 12px; }
.goals details summary { cursor: pointer; }
.badge.st-good, .badge.st-warn, .badge.st-bad, .rec .badge { text-transform: none; }
.tx-code { font: 700 1.8rem/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .15em; margin: 6px 0; }

/* ---------- Food search and barcode ---------- */
.food-add { display: flex; flex-direction: column; gap: 8px; }
.food-search { display: flex; gap: 6px; }
.food-search input { flex: 1; min-width: 0; }
.food-search .btn { padding: 10px 12px; }
.food-results:empty { display: none; }
.food-results .chips { margin: 4px 0 0; }
.food-hits { list-style: none; margin: 0; padding: 0; border: 1px solid var(--border); border-radius: 12px; max-height: 320px; overflow-y: auto; }
.food-hits li + li { border-top: 1px solid var(--border); }
.food-hits button { display: flex; justify-content: space-between; align-items: center; gap: 12px; width: 100%; min-height: 44px; padding: 10px 14px; border: 0; background: var(--surface); color: var(--text); text-align: left; cursor: pointer; font-size: .95rem; }
.food-hits button:hover, .food-hits button:focus-visible { background: var(--accent-soft); }
.food-hits button .muted { flex: none; }
.food-row input[readonly] { background: var(--surface-2); border-color: transparent; color: var(--text-2); }
.food-row .grams { position: relative; display: block; }
.food-row .grams input { width: 100%; padding-right: 22px; text-align: center; }
.food-row .grams span { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: .85rem; pointer-events: none; }
.scanner { position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, .6); display: grid; place-items: center; padding: 16px; }
.scanner-box { background: var(--surface); color: var(--text); border-radius: var(--radius); padding: 16px; width: min(440px, 100%); display: flex; flex-direction: column; gap: 12px; max-height: calc(100vh - 32px); overflow-y: auto; }
.scanner-video { position: relative; border-radius: 12px; overflow: hidden; background: #000; aspect-ratio: 4 / 3; }
.scanner-video video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scanner-frame { position: absolute; left: 12%; right: 12%; top: 32%; bottom: 32%; border: 3px solid rgba(255, 255, 255, .9); border-radius: 10px; box-shadow: 0 0 0 999px rgba(0, 0, 0, .35); }
.scanner form input { min-width: 0; }
