/* FitPlate: mobile-first PWA styles. No build step. */

:root {
  color-scheme: light dark;

  --bg: #f6f7f4;
  --surface: #ffffff;
  --surface-2: #eef1ec;
  --line: #e1e6dd;
  --ink: #15201a;
  --ink-2: #4b5a51;
  --ink-3: #7e8c84;
  --brand: #2b3a67;
  --brand-ink: #ffffff;
  --brand-soft: #e4e9f6;
  --danger: #c93c3c;

  --c-kcal: #4f8f22;
  --c-protein: #3b7ddd;
  --c-fat: #d9930f;
  --c-carbs: #9b5de5;

  --radius: 18px;
  --radius-s: 12px;
  --shadow: 0 1px 2px rgb(20 40 30 / 0.05), 0 8px 24px rgb(20 40 30 / 0.07);
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --tab-h: 64px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* Dark tokens: follow the system unless the user forced a theme in Profile (data-theme on <html>). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #111513;
      --surface: #1a201c;
      --surface-2: #232b26;
      --line: #2c3630;
      --ink: #eef3ef;
      --ink-2: #b4c0b8;
      --ink-3: #7f8c84;
      --brand: #8294d8;
      --brand-ink: #0f1630;
      --brand-soft: #222a45;
      --danger: #ef6b6b;
    
      --c-kcal: #5c9e2d;
      --c-protein: #5a8fe6;
      --c-fat: #bf8410;
      --c-carbs: #9f74e0;
      --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 8px 24px rgb(0 0 0 / 0.35);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111513;
    --surface: #1a201c;
    --surface-2: #232b26;
    --line: #2c3630;
    --ink: #eef3ef;
    --ink-2: #b4c0b8;
    --ink-3: #7f8c84;
    --brand: #8294d8;
    --brand-ink: #0f1630;
    --brand-soft: #222a45;
    --danger: #ef6b6b;
  
    --c-kcal: #5c9e2d;
    --c-protein: #5a8fe6;
    --c-fat: #bf8410;
    --c-carbs: #9f74e0;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 8px 24px rgb(0 0 0 / 0.35);
}
:root[data-theme="light"] { color-scheme: light; }

/* Platform baseline (see mobile-native) */
html {
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
  background: var(--bg);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.4;
  color: var(--ink);
  background: var(--bg);
  min-height: 100dvh;
}
input, textarea, select, button { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
input, select { font-size: 16px; }
button, a, [role="button"], .tab, .chip {
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
button { background: none; border: 0; padding: 0; cursor: pointer; }
h1, h2, h3, p { margin: 0; }
.icon { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.icon.s { width: 18px; height: 18px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* Layout */
.app { min-height: 100dvh; display: flex; flex-direction: column; }
.screen {
  flex: 1;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: calc(12px + env(safe-area-inset-top)) 16px calc(var(--tab-h) + 24px + env(safe-area-inset-bottom));
  animation: screen-in 260ms var(--ease-out);
}
@keyframes screen-in { from { opacity: 0; transform: translateY(6px); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; min-height: 44px; }
.topbar h1 { font-size: 22px; font-weight: 700; letter-spacing: -0.01em; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.brand img { width: 30px; height: 30px; border-radius: 9px; }

.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}
.card + .card, .section + .section { margin-top: 14px; }
.section-title { display: flex; align-items: center; justify-content: space-between; font-size: 13px; font-weight: 600; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.06em; margin: 18px 4px 8px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 20px; border-radius: 14px;
  background: var(--brand); color: var(--brand-ink); font-weight: 600;
  transition: transform 120ms var(--ease-out), background 120ms, opacity 120ms;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.55; }
.btn.block { width: 100%; }
.btn.ghost { background: var(--surface-2); color: var(--ink); }
.btn.danger { background: transparent; color: var(--danger); }
.btn.small { min-height: 38px; padding: 0 14px; font-size: 14px; border-radius: 11px; }
.icon-btn {
  width: 44px; height: 44px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  color: var(--ink-2); transition: background 120ms, transform 120ms var(--ease-out);
}
.icon-btn:active { background: var(--surface-2); transform: scale(0.94); }
@media (hover: hover) and (pointer: fine) {
  .btn:hover { filter: brightness(1.05); }
  .icon-btn:hover { background: var(--surface-2); }
  .row:hover { background: var(--surface-2); }
}

/* Forms */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.input {
  width: 100%; min-height: 50px; padding: 0 14px; border-radius: 14px;
  border: 1.5px solid var(--line); background: var(--surface); color: var(--ink);
  outline: none; transition: border-color 120ms, box-shadow 120ms;
}
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft); }
.input-wrap { position: relative; }
.input-wrap .icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--ink-3); pointer-events: none; }
.input-wrap .input { padding-left: 44px; }
.error { color: var(--danger); font-size: 14px; margin: 6px 0 10px; }
.hint { color: var(--ink-3); font-size: 14px; }

/* Auth */
.auth { flex: 1; display: flex; flex-direction: column; justify-content: center; max-width: 420px; margin: 0 auto; width: 100%; padding: 32px 20px calc(32px + env(safe-area-inset-bottom)); }
.auth .logo { width: 84px; height: 84px; border-radius: 24px; margin: 0 auto 18px; display: block; box-shadow: var(--shadow); }
.auth h1 { text-align: center; font-size: 30px; letter-spacing: -0.02em; }
.auth .tagline { text-align: center; color: var(--ink-2); margin: 6px 0 28px; }
.segmented { display: grid; grid-template-columns: 1fr 1fr; background: var(--surface-2); border-radius: 14px; padding: 4px; margin-bottom: 20px; }
.segmented button { min-height: 40px; border-radius: 11px; font-weight: 600; color: var(--ink-2); transition: background 160ms, color 160ms; }
.segmented button[aria-selected="true"], .segmented button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgb(0 0 0 / 0.08); }

