/* Component library styles — mirrors the Penpot 44 components (atoms → organisms).
   Class names map 1:1 to the JS component functions in js/components.js. */

/* default icon size — bare icon() calls; larger contexts override below */
.ic { width: 20px; height: 20px; flex: 0 0 auto; }
.cal > .ic { color: var(--muted); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border-radius: var(--r-pill);
  font-weight: 600; font-size: var(--fs-body);
  padding: 12px 20px; min-height: 44px;
  transition: filter 0.12s ease, background 0.12s ease;
}
.btn:active { filter: brightness(0.94); }
.btn svg { width: 18px; height: 18px; }
.btn--primary { background: var(--green-solid); color: var(--on-green); }
.btn--secondary { background: var(--card); color: var(--ink); border: 1px solid var(--border); }
.btn--text { background: none; color: var(--green); padding: 8px 10px; min-height: 0; }
.btn--danger { background: var(--danger); color: #fff; }
.btn--full { width: 100%; }
.btn--lg { min-height: 54px; font-size: 16px; }
.btn[disabled] { opacity: 0.5; pointer-events: none; }

.iconbtn {
  width: 40px; height: 40px; border-radius: var(--r-pill);
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--ink); background: var(--card); border: 1px solid var(--border);
}
.iconbtn.ghost { background: none; border: none; }
.iconbtn svg { width: 20px; height: 20px; }

