:root {
  --bg: #f2f3f7;
  --card: #ffffff;
  --card2: #f7f8fb;
  --text: #111318;
  --text2: #5b6170;
  --muted: #6b7180;
  --line: #e3e5ec;
  --accent: #2f6fed;
  --accent-ink: #ffffff;
  --accent-soft: #e4ecfc;
  --accent-track: #d6e2fb;
  --good: #2e9e5b;
  --good-soft: #dff3e6;
  --warn: #8f6400;
  --warn-soft: #fbefcf;
  --bad: #d64545;
  --bad-soft: #fbe0e0;
  --radius: 16px;
  --tab-h: 58px;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1014;
    --card: #181b22;
    --card2: #1f232c;
    --text: #f2f3f7;
    --text2: #aab0bf;
    --muted: #7a8091;
    --line: #2a2f3a;
    --accent: #6f9dff;
    --accent-ink: #0b1220;
    --accent-soft: #1b2740;
    --accent-track: #233357;
    --good: #4cc07a;
    --good-soft: #163324;
    --warn: #e2ad3f;
    --warn-soft: #3a2d10;
    --bad: #ef6b6b;
    --bad-soft: #3d1c1c;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; height: 100%; background: var(--bg); color: var(--text); }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px; line-height: 1.35;
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  touch-action: manipulation;
  user-select: none; -webkit-user-select: none;
}
input, textarea { user-select: text; -webkit-user-select: text; }
body.sheet-open { overflow: hidden; }
button { font: inherit; color: inherit; cursor: pointer; }
input, textarea, select { font: inherit; color: inherit; }
h1, h2, h3, p { margin: 0; }
.ic { width: 22px; height: 22px; display: inline-block; vertical-align: middle; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.text2 { color: var(--text2); }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }

/* ---- app frame ---- */
#app { height: 100dvh; display: flex; flex-direction: column; max-width: 600px; margin: 0 auto; }
#view { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.screen { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.topbar {
  padding: calc(var(--sat) + 10px) 16px 8px;
  display: flex; align-items: center; gap: 10px;
  background: var(--bg);
}
.topbar h1 { font-size: 28px; font-weight: 800; letter-spacing: -0.3px; flex: 1; }
.topbar .sub { font-size: 14px; color: var(--text2); font-weight: 500; }
.content {
  flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch;
  /* the strip above the tab bar is kept empty at scroll end: toasts and visitors live there */
  padding: 4px 16px calc(var(--tab-h) + var(--sab) + 84px);
}

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; max-width: 600px; margin: 0 auto;
  height: calc(var(--tab-h) + var(--sab));
  padding-bottom: var(--sab);
  background: var(--card); border-top: 1px solid var(--line);
  display: flex;
}
.tabbar button {
  flex: 1; border: 0; background: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: 11px; font-weight: 600; color: var(--muted); padding: 6px 0 4px;
}
.tabbar button .ic { width: 24px; height: 24px; }
.tabbar button.active { color: var(--accent); }

