/* Calorigin — bubblegum + plum, Fraunces diva numerals, stickers only on things you can press. */
:root {
  --bg: #FFE3F0;
  --surface: #FFF6FA;
  --sunken: #FFEAF4;
  --ink: #3A0B2E;
  --ink-soft: #7B4A6C;
  --hot: #FF2D87;
  --hot-ink: #3A0B2E;
  --hot-text: #C2105F;
  --lilac: #B9A4FF;
  --butter: #FFE15A;
  --mint: #39C79A;
  --warn: #E5532A;
  --line: #F2BCD8;
  --shadow: #3A0B2E;
  --display: 'Fraunces', 'Georgia', serif;
  --body: 'Bricolage Grotesque', -apple-system, system-ui, sans-serif;
  --r-big: 28px;
  --r-mid: 18px;
  --r-small: 12px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #22091B; --surface: #33112A; --sunken: #2A0D22; --ink: #FFE3F0; --ink-soft: #D9A6C6;
    --hot: #FF4D9A; --hot-ink: #22091B; --hot-text: #FF8CC0; --lilac: #A48CFF; --butter: #FFD93D;
    --mint: #4ADBA9; --warn: #FF7A52; --line: #5A2149; --shadow: #0E030B;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #22091B; --surface: #33112A; --sunken: #2A0D22; --ink: #FFE3F0; --ink-soft: #D9A6C6;
  --hot: #FF4D9A; --hot-ink: #22091B; --hot-text: #FF8CC0; --lilac: #A48CFF; --butter: #FFD93D;
  --mint: #4ADBA9; --warn: #FF7A52; --line: #5A2149; --shadow: #0E030B;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--body);
  font-optical-sizing: auto;
  font-size: 1rem;
  font-weight: 420;
  line-height: 1.45;
  min-height: 100dvh;
  padding: env(safe-area-inset-top) 0 calc(112px + env(safe-area-inset-bottom));
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--lilac); outline-offset: 2px; border-radius: 6px; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
.wrap { max-width: 560px; margin: 0 auto; padding: 0 16px; }
.num { font-variant-numeric: lining-nums tabular-nums; }
.diva { font-family: var(--display); font-style: italic; font-weight: 800; font-variation-settings: "opsz" 144, "SOFT" 100, "WONK" 1; }