/* ---------- card / section ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  padding: 16px;
  box-shadow: var(--shadow-card);
  display: flex; flex-direction: column; gap: 12px;
}
.card.tap { cursor: pointer; }
.card.pad-0 { padding: 0; overflow: hidden; }
.card.tint-green { background: var(--green-tint); border-color: transparent; }
.section { display: flex; flex-direction: column; gap: 10px; }

/* ---------- avatar / badge / chips ---------- */
.avatar {
  position: relative;
  border-radius: 50%; color: #fff; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
  flex: 0 0 auto;
}
.avatar.s { width: 32px; height: 32px; font-size: 13px; }
.avatar.m { width: 40px; height: 40px; font-size: 15px; }
.avatar.l { width: 56px; height: 56px; font-size: 20px; }
.avatar--green { background: #2E7D32; }
.avatar--terracotta { background: #C65D3B; }
.avatar--purple { background: #6C6FC0; }
.avatar--amber { background: #D8A31E; }
.avatar--photo { padding: 0; overflow: hidden; }
/* The photo overlays the coloured initial (absolute, so removing it on load-error
   reveals the initial beneath — the accessible fallback). */
.avatar__img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; border-radius: inherit; }

/* FB2-2 avatar cropper */
.cropper__view { position: relative; width: 240px; height: 240px; margin: 4px auto 2px; border-radius: 50%; overflow: hidden; background: var(--surface-2, #eee); touch-action: none; cursor: grab; }
.cropper__view:active { cursor: grabbing; }
.cropper__img { position: absolute; top: 0; left: 0; max-width: none; user-select: none; -webkit-user-drag: none; }
.cropper__zoom { flex: 1; }

/* FB2-2 editable avatar (Profile) */
.avatar-edit { position: relative; display: inline-flex; border: none; background: none; padding: 0; cursor: pointer; }
.avatar-edit__badge { position: absolute; right: -2px; bottom: -2px; width: 22px; height: 22px; border-radius: 50%; background: var(--green, #2E7D32); color: #fff; display: inline-flex; align-items: center; justify-content: center; box-shadow: 0 0 0 2px var(--bg, #fff); }
.avatar-edit__badge svg { width: 13px; height: 13px; }

.badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 22px; height: 22px; padding: 0 7px;
  background: var(--chip); color: var(--muted);
  border-radius: var(--r-pill); font-size: 12px; font-weight: 700;
}
.badge.green { background: var(--green-tint); color: var(--green); }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px; border-radius: var(--r-pill);
  background: var(--card); border: 1px solid var(--border);
  font-size: var(--fs-sm); font-weight: 600;
}
.pill svg { width: 15px; height: 15px; }
.pill.green { background: var(--green-tint); border-color: transparent; color: var(--green); }

/* Household context on #/today — deliberately compact and page-aligned (no card
   fill, border, or button padding) so it reads as a quiet label, not a dropdown
   CTA (design feedback 0eadddcf). Interactive → global :focus-visible applies. */
.household-chip {
  display: inline-flex; align-items: center; gap: 5px;
  align-self: flex-start;
  margin: -2px 0 0; padding: 2px 0;
  background: none; border: none;
  color: var(--muted); font-size: var(--fs-sm); font-weight: 500;
  cursor: pointer;
}
.household-chip svg { width: 14px; height: 14px; }
.household-chip span { color: var(--ink); font-weight: 600; }
.household-chip:hover { color: var(--ink); }

.chip {
  display: inline-flex; align-items: center;
  padding: 3px 9px; border-radius: var(--r-pill);
  background: var(--chip); color: var(--muted);
  font-size: 12px; font-weight: 600;
}

/* ---------- brand ---------- */
.brand-mark { border-radius: 22%; display: block; }
.brand-lockup { display: inline-flex; align-items: center; gap: 8px; }
.brand-lockup img { width: 34px; height: 34px; border-radius: 9px; }
.brand-lockup b { font-size: 17px; font-weight: 700; }

/* ---------- suggestion row ---------- */
.sugg {
  display: flex; align-items: center; gap: 12px;
}
.sugg__ic {
  width: 40px; height: 40px; border-radius: 12px;
  background: var(--green-tint); color: var(--green);
  display: flex; align-items: center; justify-content: center; flex: 0 0 auto;
  font-size: 18px;
}
.sugg__ic svg { width: 20px; height: 20px; }
.sugg__body { flex: 1; min-width: 0; }
.sugg__name { font-weight: 700; font-size: var(--fs-body); }
.sugg__reason { color: var(--muted); font-size: var(--fs-sm); }
.sugg__acts { display: flex; gap: 8px; flex: 0 0 auto; }
.thumb {
  width: 44px; height: 40px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); background: var(--card); color: var(--muted);
}
.thumb svg { width: 20px; height: 20px; }
.thumb--up.on { background: var(--green-solid); color: #fff; border-color: transparent; }
.thumb--down.on { background: var(--chip); color: var(--ink); }
.sugg.dismissed { opacity: 0.45; }

/* ---------- household language: LF4 production picker + LF1 preview card ---------- */
.language-suggestion__head { display: flex; align-items: flex-start; gap: 12px; }
.language-suggestion__icon {
  width: 40px; height: 40px; border-radius: 12px; flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--green); background: var(--green-tint);
}
.language-suggestion__icon svg { width: 20px; height: 20px; }
.language-suggestion__actions { display: flex; flex-direction: column; gap: 8px; }
.language-suggestion__dismiss {
  align-self: center; min-height: 44px; padding: 8px 16px;
  color: var(--muted); font-weight: 600;
}
.language-picker { gap: 12px; }
.language-household-note {
  display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px;
  border-radius: 12px; background: var(--green-tint); color: var(--ink);
  font-size: var(--fs-sm);
}
.language-household-note__icon { color: var(--green); flex: 0 0 auto; }
.language-household-note__icon svg { width: 18px; height: 18px; }
.language-list { display: flex; flex-direction: column; }
.language-option {
  width: 100%; min-height: 56px; display: flex; align-items: center; gap: 12px;
  padding: 10px 4px; text-align: left; border-bottom: 1px solid var(--border);
}
.language-option:last-child { border-bottom: none; }
.language-option__names { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.language-option__check { color: var(--green); display: inline-flex; }
.language-option__check svg { width: 20px; height: 20px; }
.language-option.selected { color: var(--green); }
.language-empty { padding: 18px 4px; text-align: center; }
.language-reassurance { margin-bottom: 2px; }

/* ---------- dinner idea ---------- */
.idea__label { display: flex; align-items: center; gap: 6px; color: var(--amber); font-weight: 700;
  font-size: var(--fs-label); letter-spacing: 0.06em; text-transform: uppercase; }
.idea__label svg { width: 15px; height: 15px; }
.idea__dish { font-size: 20px; font-weight: 700; line-height: 1.2; }
.idea__miss { color: var(--muted); font-size: var(--fs-body); }
.idea__foot { display: flex; align-items: center; }
.idea__foot .sugg__acts { }
.idea__swap { margin-left: auto; }

/* ---------- calories card / donut ---------- */
.cal { display: flex; align-items: center; gap: 16px; }
.cal__body { flex: 1; min-width: 0; }
.cal__big { font-size: 24px; font-weight: 700; }
.donut { position: relative; flex: 0 0 auto; }
.donut__center { position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center; }
/* Centre number is the heaviest type in the app (matches Penpot); the "of X kcal"
   sub is small enough to stay INSIDE the ring on one line (feedback: it must not
   cross the circle). */
.donut__num { font-size: var(--fs-num); font-weight: 800; line-height: 1;
  letter-spacing: -0.5px; font-variant-numeric: tabular-nums; }
.donut__sub { font-size: 10px; color: var(--muted); margin-top: 2px;
  white-space: nowrap; letter-spacing: -0.2px; }

/* ---------- macro bars / summary ---------- */
.macro { display: flex; flex-direction: column; gap: 6px; }
.macro__top { display: flex; justify-content: space-between; font-weight: 600; }
.macro__top .v { color: var(--muted); font-weight: 500; }
.macro__rail { height: 8px; border-radius: 999px; background: var(--track); overflow: hidden; }
.macro__fill { height: 100%; border-radius: 999px; }
.macro--p .macro__fill { background: var(--macro-p); }
.macro--c .macro__fill { background: var(--macro-c); }
.macro--f .macro__fill { background: var(--macro-f); }

.msum { display: flex; justify-content: space-between; gap: 8px; }
.msum__col { display: flex; flex-direction: column; gap: 2px; }
.msum__v { font-size: 19px; font-weight: 700; }
.msum__k { font-size: 11px; letter-spacing: 0.04em; color: var(--muted); font-weight: 600; }
.msum--p .msum__v { color: var(--macro-p); }
.msum--c .msum__v { color: var(--macro-c); }
.msum--f .msum__v { color: var(--macro-f); }

/* Goals estimate disclosure — compact visually, full-size keyboard/touch target. */
.goal-estimate { display: flex; align-items: center; gap: 4px; }
.goal-estimate__values { flex: 1; min-width: 0; }
.info-icon { flex: 0 0 auto; color: var(--muted); }
.info-icon svg { width: 18px; height: 18px; }
.estimate-info { display: flex; flex-direction: column; gap: 12px; }
.estimate-info__formula {
  display: flex; flex-direction: column; gap: 6px;
  padding: 12px; border-radius: 12px; background: var(--chip);
}
.estimate-info__sources { display: flex; flex-direction: column; gap: 8px; }
.estimate-info__sources a { text-decoration: underline; text-underline-offset: 3px; }

/* ---------- nudge line ---------- */
.nudge { display: flex; align-items: center; gap: 8px; color: var(--green); font-weight: 600; }
.nudge svg { width: 18px; height: 18px; }
.nudge.over { color: var(--macro-p); }
.nudge.no_target { color: var(--muted); }

/* ---------- quick tiles ---------- */
.tiles { display: flex; gap: 12px; }
/* icon + label centred within the tile (per Penpot) */
.tile { flex: 1; background: var(--chip); border-radius: 14px; padding: 14px 10px;
  display: flex; flex-direction: column; align-items: center; gap: 10px; }
.tile__ic { width: 40px; height: 40px; border-radius: 50%; background: var(--card);
  display: flex; align-items: center; justify-content: center; color: var(--green); }
.tile__ic svg { width: 20px; height: 20px; }
.tile.history .tile__ic { color: var(--amber); }
.tile.meals .tile__ic { color: var(--macro-p); }
.tile__label { font-weight: 700; font-size: var(--fs-sm); text-align: center; }

/* ---------- list: checkbox + item ---------- */
.checkbox {
  width: 26px; height: 26px; border-radius: 8px; flex: 0 0 auto;
  border: 2px solid var(--border); background: var(--card);
  display: flex; align-items: center; justify-content: center; color: transparent;
}
.checkbox.on { background: var(--green-solid); border-color: var(--green-solid); color: #fff; }
.checkbox svg { width: 16px; height: 16px; }
/* Shopping-list row: checkbox + name (+ qty) + a visible bin icon. The bin is
   the SAME ghost trash-2 IconButton used on the meal-log and receipt rows, so
   delete is uniform across every page (feedback) — no swipe gesture. */
.litem { display: flex; align-items: center; gap: 12px; padding: 12px 0; }
.litem__name { flex: 1; min-width: 0; font-weight: 600; text-align: left;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.litem__qty { color: var(--muted); font-size: var(--fs-sm); flex: 0 0 auto; }
.litem .iconbtn { flex: 0 0 auto; }
.litem.ticked .litem__name { color: var(--muted); text-decoration: line-through; }
.litem.ticked .litem__qty { color: var(--muted); }

/* ---------- receipt item row ---------- */
.ritem { display: flex; align-items: flex-start; gap: 12px; padding: 12px 0; }
.ritem__body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.ritem__name { font-weight: 700; }
.ritem__meta { display: flex; align-items: center; gap: 8px; }
.ritem__qty { color: var(--muted); font-size: var(--fs-sm); }
.ritem__price { font-weight: 700; white-space: nowrap; }

/* ---------- fields / inputs / segmented ---------- */
.field { display: flex; flex-direction: column; gap: 6px; flex: 1 1 0; min-width: 0; }
.field__label { font-weight: 600; font-size: var(--fs-sm); }
.field__box {
  display: flex; align-items: center; gap: 6px;
  border: 1px solid var(--border); border-radius: var(--r-field);
  background: var(--field); padding: 12px;
}
.field__box input { flex: 1; min-width: 0; border: none; background: none; font-weight: 600; }
.field__box input:focus { outline: none; }
.field__unit { color: var(--muted); font-size: var(--fs-sm); }

.input {
  display: flex; align-items: center; gap: 10px;
  border: 1px solid var(--border); border-radius: var(--r-field);
  background: var(--field); padding: 13px 14px;
}
.input.chip-bg { background: var(--chip); border-color: transparent; }
.input svg { width: 18px; height: 18px; color: var(--muted); flex: 0 0 auto; }
.input input { flex: 1; min-width: 0; border: none; background: none; }
.input input:focus { outline: none; }
.input input::placeholder { color: var(--muted); }

.seg {
  display: flex; background: var(--chip); border-radius: var(--r-pill); padding: 4px; gap: 4px;
}
.seg__opt {
  flex: 1; text-align: center; padding: 9px 8px; border-radius: var(--r-pill);
  font-weight: 600; font-size: var(--fs-sm); color: var(--muted); white-space: nowrap;
}
.seg__opt.on { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,0.12); }

/* ---------- toggle ---------- */
.toggle { width: 46px; height: 28px; border-radius: 999px; background: var(--track); position: relative;
  flex: 0 0 auto; transition: background 0.15s ease; }
.toggle::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px;
  border-radius: 50%; background: #fff; transition: left 0.15s ease; box-shadow: 0 1px 2px rgba(0,0,0,0.25); }
.toggle.on { background: var(--green-solid); }
.toggle.on::after { left: 21px; }

/* ---------- setting row / member row ---------- */
.srow { display: flex; align-items: center; gap: 12px; padding: 14px 0; }
.srow svg.lead { width: 20px; height: 20px; color: var(--ink); flex: 0 0 auto; }
.srow__label { flex: 1; font-weight: 600; text-align: left; }
.srow__trail { color: var(--muted); display: flex; align-items: center; gap: 8px; }
.srow__trail svg { width: 18px; height: 18px; }

.mrow { display: flex; align-items: center; gap: 12px; padding: 12px 0; }
.mrow__body { flex: 1; min-width: 0; }
/* The name is a link/button to the member's profile (keyboard-accessible; base
   button reset gives it no chrome). It reads as tappable on hover/focus. */
.mrow__name { font-weight: 700; text-align: left; color: var(--ink); padding: 0; max-width: 100%; }
button.mrow__name:hover, button.mrow__name:focus-visible { color: var(--green); text-decoration: underline; }
.mrow__role { color: var(--muted); font-size: var(--fs-sm); }

/* ---------- invite block ---------- */
.invite { display: flex; flex-direction: column; gap: 12px; }
.invite__field { display: flex; align-items: center; gap: 10px; background: var(--chip);
  border-radius: var(--r-field); padding: 13px 14px; font-weight: 600; }
.invite__field .grow { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.invite__help { color: var(--muted); font-size: var(--fs-sm); }

/* ---------- list selector (T9 header) ---------- */
.lsel { display: flex; align-items: center; gap: 10px; padding: 4px 12px 0; }
.lsel__trigger { display: flex; align-items: center; gap: 8px; min-width: 0; }
.lsel__name { min-width: 0; flex: 0 1 auto; width: auto; max-width: 58vw; padding: 0; color: var(--ink); font: inherit; font-size: var(--fs-title); font-weight: 700; line-height: 1.25; text-align: left; background: transparent; border: 0; border-radius: 0; }
.lsel__name:focus { outline: 2px solid var(--green); outline-offset: 3px; border-radius: 4px; }
.lsel__trigger > svg { width: 20px; height: 20px; color: var(--muted); flex: 0 0 auto; }
.lsel__sharing { width: 40px; height: 40px; display: inline-flex; align-items: center; justify-content: center; color: var(--muted); border-radius: 50%; }
.lsel__sharing:focus-visible, .lsel__sharing:hover { color: var(--green); background: var(--chip); }
.lsel__sharing svg { width: 20px; height: 20px; }

/* ---------- stepper / ingredient row ---------- */
.stepper { display: inline-flex; align-items: center; gap: 10px; }
.stepper button { width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--border);
  background: var(--card); display: flex; align-items: center; justify-content: center; color: var(--ink); }
.stepper button svg { width: 16px; height: 16px; }
.stepper__val { min-width: 54px; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }

.ing { display: flex; flex-direction: column; gap: 8px; padding: 12px 0; }
.ing__top { display: flex; align-items: center; gap: 10px; }
.ing__name { flex: 1; font-weight: 600; }
.ing__kcal { color: var(--muted); font-weight: 600; font-size: var(--fs-sm); }
.ing__macros { display: flex; gap: 8px; }
.mtag { font-size: 11px; font-weight: 700; }
.mtag.p { color: var(--macro-p); }
.mtag.c { color: var(--macro-c); }
.mtag.f { color: var(--macro-f); }

/* ---------- meal log row / photo thumb ---------- */
.pthumb { width: 44px; height: 44px; border-radius: 10px; background: var(--chip); color: var(--muted);
  display: flex; align-items: center; justify-content: center; flex: 0 0 auto; overflow: hidden; }
.pthumb.lg { width: 56px; height: 56px; }
.pthumb svg { width: 22px; height: 22px; }
.pthumb img { width: 100%; height: 100%; object-fit: cover; }
.mlrow { display: flex; align-items: center; gap: 12px; padding: 12px 0; }
.mlrow__body { flex: 1; min-width: 0; }
.mlrow__name { font-weight: 700; }
.mlrow__meta { color: var(--muted); font-size: var(--fs-sm); }

/* ---------- shop row (history) ---------- */
.shoprow { display: flex; align-items: center; gap: 10px; padding: 14px 0; }
.shoprow__body { flex: 1; min-width: 0; }
.shoprow__storeline { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.shoprow__store { font-weight: 700; }
.shoprow__meta { color: var(--muted); font-size: var(--fs-sm); }
.shoprow__price { font-weight: 700; }
.shoprow__chev { color: var(--muted); transition: transform 0.15s ease; }
.shoprow__chev.open { transform: rotate(180deg); }
.shoprow__preview { background: var(--chip); border-radius: 12px; padding: 8px 12px; margin: 0 0 6px;
  display: flex; flex-direction: column; }
.shoprow__pline { display: flex; align-items: flex-start; gap: 8px; padding: 8px 0; }

/* month header */
.monthhead { display: flex; justify-content: space-between; align-items: baseline; padding: 8px 4px 0; }
.monthhead__m { font-size: var(--fs-label); font-weight: 700; letter-spacing: 0.06em; color: var(--muted); }
.monthhead__t { font-weight: 700; color: var(--muted); }

/* day header (meal log) */
.dayhead { display: flex; justify-content: space-between; align-items: baseline; padding: 6px 4px 0; }
.dayhead__d { font-size: var(--fs-label); font-weight: 700; letter-spacing: 0.06em; color: var(--muted); }
.dayhead__k { color: var(--muted); font-weight: 600; font-size: var(--fs-sm); }

/* ---------- empty / setup prompt ---------- */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; padding: 28px 20px; }
.empty__ic { width: 56px; height: 56px; border-radius: 50%; background: var(--green-tint); color: var(--green);
  display: flex; align-items: center; justify-content: center; }
.empty__ic svg { width: 26px; height: 26px; }
.empty__title { font-weight: 700; font-size: var(--fs-h); }
.empty__body { color: var(--muted); }

/* ---------- slider (goals weekly pace) — custom, pointer-following ---------- */
.slider { display: flex; flex-direction: column; gap: 6px; }
.slider__top { display: flex; justify-content: space-between; align-items: center; }
.slider__val { color: var(--green); font-weight: 700; }
/* 44px-tall hit area so touch can grab it anywhere; the visible rail is centred.
   touch-action:none — we own the horizontal drag, so the browser won't hijack it
   as a scroll (this is what lets the thumb follow the finger smoothly). */
.slider__track {
  position: relative; height: 44px; width: 100%;
  display: flex; align-items: center;
  touch-action: none; user-select: none; -webkit-user-select: none; cursor: pointer;
}
.slider__rail { position: relative; width: 100%; height: 6px; border-radius: 999px; background: var(--track); }
/* bipolar fill: JS sets left+width so it grows out of the centre origin (0), not
   the left edge — empty at 0, left for a loss, right for a gain. */
.slider__fill { position: absolute; top: 0; bottom: 0; border-radius: 999px; background: var(--green-solid); }
.slider__thumb {
  position: absolute; top: 50%; left: 0; transform: translate(-50%, -50%);
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--card); border: 3px solid var(--green-solid);
  box-shadow: 0 1px 3px rgba(0,0,0,0.2); pointer-events: none;
}
.slider__track.dragging .slider__thumb { box-shadow: 0 0 0 6px rgba(46,125,50,0.15), 0 1px 3px rgba(0,0,0,0.2); }
.slider__ends { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; }

/* ---------- overlays: scrim, sheet, dialog, toast, banner ---------- */
/* A viewport primitive, shared by every sheet/dialog. On phones `fixed` follows
   the visible viewport instead of a long document. In the desktop preview the
   transformed .app-frame is its fixed containing block, so it remains bounded
   to the phone frame. */
.overlay-root { position: fixed; inset: 0; z-index: 50; overflow: hidden; }
.scrim { position: absolute; inset: 0; background: var(--scrim); animation: fade 0.15s ease; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes sheet-up { from { transform: translateY(100%); } to { transform: none; } }
@keyframes pop-in { from { transform: scale(0.94); opacity: 0; } to { transform: none; opacity: 1; } }

.sheet {
  position: absolute; left: 0; right: 0; bottom: 0;
  background: var(--card); border-top-left-radius: var(--r-sheet); border-top-right-radius: var(--r-sheet);
  box-shadow: var(--shadow-pop); max-height: 82%; display: flex; flex-direction: column;
  animation: sheet-up 0.22s ease; padding-bottom: env(safe-area-inset-bottom, 0);
}
.sheet__grab { width: 40px; height: 5px; border-radius: 999px; background: var(--border); margin: 10px auto 4px; }
.sheet__head { display: flex; align-items: center; gap: 12px; padding: 6px 16px 12px; }
.sheet__title { flex: 1; font-weight: 700; font-size: var(--fs-h); }
.sheet__sub { color: var(--muted); font-size: var(--fs-sm); font-weight: 400; }
.sheet__body { overflow-y: auto; padding: 0 16px 16px; display: flex; flex-direction: column; gap: 4px; overscroll-behavior-y: contain; }

/* O-CAL — accessible month-grid date picker (FB2-1) */
.cal-pick { display: flex; flex-direction: column; gap: 10px; padding-bottom: 4px; }
.cal-pick__head { display: flex; align-items: center; gap: 8px; }
.cal-pick__title { flex: 1; text-align: center; font-weight: 700; font-size: var(--fs-h); }
.cal-pick__nav {
  flex: 0 0 auto; width: 40px; height: 40px; border-radius: var(--r-pill);
  display: flex; align-items: center; justify-content: center; color: var(--ink);
}
.cal-pick__nav svg { width: 20px; height: 20px; }
.cal-pick__nav:hover { background: var(--chip); }
.cal-pick__dow { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.cal-pick__dow span {
  text-align: center; font-size: var(--fs-label); font-weight: 700;
  letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted);
}
.cal-pick__grid { display: flex; flex-direction: column; gap: 2px; }
.cal-pick__row { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.cal-pick__pad { min-height: 44px; }
.cal-pick__day {
  position: relative; min-height: 44px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 600; color: var(--ink);
}
.cal-pick__day:hover:not([disabled]) { background: var(--chip); }
.cal-pick__day.is-today { box-shadow: inset 0 0 0 1.5px var(--green); color: var(--green); }
.cal-pick__day.is-selected { background: var(--green-solid); color: var(--on-green); box-shadow: none; }
.cal-pick__day[disabled] { color: var(--muted); opacity: 0.4; cursor: default; }
.cal-pick__dot {
  position: absolute; bottom: 6px; left: 50%; transform: translateX(-50%);
  width: 5px; height: 5px; border-radius: 50%; background: var(--green);
}
.cal-pick__day.is-selected .cal-pick__dot { background: var(--on-green); }

.dialog-wrap { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 24px; }
.dialog {
  background: var(--card); border-radius: 18px; box-shadow: var(--shadow-pop);
  width: 100%; max-width: 320px; padding: 22px; display: flex; flex-direction: column; gap: 8px;
  animation: pop-in 0.16s ease; z-index: 1;
}
.dialog__title { font-weight: 700; font-size: var(--fs-h); }
.dialog__msg { color: var(--muted); }
.dialog__acts { display: flex; gap: 10px; margin-top: 12px; }
.dialog__acts .btn { flex: 1; }
.dialog__acts--stack { flex-direction: column; }
.dialog__acts--stack .btn--primary { order: -1; }

.duplicate-compare { display: flex; flex-direction: column; gap: 8px; }
.duplicate-compare__row { padding: 9px 10px; border-radius: 10px; background: var(--chip); }
.duplicate-compare__label { display: block; color: var(--ink); font-weight: 700; }

.toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px) + 16px); z-index: 60;
  background: var(--ink); color: var(--bg); border-radius: 14px; padding: 14px 16px;
  display: flex; align-items: center; gap: 12px; box-shadow: var(--shadow-pop);
  animation: sheet-up 0.2s ease;
}
.toast__msg { flex: 1; font-weight: 600; }
.toast__undo { color: var(--green); font-weight: 700; }
[data-theme="dark"] .toast { background: #34322a; color: var(--ink); }

.banner {
  display: flex; align-items: center; gap: 10px;
  background: var(--green-tint); color: var(--ink); border-radius: 12px; padding: 12px 14px; font-weight: 600;
}
.banner.warn { background: #FBEED3; color: #7a5a11; }
.banner.error { background: #F7E0DD; color: #8a2e23; }
.banner svg { width: 18px; height: 18px; flex: 0 0 auto; }

/* ---------- scan (dark) ---------- */
.scan-hero { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 18px; text-align: center; padding: 24px; }
.scan-hero__ic { width: 96px; height: 96px; border-radius: 50%; background: var(--green-solid); color: #fff;
  display: flex; align-items: center; justify-content: center; }
.scan-hero__ic svg { width: 40px; height: 40px; }
.scan-hero[role="button"] { cursor: pointer; }
.scan-hero__title { font-size: 24px; font-weight: 700; }
.scan-hero__sub { color: #b8b2a5; max-width: 260px; }
.scan-sheet { background: var(--bg); border-top-left-radius: var(--r-sheet); border-top-right-radius: var(--r-sheet);
  padding: 20px 16px calc(20px + env(safe-area-inset-bottom, 0)); display: flex; flex-direction: column; gap: 12px; }
.scan-close { position: absolute; top: 14px; left: 14px; color: #fff; z-index: 2; }
.scan-photo { width: 200px; height: 260px; border-radius: 16px; background: #ded7c9; color: #8a8577;
  display: flex; align-items: center; justify-content: center; overflow: hidden; }
.scan-photo svg { width: 64px; height: 64px; }
.scan-photo img { width: 100%; height: 100%; object-fit: cover; }
.progressbar { width: 220px; height: 6px; border-radius: 999px; background: #4a473c; overflow: hidden; }
.progressbar__fill { height: 100%; background: var(--green); border-radius: 999px; transition: width 0.4s ease; }
.capture-input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.scan-preview-note { padding: 6px 10px; border: 1px solid rgba(255,255,255,.22); border-radius: 999px;
  color: #d9d3c5; font-size: 12px; font-weight: 700; letter-spacing: .02em; }
.scan-hero__ic.error { background: #9d4033; }
.scan-crop-screen { flex: 1; min-height: 0; padding: 58px 16px 16px; display: flex; flex-direction: column;
  align-items: center; gap: 8px; overflow: auto; }
.scan-crop-title { font-size: 20px; font-weight: 700; text-align: center; }
.scan-crop { position: relative; width: min(100%, 390px); max-height: 58dvh; margin-top: 10px;
  background: #111; overflow: hidden; touch-action: none; }
.scan-crop > img { display: block; width: 100%; height: 100%; object-fit: contain; user-select: none; -webkit-user-drag: none; }
.scan-crop__frame { position: absolute; border: 2px solid #fff; box-shadow: 0 0 0 999px rgba(0,0,0,.48); }
.scan-crop__corner { position: absolute; width: 52px; height: 52px; touch-action: none; }
.scan-crop__corner::before { content: ""; position: absolute; width: 22px; height: 22px; border-color: var(--green);
  border-style: solid; }
.scan-crop__corner.nw { left: -26px; top: -26px; }
.scan-crop__corner.ne { right: -26px; top: -26px; }
.scan-crop__corner.sw { left: -26px; bottom: -26px; }
.scan-crop__corner.se { right: -26px; bottom: -26px; }
.scan-crop__corner.nw::before { right: 2px; bottom: 2px; border-width: 4px 0 0 4px; }
.scan-crop__corner.ne::before { left: 2px; bottom: 2px; border-width: 4px 4px 0 0; }
.scan-crop__corner.sw::before { right: 2px; top: 2px; border-width: 0 0 4px 4px; }
.scan-crop__corner.se::before { left: 2px; top: 2px; border-width: 0 4px 4px 0; }

/* Phase-3 receipt edit stays readable at Telegram phone widths. */
.receipt-head-fields { display: grid; grid-template-columns: minmax(0, 1fr) minmax(128px, .65fr); gap: 10px; }
.receipt-edit-grid { display: grid; grid-template-columns: minmax(0, 1fr) 112px; gap: 8px; }
.money-input { display: flex; align-items: center; gap: 4px; }
.money-input input { min-width: 0; }
.category-edit { align-self: flex-start; }
.receipt-open { display: block; margin: 4px 12px 10px auto; }
@media (max-width: 360px) {
  .receipt-head-fields { grid-template-columns: 1fr; }
  .receipt-edit-grid { grid-template-columns: 1fr 100px; }
}

/* ---------- board index (design-QA) ---------- */
.boards { display: flex; flex-direction: column; gap: 18px; }
.boards__group { display: flex; flex-direction: column; gap: 8px; }
.boards__grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.boards__cell { border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; background: var(--card);
  display: flex; flex-direction: column; gap: 2px; text-align: left; }
.boards__code { font-size: 11px; color: var(--muted); font-weight: 700; letter-spacing: 0.04em; }
.boards__title { font-weight: 600; font-size: var(--fs-sm); }

/* O-TYPEMEAL — photo-or-describe sheet */
.mealtext {
  border: 1px solid var(--border); border-radius: var(--r-field);
  background: var(--field); padding: 12px; resize: vertical; min-height: 96px;
  width: 100%; box-sizing: border-box;
}
.mealtext:focus { outline: none; border-color: var(--green); }
.mealtext::placeholder { color: var(--muted); }
.sheet-or {
  display: flex; align-items: center; gap: 10px;
  color: var(--muted); font-size: var(--fs-sm);
}
.sheet-or::before, .sheet-or::after {
  content: ""; flex: 1; height: 1px; background: var(--border);
}
.meal-working {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  padding: 24px 8px; text-align: center;
}
.meal-working__ic {
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--green-solid); color: #fff;
  display: flex; align-items: center; justify-content: center;
}
.meal-working__bars { width: 100%; display: flex; flex-direction: column; gap: 8px; }
.meal-working__bars .skel { height: 10px; }
.meal-working__bars .skel:nth-child(2) { width: 80%; }
.meal-working__bars .skel:nth-child(3) { width: 55%; }

/* skeleton (S-LOAD) */
.skel { background: var(--chip); border-radius: 8px; position: relative; overflow: hidden; }
.skel::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.35), transparent); animation: shimmer 1.3s infinite; }
[data-theme="dark"] .skel::after { background: linear-gradient(90deg, transparent, rgba(255,255,255,0.06), transparent); }
@keyframes shimmer { 100% { transform: translateX(100%); } }
@media (prefers-reduced-motion: reduce) { .skel::after { animation: none; } }

/* theme + qa floating controls */
.fabrow { position: absolute; top: 10px; right: 10px; z-index: 40; display: flex; gap: 6px; }
.fabrow .iconbtn { width: 34px; height: 34px; background: color-mix(in srgb, var(--card) 82%, transparent); }
.fabrow .iconbtn svg { width: 17px; height: 17px; }