/* ---- cards and rows ---- */
.card {
  background: var(--card); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 12px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.card h2 { font-size: 15px; font-weight: 700; color: var(--text2); text-transform: none; margin-bottom: 8px; display: flex; align-items: center; justify-content: space-between; }
.card h2 .link { font-weight: 600; }
.card.tight { padding: 6px 16px; }
.section-title { font-size: 13px; font-weight: 700; color: var(--muted); letter-spacing: 0.3px; text-transform: uppercase; margin: 18px 4px 8px; }
.row { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
.row .grow { flex: 1; min-width: 0; }
.row .title { font-weight: 600; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .sub { font-size: 13px; color: var(--text2); margin-top: 1px; }
.row .val { font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.row .val .u { color: var(--muted); font-weight: 500; font-size: 13px; margin-left: 2px; }
.row.tappable { cursor: pointer; }
.row.tappable:active { background: var(--card2); margin: 0 -16px; padding-left: 16px; padding-right: 16px; }
.link { color: var(--accent); background: none; border: 0; padding: 0 10px; font-weight: 600; font-size: 15px; min-height: 44px; display: inline-flex; align-items: center; }
.link.danger { color: var(--bad); }
.daypick { background: none; border: 0; padding: 0; text-align: left; flex: 1; min-width: 0; }
.daypick h1 { display: flex; align-items: center; gap: 2px; }
.daypick h1 .ic { width: 22px; height: 22px; color: var(--muted); margin-top: 4px; }
.daypick:active h1 { opacity: .7; }

/* ---- buttons ---- */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
  height: 50px; border-radius: 14px; border: 0; background: var(--accent); color: var(--accent-ink);
  font-size: 17px; font-weight: 700; margin-top: 10px;
}
.btn:active { filter: brightness(0.92); }
.btn:disabled { opacity: 0.5; }
.btn.secondary { background: var(--accent-soft); color: var(--accent); }
.btn.danger { background: var(--bad-soft); color: var(--bad); }
.btn.ghost { background: transparent; color: var(--accent); height: 44px; }
.btn.sm { height: 40px; font-size: 15px; width: auto; padding: 0 14px; margin: 0; border-radius: 12px; }
.btn-row { display: flex; gap: 10px; }
.btn-row .btn { flex: 1; }
.iconbtn {
  width: 40px; height: 40px; border-radius: 12px; border: 0; background: var(--card); color: var(--text2);
  display: inline-flex; align-items: center; justify-content: center; box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.iconbtn:active { background: var(--card2); }
.iconbtn.accent { color: var(--accent); }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; margin: 0 -16px; padding-left: 16px; padding-right: 16px; scrollbar-width: none; -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; }
.chips.scroll .chip { flex: 0 0 auto; }
.chips.scroll::-webkit-scrollbar { display: none; }
.chip {
  border: 0; background: var(--card2); color: var(--text2); border-radius: 999px; padding: 8px 14px; font-size: 14px; font-weight: 600; white-space: nowrap;
  border: 1px solid var(--line);
}
.chip.active { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.chip.on { background: var(--accent); color: var(--accent-ink); border-color: transparent; }

/* ---- inputs ---- */
.field { margin: 10px 0; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--text2); margin: 0 2px 6px; }
.field .hint { font-size: 12px; color: var(--muted); margin: 6px 2px 0; }
.input, textarea.input, select.input {
  width: 100%; height: 46px; border-radius: 12px; border: 1px solid var(--line); background: var(--card2); padding: 0 12px;
  font-size: 17px; outline: none; -webkit-appearance: none; appearance: none;
}
.input:focus { border-color: var(--accent); }
textarea.input { height: auto; min-height: 150px; padding: 10px 12px; line-height: 1.4; resize: vertical; }
.input.sm { height: 40px; font-size: 15px; }
.input-row { display: flex; gap: 8px; align-items: center; }
.input-row .input { flex: 1; min-width: 0; }
.input-row .unit { color: var(--muted); font-size: 14px; white-space: nowrap; min-width: 36px; }
/* ---- food editor sections ---- */
.ed-sec { padding: 12px 14px 14px; margin: 10px 0; }
.ed-sec .field { margin: 10px 0 0; }
.ed-sec .input-row .field { margin-top: 10px; }
.ed-title { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; font-size: 12px; font-weight: 700; color: var(--muted); letter-spacing: .4px; text-transform: uppercase; }
.ed-title .ed-src { font-size: 12px; font-weight: 600; color: var(--text2); text-transform: none; letter-spacing: 0; text-align: right; min-width: 0; }
.ed-check { font-size: 13px; color: var(--text2); margin: 8px 0 0; line-height: 1.4; }
.ed-warn { margin: 8px 0 0; padding-left: 18px; font-size: 13px; color: var(--text2); line-height: 1.45; }
.ed-warn li + li { margin-top: 4px; }
.ed-sub { display: flex; justify-content: space-between; align-items: center; font-size: 13px; font-weight: 700; color: var(--text2); margin: 14px 0 6px; }
.ing-text { font-size: 15px; line-height: 1.55; color: var(--text); background: var(--card2); border-radius: 12px; padding: 10px 12px; overflow-wrap: anywhere; }
.ed-sec [data-nfields], .ed-sec .goal-row:first-of-type { margin-top: 6px; }
/* ---- barcode scanner ---- */
.scan-box { position: relative; border-radius: 16px; overflow: hidden; background: #111; aspect-ratio: 4 / 3; max-height: 46vh; }
.scan-video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scan-box.off .scan-video, .scan-box.off .scan-frame { display: none; }
.scan-box.off { background: var(--card2); aspect-ratio: auto; min-height: 72px; display: flex; align-items: center; justify-content: center; padding: 14px; }
.scan-box.off .scan-hint { position: static; background: none; color: var(--text2); transform: none; white-space: normal; text-align: center; line-height: 1.4; }
.scan-frame { position: absolute; inset: 18% 12%; pointer-events: none; }
.scan-frame i { position: absolute; width: 22px; height: 22px; border: 3px solid #fff; border-radius: 4px; }
.scan-frame i:nth-child(1) { top: 0; left: 0; border-right: 0; border-bottom: 0; }
.scan-frame i:nth-child(2) { top: 0; right: 0; border-left: 0; border-bottom: 0; }
.scan-frame i:nth-child(3) { bottom: 0; left: 0; border-right: 0; border-top: 0; }
.scan-frame i:nth-child(4) { bottom: 0; right: 0; border-left: 0; border-top: 0; }
.scan-hint { position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); background: rgba(0,0,0,.55); color: #fff; font-size: 13px; font-weight: 600; padding: 5px 12px; border-radius: 999px; white-space: nowrap; }
.search-row { display: flex; gap: 8px; align-items: stretch; margin: 8px 0 12px; }
.search-row .search { flex: 1; min-width: 0; margin: 0; }
.search-row .btn.add-food { flex: 0 0 auto; width: auto; height: 44px; margin: 0; padding: 0 16px; border-radius: 14px; white-space: nowrap; font-size: 15px; }
.search-row .add-food .ic { width: 18px; height: 18px; }
.search { position: relative; margin: 8px 0 12px; }
.search .ic { position: absolute; left: 12px; top: 12px; width: 20px; height: 20px; color: var(--muted); }
.search .input { padding-left: 40px; height: 44px; border-radius: 14px; background: var(--card); }
.switch { position: relative; width: 50px; height: 30px; border-radius: 15px; background: var(--line); border: 0; flex: none; transition: background .2s; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 12px; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform .2s; }
.switch.on { background: var(--good); }
.switch.on::after { transform: translateX(20px); }

/* ---- food tiles ---- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.tile {
  background: var(--card); border-radius: 16px; padding: 0; border: 0; text-align: left; display: flex; flex-direction: column;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04); overflow: hidden; position: relative;
}
.tile:active { transform: scale(0.97); }
.tile .art { width: 100%; aspect-ratio: 4 / 3; border-radius: 0; }
.tile .cap { padding: 9px 12px 12px; display: flex; flex-direction: column; flex: 1; }
.tile .cap .kcal { margin-top: auto; padding-top: 3px; }
.tile .name { font-size: 15px; font-weight: 700; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 37px; letter-spacing: -0.1px; }
.tile .kcal { font-size: 12.5px; color: var(--text2); margin-top: 3px; font-variant-numeric: tabular-nums; font-weight: 500; }
.tile .fav { position: absolute; top: 6px; right: 6px; width: 30px; height: 30px; display: flex; align-items: center; justify-content: center; border-radius: 50%; background: rgba(255,255,255,.55); color: #fff; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.tile .fav .ic { width: 16px; height: 16px; display: block; fill: rgba(255,255,255,.85); stroke: rgba(0,0,0,.18); stroke-width: 1.4; stroke-linejoin: round; }
.tile .fav.on { background: rgba(255,255,255,.92); color: #ff4d7a; }
.tile .fav.on .ic { fill: currentColor; filter: none; }
.tile .fav:active { transform: scale(0.88); }
.art {
  display: flex; align-items: center; justify-content: center; border-radius: 14px; flex: none; overflow: hidden;
  background: hsl(var(--hue) 70% 90%);
}
@media (prefers-color-scheme: dark) { .art { background: hsl(var(--hue) 35% 24%); } }
.art span { font-size: 44px; line-height: 1; }
.art.sm { width: 44px; height: 44px; } .art.sm span { font-size: 24px; }
.art.md { width: 56px; height: 56px; } .art.md span { font-size: 30px; }
.art.lg { width: 84px; height: 84px; border-radius: 20px; } .art.lg span { font-size: 46px; }
.art.tile { width: 100%; aspect-ratio: 4 / 3; border-radius: 0; } .art.tile span { font-size: 54px; }
.art img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* ---- summary / meters ---- */
.hero { display: flex; align-items: center; gap: 16px; }
.ring { position: relative; width: 118px; height: 118px; flex: none; }
.ring svg { width: 100%; height: 100%; display: block; }
.ring .track { fill: none; stroke: var(--accent-track); stroke-width: 11; }
.ring .fill { fill: none; stroke: var(--accent); stroke: url(#plate-ring-g); stroke-width: 11; stroke-linecap: round; transition: stroke-dashoffset .5s ease; }
.ring .fill[stroke-dashoffset="0.00"] { stroke-linecap: butt; }
.ring #plate-ring-g stop:first-child { stop-color: color-mix(in srgb, var(--accent) 55%, var(--card)); }
.ring #plate-ring-g stop:last-child { stop-color: var(--accent); }
.hero.warn .ring .track { stroke: var(--warn-soft); }
.hero.warn .ring #plate-ring-g stop:first-child { stop-color: #FFCB94; }
.hero.warn .ring #plate-ring-g stop:last-child { stop-color: #EE8434; }   /* a warm orange, never brown */
.hero.bad .ring .track { stroke: var(--bad-soft); }
.hero.bad .ring #plate-ring-g stop:first-child { stop-color: color-mix(in srgb, var(--bad) 55%, var(--card)); }
.hero.bad .ring #plate-ring-g stop:last-child { stop-color: var(--bad); }
.hero.good .ring .track { stroke: var(--good-soft); }
.hero.good .ring #plate-ring-g stop:first-child { stop-color: color-mix(in srgb, var(--good) 55%, var(--card)); }
.hero.good .ring #plate-ring-g stop:last-child { stop-color: var(--good); }
.ring-in { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1; }
.ring-in b { font-size: 27px; font-weight: 800; letter-spacing: -0.8px; color: var(--text); }
.ring-in span { font-size: 11px; font-weight: 700; color: var(--muted); margin-top: 3px; letter-spacing: .2px; }
.hero-side { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.hero-goal { font-size: 15px; color: var(--text2); font-weight: 600; }
.hero-goal b { color: var(--text); font-weight: 800; font-size: 17px; }
.hero-bonus { font-size: 12px; color: var(--muted); font-weight: 600; }
.hero-chip { align-self: flex-start; font-size: 13px; font-weight: 800; padding: 5px 11px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); }
.hero-chip.good { background: var(--good-soft); color: var(--good); }
.hero-chip.warn { background: var(--warn-soft); color: var(--warn); }
.hero-chip.bad { background: var(--bad-soft); color: var(--bad); }
.meter { height: 7px; border-radius: 4px; background: var(--accent-track); overflow: hidden; margin-top: 10px; }
.meter i { display: block; height: 100%; border-radius: 4px; background: var(--accent); transition: width .35s ease; }
.meter.warn { background: var(--warn-soft); } .meter.warn i { background: var(--warn); }
.meter.bad { background: var(--bad-soft); } .meter.bad i { background: var(--bad); }
.meter.good { background: var(--good-soft); } .meter.good i { background: var(--good); }
.watch { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 14px; }
.watch .w { min-width: 0; background: var(--card2); border-radius: 16px; padding: 10px 12px 11px; position: relative; }
.watch .w[data-src] { cursor: pointer; transition: transform .12s ease; }
.watch .w[data-src]:active { transform: scale(0.97); }
.w-add { position: absolute; top: 8px; right: 8px; height: 30px; padding: 0 11px; border-radius: 999px; display: inline-flex; align-items: center; font-size: 13px; font-weight: 800; background: var(--card); color: var(--accent); box-shadow: 0 1px 3px rgba(0,0,0,.08); cursor: pointer; }
.w-add:active { transform: scale(0.92); }
.card.summary { display: block; width: 100%; text-align: left; cursor: pointer; }
.day-open { display: flex; align-items: center; justify-content: center; gap: 4px; width: 100%; margin-top: 10px; padding: 8px 0; border: 0; background: none; text-align: center; font-weight: 600; color: var(--text2); }
.day-open:disabled { opacity: 1; }
.day-open-chev .ic { width: 16px; height: 16px; transform: rotate(90deg); transition: transform .2s ease; display: block; }
.day-open-chev.up .ic { transform: rotate(-90deg); }
.day-panel { margin-top: -4px; }
.day-panel .meal-head:first-child { padding-top: 8px; }
.day-body { margin: 10px 2px 4px; }
.day-actions { padding: 8px 0 10px; }
.day-actions .btn { flex: 1; }
.card.welcome { position: relative; }
.card.welcome .title { padding-right: 36px; }
/* estimates, Claude's second look, the weekly note */
.goal-row .n small.est { display: block; color: var(--text2); font-size: 11px; font-weight: 600; }
.note.est-box, .note.review-box { background: var(--card2); border: 1px solid var(--line); }
.note.est-box b, .note.review-box b { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; color: var(--text); }
.note.est-box b .ic, .note.review-box b .ic { width: 16px; height: 16px; color: var(--accent); }
.rv-item { padding: 6px 0; border-top: 1px solid var(--line); }
.rv-line { font-weight: 700; font-size: 14px; }
.rv-why { font-size: 13px; color: var(--text2); }
.card.weekly { position: relative; }
.weekly-t { font-weight: 800; font-size: 15px; padding-right: 36px; }
.weekly-text { margin: 6px 0 4px; font-size: 15px; line-height: 1.5; color: var(--text); }
/* the care-team summary */
.report .rp-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; border-bottom: 2px solid var(--text); padding-bottom: 8px; }
.report .rp-t { font-size: 20px; font-weight: 800; }
.report .rp-span { font-size: 14px; color: var(--text2); font-weight: 600; }
.report .rp-line { font-size: 14px; margin: 10px 0; }
.rp-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.rp-table th { text-align: left; font-size: 11.5px; color: var(--muted); font-weight: 700; padding: 6px 4px; border-bottom: 1px solid var(--line); }
.rp-table td { padding: 7px 4px; border-bottom: 1px solid var(--line); }
.rp-table td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.rp-table tr.over td:first-child { font-weight: 800; }
.rp-sub { font-size: 13px; font-weight: 800; margin: 14px 0 4px; }
.rp-list { margin: 0; padding-left: 18px; font-size: 13.5px; }
.rp-note { font-size: 14px; line-height: 1.5; margin: 0; }
.rp-foot { font-size: 11.5px; color: var(--muted); margin: 14px 0 12px; }
@media print {
  html:has(body.printing-report), body.printing-report { height: auto !important; overflow: visible !important; background: #fff !important; }
  body.printing-report { --text: #111; --text2: #444; --muted: #666; --line: #ccc; --card: #fff; --card2: #fff; color: #111; }
  body.printing-report .sheet.report-sheet { background: #fff !important; }
  body.printing-report #app, body.printing-report .tabbar, body.printing-report #toasts, body.printing-report .sheet-backdrop, body.printing-report .sheet:not(.report-sheet), body.printing-report #pk-layer { display: none !important; }
  body.printing-report .sheet.report-sheet { position: static !important; transform: none !important; max-height: none !important; box-shadow: none !important; width: auto !important; border-radius: 0 !important; }
  body.printing-report .report-sheet .sheet-grabber, body.printing-report .report-sheet .sheet-head, body.printing-report .no-print { display: none !important; }
  body.printing-report .report-sheet .sheet-body { overflow: visible !important; padding: 0 !important; }
  body.printing-report .report { color: #000; }
}
/* additive note */
.note.add-box { background: var(--card2); border: 1px solid var(--line); }
.note.add-box b { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; color: var(--text); }
.note.add-box b .ic { width: 16px; height: 16px; color: var(--text2); }
/* limits, day by day */
.lim-row { padding: 8px 0 10px; border-top: 1px solid var(--line); }
.lim-row:first-of-type { border-top: 0; }
.lim-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; font-weight: 700; font-size: 14px; }
.lim-count { font-size: 12.5px; font-weight: 700; color: var(--text2); }
.lim-count.good { color: var(--good); } .lim-count.bad { color: var(--bad); }
.lim-dots { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.lim-dots.big { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.lim-dot { border: 0; background: none; padding: 0; display: flex; flex-direction: column; align-items: center; gap: 3px; color: var(--muted); }
.lim-dot i { display: block; width: 12px; height: 12px; border-radius: 50%; background: var(--line); }
.lim-dots.big .lim-dot i { width: 22px; height: 22px; }
.lim-dot span { font-size: 11px; font-weight: 700; }
.lim-dot.within i { background: var(--good); }
.lim-dot.close i { background: var(--warn); }
.lim-dot.over i { background: var(--bad); }
.lim-dot.none i { background: transparent; box-shadow: inset 0 0 0 2px var(--line); }
.lim-dot.future i { background: transparent; box-shadow: inset 0 0 0 2px var(--line); opacity: .45; }
.lim-dot.today i { background: transparent !important; box-shadow: inset 0 0 0 3px currentColor; }
.lim-dot.today.within { color: var(--good); } .lim-dot.today.close { color: var(--warn); } .lim-dot.today.over { color: var(--bad); }
.lim-dot.today span { color: var(--text); }
/* saved meals */
.meal-parts { display: flex; flex-direction: column; gap: 6px; margin: 6px 0 4px; }
.meal-part { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 14px; background: var(--card2); cursor: pointer; transition: opacity .15s ease; }
.meal-part.off { opacity: .45; }
.meal-part.gone { opacity: .45; cursor: default; }
.meal-part .grow { display: flex; flex-direction: column; min-width: 0; }
.meal-part-nm { font-weight: 700; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meal-part-amt { font-size: 12.5px; color: var(--text2); }
.meal-check { width: 24px; height: 24px; border-radius: 50%; background: var(--accent); color: #fff; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.meal-check .ic { width: 15px; height: 15px; stroke-width: 3; }
.meal-part.off .meal-check { background: transparent; box-shadow: inset 0 0 0 2px var(--line); color: transparent; }
.mini-step { display: inline-flex; gap: 6px; flex: none; }
.mini-step button { width: 34px; height: 34px; border-radius: 50%; border: 0; background: var(--card); color: var(--accent); display: inline-flex; align-items: center; justify-content: center; box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.mini-step button .ic { width: 16px; height: 16px; }
.mini-step [data-remove] { color: var(--muted); }
.pick .pick-in { width: 24px; height: 24px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; box-shadow: inset 0 0 0 2px var(--line); color: transparent; flex: none; }
.pick.in .pick-in { background: var(--accent); color: #fff; box-shadow: none; }
.pick .pick-in .ic { width: 14px; height: 14px; stroke-width: 3; }
/* yesterday's meal again */
.card.again { position: relative; padding: 14px 16px 12px; }
.again-t { font-weight: 800; font-size: 16px; padding-right: 36px; }
.again-x { position: absolute; top: 8px; right: 8px; width: 34px; height: 34px; border-radius: 50%; border: 0; background: var(--card2); color: var(--muted); display: inline-flex; align-items: center; justify-content: center; }
.again-x .ic { width: 16px; height: 16px; }
.again-items { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 10px; }
.again-item { font-size: 13px; font-weight: 600; background: var(--card2); border-radius: 999px; padding: 5px 10px; }
.again-item i { font-style: normal; color: var(--muted); }
.again-row { display: flex; align-items: center; gap: 12px; }
.again-row .btn { width: auto; }
/* the day's entries by meal */
.meal-head { display: flex; align-items: center; gap: 8px; padding: 14px 0 4px; font-weight: 800; font-size: 14px; }
.meal-head > span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meal-head > .muted { white-space: nowrap; font-weight: 600; }
.meal-head .meal-acts { margin-left: auto; display: inline-flex; gap: 2px; flex: none; }
.meal-head .link.small { font-weight: 700; padding: 0 6px; min-height: 36px; white-space: nowrap; }
.copy-what { display: flex; flex-direction: column; gap: 8px; }
.copy-item { display: flex; align-items: center; gap: 10px; }
.copy-item .grow { display: flex; flex-direction: column; min-width: 0; }
.copy-item b { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.copy-item span span { font-size: 12.5px; color: var(--text2); }
/* swipe rows */
.swipe { position: relative; overflow: hidden; }
.swipe-front { position: relative; z-index: 1; background: var(--card); touch-action: pan-y; transition: transform .22s cubic-bezier(.2,.8,.2,1); }
.swipe-acts { position: absolute; top: 0; right: 0; bottom: 0; display: flex; }
.swipe-act { width: 78px; border: 0; color: #fff; font-size: 12px; font-weight: 700; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; }
.swipe-act .ic { width: 20px; height: 20px; }
.swipe-act.amt { background: var(--accent); }
.swipe-act.del { background: var(--bad); }
/* sources sheet */
.src-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 4px 0 12px; }
.src-total { display: flex; flex-direction: column; }
.src-total b { font-size: 30px; font-weight: 800; letter-spacing: -0.6px; line-height: 1.05; }
.src-total b .u { font-size: 15px; color: var(--muted); font-weight: 600; margin-left: 3px; }
.src-total span { font-size: 13px; color: var(--text2); font-weight: 600; margin-top: 2px; }
.src-head.bad .src-total b { color: var(--bad); } .src-head.warn .src-total b { color: var(--warn); } .src-head.good .src-total b { color: var(--good); }
.src-list { display: flex; flex-direction: column; }
.src-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border: 0; border-bottom: 1px solid var(--line); background: none; text-align: left; width: 100%; color: inherit; }
.src-row:last-child { border-bottom: 0; }
.src-row:disabled { opacity: 1; }
.src-name { display: flex; justify-content: space-between; gap: 10px; font-size: 15px; font-weight: 600; }
.src-name span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.src-name b { white-space: nowrap; font-variant-numeric: tabular-nums; }
.src-name b .u { color: var(--muted); font-weight: 500; font-size: 12px; margin-left: 2px; }
.src-bar { height: 6px; border-radius: 4px; background: var(--accent-track); margin-top: 6px; overflow: hidden; }
.src-bar i { display: block; height: 100%; border-radius: 4px; background: var(--accent); }
.src-sub { font-size: 12px; color: var(--muted); margin-top: 4px; font-weight: 500; }
/* tile notes */
.tile-flags { position: absolute; left: 8px; right: 44px; top: 8px; display: flex; flex-direction: column; align-items: flex-start; gap: 4px; pointer-events: none; }
.tile-flag { font-size: 11px; font-weight: 800; line-height: 1.2; padding: 4px 8px; border-radius: 10px; white-space: normal; max-width: 100%; box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.tile-flag.over { background: var(--bad); color: #fff; }
.tile-flag.add { background: rgba(255,255,255,.92); color: var(--text2); }
/* amount sheet */
.add-note { color: var(--text2); font-weight: 600; }
.swap { margin: 12px 0 2px; padding: 12px; border-radius: 16px; background: var(--bad-soft); }
.swap-msg { display: flex; align-items: center; gap: 8px; color: var(--bad); font-weight: 700; font-size: 14px; }
.swap-msg .ic { width: 18px; height: 18px; flex: none; }
.swap-lab { font-size: 12px; font-weight: 700; color: var(--text2); margin: 10px 0 6px; }
.swap-alts { display: flex; flex-direction: column; gap: 6px; }
.swap-alt { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; border-radius: 12px; background: var(--card); text-align: left; color: inherit; }
.swap-alt .grow { display: flex; flex-direction: column; min-width: 0; }
.swap-nm { font-weight: 700; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.swap-v { font-size: 12px; color: var(--text2); }
.swap-v .u { margin-left: 2px; color: var(--muted); }
.swap-alt .ic { width: 16px; height: 16px; color: var(--muted); }
.watch .w.good { background: var(--good-soft); }
.watch .w.warn { background: var(--warn-soft); }
.watch .w.bad { background: var(--bad-soft); }
.watch .w .l { display: flex; flex-direction: column; gap: 2px; font-size: 13px; color: var(--text2); font-weight: 600; }
.watch .w .l b { color: var(--text); font-variant-numeric: tabular-nums; font-weight: 800; font-size: 19px; letter-spacing: -0.3px; white-space: nowrap; line-height: 1.1; }
.watch .w .l b .u { color: var(--muted); font-weight: 600; font-size: 12px; margin-left: 2px; }
.watch .w .meter { margin-top: 8px; height: 6px; background: rgba(0,0,0,.06); }
.watch .w .r { font-size: 12px; color: var(--muted); margin-top: 6px; font-weight: 600; }
.watch .w .r.bad { color: var(--bad); font-weight: 700; }
.watch .w .r.warn { color: var(--warn); font-weight: 700; }
.watch .w .r.good { color: var(--good); font-weight: 700; }
@media (prefers-color-scheme: dark) { .watch .w .meter { background: rgba(255,255,255,.1); } }

/* nutrient panel rows */
.nrow { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 10px 0; border-bottom: 1px solid var(--line); align-items: center; }
.nrow:last-child { border-bottom: 0; }
.nrow .n { font-size: 15px; font-weight: 500; }
.nrow .v { font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.nrow .v .u { color: var(--muted); font-weight: 500; font-size: 13px; margin-left: 3px; }
.nrow .meter { grid-column: 1 / -1; margin-top: 4px; height: 5px; }
.nrow .g { grid-column: 1 / -1; font-size: 12px; color: var(--muted); font-weight: 600; margin-top: 2px; }
.nrow .g.good { color: var(--good); }
.nrow .g.bad { color: var(--bad); font-weight: 600; }
.nrow .g.warn { color: var(--warn); font-weight: 600; }
.nrow.dim .n, .nrow.dim .v { color: var(--muted); font-weight: 500; }
.group-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 0 0; min-height: 44px; font-size: 13px; font-weight: 700; color: var(--muted); letter-spacing: .3px; text-transform: uppercase; }
.group-head[data-toggle] { cursor: pointer; }
.group-head[data-toggle]:active { opacity: .7; }

/* ---- segmented control ---- */
.seg { position: relative; display: flex; background: var(--line); border-radius: 12px; padding: 3px; margin: 6px 0 10px; }
.seg button { flex: 1; height: 34px; border: 0; background: transparent; font-weight: 600; font-size: 13px; color: var(--text2); position: relative; z-index: 1; border-radius: 10px; }
.seg button.active { color: var(--text); }
.seg .ind { position: absolute; top: 3px; bottom: 3px; left: 3px; background: var(--card); border-radius: 10px; box-shadow: 0 1px 3px rgba(0,0,0,.12); transition: transform .25s cubic-bezier(.2,.8,.2,1); }
.period-nav { display: flex; align-items: center; gap: 6px; margin: 2px 0 10px; }
.period-nav .title { flex: 1; text-align: center; font-weight: 700; font-size: 17px; }
.period-nav .title small { display: block; font-weight: 500; font-size: 12px; color: var(--muted); }
.view-anim { animation: fadeSlide .22s ease; }
@keyframes fadeSlide { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---- chart ---- */
.chart-wrap { margin: 4px -6px 0; }
.chart { display: block; width: 100%; height: auto; -webkit-tap-highlight-color: transparent; }
.chart .grid { stroke: var(--line); stroke-width: 1; opacity: .7; }
.chart .axis { stroke: var(--line); stroke-width: 1; }
.chart .tick, .chart .xlab { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .xlab.today { fill: var(--accent); font-weight: 700; }
.chart .xlab.sel { fill: var(--text); font-weight: 800; }
.chart .g-ok stop:first-child { stop-color: color-mix(in srgb, var(--accent) 55%, var(--card)); }
.chart .g-ok stop:last-child { stop-color: var(--accent); }
.chart .g-over stop:first-child { stop-color: color-mix(in srgb, var(--bad) 60%, var(--card)); }
.chart .g-over stop:last-child { stop-color: var(--bad); }
.chart .bar .fill { fill: var(--accent); fill: url(#plate-g-ok); transition: opacity .15s ease; }
.chart .bar.over .over-fill { fill: var(--bad); fill: url(#plate-g-over); }
.chart .bar.dim .fill { opacity: .42; }
.chart .bar.future .fill { opacity: .25; }
.chart .bar .stub { fill: var(--line); }
.chart .bar .hit { fill: transparent; cursor: pointer; }
.chart .zone { fill: var(--bad); opacity: .045; }
.chart .goal { stroke: var(--text2); stroke-width: 1.2; stroke-dasharray: 3 4; stroke-linecap: round; opacity: .7; }
.chart .goal.limit { stroke: var(--bad); opacity: .55; }
.chart .goal-pill rect { fill: var(--card2); stroke: var(--line); }
.chart .goal-pill text { fill: var(--text2); font-size: 10.5px; font-weight: 700; }
.chart .goal-pill.limit rect { fill: var(--bad-soft); stroke: none; }
.chart .goal-pill.limit text { fill: var(--bad); }
.chart .tip rect, .chart .tip path { fill: var(--accent); }
.chart .tip.over rect, .chart .tip.over path { fill: var(--bad); }
.chart .tip text { fill: var(--accent-ink); font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; }
@media (prefers-reduced-motion: reduce) { .chart .bar .fill { transition: none; } }

/* ---- entries ---- */
.entry { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); background: none; border-left: 0; border-right: 0; border-top: 0; width: 100%; text-align: left; }
.entry:last-child { border-bottom: 0; }
.entry .grow { flex: 1; min-width: 0; }
.entry .title { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.entry .sub { font-size: 13px; color: var(--text2); }
.entry .kcal { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.entry .kcal .u { color: var(--muted); font-weight: 500; font-size: 12px; }
.entry .sent { color: var(--good); width: 16px; height: 16px; }
.empty { text-align: center; color: var(--muted); padding: 26px 10px; font-size: 15px; }
.empty .ic { width: 34px; height: 34px; color: var(--line); display: block; margin: 0 auto 8px; }

/* ---- sheets ---- */
#sheets { position: relative; z-index: 50; }
.sheet-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.4); opacity: 0; transition: opacity .25s; }
.sheet-backdrop.open { opacity: 1; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; max-height: 92dvh; display: flex; flex-direction: column;
  background: var(--card); border-radius: 22px 22px 0 0; transform: translateY(100%); transition: transform .3s cubic-bezier(.2,.8,.2,1);
  box-shadow: 0 -4px 30px rgba(0,0,0,.18);
}
@media (min-width: 640px) { .sheet { left: 50%; right: auto; width: 600px; transform: translate(-50%, 100%); } .sheet.open { transform: translate(-50%, 0) !important; } }
.sheet.open { transform: translateY(0); }
.sheet-grabber { display: flex; justify-content: center; padding: 8px 0 0; }
.sheet-grabber i { width: 40px; height: 5px; border-radius: 3px; background: var(--line); }
.sheet-head { display: flex; align-items: center; gap: 8px; padding: 6px 12px 8px 20px; }
.sheet-title { flex: 1; font-size: 19px; font-weight: 800; letter-spacing: -0.2px; }
.sheet-close { width: 32px; height: 32px; border-radius: 16px; border: 0; background: var(--card2); color: var(--text2); font-size: 14px; font-weight: 700; }
.sheet-body { overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 0 20px calc(18px + var(--sab)); }
.confirm-msg { color: var(--text2); margin: 6px 0 14px; font-size: 16px; }

/* add sheet */
.add-head { display: flex; align-items: center; gap: 14px; margin: 2px 0 14px; }
.add-head .nm { font-size: 18px; font-weight: 700; line-height: 1.2; }
.add-head .sv { font-size: 14px; color: var(--text2); margin-top: 2px; }
.amount { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 8px 0 10px; }
.amount .disp { flex: 1; text-align: center; }
.amount .disp b { display: block; font-size: 42px; font-weight: 800; letter-spacing: -1px; line-height: 1; }
.amount .disp span { font-size: 14px; color: var(--text2); font-weight: 600; }
.amount .stepbtn { width: 60px; height: 60px; border-radius: 30px; border: 0; background: var(--accent-soft); color: var(--accent); display: flex; align-items: center; justify-content: center; }
.amount .stepbtn .ic { width: 26px; height: 26px; }
.amount .disp .amt-in { display: block; width: 100%; border: 0; background: transparent; text-align: center; font: inherit; font-size: 42px; font-weight: 800; letter-spacing: -1px; line-height: 1; color: inherit; padding: 0; }
.amount .disp .amt-in:focus { outline: none; text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 6px; }
.unit-pick { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 12px 0 8px; }
.unit-pick select { flex: 0 1 60%; min-width: 0; appearance: none; -webkit-appearance: none; padding-right: 34px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2396707F' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; background-size: 16px; }
.amt-eq { text-align: center; min-height: 18px; margin: -4px 0 8px; }
.amount .stepbtn:active { filter: brightness(.9); }
.preview { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 14px; }
.preview .p { background: var(--card2); border-radius: 12px; padding: 8px 10px; }
.preview .p .l { font-size: 12px; color: var(--text2); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.preview .p .v { font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 2px; }
.preview .p .v .u { color: var(--muted); font-weight: 500; font-size: 12px; }
.preview .p .l.st { color: var(--muted); }
.preview .p.bad { background: var(--bad-soft); } .preview .p.bad .v, .preview .p.bad .l.st { color: var(--bad); }
.preview .p.warn { background: var(--warn-soft); } .preview .p.warn .v, .preview .p.warn .l.st { color: var(--warn); }
.preview .p.good { background: var(--good-soft); } .preview .p.good .l.st { color: var(--good); }
.when { display: flex; gap: 8px; align-items: center; margin-top: 12px; }
.when .input { flex: 1; }

/* recipe review */
.ing { padding: 10px 0; border-bottom: 1px solid var(--line); }
.ing:last-child { border-bottom: 0; }
.ing .top { display: flex; align-items: flex-start; gap: 10px; }
.ing .q { font-weight: 700; white-space: nowrap; min-width: 52px; font-variant-numeric: tabular-nums; }
.ing .nm { flex: 1; min-width: 0; }
.ing .nm .raw { font-weight: 600; }
.ing .nm .match { font-size: 13px; color: var(--text2); margin-top: 2px; }
.ing .nm .match.bad { color: var(--bad); font-weight: 600; }
.ing .nm .match.warn { color: var(--warn); font-weight: 600; }
.ing .g { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; text-align: right; }
.ing .g .u { color: var(--muted); font-weight: 500; font-size: 12px; }
.ing .g.approx::after { content: ' ≈'; color: var(--warn); }
.badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 6px; background: var(--card2); color: var(--text2); vertical-align: middle; }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.good { background: var(--good-soft); color: var(--good); }
.pick { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); background: none; border-top: 0; border-left: 0; border-right: 0; width: 100%; text-align: left; }
.pick .grow { flex: 1; min-width: 0; }
.pick .d { font-weight: 600; font-size: 15px; }
.pick .s { font-size: 12px; color: var(--muted); }
.pick .chk { width: 22px; color: var(--accent); }
.emoji-row { display: flex; gap: 6px; flex-wrap: wrap; }
.emoji-row button { width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--card2); font-size: 24px; }
.emoji-row button.active { border-color: var(--accent); background: var(--accent-soft); }
.steps { display: flex; gap: 6px; margin: 4px 0 12px; }
.steps i { flex: 1; height: 4px; border-radius: 2px; background: var(--line); }
.steps i.on { background: var(--accent); }
.progress { height: 6px; border-radius: 3px; background: var(--accent-track); overflow: hidden; margin: 8px 0; }
.progress i { display: block; height: 100%; background: var(--accent); transition: width .2s; }

/* toasts */
#toasts { position: fixed; left: 0; right: 0; bottom: calc(var(--tab-h) + var(--sab) + 12px); z-index: 60; display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; }
/* while a sheet is open the lane moves to the top, clear of the sheet's buttons */
body.sheet-open #toasts { bottom: auto; top: calc(var(--sat) + 10px); flex-direction: column-reverse; }
body.sheet-open .toast { transform: translateY(-8px); }
.toast { pointer-events: auto; background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-size: 14px; font-weight: 600; opacity: 0; transform: translateY(8px); transition: all .2s; display: flex; gap: 12px; align-items: center; max-width: 92vw; }
.toast.show { opacity: 1; transform: none; }
/* a sticker riding a toast */
.toast.cast { padding: 6px 16px 6px 8px; border-radius: 26px; }
.toast-cast { display: flex; align-items: flex-end; flex: none; }
.toast-cast .ck { animation: none; }
.toast.moment { padding: 10px 20px 10px 12px; border-radius: 30px; font-size: 15px; font-weight: 800; gap: 14px; }
.toast.moment .toast-cast { margin: -22px 0 -6px; filter: drop-shadow(0 4px 8px rgba(0, 0, 0, .18)); }
/* a moment has nothing to tap, so taps go through to whatever is under it */
.toast.moment { pointer-events: none; }
.toast.bad { background: var(--bad); color: #fff; }
.toast-act { background: none; border: 0; color: #9cc0ff; font-weight: 700; }   /* light blue on the dark toast */
@media (prefers-color-scheme: dark) { .toast-act { color: #1d5fd6; } }         /* dark blue on the light toast */

/* settings */
.goal-row { display: grid; grid-template-columns: 1fr 92px 86px; gap: 8px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.goal-row:last-child { border-bottom: 0; }
.goal-row .n { font-weight: 600; font-size: 15px; }
.goal-row .n small { display: block; color: var(--muted); font-weight: 500; font-size: 12px; }
.goal-row .input { height: 40px; font-size: 15px; padding: 0 8px; text-align: right; }
.goal-row .mode { height: 40px; border-radius: 10px; border: 1px solid var(--line); background: var(--card2); font-size: 13px; font-weight: 700; color: var(--text2); }
.goal-row .mode.limit { color: var(--bad); }
.goal-row .mode.target { color: var(--good); }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 15px; }
.kv:last-child { border-bottom: 0; }
.kv b { font-variant-numeric: tabular-nums; }
.note { background: var(--card2); border-radius: 12px; padding: 10px 12px; font-size: 13px; color: var(--text2); margin: 8px 0; line-height: 1.4; }
.note b { color: var(--text); }
pre.code { background: var(--card2); border-radius: 10px; padding: 10px; font-size: 12px; overflow-x: auto; user-select: text; -webkit-user-select: text; white-space: pre-wrap; word-break: break-word; }
.steps-list { padding-left: 20px; margin: 6px 0; color: var(--text2); font-size: 14px; line-height: 1.5; }
.steps-list li { margin: 4px 0; }
.steps-list b { color: var(--text); }

/* garden */
.garden-row { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; padding: 6px 0 2px; }
.garden-day { display: inline-flex; }
.garden-day svg { display: block; }
.garden-cap { text-align: center; font-size: 13px; color: var(--text2); font-weight: 600; margin-top: 6px; }
/* screen transition: only when the tab changes, never on a data refresh */
.screen.enter .content { animation: fadeSlide .2s ease; }
.tile { transition: transform .12s ease; }
.chip, .btn, .act-chip, .plan-row, .pick, .entry, .row.tappable { transition: background-color .15s ease, color .15s ease, transform .12s ease, border-color .15s ease; }
.chip:active, .act-chip:active { transform: scale(0.96); }
@media (prefers-reduced-motion: reduce) { .tile, .chip, .btn, .act-chip, .meter i, .seg .ind, .switch, .switch::after { transition: none !important; } .screen.enter .content { animation: none; } }
@media (prefers-reduced-motion: reduce) { .screen .content, .view-anim { animation: none; } }

/* cast settings grid, love note */
.cast-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
.cast-tile { min-width: 0; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 10px 6px 8px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.cast-tile.resting { opacity: .4; filter: grayscale(1); }
.cast-art { height: 64px; width: 100%; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.cast-art .ck { max-width: 100%; }
.cast-art .ck img { max-width: 100%; height: 100%; object-fit: contain; }
.cast-art .ck { animation: none; }
.cast-art .ck img { animation-play-state: paused; }
.cast-name { font-size: 12px; font-weight: 700; line-height: 1.2; max-width: 100%; overflow-wrap: anywhere; }
.cast-roles { font-size: 10px; color: var(--muted); line-height: 1.3; max-width: 100%; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.cast-tile .link.small { min-height: 28px; font-size: 12px; }
.envelope { font-size: 18px; }
.love-note { padding: 8px 0 4px; }
.love-note-cast { display: flex; justify-content: center; margin-bottom: 6px; }
.love-note-text { font-size: 20px; font-weight: 700; line-height: 1.4; text-align: center; padding: 10px 6px 14px; color: var(--text); white-space: pre-wrap; }

/* activity strip under the day card */
.act-strip { margin: -4px 0 12px; }
.act-head { display: flex; justify-content: space-between; align-items: baseline; padding: 0 4px 6px; }
.act-row { display: flex; flex-wrap: wrap; gap: 6px; }
.act-chip { border: 1px solid var(--line); background: var(--card); color: var(--text); border-radius: 999px; padding: 9px 13px; font-size: 13px; font-weight: 600; display: inline-flex; gap: 6px; align-items: center; min-height: 42px; }
.act-chip b { color: var(--good); }
.act-chip.add { color: var(--accent); border-style: dashed; }
.act-chip .ic { width: 16px; height: 16px; }
/* planned meals */
.plan-strip { margin: -4px 0 12px; }
.plan-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; background: var(--card); border: 1px dashed var(--line); border-radius: 14px; margin-bottom: 6px; width: 100%; text-align: left; color: var(--text); }
.plan-row .grow { flex: 1; min-width: 0; }
.plan-row .title { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.plan-row .sub { font-size: 12px; color: var(--text2); }
.badge.plan { background: var(--accent-soft); color: var(--accent); }
.daychips { display: flex; flex-wrap: wrap; gap: 6px; }
.daychips .chip { min-width: 64px; justify-content: center; }
.plan-apply { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; margin: 10px 2px; }
.plan-apply input { width: 20px; height: 20px; accent-color: var(--accent); }

/* snap a label */
.shots { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 6px 0 12px; }
.shot { position: relative; aspect-ratio: 3 / 4; border-radius: 12px; overflow: hidden; background: var(--card2); border: 1px solid var(--line); }
.shot img { width: 100%; height: 100%; object-fit: cover; display: block; }
.shot .badge { position: absolute; left: 6px; bottom: 6px; background: rgba(0,0,0,.55); color: #fff; }
.shot-x { position: absolute; top: 4px; right: 4px; width: 28px; height: 28px; border-radius: 50%; border: 0; background: rgba(0,0,0,.55); color: #fff; font-size: 13px; }
.shot-x::before { content: ''; position: absolute; inset: -9px; }   /* 46px hit area */
.shot.add { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; color: var(--accent); border-style: dashed; font-size: 12px; font-weight: 600; }
.shot.add .ic { width: 22px; height: 22px; }
@keyframes lbl-pulse { from { width: 20%; } to { width: 85%; } }

.act-chip.health { border-color: var(--accent-soft); background: var(--accent-soft); }
code { background: var(--card2); border-radius: 5px; padding: 1px 5px; font-size: 12px; user-select: text; -webkit-user-select: text; }

/* hold-to-log on a tile */
.tile.holding { transform: scale(0.95); }
.tile.quick { animation: tile-quick .5s cubic-bezier(.3, 1.5, .5, 1); box-shadow: 0 0 0 3px var(--accent); }
@keyframes tile-quick { 0% { transform: scale(0.95); } 50% { transform: scale(1.04); } 100% { transform: scale(1); } }
.tile { user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: manipulation; }

.card.welcome { border: 1px solid var(--accent-soft); }
.card.welcome .title { font-weight: 800; font-size: 17px; }
.card.welcome .link { padding: 0; min-height: 0; display: inline; font-size: inherit; }

/* keyboard and switch-control users see where focus is; touch does not */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 8px; }
.tile:focus-visible { outline-offset: -2px; border-radius: 16px; }

.cast-more { text-align: center; padding: 14px 0 6px; }
