@font-face { font-family: "Nunito"; src: url("/fonts/nunito-latin-wght-normal.woff2") format("woff2"); font-weight: 200 1000; font-display: swap; }

:root {
  color-scheme: light;
  --bg: #ffffff;
  --card: #ffffff;
  --soft: #f4f6f8;
  --line: #e4e8ec;
  --track: #e9ecf0;
  --ink: #2b3440;
  --muted: #6b7684;
  --brand: #0b9e73;
  --brand-edge: #077a58;
  --brand-soft: #e2f7ef;
  --gold: #ffb020;
  --gold-ink: #a86a00;
  --gold-soft: #fff4dc;
  --flame: #ff7a2f;
  --protein: #2f80ed;
  --carbs: #8f5bff;
  --fat: #ff8a1f;
  --rose: #e8384f;
  --rose-soft: #ffe8eb;
  --tabs-h: 68px;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #131b22;
    --card: #1a242d;
    --soft: #222e38;
    --line: #33424f;
    --track: #33424f;
    --ink: #f0f4f7;
    --muted: #a3b0bb;
    --brand: #12b886;
    --brand-edge: #0b8a64;
    --brand-soft: #173a30;
    --gold-ink: #ffc65c;
    --gold-soft: #3a2f17;
    --rose-soft: #40222a;
    --protein: #58a0f5;
    --carbs: #a884ff;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { background: var(--bg); }
body { margin: 0; min-height: 100dvh; color: var(--ink); background: var(--bg); font: 600 16px/1.4 "Nunito", -apple-system, system-ui, sans-serif; overscroll-behavior-y: none; font-variant-numeric: tabular-nums; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 26px; font-weight: 900; line-height: 1.15; }
h2 { font-size: 19px; font-weight: 900; line-height: 1.2; }
a { color: var(--brand); }
:focus-visible { outline: 3px solid var(--protein); outline-offset: 2px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.ico { width: 1em; height: 1em; display: block; flex: none; }
.muted { color: var(--muted); }
.small { font-size: 14px; }

#screen { max-width: 520px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 10px) 16px calc(var(--tabs-h) + env(safe-area-inset-bottom) + 24px); display: flex; flex-direction: column; gap: 14px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 8px; }

.card { background: var(--card); border: 2px solid var(--line); border-radius: 18px; padding: 16px; }

/* Buttons press down into their bottom edge */
.btn { --edge: var(--line); position: relative; border: 2px solid var(--line); border-bottom-width: 5px; border-radius: 15px; min-height: 50px; padding: 9px 16px; background: var(--card); color: var(--ink); font-size: 16px; font-weight: 900; display: inline-flex; align-items: center; justify-content: center; gap: 8px; transition: transform .06s, border-bottom-width .06s; }
.btn:active { transform: translateY(3px); border-bottom-width: 2px; margin-bottom: 3px; }
.btn.primary { background: var(--brand); border-color: var(--brand-edge); color: #fff; }
.btn.gold { background: var(--gold); border-color: #d98e00; color: #3d2600; }
.btn.danger { color: var(--rose); }
.btn.slim { min-height: 42px; padding: 6px 12px; font-size: 14px; }
.btn.wide { display: flex; width: 100%; }
.btn[disabled] { opacity: .45; }
.btn .ico { font-size: 20px; }
.btn-row { display: flex; gap: 10px; }
.btn-row .btn { flex: 1 1 0; }
.icon-btn { border: 0; background: transparent; width: 44px; height: 44px; color: var(--muted); font-size: 24px; font-weight: 800; flex: none; display: grid; place-items: center; border-radius: 12px; }
.icon-btn:active { background: var(--soft); }

/* Progress bars */
.bar { height: 14px; border-radius: 99px; background: var(--track); overflow: hidden; }
.bar > i { display: block; height: 100%; min-width: 0; border-radius: 99px; background: var(--c, var(--brand)); position: relative; transition: width .5s cubic-bezier(.2,.9,.3,1.2); }
.bar > i::after { content: ""; position: absolute; left: 7px; right: 7px; top: 3px; height: 3px; border-radius: 9px; background: rgba(255,255,255,.4); }

/* Top stats */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 40px; }
.stat-pill { display: flex; align-items: center; gap: 5px; font-size: 18px; font-weight: 900; }
.stat-pill .ico { font-size: 24px; }
.stat-pill.flame { color: var(--flame); } .stat-pill.flame.cold { color: var(--muted); }
.stat-pill.bolt { color: var(--gold-ink); } .stat-pill.bolt .ico { color: var(--gold); }
.stat-pill.level { color: var(--brand); }
.stat-pill.level .ico { color: var(--brand); }

/* Character */
.buddy-card { display: flex; flex-direction: column; gap: 12px; }
.buddy-row { display: flex; align-items: flex-end; gap: 10px; }
.buddy-art { width: 112px; flex: none; }
.buddy { width: 100%; height: auto; display: block; overflow: visible; }
.buddy-body { transform-origin: 100px 196px; animation: breathe 2.6s ease-in-out infinite; }
.eyes { transform-origin: 100px 120px; animation: blink 4.6s infinite; }
.aura { transform-origin: 100px 108px; animation: pulse 2.6s ease-in-out infinite; }
.buddy.cheer .arm-l, .buddy.cheer .arm-r { transform-origin: 100px 120px; }
@keyframes breathe { 50% { transform: scale(1.025, .97); } }
@keyframes blink { 0%, 95%, 100% { transform: scaleY(1); } 97.500% { transform: scaleY(.08); } }
@keyframes pulse { 50% { transform: scale(1.06); opacity: .16; } }
.speech { position: relative; flex: 1; min-width: 0; margin-bottom: 26px; padding: 11px 14px; border: 2px solid var(--line); border-radius: 16px; font-size: 15px; font-weight: 800; background: var(--card); }
.speech::after { content: ""; position: absolute; left: -9px; bottom: 16px; width: 14px; height: 14px; background: var(--card); border-left: 2px solid var(--line); border-bottom: 2px solid var(--line); transform: rotate(45deg); }
.level-line { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 6px; }
.level-line b { font-weight: 900; font-size: 17px; }
.buddy-name { overflow-wrap: anywhere; }

/* Fuel: the calorie sum and rings */
.fuel { display: flex; align-items: center; gap: 16px; }
.ring { position: relative; width: 124px; height: 124px; flex: none; }
.ring svg { width: 100%; height: 100%; display: block; }
.ring-fill { transition: stroke-dasharray .6s cubic-bezier(.2,.9,.3,1.1); }
.ring-inner { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; line-height: 1.05; }
.ring-inner b { font-size: 26px; font-weight: 900; }
.ring-inner span { font-size: 12px; color: var(--muted); font-weight: 800; }
.sum { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.sum div { display: flex; justify-content: space-between; gap: 8px; font-weight: 800; }
.sum span { color: var(--muted); }
.macros { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 16px; }
.macro b { display: flex; justify-content: space-between; align-items: center; font-weight: 900; font-size: 14px; color: var(--c); margin-bottom: 5px; gap: 4px; }
.macro b .ico { font-size: 15px; }
.macro .bar { height: 10px; }
.macro .bar > i::after { display: none; }
.macro small { display: block; font-size: 12.500px; color: var(--muted); font-weight: 700; margin-top: 4px; }

/* Quests */
.quest { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 2px solid var(--soft); }
.quest:first-child { border-top: 0; padding-top: 0; }
.quest:last-child { padding-bottom: 0; }
.quest-ico { width: 44px; height: 44px; flex: none; border-radius: 13px; display: grid; place-items: center; font-size: 25px; background: color-mix(in srgb, var(--c) 16%, transparent); color: var(--c); }
.quest.done .quest-ico { background: var(--brand); color: #fff; }
.quest-main { flex: 1; min-width: 0; }
.quest-main b { display: block; font-weight: 800; margin-bottom: 5px; }
.quest-bar { position: relative; }
.quest-bar .bar { height: 18px; }
.quest-bar em { position: absolute; inset: 0; display: grid; place-items: center; font-style: normal; font-size: 12px; font-weight: 900; color: var(--ink); }
.quest.done .quest-bar em { color: #fff; }
.quest-xp { display: flex; align-items: center; gap: 2px; font-weight: 900; font-size: 15px; color: var(--gold-ink); white-space: nowrap; }
.quest-xp .ico { color: var(--gold); font-size: 17px; }
.quest.done .quest-xp { color: var(--brand); }

/* Boss */
.boss { display: flex; gap: 14px; align-items: center; }
.boss-art { width: 86px; flex: none; }
.boss-art svg { width: 100%; height: auto; display: block; }
.boss:not(.defeated) .boss-art { animation: wobble 1.8s ease-in-out infinite; }
.boss.defeated .boss-art { opacity: .55; filter: grayscale(.7); }
@keyframes wobble { 25% { transform: rotate(-3deg); } 75% { transform: rotate(3deg); } }
.boss-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.eyebrow { font-size: 13px; font-weight: 900; color: var(--rose); }
.boss.defeated .eyebrow { color: var(--brand); }

/* Diary */
.day-nav { display: flex; align-items: center; justify-content: space-between; }
.day-nav h1 { text-align: center; flex: 1; }
.equation { display: grid; grid-template-columns: 1fr auto 1fr auto 1fr; align-items: center; text-align: center; gap: 4px; }
.equation b { display: block; font-size: 22px; font-weight: 900; line-height: 1.1; }
.equation span { font-size: 12px; font-weight: 800; color: var(--muted); }
.equation i { font-style: normal; font-size: 20px; font-weight: 900; color: var(--muted); }
.equation .left b { color: var(--brand); } .equation .left.over b { color: var(--rose); }
.meal-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.meal-kcal { font-weight: 900; color: var(--muted); }
.entry { display: flex; align-items: center; gap: 6px; padding: 9px 0; border-top: 2px solid var(--soft); }
.entry-main { flex: 1; min-width: 0; }
.entry-main b { display: block; font-weight: 800; overflow-wrap: anywhere; line-height: 1.25; }
.entry-kcal { font-weight: 900; white-space: nowrap; }
.entry .icon-btn { margin-right: -10px; }
.card > .entry:first-child { border-top: 0; padding-top: 0; }
.add-link { margin-top: 8px; border: 0; background: none; padding: 8px 0 0; min-height: 40px; display: flex; align-items: center; gap: 6px; font-weight: 900; color: var(--brand); width: 100%; border-top: 2px solid var(--soft); }
.empty { color: var(--muted); font-size: 14.500px; padding: 8px 0 4px; }

/* Gym */
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; }
.tiles b { display: block; font-size: 25px; font-weight: 900; color: var(--c, var(--ink)); line-height: 1.1; }
.tiles span { font-size: 12.500px; font-weight: 700; color: var(--muted); line-height: 1.2; display: block; }
.goal { display: flex; flex-direction: column; gap: 6px; padding: 12px 0; border-top: 2px solid var(--soft); }
.goal:first-child { border-top: 0; padding-top: 0; }
.goal:last-child { padding-bottom: 0; }
.goal-top { display: flex; align-items: center; gap: 6px; }
.goal-top b { flex: 1; font-weight: 800; overflow-wrap: anywhere; }
.goal-top .icon-btn { margin: -6px -10px -6px 0; }

/* Character page */
.hero-top { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px; }
.hero-top .buddy-art { width: 150px; }
.hero-top h1 { overflow-wrap: anywhere; }
.rank { color: var(--brand); font-weight: 900; }
.stat { display: flex; flex-direction: column; gap: 5px; padding: 11px 0; border-top: 2px solid var(--soft); }
.stat:first-child { border-top: 0; padding-top: 0; }
.stat:last-child { padding-bottom: 0; }
.stat-top { display: flex; justify-content: space-between; gap: 8px; }
.stat-top b { font-weight: 900; }
.stat-top em { font-style: normal; font-weight: 900; color: var(--c); }
.road { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 4px 0; }
.road-step { display: flex; flex-direction: column; align-items: center; gap: 4px; transform: translateX(var(--x)); }
.node { width: 62px; height: 56px; border-radius: 50%; display: grid; place-items: center; font-size: 26px; font-weight: 900; background: var(--track); color: var(--muted); box-shadow: 0 6px 0 var(--line); }
.road-step.done .node { background: var(--gold); color: #3d2600; box-shadow: 0 6px 0 #d98e00; }
.road-step.now .node { background: var(--brand); color: #fff; box-shadow: 0 6px 0 var(--brand-edge), 0 0 0 5px var(--brand-soft), 0 6px 0 5px var(--brand-soft); }
.road-step .ev { width: 62px; }
.road-label { font-size: 13px; font-weight: 800; color: var(--muted); margin-top: 6px; }
.road-step.now .road-label { color: var(--brand); }
.badges { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.badge { padding: 12px; border: 2px solid var(--line); border-radius: 16px; display: flex; flex-direction: column; gap: 2px; align-items: flex-start; }
.badge .ico { font-size: 26px; color: var(--muted); margin-bottom: 2px; }
.badge b { font-weight: 900; line-height: 1.2; color: var(--muted); }
.badge span { font-size: 13px; color: var(--muted); line-height: 1.25; font-weight: 700; }
.badge.got { background: var(--gold-soft); border-color: var(--gold); }
.badge.got .ico { color: var(--gold); }
.badge.got b { color: var(--ink); }

/* Forms */
label.field { display: flex; flex-direction: column; gap: 5px; font-size: 14px; font-weight: 800; color: var(--muted); }
/* 16px stops iPhone Safari zooming in when a field gets focus */
input[type="text"], input[type="number"], input[type="search"], input[type="password"], input[type="date"], select { width: 100%; min-height: 50px; padding: 10px 14px; font-size: 16px; font-weight: 700; color: var(--ink); background: var(--soft); border: 2px solid var(--line); border-radius: 14px; appearance: none; -webkit-appearance: none; }
input:focus, select:focus { outline: none; border-color: var(--brand); }
.form { display: flex; flex-direction: column; gap: 12px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.seg { display: grid; grid-template-columns: repeat(var(--n, 4), minmax(0, 1fr)); gap: 6px; }
.seg button { min-height: 44px; padding: 5px 4px; border: 2px solid var(--line); border-bottom-width: 4px; border-radius: 12px; background: var(--card); color: var(--muted); font-size: 14px; font-weight: 900; }
.seg button.on { background: var(--brand-soft); border-color: var(--brand); color: var(--brand); }
.result { width: 100%; display: flex; align-items: center; gap: 10px; text-align: left; padding: 10px 0; min-height: 56px; border: 0; border-top: 2px solid var(--soft); background: none; }
.result-main { flex: 1; min-width: 0; }
.result-main b { display: block; font-weight: 800; overflow-wrap: anywhere; line-height: 1.25; }
.subhead { font-weight: 900; margin-top: 12px; }

/* Sheets */
.sheet-back { position: fixed; inset: 0; z-index: 30; background: rgba(15,22,28,.5); display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 520px; max-height: 92dvh; overflow-y: auto; -webkit-overflow-scrolling: touch; background: var(--card); border-radius: 24px 24px 0 0; padding: 12px 16px calc(env(safe-area-inset-bottom) + 20px); display: flex; flex-direction: column; gap: 12px; animation: rise .22s cubic-bezier(.2,.9,.3,1); }
@keyframes rise { from { transform: translateY(70px); opacity: .4; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 44px; }
.sheet-head .icon-btn { margin-right: -10px; }

/* Scan */
.scan-box { position: relative; overflow: hidden; border-radius: 16px; background: var(--soft); }
.scan-box img { display: block; width: 100%; max-height: 240px; object-fit: cover; }
.scan-line { position: absolute; left: 0; right: 0; height: 4px; border-radius: 4px; background: #fff; box-shadow: 0 0 18px 6px var(--brand); animation: scan 1.4s ease-in-out infinite alternate; }
@keyframes scan { from { top: 4%; } to { top: 94%; } }
.scan-item { padding: 11px 0; border-top: 2px solid var(--soft); display: flex; flex-direction: column; gap: 8px; }
.scan-item .goal-top .icon-btn { margin: -6px -10px -6px 0; }
.conf { font-size: 12px; font-weight: 900; padding: 2px 9px; border-radius: 99px; text-transform: capitalize; }
.conf.low { color: var(--rose); background: var(--rose-soft); } .conf.medium { color: var(--gold-ink); background: var(--gold-soft); } .conf.high { color: var(--brand); background: var(--brand-soft); }
.notice { padding: 11px 13px; background: var(--soft); border-radius: 14px; font-size: 14px; font-weight: 700; }
.notice.error { background: var(--rose-soft); color: var(--rose); }

/* Tabs */
#tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; justify-content: center; background: var(--card); border-top: 2px solid var(--line); padding: 0 6px env(safe-area-inset-bottom); }
#tabs[hidden] { display: none; }
.tab { flex: 1; max-width: 100px; height: var(--tabs-h); border: 0; background: none; color: var(--muted); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; font-size: 12px; font-weight: 900; }
.tab .tile { width: 48px; height: 34px; border-radius: 11px; display: grid; place-items: center; font-size: 25px; }
.tab.on { color: var(--brand); }
.tab.on .tile { background: var(--brand-soft); }
.tab.scan { color: var(--brand); }
.tab.scan .disc { width: 60px; height: 58px; margin-top: -24px; border-radius: 19px; background: var(--brand); color: #fff; display: grid; place-items: center; font-size: 31px; border-bottom: 5px solid var(--brand-edge); box-shadow: 0 0 0 4px var(--card); transition: transform .06s; }
.tab.scan:active .disc { transform: translateY(3px); border-bottom-width: 2px; }

/* Toasts */
#toasts { position: fixed; left: 0; right: 0; top: calc(env(safe-area-inset-top) + 10px); z-index: 60; display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; padding: 0 16px; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 10px; padding: 9px 15px; border-radius: 14px; background: var(--ink); color: var(--bg); font-weight: 800; font-size: 15px; box-shadow: 0 8px 24px rgba(0,0,0,.25); animation: pop .28s cubic-bezier(.2,1.5,.4,1); }
.toast.xp { background: var(--gold); color: #3d2600; font-weight: 900; }
.toast.quest { background: var(--brand); color: #fff; }
.toast button { border: 0; background: none; color: inherit; text-decoration: underline; font-weight: 900; min-height: 34px; padding: 0 2px; }
@keyframes pop { from { transform: scale(.7); opacity: 0; } }

/* Level up */
.levelup { position: fixed; inset: 0; z-index: 50; background: var(--bg); display: grid; place-items: center; padding: 24px; text-align: center; overflow: hidden; }
.levelup-box { display: flex; flex-direction: column; align-items: center; gap: 10px; width: 100%; max-width: 340px; animation: pop .4s cubic-bezier(.2,1.5,.4,1); position: relative; }
.levelup .buddy-art { width: 190px; }
.levelup h2 { font-size: 40px; color: var(--gold-ink); line-height: 1; }
.levelup .btn { margin-top: 12px; }
.confetti { position: absolute; top: -20px; width: 10px; height: 16px; border-radius: 3px; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }

/* Welcome */
.welcome-top { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 6px; padding-top: 8px; }
.welcome-top .buddy-art { width: 130px; }
.welcome-top h1 { font-size: 34px; color: var(--brand); }

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