@font-face { font-family: 'Jakarta'; src: url('/fonts/jakarta.woff2') format('woff2'); font-weight: 200 800; font-display: swap; }
:root {
  --bg: #110e18; --bg2: #171222; --card: #1d1829; --card-hi: #241e33; --card2: #2a2339; --line: rgba(255,255,255,.07); --line2: rgba(255,255,255,.12);
  --text: #f4f0fa; --muted: #aaa1bd; --faint: #6f6785;
  --accent: #b69cff; --accent2: #8f6bff; --accent-ink: #170f2b; --gold: #e8c66a; --gold2: #b8913a;
  --good: #0aac23; --warn: #fbb315; --bad: #dc3c3d;
  --carb: #e8c66a; --protein: #6fc3ff; --fat: #ff8fb1; --kcal: #b69cff;
  --r: 20px; --r-sm: 14px; --safe-b: env(safe-area-inset-bottom, 0px);
  --shadow: 0 1px 0 rgba(255,255,255,.04) inset, 0 10px 30px -12px rgba(0,0,0,.6);
  --ease: cubic-bezier(.2,.8,.2,1);
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { background: var(--bg); }
body { margin: 0; color: var(--text); font: 16px/1.45 'Jakarta', system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; letter-spacing: -.005em;
  background: radial-gradient(1200px 500px at 50% -180px, rgba(143,107,255,.22), transparent 70%), radial-gradient(600px 300px at 100% 0, rgba(232,198,106,.07), transparent 70%), var(--bg);
  background-attachment: fixed; min-height: 100vh; padding-bottom: calc(84px + var(--safe-b)); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
a { color: var(--accent); text-decoration: none; }
::selection { background: rgba(182,156,255,.35); }
.boot { padding: 42vh 0; text-align: center; color: var(--muted); }
#app { max-width: 720px; margin: 0 auto; padding: 14px 16px 28px; animation: viewIn .28s var(--ease); }
@keyframes viewIn { from { opacity: 0; transform: translateY(6px); } }
h1 { font-size: 1.7rem; font-weight: 800; letter-spacing: -.03em; margin: 8px 0 14px; }
h2 { font-size: .78rem; margin: 22px 4px 8px; color: var(--muted); font-weight: 700; letter-spacing: .09em; text-transform: uppercase; }
h3 { font-size: 1.02rem; font-weight: 700; margin: 0 0 6px; letter-spacing: -.01em; }
.muted { color: var(--muted); } .faint { color: var(--faint); } .small { font-size: .85rem; } .tiny { font-size: .75rem; }
.row { display: flex; gap: 8px; align-items: center; } .row.wrap { flex-wrap: wrap; } .grow { flex: 1; min-width: 0; }
.between { justify-content: space-between; } .center { text-align: center; } .right { text-align: right; }
.stack > * + * { margin-top: 10px; }
code { background: var(--card2); padding: 3px 8px; border-radius: 8px; font-size: .85rem; word-break: break-all; }

/* cards */
.card { background: linear-gradient(180deg, var(--card-hi), var(--card)); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; margin: 12px 0; box-shadow: var(--shadow); }
.card.flat { background: transparent; box-shadow: none; }
.card.hero { position: relative; border: 1px solid transparent;
  background: linear-gradient(160deg, #2a2140, #1b1628 60%) padding-box,
              linear-gradient(var(--rim-angle, 135deg), rgba(232,198,106,.85), rgba(182,156,255,.35) 35%, rgba(255,255,255,.05) 60%, rgba(232,198,106,.5)) border-box;
  animation: rim 9s linear infinite; }
@property --rim-angle { syntax: '<angle>'; initial-value: 135deg; inherits: false; }
@keyframes rim { to { --rim-angle: 495deg; } }
@media (prefers-reduced-motion: reduce) { .card.hero, #app { animation: none; } }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
@media (max-width: 380px) { .grid4 { grid-template-columns: repeat(2, 1fr); } }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line2); background: var(--card2);
  border-radius: 14px; padding: 10px 16px; cursor: pointer; min-height: 46px; color: var(--text); font-weight: 600; font-size: .95rem;
  transition: transform .12s var(--ease), background .2s, box-shadow .2s, border-color .2s; }
.btn:hover { border-color: rgba(182,156,255,.35); }
.btn:active { transform: scale(.97); }
.btn.primary { background: linear-gradient(180deg, #c7b3ff, var(--accent2)); color: var(--accent-ink); border-color: transparent; font-weight: 700;
  box-shadow: 0 8px 22px -10px rgba(143,107,255,.9), 0 1px 0 rgba(255,255,255,.4) inset; }
.btn.danger { color: #ffb3b3; border-color: rgba(220,60,61,.4); background: rgba(220,60,61,.08); }
.btn.ghost { background: transparent; border-color: var(--line); }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: .88rem; border-radius: 11px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.iconbtn { background: none; border: 0; padding: 8px; min-width: 42px; min-height: 42px; cursor: pointer; color: var(--muted); border-radius: 12px; font-size: 1.05rem;
  display: inline-flex; align-items: center; justify-content: center; transition: background .15s; }
.iconbtn:hover, .iconbtn:active { background: var(--card2); color: var(--text); }
.ico { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* forms */
label.field { display: block; margin: 10px 0; }
label.field > span { display: block; font-size: .8rem; font-weight: 600; color: var(--muted); margin: 0 0 5px 2px; }
input[type=text], input[type=number], input[type=password], input[type=search], input[type=date], input[type=time], input[type=datetime-local], select, textarea {
  width: 100%; background: rgba(8,6,13,.55); border: 1px solid var(--line2); border-radius: 13px; padding: 11px 13px; min-height: 46px;
  transition: border-color .15s, box-shadow .15s; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px rgba(182,156,255,.18); }
input::placeholder, textarea::placeholder { color: var(--faint); }
input[type=search] { padding-left: 40px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23857c9b' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-size: 18px; background-position: 13px center; }
textarea { min-height: 90px; resize: vertical; }
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23aaa1bd' stroke-width='2.2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-size: 16px; background-position: right 12px center; padding-right: 36px; }
.check { display: flex; gap: 12px; align-items: center; padding: 8px 0; cursor: pointer; }
.check input { width: 22px; height: 22px; accent-color: var(--accent2); }
.seg { display: flex; background: rgba(8,6,13,.5); border: 1px solid var(--line); border-radius: 15px; padding: 4px; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.seg::-webkit-scrollbar { display: none; }
.seg button { flex: 1; border: 0; background: none; padding: 8px 12px; border-radius: 11px; cursor: pointer; color: var(--muted); white-space: nowrap; min-height: 38px; font-weight: 600; font-size: .9rem; transition: background .2s, color .2s; }
.seg button.on { background: var(--card2); color: var(--text); box-shadow: 0 2px 8px rgba(0,0,0,.3); }

/* bottom tabs */
#tabs { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(10px + var(--safe-b)); width: min(560px, calc(100% - 20px));
  background: rgba(28,23,40,.82); backdrop-filter: blur(18px) saturate(1.4); -webkit-backdrop-filter: blur(18px) saturate(1.4);
  border: 1px solid var(--line2); border-radius: 22px; display: flex; padding: 6px; z-index: 20; box-shadow: 0 12px 40px -8px rgba(0,0,0,.7); }
#tabs a { flex: 1; text-align: center; padding: 7px 0 6px; color: var(--faint); font-size: .68rem; font-weight: 600; border-radius: 16px; transition: color .2s, background .2s;
  display: flex; flex-direction: column; align-items: center; gap: 2px; }
#tabs a .ico { width: 23px; height: 23px; }
#tabs a.on { color: var(--text); background: rgba(182,156,255,.16); }
#tabs a.on .ico { color: var(--accent); }

/* Today header */
.hello { display: flex; align-items: flex-end; justify-content: space-between; margin: 6px 2px 4px; }
.hello .greet { font-size: .9rem; color: var(--muted); font-weight: 600; }
.hello h1 { margin: 0; }
.dayhead { display: flex; align-items: center; gap: 4px; }
.dayhead .when { font-size: .85rem; color: var(--muted); font-weight: 600; min-width: 92px; text-align: center; }

/* hero summary */
.hero-grid { display: grid; grid-template-columns: auto 1fr; gap: 18px; align-items: center; }
.ring { position: relative; width: 136px; height: 136px; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring .track { stroke: rgba(255,255,255,.07); }
.ring .val { transition: stroke-dashoffset .8s var(--ease); filter: drop-shadow(0 0 6px rgba(182,156,255,.45)); }
.ring .mid { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ring .mid b { font-size: 1.75rem; font-weight: 800; letter-spacing: -.03em; font-variant-numeric: tabular-nums; line-height: 1; }
.ring .mid span { font-size: .72rem; color: var(--muted); font-weight: 600; margin-top: 3px; }
.macros { display: grid; gap: 11px; }
.macro-row .top { display: flex; justify-content: space-between; font-size: .82rem; font-weight: 600; }
.macro-row .top span:last-child { color: var(--muted); font-variant-numeric: tabular-nums; }
.macro-row .top b { color: var(--text); }
.eq { display: flex; justify-content: space-between; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); font-size: .78rem; color: var(--muted); text-align: center; }
.eq b { display: block; color: var(--text); font-size: .98rem; font-variant-numeric: tabular-nums; }
@media (max-width: 360px) { .hero-grid { grid-template-columns: 1fr; justify-items: center; } .macros { width: 100%; } }

.big { font-size: 2rem; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; letter-spacing: -.03em; }
.stat { background: rgba(255,255,255,.035); border: 1px solid var(--line); border-radius: 16px; padding: 11px 12px; }
.stat .v { font-size: 1.35rem; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.stat .l { font-size: .74rem; color: var(--muted); font-weight: 600; }
.bar { height: 7px; background: rgba(255,255,255,.07); border-radius: 6px; overflow: hidden; margin-top: 6px; }
.bar > i { display: block; height: 100%; border-radius: 6px; background: var(--accent); transition: width .7s var(--ease); }
.bar.over > i { background: var(--warn) !important; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; }

/* quick actions */
.quick { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 8px; margin: 12px 0; }
.qbtn { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 4px 10px; border-radius: 18px; border: 1px solid var(--line);
  background: linear-gradient(180deg, var(--card-hi), var(--card)); cursor: pointer; font-size: .8rem; font-weight: 600; color: var(--text); transition: transform .12s var(--ease), border-color .2s; }
.qbtn:active { transform: scale(.96); }
.qbtn:hover { border-color: var(--line2); }
.qbtn .bub { width: 40px; height: 40px; border-radius: 13px; display: grid; place-items: center; }
.qbtn .bub .ico { width: 21px; height: 21px; }

/* lists */
.list { list-style: none; margin: 0; padding: 0; }
.item { display: flex; align-items: center; gap: 12px; padding: 11px 4px; border-top: 1px solid var(--line); cursor: pointer; border-radius: 10px; transition: background .15s; }
.item:first-child { border-top: 0; }
.item:hover { background: rgba(255,255,255,.025); }
.item .main { flex: 1; min-width: 0; }
.item .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; font-size: .95rem; }
.item .sub { font-size: .8rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.item .num b { display: block; font-weight: 700; }
.mealhead { display: flex; align-items: center; gap: 12px; margin-bottom: 4px; }
.mealhead .mi { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; font-size: 1.2rem; flex: none; }
.mealhead h3 { margin: 0; }
.mealhead .meta { font-size: .8rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.mealhead .carbs { margin-left: auto; text-align: right; }
.mealhead .carbs b { font-size: 1.1rem; display: block; font-variant-numeric: tabular-nums; }
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 99px; font-size: .78rem; font-weight: 600; background: var(--card2); color: var(--muted); border: 1px solid var(--line); }
.pill.good { color: #8ef09c; background: rgba(10,172,35,.12); border-color: rgba(10,172,35,.35); }
.pill.warn { color: #ffd77a; background: rgba(251,179,21,.1); border-color: rgba(251,179,21,.35); }
.pill.bad { color: #ffb0b0; background: rgba(220,60,61,.12); border-color: rgba(220,60,61,.4); }
.empty { padding: 20px; text-align: center; color: var(--muted); }

/* sheets */
.sheet-bg { position: fixed; left: 0; right: 0; top: var(--vvtop, 0px); height: var(--vvh, 100%); background: rgba(6,4,10,.6); backdrop-filter: blur(3px); z-index: 40; display: flex; align-items: flex-end; justify-content: center; animation: fade .18s; }
.sheet { background: linear-gradient(180deg, #1f1a2c, var(--bg2) 120px); border: 1px solid var(--line2); border-bottom: 0; width: 100%; max-width: 720px; max-height: calc(var(--vvh, 100vh) * .94); overflow-y: auto;
  border-radius: 26px 26px 0 0; padding: 6px 18px calc(22px + var(--safe-b)); animation: up .26s var(--ease); box-shadow: 0 -20px 60px rgba(0,0,0,.5); overscroll-behavior: contain; }
.sheet.full { height: calc(var(--vvh, 100vh) * .94); }
body.kb #tabs, body.kb .rest { display: none; }
body.kb .sheet { border-radius: 18px 18px 0 0; padding-bottom: 14px; }
.sheet .grab { width: 42px; height: 5px; border-radius: 3px; background: rgba(255,255,255,.18); margin: 6px auto 4px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; position: sticky; top: -6px; background: #1f1a2c; padding: 8px 0; z-index: 2; }
.sheet-head h2 { margin: 0; color: var(--text); font-size: 1.15rem; text-transform: none; letter-spacing: -.01em; font-weight: 800; }
@keyframes up { from { transform: translateY(60px); opacity: .3; } }
@keyframes fade { from { opacity: 0; } }
#toast { position: fixed; left: 50%; bottom: calc(96px + var(--safe-b)); transform: translate(-50%, 10px); background: #2f2742; border: 1px solid var(--line2);
  padding: 11px 18px; border-radius: 14px; z-index: 60; opacity: 0; pointer-events: none; transition: opacity .2s, transform .25s var(--ease); max-width: 90vw; font-weight: 600; font-size: .92rem;
  box-shadow: 0 12px 30px rgba(0,0,0,.5); }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* scanner */
.scanner { position: relative; background: #000; border-radius: 20px; overflow: hidden; aspect-ratio: 4/3; box-shadow: var(--shadow); }
.scanner video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scanner .reticle { position: absolute; inset: 30% 12%; border-radius: 16px; box-shadow: 0 0 0 999px rgba(0,0,0,.45); }
.scanner .reticle::before { content: ''; position: absolute; inset: 0; border-radius: 16px; border: 3px solid var(--gold); clip-path: polygon(0 0, 22% 0, 22% 3px, 3px 3px, 3px 30%, 0 30%, 0 70%, 3px 70%, 3px calc(100% - 3px), 22% calc(100% - 3px), 22% 100%, 0 100%, 0 0, 100% 0, 78% 0, 78% 3px, calc(100% - 3px) 3px, calc(100% - 3px) 30%, 100% 30%, 100% 70%, calc(100% - 3px) 70%, calc(100% - 3px) calc(100% - 3px), 78% calc(100% - 3px), 78% 100%, 100% 100%, 100% 0); }
.scanner .reticle::after { content: ''; position: absolute; left: 8%; right: 8%; height: 2px; top: 50%; background: linear-gradient(90deg, transparent, #ff5a5a, transparent); box-shadow: 0 0 12px #ff5a5a; animation: scan 1.8s ease-in-out infinite; }
@keyframes scan { 0%, 100% { transform: translateY(-38px); } 50% { transform: translateY(38px); } }
.photo-prev { max-width: 100%; max-height: 240px; border-radius: 16px; display: block; margin: 10px auto; box-shadow: var(--shadow); }
.option-card { display: flex; gap: 14px; align-items: flex-start; }
.option-card .bub { width: 46px; height: 46px; border-radius: 15px; display: grid; place-items: center; flex: none; }

/* workout */
.settable { width: 100%; border-collapse: separate; border-spacing: 0 4px; font-variant-numeric: tabular-nums; }
.settable th { font-size: .7rem; color: var(--muted); font-weight: 700; text-align: center; padding: 2px; text-transform: uppercase; letter-spacing: .06em; }
.settable td { padding: 0 2px; text-align: center; }
.settable tr td:first-child { border-radius: 12px 0 0 12px; } .settable tr td:last-child { border-radius: 0 12px 12px 0; }
.settable input { text-align: center; padding: 8px 4px; min-height: 42px; font-weight: 700; }
.settable tr.done td { background: rgba(10,172,35,.13); }
.settable tr.done input { border-color: rgba(10,172,35,.35); }
.settable .setno { width: 38px; }
.settable .prev { color: var(--faint); font-size: .78rem; width: 70px; }
.settable .ok { width: 48px; }
.tick { width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line2); background: var(--card2); cursor: pointer; color: var(--muted); font-weight: 700; transition: all .15s var(--ease); }
.tick.on { background: var(--good); color: #fff; border-color: var(--good); box-shadow: 0 4px 14px -4px rgba(10,172,35,.8); }
.rest { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(96px + var(--safe-b)); background: linear-gradient(180deg, #c7b3ff, var(--accent2)); color: var(--accent-ink);
  border-radius: 99px; padding: 8px 10px 8px 18px; font-weight: 800; z-index: 30; display: flex; gap: 8px; align-items: center; box-shadow: 0 12px 30px -6px rgba(143,107,255,.7); }
.rest button { background: rgba(0,0,0,.14); border: 0; border-radius: 99px; padding: 7px 12px; cursor: pointer; color: inherit; font-weight: 700; }
.timer { font-variant-numeric: tabular-nums; }
.week-dots { display: flex; gap: 5px; }
.week-dots span { width: 26px; height: 26px; border-radius: 9px; display: inline-flex; align-items: center; justify-content: center; font-size: .68rem; font-weight: 700; background: rgba(255,255,255,.05); color: var(--faint); }
.week-dots span.on { background: linear-gradient(180deg, #2fd14a, var(--good)); color: #fff; box-shadow: 0 4px 10px -4px rgba(10,172,35,.9); }
.week-dots span.today { outline: 2px solid rgba(182,156,255,.6); outline-offset: 1px; }

/* charts */
.chart { position: relative; touch-action: pan-y; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .tip { position: absolute; pointer-events: none; background: rgba(12,9,18,.96); border: 1px solid var(--line2); border-radius: 10px; padding: 7px 10px; font-size: .8rem;
  white-space: nowrap; transform: translate(-50%, calc(-100% - 12px)); z-index: 5; display: none; box-shadow: 0 8px 20px rgba(0,0,0,.5); }
.chart .axis { fill: var(--faint); font-size: 11px; font-family: 'Jakarta', system-ui, sans-serif; }
.chart .grid { stroke: rgba(255,255,255,.06); stroke-width: 1; }
table.data { width: 100%; border-collapse: collapse; font-size: .9rem; font-variant-numeric: tabular-nums; }
table.data th, table.data td { padding: 9px 6px; border-top: 1px solid var(--line); text-align: right; }
table.data th:first-child, table.data td:first-child { text-align: left; }
table.data th { color: var(--muted); font-weight: 700; font-size: .72rem; border-top: 0; text-transform: uppercase; letter-spacing: .06em; }
details summary { cursor: pointer; color: var(--muted); padding: 6px 0; font-weight: 600; }
.notice { background: rgba(232,198,106,.08); border: 1px solid rgba(232,198,106,.3); color: #f3dc9b; border-radius: 14px; padding: 11px 13px; font-size: .9rem; margin: 10px 0; }
.err { background: rgba(220,60,61,.1); border: 1px solid rgba(220,60,61,.4); color: #ffc4c4; border-radius: 14px; padding: 11px 13px; margin: 10px 0; font-size: .92rem; }
.login { max-width: 400px; margin: 9vh auto 0; padding: 26px 22px; }
.login .logo { width: 76px; height: 76px; margin: 0 auto 6px; display: block; border-radius: 22px; box-shadow: 0 14px 40px -10px rgba(143,107,255,.8); }
.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip { border: 1px solid var(--line2); background: var(--card2); border-radius: 99px; padding: 7px 13px; cursor: pointer; font-size: .86rem; font-weight: 600; color: var(--text); transition: all .15s; }
.chip.on { background: linear-gradient(180deg, #c7b3ff, var(--accent2)); color: var(--accent-ink); border-color: transparent; }
.spin { display: inline-block; width: 16px; height: 16px; border: 2px solid var(--line2); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -3px; }
@keyframes spin { to { transform: rotate(360deg); } }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: .8rem; color: var(--muted); margin-top: 8px; font-weight: 600; }
.tir { display: flex; height: 14px; border-radius: 8px; overflow: hidden; gap: 2px; margin: 10px 0 4px; }
@media print { #tabs, .noprint { display: none !important; } body { background: #fff; color: #000; } }
