@font-face { font-family: 'Fraunces'; font-weight: 800; font-display: swap; src: url('../fonts/fraunces-latin-800-normal.woff2') format('woff2'); }
@font-face { font-family: 'Figtree'; font-weight: 400; font-display: swap; src: url('../fonts/figtree-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'Figtree'; font-weight: 500; font-display: swap; src: url('../fonts/figtree-latin-500-normal.woff2') format('woff2'); }
@font-face { font-family: 'Figtree'; font-weight: 600; font-display: swap; src: url('../fonts/figtree-latin-600-normal.woff2') format('woff2'); }
@font-face { font-family: 'Figtree'; font-weight: 700; font-display: swap; src: url('../fonts/figtree-latin-700-normal.woff2') format('woff2'); }

:root {
  --bg: #EDEFEC;
  --card: #FFFFFF;
  --ink: #1F2421;
  --ink-2: #3A403C;
  --muted: #5B625D;
  --line: #EEF0ED;
  --line-2: #E0E4DF;
  --track: #E7EAE6;
  --track-warm: #EEE6DF;
  --accent: #B84A00;
  --accent-ink: #9A3D00;
  --accent-soft: #F7D9C8;
  --accent-wash: #F7F1EC;
  --chip: #F3EDE7;
  --over: #D9A27C;
  --protein: #C8372D;
  --fat: #A88A26;
  --carbs: #C77700;
  --sage: #9DB59C;
  --water: #5E8FB5;
  --good: #2F6B37;
  --danger: #A12B1E;
  --radius: 28px;
  --display: 'Fraunces', Georgia, serif;
  --body: 'Figtree', system-ui, -apple-system, sans-serif;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161917;
    --card: #222624;
    --ink: #EEF0ED;
    --ink-2: #D3D8D4;
    --muted: #A2AAA4;
    --line: #2E3330;
    --line-2: #3A403C;
    --track: #343A36;
    --track-warm: #3D3530;
    --accent: #D9692A;
    --accent-ink: #F2A577;
    --accent-soft: #4A2B1A;
    --accent-wash: #33261E;
    --chip: #3A2E26;
    --over: #A8734F;
    --good: #7BC285;
    --danger: #F08A7E;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
.help svg, .xsmall svg, .small svg { display: inline; vertical-align: -2px; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-ink); }
img, svg { display: block; }
button, input, select, textarea { font: inherit; color: inherit; }

.num { font-family: var(--display); font-weight: 800; letter-spacing: -0.01em; font-variant-numeric: lining-nums; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.xsmall { font-size: 12px; }
.strong { font-weight: 700; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.app { max-width: 560px; margin: 0 auto; min-height: 100vh; padding-bottom: calc(110px + var(--safe-bottom)); }
.app.bare { padding-bottom: 32px; }
.page { padding: 8px 16px 24px; display: flex; flex-direction: column; gap: 14px; }

/* Header */
.topbar { padding: 24px 20px 8px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.topbar h1 { margin: 0; font-family: var(--display); font-weight: 800; font-size: 30px; line-height: 1.1; }
.topbar .sub { font-size: 13px; color: var(--muted); }
.topbar .left { display: flex; align-items: center; gap: 10px; min-width: 0; }

.round {
  width: 44px; height: 44px; flex: none; border-radius: 22px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--card); border: 0; color: var(--ink); cursor: pointer; text-decoration: none;
}
.round.accent { background: var(--accent); color: #fff; }
.round.soft { background: var(--chip); color: var(--accent-ink); }
.round.outline { background: transparent; border: 1.5px solid var(--ink); }
.round.water { background: var(--water); color: #fff; }
.round.small { width: 40px; height: 40px; }

/* Cards */
.card { background: var(--card); border-radius: var(--radius); padding: 20px; }
.card.tight { padding: 0; overflow: hidden; }
.card h2, .card .h { margin: 0; font-size: 16px; font-weight: 700; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; align-items: center; gap: 12px; }
.between { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }

/* Bars */
.bar { height: 6px; border-radius: 3px; background: var(--track); overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 3px; background: var(--accent); }
.bar.warm { background: var(--track-warm); }
.bar.thick { height: 10px; border-radius: 5px; }

/* Week strip */
.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; padding: 0 16px 6px; }
.week a { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 8px 0 6px; border-radius: 18px; text-decoration: none; color: var(--ink); }
.week a .d { font-size: 12px; font-weight: 600; color: var(--muted); }
.week a .n { font-family: var(--display); font-weight: 800; font-size: 18px; }
.week a .dot { width: 6px; height: 6px; border-radius: 3px; background: transparent; }
.week a .dot.on { background: var(--good); }
.week a.active { background: var(--accent-soft); }
.week a.active .d, .week a.active .n { color: var(--accent-ink); }
.week a.today .n { text-decoration: underline; text-underline-offset: 4px; text-decoration-thickness: 2px; }

/* Summary */
.summary { display: flex; gap: 20px; align-items: center; }
.ring { position: relative; width: 132px; height: 132px; flex: none; }
.ring svg { width: 132px; height: 132px; }
.ring .inner { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.ring .inner .num { font-size: 30px; line-height: 1; }
.macros { flex: 1; display: flex; flex-direction: column; gap: 11px; min-width: 0; }
.macro .top { display: flex; justify-content: space-between; font-size: 13px; gap: 6px; }

.tile { background: var(--card); border-radius: 24px; padding: 16px 18px; display: flex; flex-direction: column; gap: 6px; }

/* Meal blocks */
.meal-head { display: flex; align-items: center; gap: 12px; padding: 16px 16px 16px 20px; }
.meal-head .info { flex: 1; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.meal-head .name { font-size: 18px; font-weight: 700; }
.meal-head .note { font-size: 12px; color: var(--muted); }
.meal-head .note.good { color: var(--good); }
.meal-head .note.adjusted { color: var(--accent-ink); }
details.meal > summary { list-style: none; cursor: pointer; }
details.meal > summary::-webkit-details-marker { display: none; }
.meal-body { border-top: 1px solid var(--line); }

.item { display: flex; align-items: center; gap: 12px; padding: 12px 16px 12px 20px; border-bottom: 1px solid var(--line); text-decoration: none; color: inherit; }
.item:last-child { border-bottom: 0; }
.item .ic { width: 38px; height: 38px; flex: none; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 15px; color: #1F2421; }
.item .txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.item .txt .t { font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .txt .s { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .k { display: flex; flex-direction: column; align-items: flex-end; flex: none; }
.item .k .num { font-size: 17px; }
.item .k .u { font-size: 11px; color: var(--muted); }

.actions { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 20px 16px; }

/* Buttons and chips */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 16px; border-radius: 16px; border: 0;
  font-size: 15px; font-weight: 700; text-decoration: none; cursor: pointer;
  background: var(--accent); color: #fff;
}
.btn.block { width: 100%; min-height: 54px; border-radius: 20px; font-size: 16px; }
.btn.soft { background: var(--chip); color: var(--accent-ink); font-weight: 600; font-size: 14px; }
.btn.grey { background: var(--line); color: var(--ink-2); font-weight: 600; font-size: 14px; }
.btn.ghost { background: transparent; color: var(--ink-2); border: 1px solid var(--line-2); font-weight: 600; font-size: 14px; }
.btn.danger { background: transparent; color: var(--danger); border: 1px solid var(--line-2); font-weight: 600; font-size: 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; min-height: 40px; padding: 8px 14px; border-radius: 16px; border: 1px solid var(--line-2); background: var(--card); font-size: 14px; color: var(--ink); text-decoration: none; cursor: pointer; }
.tabs { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.tabs a { flex: none; padding: 9px 14px; border-radius: 16px; background: var(--track); color: var(--ink); font-size: 14px; font-weight: 600; text-decoration: none; }
.tabs a.on { background: var(--ink); color: var(--bg); }
.badge { font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 10px; background: var(--chip); color: var(--accent-ink); white-space: nowrap; }
.badge.off { background: #F1ECE4; color: #6B4E2A; }
.badge.eigen { background: #E6EEF6; color: #2F5779; }
.badge.recept { background: #E2F0D6; color: #2F6B37; }

/* Forms */
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--ink-2); font-weight: 600; }
.input, .select {
  width: 100%; min-height: 48px; border-radius: 14px; border: 1px solid var(--line-2);
  background: var(--card); padding: 0 14px; font-size: 16px; font-weight: 400; color: var(--ink);
}
.input:focus, .select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.searchbox { display: flex; align-items: center; gap: 10px; background: var(--card); border-radius: 18px; border: 1px solid var(--line-2); padding: 0 14px; min-height: 52px; }
.searchbox input { flex: 1; border: 0; background: transparent; font-size: 16px; outline: none; min-width: 0; }
.unit-input { display: flex; align-items: center; gap: 6px; background: var(--line); border-radius: 14px; padding: 0 12px; min-height: 46px; }
.unit-input input { width: 72px; border: 0; background: transparent; text-align: right; font-size: 16px; outline: none; }
.help { font-size: 12px; color: var(--muted); font-weight: 400; }
.segment { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; background: var(--line); border-radius: 18px; padding: 4px; }
.segment label { text-align: center; padding: 10px 4px; border-radius: 14px; font-size: 14px; font-weight: 700; color: var(--ink-2); cursor: pointer; }
.segment input { position: absolute; opacity: 0; pointer-events: none; }
.segment input:checked + span { color: var(--accent-ink); }
.segment label:has(input:checked) { background: var(--card); }
.segment label:has(input:focus-visible) { outline: 2px solid var(--accent); }

/* Portion picker */
.portion { display: flex; align-items: center; border-radius: 18px; border: 1.5px solid var(--track); background: var(--card); }
.portion:has(input:checked) { border-color: var(--accent); background: var(--accent-wash); }
.portion label { flex: 1; display: flex; align-items: center; gap: 12px; padding: 12px 0 12px 14px; cursor: pointer; min-width: 0; }
.portion input[type=radio] { width: 20px; height: 20px; accent-color: var(--accent); flex: none; margin: 0; }
.portion .pt { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.portion .pt b { font-size: 15px; }
.portion .pt span { font-size: 12px; color: var(--muted); }
.portion .num { font-size: 17px; }
.portion .edit { width: 44px; height: 44px; border: 0; background: transparent; color: var(--muted); display: flex; align-items: center; justify-content: center; cursor: pointer; border-radius: 22px; }

.nutri { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.nutri div { border-radius: 16px; padding: 10px; display: flex; flex-direction: column; gap: 2px; }
.nutri .num { font-size: 20px; }
.nutri span:last-child { font-size: 12px; color: var(--muted); }
.n-kcal { background: #FBF1EB; } .n-e { background: #FBECEB; } .n-k { background: #FBF2E3; } .n-v { background: #F6F1DF; }
@media (prefers-color-scheme: dark) { .n-kcal, .n-e, .n-k, .n-v { background: var(--line); } }

table.values { width: 100%; border-collapse: collapse; font-size: 14px; }
table.values th, table.values td { padding: 9px 0; text-align: right; border-top: 1px solid var(--line); }
table.values thead th { border-top: 0; font-size: 12px; color: var(--muted); font-weight: 600; }
table.values th:first-child { text-align: left; font-weight: 500; }
table.values tr.sub th { color: var(--muted); padding-left: 10px; }

/* Lists */
.list { background: var(--card); border-radius: 22px; overflow: hidden; }
.list .row-item { display: flex; align-items: center; gap: 12px; padding: 10px 10px 10px 16px; border-bottom: 1px solid var(--line); }
.list .row-item:last-child { border-bottom: 0; }
.list .row-item a.main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; text-decoration: none; color: var(--ink); }
.list .row-item .t { font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 6px; min-width: 0; }
.list .row-item .t span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .row-item .s { font-size: 13px; color: var(--muted); }
.list .head { padding: 12px 16px 6px; font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.empty { padding: 22px 18px; text-align: center; color: var(--muted); font-size: 14px; }
.menu a { display: flex; align-items: center; gap: 14px; padding: 16px 20px; border-bottom: 1px solid var(--line); color: var(--ink); text-decoration: none; font-weight: 600; }
.menu a:last-child, .menu form:last-child button { border-bottom: 0; }
.menu a .icon, .menu button .icon { color: var(--accent-ink); }
.menu a .r { margin-left: auto; color: var(--muted); font-weight: 400; font-size: 14px; }
.menu button { width: 100%; display: flex; align-items: center; gap: 14px; padding: 16px 20px; border: 0; background: transparent; color: var(--ink); font-weight: 600; cursor: pointer; text-align: left; }

/* Flash */
.flash { margin: 8px 16px 0; padding: 12px 16px; border-radius: 16px; font-size: 14px; font-weight: 600; background: #E3EFE3; color: #1F4D26; }
.flash.error { background: #F8E1DD; color: #7A2216; }

/* Bottom nav */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  background: var(--card); border-top: 1px solid var(--line-2);
  padding: 8px 8px calc(10px + var(--safe-bottom));
}
.tabbar .in { max-width: 560px; margin: 0 auto; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); align-items: center; }
.tabbar a { display: flex; flex-direction: column; align-items: center; gap: 3px; text-decoration: none; color: var(--ink-2); font-size: 12px; }
.tabbar a .pill { padding: 5px 16px; border-radius: 16px; display: flex; }
.tabbar a.on { color: var(--accent-ink); font-weight: 700; }
.tabbar a.on .pill { background: var(--accent-soft); }
.tabbar a.plus { justify-self: center; width: 62px; height: 62px; border-radius: 31px; background: var(--accent); color: #fff; justify-content: center; margin-top: -26px; box-shadow: 0 0 0 6px var(--card); }

/* Sheet (add screen) */
.sheet-top { display: flex; justify-content: space-between; align-items: center; padding: 18px 16px 6px 20px; }
.quickgrid { display: grid; grid-template-columns: 2fr 1fr; gap: 10px; }
.scanbtn { background: var(--accent); color: #fff; border-radius: 22px; padding: 16px; display: flex; flex-direction: column; gap: 16px; text-decoration: none; }
.scanbtn b { font-size: 17px; }
.scanbtn span { font-size: 13px; opacity: .9; }
.sidebtns { display: flex; flex-direction: column; gap: 10px; }
.sidebtns a, .sidebtns button { flex: 1; background: var(--card); border-radius: 18px; display: flex; align-items: center; gap: 8px; padding: 0 12px; font-size: 14px; font-weight: 600; text-decoration: none; color: var(--ink); border: 0; cursor: pointer; }

dialog { border: 0; border-radius: 24px; padding: 20px; width: min(92vw, 420px); background: var(--card); color: var(--ink); }
dialog::backdrop { background: rgba(20, 24, 22, .45); }

/* Scanner */
.scanner { position: fixed; inset: 0; background: #111; color: #fff; display: flex; flex-direction: column; }
.scanner video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.scanner .top { position: relative; z-index: 2; display: flex; justify-content: space-between; align-items: center; padding: calc(16px + env(safe-area-inset-top, 0px)) 16px 0; }
.scanner .top .round { background: rgba(40, 44, 42, .8); color: #fff; }
.scanner .frame { position: relative; z-index: 2; margin: auto; width: 280px; height: 170px; border-radius: 18px; box-shadow: 0 0 0 9999px rgba(0, 0, 0, .45); }
.scanner .frame::after { content: ''; position: absolute; left: 18px; right: 18px; top: 50%; height: 3px; border-radius: 2px; background: #F08A4B; }
.scanner .bottom { position: relative; z-index: 2; padding: 16px 16px calc(28px + var(--safe-bottom)); display: flex; flex-direction: column; gap: 12px; align-items: center; text-align: center; }
.scanner .msg { font-size: 15px; color: #D7DCD8; }
.scanner form { display: flex; gap: 8px; width: 100%; max-width: 360px; }
.scanner form input { flex: 1; min-height: 48px; border-radius: 14px; border: 0; padding: 0 14px; font-size: 16px; color: #1F2421; }

.toast { position: fixed; left: 50%; bottom: calc(100px + var(--safe-bottom)); transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: 16px; font-size: 14px; font-weight: 600; z-index: 50; opacity: 0; transition: opacity .2s; pointer-events: none; }
.toast.show { opacity: 1; }

.auth { padding: 48px 20px 20px; display: flex; flex-direction: column; gap: 18px; }
.auth .logo { font-family: var(--display); font-weight: 800; font-size: 40px; line-height: 1; }
.auth .logo span { color: var(--accent); }

@media (min-width: 600px) {
  body { padding-top: 12px; }
}

/* ---------- App feel: motion ---------- */

/* Smooth page-to-page transitions (Safari 18.2+, Chrome 126+). */
@view-transition { navigation: auto; }
::view-transition-old(root) { animation: vt-out .16s ease both; }
::view-transition-new(root) { animation: vt-in .26s cubic-bezier(.2, .8, .2, 1) both; }
.tabbar { view-transition-name: tabbar; }
::view-transition-group(tabbar) { animation: none; }
@keyframes vt-out { to { opacity: 0; transform: scale(.985); } }
@keyframes vt-in { from { opacity: 0; transform: translateY(10px); } }

/* Content rises in, one block after the other. */
@keyframes rise { from { opacity: 0; transform: translateY(12px); } }
.topbar, .week, .sheet-top { animation: rise .35s cubic-bezier(.2, .8, .2, 1) both; }
.page > * { animation: rise .4s cubic-bezier(.2, .8, .2, 1) both; }
.page > *:nth-child(1) { animation-delay: .03s; }
.page > *:nth-child(2) { animation-delay: .07s; }
.page > *:nth-child(3) { animation-delay: .11s; }
.page > *:nth-child(4) { animation-delay: .15s; }
.page > *:nth-child(5) { animation-delay: .19s; }
.page > *:nth-child(6) { animation-delay: .23s; }
.page > *:nth-child(n+7) { animation-delay: .27s; }
.flash { animation: rise .35s cubic-bezier(.2, .8, .2, 1) both; }

/* Bars and the ring fill up. */
@keyframes grow { from { transform: scaleX(0); } }
.bar > span { transform-origin: left center; animation: grow .8s cubic-bezier(.2, .8, .2, 1) .15s both; }
@keyframes ring-fill { from { stroke-dasharray: 0 400; } }
.ring .prog { animation: ring-fill 1s cubic-bezier(.2, .8, .2, 1) .1s both; }

/* Press feedback, like native buttons. */
.btn, .round, .chip, .tabs a, .tabbar a, .item, .row-item, .portion label, .scanbtn, .sidebtns > *, .week a, .menu a, .menu button {
  transition: transform .14s ease, background-color .2s ease, opacity .2s ease;
  -webkit-tap-highlight-color: transparent;
}
.btn:active, .round:active, .chip:active, .tabs a:active, .scanbtn:active, .sidebtns > *:active, .week a:active { transform: scale(.95); }
.item:active, .row-item:active, .menu a:active, .menu button:active, .portion label:active { transform: scale(.985); }
.tabbar a:active .pill { transform: scale(.9); }
.tabbar a .pill { transition: transform .14s ease, background-color .25s ease; }
.tabbar a.plus { transition: transform .2s cubic-bezier(.3, 1.6, .5, 1); }
.tabbar a.plus:active { transform: scale(.9) rotate(90deg); }

/* Meals open smoothly. */
details.meal[open] .meal-body { animation: rise .3s cubic-bezier(.2, .8, .2, 1) both; }

/* Dialogs slide up as a sheet. */
dialog[open] { animation: sheet-in .32s cubic-bezier(.2, .9, .3, 1) both; }
dialog[open]::backdrop { animation: fade-in .25s ease both; }
@keyframes sheet-in { from { opacity: 0; transform: translateY(40px) scale(.98); } }
@keyframes fade-in { from { opacity: 0; } }
@media (max-width: 600px) {
  dialog { margin: auto auto 0; width: 100%; max-width: 100%; border-radius: 26px 26px 0 0; padding-bottom: calc(24px + var(--safe-bottom)); }
}

/* Toast slides in. */
.toast { transform: translate(-50%, 16px); transition: opacity .2s ease, transform .3s cubic-bezier(.2, .9, .3, 1.2); }
.toast.show { transform: translate(-50%, 0); }

/* Just-added check pops. */
@keyframes pop { 0% { transform: scale(.6); } 60% { transform: scale(1.15); } 100% { transform: scale(1); } }
.round.done { background: var(--good); color: #fff; animation: pop .35s ease both; }

/* Search results appear. */
#results:not([hidden]) .row-item { animation: rise .25s ease both; }

/* ---------- "Works better as an app" banner ---------- */
.install {
  position: fixed; left: 12px; right: 12px; z-index: 40;
  bottom: calc(96px + var(--safe-bottom));
  max-width: 536px; margin: 0 auto;
  background: var(--ink); color: var(--bg);
  border-radius: 22px; padding: 14px 14px 14px 16px;
  display: flex; align-items: center; gap: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .22);
  animation: install-in .5s cubic-bezier(.2, .9, .3, 1.15) .6s both;
}
.app.bare ~ .install, body.bare .install { bottom: calc(16px + var(--safe-bottom)); }
.install.hide { animation: install-out .25s ease both; }
@keyframes install-in { from { opacity: 0; transform: translateY(30px) scale(.96); } }
@keyframes install-out { to { opacity: 0; transform: translateY(30px); } }
.install img { width: 44px; height: 44px; border-radius: 11px; flex: none; }
.install .t { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.install .t b { font-size: 15px; }
.install .t span { font-size: 13px; opacity: .8; }
.install .t svg { display: inline; vertical-align: -3px; }
.install .go { border: 0; border-radius: 14px; padding: 10px 14px; font-weight: 700; font-size: 14px; background: var(--accent); color: #fff; cursor: pointer; min-height: 40px; }
.install .x { border: 0; background: transparent; color: inherit; opacity: .7; width: 36px; height: 36px; border-radius: 18px; display: flex; align-items: center; justify-content: center; cursor: pointer; flex: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after, ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) {
    animation: none !important; transition: none !important;
  }
}

/* ---------- Notification settings ---------- */
.switch { position: relative; flex: none; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { display: block; width: 52px; height: 32px; border-radius: 16px; background: var(--track); transition: background-color .2s ease; }
.switch .knob { position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 13px; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .25s cubic-bezier(.3, 1.4, .5, 1); }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track .knob { transform: translateX(20px); }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }
.times { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; transition: opacity .2s ease; }
.timefield { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); font-weight: 600; }
.timefield input { min-height: 44px; border-radius: 12px; border: 1px solid var(--line-2); background: var(--card); padding: 0 10px; font-size: 16px; color: var(--ink); width: 100%; }
.daypick { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; transition: opacity .2s ease; }
.daypick label { cursor: pointer; }
.daypick input { position: absolute; opacity: 0; pointer-events: none; }
.daypick span { display: flex; align-items: center; justify-content: center; height: 40px; border-radius: 12px; background: var(--line); font-size: 13px; font-weight: 700; color: var(--ink-2); transition: background-color .15s ease, color .15s ease; }
.daypick input:checked + span { background: var(--accent-soft); color: var(--accent-ink); }
.daypick input:focus-visible + span { outline: 2px solid var(--accent); }
.notif.off .times, .notif.off .daypick { opacity: .35; pointer-events: none; }
.mealrows { display: flex; flex-direction: column; gap: 8px; transition: opacity .2s ease; }
.mealrow { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.mealrow input[type=time] { min-height: 44px; border-radius: 12px; border: 1px solid var(--line-2); background: var(--card); padding: 0 10px; font-size: 16px; color: var(--ink); width: 120px; transition: opacity .2s ease; }
.mealrow.skip input[type=time] { opacity: .35; pointer-events: none; }
.mealrow.skip .check { color: var(--muted); }
.check { display: flex; align-items: center; gap: 10px; font-size: 15px; font-weight: 600; cursor: pointer; min-height: 44px; }
.check input { position: absolute; opacity: 0; pointer-events: none; }
.check .box { width: 24px; height: 24px; border-radius: 7px; border: 2px solid var(--line-2); display: flex; align-items: center; justify-content: center; color: transparent; transition: background-color .15s ease, border-color .15s ease; }
.check input:checked + .box { background: var(--accent); border-color: var(--accent); color: #fff; }
.check input:focus-visible + .box { outline: 2px solid var(--accent); outline-offset: 2px; }
.notif.off .mealrows { opacity: .35; pointer-events: none; }

/* In-place updates */
[data-water-bar] { transition: width .5s cubic-bezier(.2, .8, .2, 1); }
@keyframes bump { 0% { transform: scale(1); } 40% { transform: scale(1.12); } 100% { transform: scale(1); } }
.bump { display: inline-block; animation: bump .35s cubic-bezier(.3, 1.4, .5, 1); transform-origin: left center; }
.round { position: relative; overflow: hidden; }
.round.ripple::after { content: ''; position: absolute; inset: 0; border-radius: inherit; background: currentColor; opacity: .3; animation: ripple .45s ease-out forwards; }
@keyframes ripple { from { transform: scale(0); opacity: .35; } to { transform: scale(1.6); opacity: 0; } }

/* Swipe to delete */
.swipe { position: relative; overflow: hidden; border-bottom: 1px solid var(--line); transition: height .25s ease, opacity .25s ease; }
.swipe:last-of-type { border-bottom: 0; }
.swipe .item { position: relative; background: var(--card); border-bottom: 0; touch-action: pan-y; will-change: transform; }
.swipe-bg { position: absolute; inset: 0; background: #C8372D; color: #fff; display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding-right: 22px; font-weight: 700; font-size: 14px; }
.swipe-bg svg { display: inline; }
.swipe.armed .swipe-bg { background: #A12B1E; }
.swipe.gone { height: 0 !important; opacity: 0; border-bottom-width: 0; }
@keyframes enter { from { opacity: 0; transform: translateY(-6px); background: var(--accent-wash); } }
.enter { animation: enter .45s cubic-bezier(.2, .8, .2, 1) both; }

/* Toast with an action (undo) */
.toast { display: flex; align-items: center; gap: 14px; white-space: nowrap; }
.toast.has-action { pointer-events: auto; }
.toast button { border: 0; background: transparent; color: var(--accent-soft); font-weight: 700; font-size: 14px; padding: 6px 2px; cursor: pointer; }

/* After the first load: values glide to new numbers instead of replaying entrances */
.ready .page > *, .ready .week, .ready .topbar, .ready details.meal[open] .meal-body { animation: none; }
.ready .bar > span { animation: none; transition: width .55s cubic-bezier(.2, .8, .2, 1); }
.ready .ring .prog { animation: none; transition: stroke-dasharray .7s cubic-bezier(.2, .8, .2, 1), stroke .3s ease; }
.ready .page > .enter, .ready .enter { animation: enter .45s cubic-bezier(.2, .8, .2, 1) both; }
.chip svg { display: inline; }
.actions .btn { font-size: 13px; padding: 8px 12px; min-height: 40px; gap: 6px; }

/* ---------- Opening "Toevoegen" from a plus: circular reveal ---------- */
.plusbtn .icon { transition: transform .35s cubic-bezier(.3, 1.5, .5, 1); }
.plusbtn.go .icon { transform: rotate(135deg) scale(1.1); }
.plusbtn.go::before {
  content: ''; position: absolute; inset: -6px; border-radius: 50%;
  border: 3px solid var(--accent); animation: burst .45s ease-out forwards; pointer-events: none;
}
.tabbar a.plus.plusbtn { position: relative; }
@keyframes burst { from { transform: scale(.8); opacity: .9; } to { transform: scale(1.9); opacity: 0; } }

@keyframes reveal { from { clip-path: circle(0 at var(--vx, 50%) var(--vy, 90%)); } to { clip-path: circle(150vmax at var(--vx, 50%) var(--vy, 90%)); } }
@keyframes recede { to { transform: scale(.94); filter: brightness(.8); } }
@keyframes sheet-down { to { transform: translateY(100%); } }
@keyframes settle { from { transform: scale(.96); filter: brightness(.85); } }

/* With cross-page view transitions (Safari 18.2+, Chrome) */
html[data-vt=reveal]::view-transition-old(root) { animation: recede .5s cubic-bezier(.3, .8, .3, 1) both; }
html[data-vt=reveal]::view-transition-new(root) { animation: reveal .5s cubic-bezier(.3, .8, .3, 1) both; }
html[data-vt=close]::view-transition-old(root) { animation: sheet-down .38s cubic-bezier(.5, 0, .7, .4) both; z-index: 2; }
html[data-vt=close]::view-transition-new(root) { animation: settle .45s cubic-bezier(.2, .8, .2, 1) both; }

/* Browsers without them (Firefox): animate the new page itself */
@supports not (view-transition-name: none) {
  html[data-vt=reveal] .app { animation: reveal .5s cubic-bezier(.3, .8, .3, 1) both; }
  html[data-vt=close] .app { animation: settle .4s cubic-bezier(.2, .8, .2, 1) both; }
}

/* The item you just added lights up in the diary */
@keyframes just-added {
  0% { background: var(--accent-soft); transform: scale(.97); }
  40% { background: var(--accent-soft); transform: scale(1); }
  100% { background: transparent; }
}
.swipe.just-added .item { animation: just-added 1.6s cubic-bezier(.2, .8, .2, 1) .35s both; }
.round.plusbtn { overflow: visible; }