/* Date strip */
.datebar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 14px; }
.datebar .date { text-align: center; }
.datebar .date strong { display: block; font-size: 18px; text-transform: capitalize; }
.datebar .date span { font-size: 13px; color: var(--ink-3); }

/* Energy ring + macros */
.energy { display: grid; grid-template-columns: 148px 1fr; gap: 14px; align-items: center; }
.ring { position: relative; width: 148px; height: 148px; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 12; stroke-linecap: round; }
.ring .track { stroke: var(--surface-2); }
.ring .bar { stroke: var(--c-kcal); transition: stroke-dashoffset 600ms var(--ease-out); }
.ring .bar.over { stroke: var(--danger); }
.ring .label { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ring .label strong { font-size: 30px; font-weight: 700; letter-spacing: -0.03em; line-height: 1; }
.ring .label span { font-size: 12px; color: var(--ink-3); margin-top: 4px; }
.macros { display: flex; flex-direction: column; gap: 12px; }
.macro .head { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 5px; }
.macro .head b { font-weight: 600; }
.macro .head span { color: var(--ink-3); font-variant-numeric: tabular-nums; }
.macro .track { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.macro .fill { height: 100%; border-radius: 4px; width: 0; transition: width 600ms var(--ease-out); }
.macro.protein .fill { background: var(--c-protein); }
.macro.fat .fill { background: var(--c-fat); }
.macro.carbs .fill { background: var(--c-carbs); }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chips[hidden] { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 14px; border-radius: 999px;
  background: var(--surface-2); color: var(--ink-2); font-size: 14px; font-weight: 600;
  transition: background 120ms, color 120ms, transform 120ms var(--ease-out);
}
.chip:active { transform: scale(0.96); }
.chip[aria-pressed="true"], .chip.on { background: var(--brand); color: var(--brand-ink); }
.streak { display: inline-flex; align-items: center; gap: 6px; color: var(--c-fat); font-weight: 700; font-size: 14px; }

/* Meals */
.meal { padding: 0; overflow: hidden; }
.meal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; }
.meal-head h3 { font-size: 16px; font-weight: 700; }
.meal-head .kcal { font-size: 14px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.meal-head .add { width: 36px; height: 36px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); display: inline-flex; align-items: center; justify-content: center; transition: transform 120ms var(--ease-out); }
.meal-head .add:active { transform: scale(0.92); }
.meal-empty { padding: 0 16px 14px; color: var(--ink-3); font-size: 14px; }
.row {
  display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center;
  width: 100%; text-align: left; padding: 11px 16px; border-top: 1px solid var(--line);
  transition: background 120ms;
}
.row:active { background: var(--surface-2); }
.row .name { grid-column: 1; grid-row: 1; font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.row .sub { grid-column: 1; grid-row: 2; font-size: 13px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.row .val { grid-column: 2; grid-row: 1 / span 2; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.row .val small { display: block; font-weight: 400; font-size: 12px; color: var(--ink-3); }
.dots { display: inline-flex; gap: 4px; vertical-align: middle; margin-left: 6px; }
.dots i { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.dots .p { background: var(--c-protein); } .dots .f { background: var(--c-fat); } .dots .c { background: var(--c-carbs); }

/* Tab bar */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: 1fr 1fr 1fr; align-items: end;
  height: calc(var(--tab-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
}
.tabbar .tab { height: var(--tab-h); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 11px; font-weight: 600; color: var(--ink-3); transition: color 120ms; }
.tabbar .tab[aria-current="page"] { color: var(--brand); }
.fab {
  position: fixed; right: 18px; bottom: calc(var(--tab-h) + 16px + env(safe-area-inset-bottom));
  width: 60px; height: 60px; border-radius: 50%; z-index: 21;
  background: var(--brand); color: var(--brand-ink);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 20px rgb(47 143 91 / 0.35);
  transition: transform 140ms var(--ease-out);
}
.fab .icon { width: 28px; height: 28px; stroke-width: 2.4; }
.fab:active { transform: scale(0.93); }

/* Bottom sheet */
.sheet-backdrop { position: fixed; inset: 0; z-index: 30; background: rgb(0 0 0 / 0.4); animation: fade 200ms; }
@keyframes fade { from { opacity: 0; } }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 31;
  max-width: 560px; margin: 0 auto;
  max-height: calc(100dvh - 24px - env(safe-area-inset-top));
  display: flex; flex-direction: column;
  background: var(--bg); border-radius: 22px 22px 0 0;
  box-shadow: 0 -8px 40px rgb(0 0 0 / 0.18);
  animation: sheet-up 320ms var(--ease-out);
  touch-action: pan-y;
}
.sheet.tall { height: calc(100dvh - 24px - env(safe-area-inset-top)); }
@keyframes sheet-up { from { transform: translateY(40px); opacity: 0.6; } }
.sheet .handle { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 10px auto 4px; }
.sheet .sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 12px 8px 20px; }
.sheet .sheet-head h2 { font-size: 18px; font-weight: 700; }
.sheet .sheet-body { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 0 16px calc(16px + env(safe-area-inset-bottom)); -webkit-overflow-scrolling: touch; }
.sheet .sheet-foot { padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--surface); display: flex; gap: 10px; }
.sheet .sheet-foot .btn { flex: 1; }
.sticky-search { position: sticky; top: 0; z-index: 2; background: var(--bg); padding: 4px 0 10px; display: flex; gap: 8px; }
.sticky-search .input-wrap { flex: 1; }
.scan-btn { width: 50px; height: 50px; border-radius: 14px; background: var(--brand-soft); color: var(--brand); display: inline-flex; align-items: center; justify-content: center; flex: none; }
.list { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.list .row:first-child { border-top: 0; }
.empty { text-align: center; color: var(--ink-3); padding: 36px 20px; }
.empty .icon { width: 40px; height: 40px; color: var(--line); stroke-width: 1.5; margin-bottom: 10px; }
.src { font-size: 10px; font-weight: 700; letter-spacing: 0.06em; padding: 2px 6px; border-radius: 6px; background: var(--surface-2); color: var(--ink-3); vertical-align: middle; margin-left: 6px; }

/* Portion sheet */
.portion-hero { text-align: center; padding: 6px 0 14px; }
.portion-hero .name { font-size: 20px; font-weight: 700; }
.portion-hero .brand-name { color: var(--ink-3); font-size: 14px; }
.grams { display: flex; align-items: center; justify-content: center; gap: 12px; margin: 10px 0 14px; }
.grams .input { width: 140px; text-align: center; font-size: 28px; font-weight: 700; min-height: 60px; border-radius: 18px; }
.grams .unit { font-size: 18px; color: var(--ink-3); }
.grams .step { width: 50px; height: 50px; border-radius: 50%; background: var(--surface-2); display: inline-flex; align-items: center; justify-content: center; font-size: 24px; font-weight: 600; }
.grams .step:active { transform: scale(0.94); }
.macro-tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 14px 0; }
.tile { background: var(--surface); border-radius: 14px; padding: 10px 6px; text-align: center; box-shadow: var(--shadow); border-top: 3px solid var(--line); }
.tile strong { display: block; font-size: 17px; font-variant-numeric: tabular-nums; }
.tile span { font-size: 11px; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.05em; }
.tile.kcal { border-color: var(--c-kcal); } .tile.protein { border-color: var(--c-protein); } .tile.fat { border-color: var(--c-fat); } .tile.carbs { border-color: var(--c-carbs); }
.meal-picker { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin: 6px 0 4px; }
.meal-picker .chip { justify-content: center; padding: 0 4px; font-size: 12px; min-height: 40px; }

/* Scanner */
.scanner { position: relative; background: #000; border-radius: var(--radius); overflow: hidden; width: 100%; height: min(52dvh, 440px); }
.scanner video { width: 100%; height: 100%; object-fit: cover; }
.scanner .window { position: absolute; left: 12%; right: 12%; top: 38%; height: 24%; border: 2px solid #fff; border-radius: 12px; box-shadow: 0 0 0 100vmax rgb(0 0 0 / 0.45); }
.scanner .window::after { content: ""; position: absolute; left: 10px; right: 10px; top: 50%; height: 2px; background: var(--brand); animation: scanline 1.6s ease-in-out infinite alternate; }
@keyframes scanline { from { transform: translateY(-30px); } to { transform: translateY(30px); } }
.scanner .status { position: absolute; left: 0; right: 0; bottom: 0; padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); color: #fff; font-size: 14px; background: linear-gradient(transparent, rgb(0 0 0 / 0.6)); display: flex; justify-content: space-between; align-items: center; }
.scanner .torch { color: #fff; }

/* Stats */
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat { background: var(--surface); border-radius: 14px; padding: 12px; box-shadow: var(--shadow); }
.stat strong { display: block; font-size: 22px; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat span { font-size: 12px; color: var(--ink-3); }
.bars { display: flex; align-items: flex-end; gap: 6px; height: 160px; padding-top: 8px; position: relative; }
.bars .goal { position: absolute; left: 0; right: 0; border-top: 1.5px dashed var(--ink-3); opacity: 0.5; }
.bars .goal span { position: absolute; right: 0; top: -18px; font-size: 11px; color: var(--ink-3); }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 6px; min-width: 0; }
.bar-col .bar { width: 100%; max-width: 34px; border-radius: 6px 6px 0 0; background: var(--c-kcal); min-height: 2px; transition: height 500ms var(--ease-out); position: relative; }
.bar-col .bar.over { background: var(--danger); }
.bar-col .bar.today { outline: 2px solid var(--brand-soft); outline-offset: 1px; }
.bar-col .day { font-size: 11px; color: var(--ink-3); white-space: nowrap; }
.bar-col .bar .v { position: absolute; left: 50%; top: -18px; transform: translateX(-50%); font-size: 11px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; color: var(--ink-2); margin-top: 8px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; margin-right: 6px; vertical-align: -1px; }

/* Language picker and meal editor */
.lang-row { margin-top: 18px; }
.segmented.lang { margin-bottom: 0; max-width: 260px; }
.segmented.three { grid-template-columns: 1fr 1fr 1fr; margin-bottom: 0; max-width: 360px; }
.auth .lang-row .segmented { margin: 0 auto; }
.meal-row { display: flex; align-items: center; gap: 6px; padding: 6px 0; border-top: 1px solid var(--line); }
.meal-row:first-child { border-top: 0; }
.meal-row .meal-name { flex: 1; min-width: 0; text-align: left; font-weight: 600; font-size: 15px; padding: 8px 0; min-height: 44px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); }
.meal-row .meal-actions { display: flex; gap: 0; flex: none; }
.meal-row .icon-btn { width: 38px; height: 38px; color: var(--ink-2); }
.meal-row .icon-btn:disabled { opacity: 0.3; }
.meal-row.is-hidden .meal-name { color: var(--ink-3); text-decoration: line-through; text-decoration-color: var(--ink-3); }

.share-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 14px 4px 0; padding-top: 12px; border-top: 1px solid var(--line); }
.share-row .hint { margin: 0; }
.badge { display: inline-flex; min-width: 22px; height: 22px; padding: 0 7px; border-radius: 11px; background: var(--brand); color: #fff; font-size: 12px; font-weight: 700; align-items: center; justify-content: center; vertical-align: middle; letter-spacing: 0; }
.row.review { grid-template-columns: 1fr; }
.row.review .name, .row.review .sub { grid-column: 1; }
.row.review .review-grid { grid-column: 1; display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 8px; }
.row.review .review-grid label { font-size: 12px; font-weight: 600; color: var(--ink-2); display: grid; gap: 4px; }
.row.review .review-grid .input { min-height: 40px; padding: 0 10px; border-radius: 10px; font-size: 16px; }
.row.review .review-actions { grid-column: 1; display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px; }

/* Onboarding interview */
.setup { max-width: 520px; margin: 0 auto; padding: calc(16px + env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom)); min-height: 100dvh; display: flex; flex-direction: column; }
.setup .steps { display: flex; gap: 6px; margin: 6px 0 18px; }
.setup .steps i { flex: 1; height: 4px; border-radius: 2px; background: var(--line); }
.setup .steps i.on { background: var(--brand); }
.setup h1 { font-size: 26px; letter-spacing: -0.02em; margin: 0 0 6px; }
.setup .intro { color: var(--ink-2); margin: 0 0 18px; }
.setup .body { flex: 1; }
.setup .nav { display: flex; gap: 10px; margin-top: 18px; }
.setup .nav .btn { flex: 1; }
.setup a:not(.btn) { color: var(--brand); font-weight: 600; }
.option-list { display: grid; gap: 10px; }
.option { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; text-align: left; background: var(--surface); border: 2px solid var(--line); border-radius: var(--radius-s); padding: 14px 16px; min-height: 60px; color: var(--ink); }
.option b { font-size: 16px; }
.option span { grid-column: 1; font-size: 13px; color: var(--ink-2); }
.option .tick { grid-column: 2; grid-row: 1 / span 2; align-self: center; width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line); }
.option[aria-pressed="true"] { border-color: var(--brand); background: var(--brand-soft); }
.option[aria-pressed="true"] .tick { background: var(--brand); border-color: var(--brand); }
.plan-hero { text-align: center; padding: 18px 0 6px; }
.plan-hero strong { display: block; font-size: 44px; font-weight: 800; letter-spacing: -0.03em; color: var(--brand); line-height: 1; }
.plan-hero span { color: var(--ink-2); font-weight: 600; }
.plan-facts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 0; }
.plan-facts div { background: var(--surface); border-radius: var(--radius-s); padding: 10px 12px; box-shadow: var(--shadow); }
.plan-facts b { display: block; font-size: 18px; }
.plan-facts span { font-size: 12px; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.04em; }
.plan-notes { color: var(--ink-2); font-size: 14px; display: grid; gap: 6px; margin: 8px 0; }
.plan-card { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center; margin-top: 12px; }
.plan-card .hint { grid-column: 1; margin: 0; }
.plan-card .btn { grid-column: 2; grid-row: 1 / span 2; }

/* Profile */
.goal-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.goal-grid .field { margin: 0; }
.profile-head { display: flex; align-items: center; gap: 14px; }
.avatar { width: 52px; height: 52px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 20px; }

/* Toast */
.toast-root { position: fixed; left: 16px; right: 92px; bottom: calc(var(--tab-h) + 16px + env(safe-area-inset-bottom)); z-index: 40; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast { pointer-events: auto; background: var(--ink); color: var(--bg); padding: 12px 16px; border-radius: 14px; font-size: 14px; font-weight: 600; box-shadow: var(--shadow); display: flex; gap: 12px; align-items: center; animation: toast-in 240ms var(--ease-out); max-width: 480px; }
.toast button { color: var(--brand-soft); font-weight: 700; }
@keyframes toast-in { from { transform: translateY(12px); opacity: 0; } }

/* Desktop: the phone column becomes a comfortable two-column grid */
@media (min-width: 900px) {
  .screen { max-width: 1000px; padding-bottom: 40px; }
  .desktop-grid { display: grid; grid-template-columns: 380px 1fr; gap: 20px; align-items: start; }
  .desktop-grid > .sticky { position: sticky; top: 16px; }
  .tabbar { top: 0; bottom: auto; height: 56px; grid-template-columns: auto 1fr auto auto auto; padding: 0 24px; border-top: 0; border-bottom: 1px solid var(--line); align-items: center; }
  .tabbar .brand-slot { margin-right: 24px; }
  .tabbar .tab { height: 56px; flex-direction: row; gap: 8px; font-size: 14px; padding: 0 14px; }
  .tabbar .brand-slot { display: flex; }
  .app { padding-top: 56px; }
  .fab { bottom: 32px; right: 32px; }
  .toast-root { bottom: 24px; }
  .sheet { bottom: auto; top: 50%; left: 50%; transform: translate(-50%, -50%); border-radius: 22px; max-height: 86dvh; width: min(560px, 92vw); animation: dialog-in 240ms var(--ease-out); }
  .sheet.tall { height: 86dvh; }
  @keyframes dialog-in { from { opacity: 0; transform: translate(-50%, -48%); } }
  .sheet .handle { display: none; }
}
@media (max-width: 899px) { .tabbar .brand-slot, .tabbar .desktop-gap { display: none; } }

/* Weight progress */
.weight-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.weight-head .section-title .hint { font-weight: 500; text-transform: none; letter-spacing: 0; }
.weight-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0 4px; }
.weight-stats div { background: var(--surface-2); border-radius: var(--radius-s); padding: 8px 10px; }
.weight-stats strong { display: block; font-size: 20px; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.weight-stats span { font-size: 11px; color: var(--ink-3); }
.weight-chart { display: block; width: 100%; height: auto; margin-top: 8px; overflow: visible; }
.weight-chart .grid { stroke: var(--line); stroke-width: 1; }
.weight-chart .tick { font-size: 10px; fill: var(--ink-3); }
.weight-chart .target { stroke: var(--c-kcal); stroke-width: 1.5; stroke-dasharray: 4 4; }
.weight-chart .target-label { fill: var(--c-kcal); font-weight: 600; }
.weight-chart .line { fill: none; stroke: var(--brand); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.weight-chart .dot { fill: var(--brand); stroke: var(--surface); stroke-width: 2; }
.weight-chart .value { font-size: 11px; fill: var(--ink-2); font-variant-numeric: tabular-nums; }
.weight-chart .value.strong { fill: var(--ink); font-weight: 700; }
.weight-list { margin-top: 10px; }
.weight-list summary { font-size: 13px; font-weight: 600; color: var(--ink-2); cursor: pointer; }
.weight-list ul { list-style: none; margin: 6px 0 0; padding: 0; }
.weight-list li { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-top: 1px solid var(--line); font-size: 14px; }
.weight-list li span { flex: 1; color: var(--ink-2); }
.weight-list li b { font-variant-numeric: tabular-nums; }

/* Offline */
.net-banner { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 10px; padding: 8px 16px; font-size: 13px; background: #fff3d6; color: #6b4b00; border-bottom: 1px solid #f1d58a; }
.net-banner[hidden] { display: none; }
.net-banner.syncing { background: var(--brand-soft); color: var(--brand); border-color: transparent; }
.net-banner .icon { width: 18px; height: 18px; flex: none; }
.net-banner b { font-weight: 700; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .net-banner { background: #3a2f12; color: #ffd98a; border-color: #5a4616; } }
:root[data-theme="dark"] .net-banner { background: #3a2f12; color: #ffd98a; border-color: #5a4616; }
.row.pending .name::after, .weight-list li.pending b::after { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #d9930f; margin-left: 6px; vertical-align: middle; }
.row.pending { background: repeating-linear-gradient(135deg, transparent 0 8px, rgb(217 147 15 / 0.06) 8px 10px); }

/* Admin panel */
.admin-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.admin-tabs::-webkit-scrollbar { display: none; }
.admin-tabs .chip { flex: none; }
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 900px) { .tiles { grid-template-columns: repeat(4, 1fr); } }
.tiles .stat strong { font-size: 24px; }
.tiles .stat.warn { outline: 2px solid #d9930f; }
.mini-bars { display: block; width: 100%; height: auto; margin-top: 6px; overflow: visible; }
.mini-bars .grid { stroke: var(--line); stroke-width: 1; }
.mini-bars .bar { fill: var(--brand); }
.mini-bars .bar.dim { fill: var(--brand-soft); }
.mini-bars .tick, .mini-bars .value { font-size: 10px; fill: var(--ink-3); }
.mini-bars .value { fill: var(--ink-2); font-weight: 600; }
.hbars { display: grid; grid-template-columns: auto 1fr auto; gap: 6px 10px; align-items: center; font-size: 14px; margin-top: 8px; }
.hbars .track { height: 10px; border-radius: 5px; background: var(--surface-2); overflow: hidden; }
.hbars .fill { height: 100%; background: var(--brand); border-radius: 5px; }
.hbars .n { font-variant-numeric: tabular-nums; color: var(--ink-2); }
.adm-table { width: 100%; border-collapse: collapse; font-size: 14px; margin-top: 8px; }
.adm-table th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-3); padding: 4px 0; }
.adm-table td { padding: 7px 0; border-top: 1px solid var(--line); vertical-align: top; }
.adm-table td.n, .adm-table th.n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.adm-table .sub { display: block; font-size: 12px; color: var(--ink-3); }
.row .tag { display: inline-block; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); margin-left: 6px; vertical-align: middle; }
.row .tag.danger { background: #fde2e2; color: #8a1c1c; }
.row .tag.brand { background: var(--brand-soft); color: var(--brand); }
.kv { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.kv div { background: var(--surface-2); border-radius: var(--radius-s); padding: 10px 12px; }
.kv b { display: block; font-size: 20px; font-variant-numeric: tabular-nums; }
.kv span { font-size: 12px; color: var(--ink-3); }
.sheet-actions { display: grid; gap: 8px; }
.sheet .sheet-foot > .sheet-actions { flex: 1; }

/* Portion units: own portions carry a small remove mark */
.units .chip { position: relative; }
.units .chip.own { padding-right: 30px; }
.units .chip .rm { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 20px; height: 20px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; font-size: 14px; background: rgba(0, 0, 0, 0.08); }
.chip.ghost { background: transparent; border: 1px dashed var(--line); }

/* Consent boxes, legal pages, small text buttons */
.check { display: flex; gap: 10px; align-items: flex-start; margin: 0 0 12px; font-size: 14px; line-height: 1.45; color: var(--ink-2); cursor: pointer; }
.check input { flex: none; width: 22px; height: 22px; margin: 1px 0 0; accent-color: var(--brand); }
.check a, .legal-links a, .prose a { color: var(--brand); text-decoration: underline; text-underline-offset: 2px; }
.link-btn { display: block; margin: 14px auto 0; background: none; border: 0; padding: 8px 12px; color: var(--ink-2); font: inherit; font-size: 14px; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.link-btn[hidden] { display: none; }
.legal-links { text-align: center; font-size: 13px; color: var(--ink-3); margin: 18px 0 0; }
.legal .topbar { justify-content: flex-start; gap: 6px; }
.draft-note { margin: 0 0 12px; padding: 10px 14px; border-radius: 12px; border: 1px dashed var(--warn, #d9930f); color: var(--ink-2); font-size: 13px; }
.prose { line-height: 1.6; font-size: 15px; }
.prose h2 { font-size: 16px; margin: 18px 0 6px; }
.prose h2:first-of-type { margin-top: 12px; }
.prose p { margin: 0 0 10px; }
.prose ul { margin: 0 0 10px; padding-left: 20px; }
.prose li { margin: 0 0 6px; }

/* Scan session: magnified view of the scan window, and one small card per code */
.scanner .loupe { position: absolute; left: 12px; top: 12px; width: 46%; aspect-ratio: 3; border-radius: 10px; border: 2px solid #fff; background: #000; box-shadow: 0 4px 14px rgb(0 0 0 / 0.4); }
.scanner .torch[aria-pressed="true"] { color: #ffd34d; }
.scan-cards { display: grid; gap: 8px; margin-top: 10px; }
.scan-card { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 10px; align-items: center; padding: 10px 12px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); animation: card-in 160ms ease-out; }
.scan-card.is-confirmed { border-color: var(--brand); box-shadow: inset 3px 0 0 var(--brand); }
.scan-card .scan-main { display: grid; gap: 2px; min-width: 0; }
.scan-card .scan-main b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scan-card .sub { font-size: 12px; color: var(--ink-3); }
.scan-card .input { font-size: 16px; min-height: 36px; padding: 0 8px; border-radius: 9px; }
.scan-card .code { width: 150px; margin-top: 4px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.scan-card .scan-actions { display: flex; align-items: center; gap: 2px; }
.scan-card .scan-grams { display: flex; align-items: center; gap: 4px; font-size: 13px; color: var(--ink-3); margin-right: 4px; }
.scan-card .scan-grams .input { width: 70px; text-align: right; }
.scan-card .accept, .scan-card .ok { color: var(--brand); }
.scan-card .ok { display: inline-flex; width: 38px; justify-content: center; }
@keyframes card-in { from { opacity: 0; transform: translateY(-4px); } }
@media (prefers-reduced-motion: reduce) { .scan-card { animation: none; } }
.scanner .torch[hidden] { display: none; }
.sheet .sheet-foot[hidden] { display: none; }
.scan-batch { margin: 12px 4px 6px; }