/* ---------- header ---------- */
.dayhead { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 0 0; }
.dayhead h1 { font-family: var(--display); font-style: italic; font-weight: 800; font-variation-settings: "opsz" 144, "SOFT" 100, "WONK" 1; font-size: 2rem; letter-spacing: -0.01em; line-height: 1.1; }
.dayhead .sub { color: var(--ink-soft); font-size: .875rem; }
.navbtn { width: 44px; height: 44px; border-radius: 50%; border: 2px solid var(--ink); background: var(--surface); font-size: 1.2rem; display: grid; place-items: center; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 999px; font-size: .75rem; font-weight: 700; background: var(--lilac); color: #22091B; }

/* ---------- hero: the one loud thing ---------- */
.hero { position: relative; display: grid; place-items: center; margin: 6px auto 0; width: min(60vw, 220px); aspect-ratio: 1; }
.hero svg { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.hero .track { stroke: var(--surface); }
.hero .rim { stroke: var(--ink); }
.hero .fill { stroke: var(--hot); stroke-linecap: round; }
.hero.over .fill { stroke: var(--warn); }
.hero-inner { position: relative; text-align: center; }
.hero-num {
  font-family: var(--display); font-style: italic; font-weight: 900;
  font-variation-settings: "opsz" 144, "SOFT" 100, "WONK" 1;
  font-variant-numeric: lining-nums; font-size: clamp(2.9rem, 15vw, 3.7rem); line-height: .9; letter-spacing: -0.03em;
  color: var(--hot); text-shadow: 2px 2px 0 var(--shadow); min-width: 4ch;
}
.hero.over .hero-num { color: var(--warn); }
.hero-cap { font-weight: 700; margin-top: 6px; font-size: .95rem; }
.hero-meta { color: var(--ink-soft); font-size: .8125rem; }
.sparkle { position: absolute; color: var(--butter); font-size: 1.5rem; text-shadow: 1px 1px 0 var(--shadow); pointer-events: none; }
.sparkle.a { top: 2%; right: 2%; } .sparkle.b { bottom: 8%; left: 0; font-size: 1rem; }
@media (prefers-reduced-motion: no-preference) {
  .celebrate .sparkle.a { animation: twinkle 1.6s ease-in-out 1; }
  .celebrate .hero .fill { animation: draw .9s cubic-bezier(.2,.8,.2,1); }
  @keyframes twinkle { 50% { transform: scale(1.5) rotate(30deg); } }
  @keyframes draw { from { stroke-dashoffset: var(--from); } }
}
.sass { text-align: center; font-style: italic; margin: 8px auto 16px; max-width: 32ch; font-size: 1rem; }

/* ---------- quick re-log ---------- */
.recent { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 10px; margin: 0 -16px 8px; padding-left: 16px; scrollbar-width: none; }
.recent::-webkit-scrollbar { display: none; }
.recent button { flex: none; min-height: 44px; border: 2px solid var(--ink); background: var(--surface); border-radius: 999px; padding: 8px 14px; font-weight: 650; font-size: .875rem; max-width: 70vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent button:active { transform: translate(1px, 1px); }

/* ---------- lipstick bars ---------- */
.bars { display: grid; gap: 12px; margin: 4px 0 18px; }
.bar-row { display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; align-items: baseline; }
.bar-row .name { font-weight: 700; }
.bar-row .val { font-variant-numeric: lining-nums tabular-nums; font-size: .875rem; color: var(--ink-soft); }
.bar { grid-column: 1 / -1; height: 10px; border: 2px solid var(--ink); border-radius: 3px 999px 999px 3px; background: var(--surface); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--hot); border-radius: 0 999px 999px 0; }
.bar.limit > i { background: var(--lilac); }
.bar.limit.over > i { background: var(--warn); }
.bar.goal.done > i { background: var(--mint); }
.bar-note { grid-column: 1 / -1; font-size: .75rem; color: var(--ink-soft); margin-top: -2px; }
details.more { margin: 0 0 18px; }
details.more summary { cursor: pointer; font-weight: 700; color: var(--hot-text); min-height: 44px; display: flex; align-items: center; list-style: none; }
details.more summary::-webkit-details-marker { display: none; }
details.more summary::after { content: '▾'; margin-left: 6px; transition: transform .2s; }
details.more[open] summary::after { transform: rotate(180deg); }

/* ---------- meals ---------- */
.meal { background: var(--surface); border: 1.5px solid var(--ink); border-radius: var(--r-mid); margin-bottom: 12px; overflow: hidden; }
.meal-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px 6px; }
.meal-head h2 { font-size: 1.125rem; font-weight: 750; letter-spacing: -0.01em; }
.meal-head .kc { font-variant-numeric: lining-nums tabular-nums; color: var(--ink-soft); font-size: .875rem; }
.item { display: grid; grid-template-columns: 1fr auto; gap: 0 10px; width: 100%; min-height: 56px; text-align: left; background: none; border: 0; border-top: 1px dashed var(--line); padding: 9px 14px; align-content: center; }
.item:active { background: var(--sunken); }
.item .t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .s { color: var(--ink-soft); font-size: .8125rem; }
.item .k { font-variant-numeric: lining-nums tabular-nums; font-weight: 750; align-self: center; grid-row: 1 / span 2; grid-column: 2; text-align: right; }
.item .k small { display: block; font-size: .7rem; font-weight: 500; color: var(--ink-soft); }
.addline { display: flex; align-items: center; width: 100%; min-height: 48px; text-align: left; background: none; border: 0; border-top: 1px dashed var(--line); padding: 0 14px; color: var(--hot-text); font-weight: 700; }

/* ---------- generic ---------- */
.page-title { font-family: var(--display); font-style: italic; font-weight: 800; font-variation-settings: "opsz" 144, "SOFT" 100, "WONK" 1; font-size: 2rem; letter-spacing: -0.01em; margin: 16px 0 12px; }
.section-title { font-size: 1.125rem; font-weight: 750; letter-spacing: -0.01em; margin: 20px 0 10px; }
.card { background: var(--surface); border: 1.5px solid var(--ink); border-radius: var(--r-mid); padding: 14px; margin-bottom: 14px; }
.card h3 { font-size: 1.125rem; font-weight: 750; letter-spacing: -0.01em; margin-bottom: 6px; }
.muted { color: var(--ink-soft); font-size: .875rem; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap-row { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 48px; border: 2px solid var(--ink); background: var(--hot); color: var(--hot-ink); font-weight: 800; padding: 10px 18px; border-radius: 999px; box-shadow: 3px 3px 0 var(--shadow); text-align: center; }
.btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--shadow); }
.btn.ghost { background: var(--surface); color: var(--ink); }
.btn.butter { background: var(--butter); color: #22091B; }
.btn.small { min-height: 44px; padding: 8px 16px; font-size: .9rem; }
.btn.block { display: flex; width: 100%; }
.btn.danger { background: var(--surface); color: var(--warn); border-color: var(--warn); box-shadow: none; }
.btn:disabled { opacity: .5; }
.linkbtn { background: none; border: 0; color: var(--hot-text); font-weight: 700; padding: 10px 0; min-height: 44px; }

label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-weight: 700; font-size: .875rem; margin-bottom: 4px; }
input[type=text], input[type=number], input[type=search], input[type=date], input[type=time], select, textarea {
  width: 100%; font-size: 16px; min-height: 46px; padding: 10px 13px; border: 2px solid var(--ink); border-radius: var(--r-small); background: var(--bg); color: var(--ink);
}
textarea { min-height: 120px; resize: vertical; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.seg { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.seg button { min-height: 44px; border: 2px solid var(--ink); background: var(--surface); border-radius: 999px; padding: 8px 16px; font-weight: 650; font-size: .9rem; }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
.opts { display: grid; gap: 8px; margin-bottom: 14px; }
.opt { text-align: left; border: 2px solid var(--ink); background: var(--surface); border-radius: var(--r-small); padding: 10px 12px; min-height: 56px; }
.opt b { display: block; }
.opt span { font-size: .85rem; color: var(--ink-soft); }
.opt[aria-pressed="true"] { background: var(--hot); color: var(--hot-ink); }
.opt[aria-pressed="true"] span { color: var(--hot-ink); }

.list { display: grid; border: 1.5px solid var(--ink); border-radius: var(--r-mid); background: var(--surface); overflow: hidden; }
.list .item:first-child { border-top: 0; }
.empty { text-align: center; padding: 28px 12px; color: var(--ink-soft); }
.empty b { display: block; font-family: var(--display); font-style: italic; font-weight: 800; font-size: 1.3rem; color: var(--ink); margin-bottom: 4px; }
.tag { font-size: .7rem; font-weight: 700; padding: 1px 7px; border-radius: 999px; background: var(--butter); color: #22091B; margin-left: 6px; vertical-align: 2px; white-space: nowrap; }
.tag.alarm { background: var(--warn); color: #fff; }

.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.stat { background: var(--sunken); border-radius: var(--r-small); padding: 10px; }
.stat b { display: block; font-size: 1.25rem; font-variant-numeric: lining-nums tabular-nums; }
.stat span { font-size: .8rem; color: var(--ink-soft); }

.supp { display: flex; align-items: center; gap: 12px; padding: 10px 14px; min-height: 56px; border-top: 1px dashed var(--line); width: 100%; background: none; border-left: 0; border-right: 0; border-bottom: 0; text-align: left; }
.list .supp:first-child { border-top: 0; }
.tick { width: 26px; height: 26px; border-radius: 8px; border: 2px solid var(--ink); display: grid; place-items: center; flex: none; font-weight: 900; }
.supp[aria-pressed="true"] .tick { background: var(--mint); }
.supp[aria-pressed="true"] .st { text-decoration: line-through; opacity: .6; }
.supp .time { font-variant-numeric: lining-nums tabular-nums; font-weight: 750; width: 3.2em; flex: none; }

.spark { width: 100%; height: 90px; }
.spark .ln { stroke: var(--hot); fill: none; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.spark .dot { fill: var(--ink); }
.spark .area { fill: var(--hot); opacity: .12; }

/* ---------- tab bar ---------- */
.tabbar {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(10px + env(safe-area-inset-bottom));
  width: min(calc(100% - 24px), 520px); display: grid; grid-template-columns: 1fr 1fr auto 1fr 1fr; align-items: center; gap: 2px;
  background: var(--ink); border-radius: 999px; padding: 6px; box-shadow: 0 5px 0 var(--shadow); z-index: 20;
}
.tab { min-height: 48px; background: none; border: 0; color: var(--bg); opacity: .72; font-size: .6875rem; font-weight: 650; display: grid; justify-items: center; align-content: center; gap: 1px; padding: 4px 2px; border-radius: 999px; }
.tab svg { width: 22px; height: 22px; }
.tab span { max-width: 9ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tab[aria-current="page"] { background: var(--butter); color: #22091B; opacity: 1; }
.fab { width: 60px; height: 60px; border-radius: 50%; margin: -22px 6px 0; background: var(--hot); color: var(--hot-ink); border: 3px solid var(--ink); box-shadow: 3px 3px 0 var(--shadow); display: grid; place-items: center; }
.fab svg { width: 28px; height: 28px; }
.fab:active { transform: translate(2px, 2px); box-shadow: none; }
.onb .tabbar { display: none; }
.onb { padding-bottom: 32px; }

/* ---------- sheet ---------- */
.backdrop { position: fixed; inset: 0; background: rgba(34, 9, 27, .45); z-index: 40; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; max-height: 92dvh; overflow: auto; overscroll-behavior: contain;
  background: var(--bg); border-top: 3px solid var(--ink); border-radius: var(--r-big) var(--r-big) 0 0;
  padding: 10px 16px calc(24px + env(safe-area-inset-bottom)); max-width: 640px; margin: 0 auto;
}
@media (prefers-reduced-motion: no-preference) {
  .sheet { animation: up .26s cubic-bezier(.2,.8,.2,1); }
  @keyframes up { from { transform: translateY(40px); opacity: 0; } }
}
.grab { width: 44px; height: 5px; border-radius: 9px; background: var(--line); margin: 0 auto 10px; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; }
.sheet-head h2 { font-family: var(--display); font-style: italic; font-weight: 800; font-variation-settings: "opsz" 144, "SOFT" 100, "WONK" 1; font-size: 1.5rem; line-height: 1.15; overflow-wrap: anywhere; }
.close { width: 44px; height: 44px; border-radius: 50%; border: 2px solid var(--ink); background: var(--surface); font-size: 1.05rem; flex: none; display: grid; place-items: center; }
.modes { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin-bottom: 14px; }
.modes button { min-height: 64px; border: 2px solid var(--ink); background: var(--surface); border-radius: var(--r-small); padding: 6px 2px; font-size: .72rem; font-weight: 700; display: grid; justify-items: center; align-content: center; gap: 3px; }
.modes svg { width: 22px; height: 22px; }
.modes button[aria-pressed="true"] { background: var(--butter); color: #22091B; }
#reader { width: 100%; border-radius: var(--r-mid); overflow: hidden; border: 2px solid var(--ink); background: #000; min-height: 220px; margin-bottom: 12px; }
.progress { padding: 14px; border: 2px dashed var(--ink); border-radius: var(--r-small); text-align: center; font-weight: 600; margin-bottom: 12px; }
.preview { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 4px 0 14px; }
.preview div { background: var(--surface); border-radius: var(--r-small); padding: 8px; text-align: center; }
.preview b { display: block; font-variant-numeric: lining-nums tabular-nums; }
.preview span { font-size: .75rem; color: var(--ink-soft); }
.nut-grid { display: grid; grid-template-columns: 1fr 112px; gap: 6px 10px; align-items: center; margin-bottom: 14px; }
.nut-grid .sub { padding-left: 14px; color: var(--ink-soft); }
.nut-grid input { padding: 8px 10px; text-align: right; font-variant-numeric: lining-nums tabular-nums; }
.nut-grid .miss input { border-color: var(--warn); border-style: dashed; }
.hint { background: var(--butter); color: #22091B; border-radius: var(--r-small); padding: 10px 12px; font-size: .875rem; margin-bottom: 12px; border: 2px solid var(--ink); }
.hint .close { width: 36px; height: 36px; background: transparent; border-color: #22091B; color: #22091B; }
.secret { -webkit-text-security: disc; }

#toast { position: fixed; left: 50%; bottom: calc(100px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px); opacity: 0; background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 999px; font-weight: 700; z-index: 60; pointer-events: none; transition: .25s; max-width: calc(100% - 32px); text-align: center; }
#toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- wordmark / onboarding ---------- */
.wordmark {
  font-family: var(--display); font-style: italic; font-weight: 900; font-variation-settings: "opsz" 144, "SOFT" 100, "WONK" 1;
  font-size: 3rem; letter-spacing: -0.02em; line-height: 1; color: var(--hot);
  -webkit-text-stroke: 1.5px var(--ink); text-shadow: 3px 3px 0 var(--ink); margin: 28px 0 12px;
}
.wordmark .star { color: var(--butter); -webkit-text-stroke: 1px var(--ink); font-size: .5em; vertical-align: super; margin-left: 2px; }
.onb-lead { font-size: 1.05rem; margin-bottom: 20px; max-width: 34ch; }
