/* 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 {
  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; }

.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); }

.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; }

/* ---------- 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; }
.donut__num { font-size: 17px; font-weight: 700; line-height: 1; }
.donut__sub { font-size: 10px; color: var(--muted); margin-top: 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); }

/* ---------- 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; }
.tile { flex: 1; background: var(--chip); border-radius: 14px; padding: 14px 10px;
  display: flex; flex-direction: column; 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); }

/* ---------- 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; }
.litem { display: flex; align-items: center; gap: 12px; padding: 12px 0; }
.litem__name { flex: 1; font-weight: 600; }
.litem__qty { color: var(--muted); font-size: var(--fs-sm); }
.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; }
.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; }
.mrow__name { font-weight: 700; }
.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 { font-size: var(--fs-title); font-weight: 700; }
.lsel__trigger svg { width: 20px; height: 20px; color: var(--muted); }

/* ---------- 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; }
.pthumb.lg { width: 56px; height: 56px; }
.pthumb svg { width: 22px; height: 22px; }
.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__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) ---------- */
.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; }
.slider input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; height: 6px;
  border-radius: 999px; background: var(--track); }
.slider input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 22px; height: 22px;
  border-radius: 50%; background: var(--card); border: 3px solid var(--green-solid); cursor: pointer; }
.slider input[type="range"]::-moz-range-thumb { width: 22px; height: 22px; border-radius: 50%;
  background: var(--card); border: 3px solid var(--green-solid); cursor: pointer; }
.slider__ends { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; }

/* ---------- overlays: scrim, sheet, dialog, toast, banner ---------- */
.overlay-root { position: absolute; inset: 0; z-index: 50; }
.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; }

.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; }

.toast {
  position: absolute; left: 16px; right: 16px; bottom: 80px; 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__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; }
.scan-photo svg { width: 64px; height: 64px; }
.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; }

/* ---------- 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); }

/* 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; }
