:root {
  --bg: #07090d; --bg2: #0c1017; --card: rgba(22, 27, 37, .72); --card-solid: #141923; --line: rgba(255, 255, 255, .07); --line2: rgba(255, 255, 255, .12);
  --text: #f1f4f9; --muted: #8a93a6; --lime: #c6ff3d; --lime2: #7dff6a; --teal: #3ee6c4; --track: rgba(255, 255, 255, .07);
  --p: #5cc8ff; --c: #ffbf5c; --f: #ff6fa5; --danger: #ff6b7a; --radius: 22px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35), inset 0 1px 0 rgba(255, 255, 255, .04);
  --grad: linear-gradient(135deg, var(--lime) 0%, var(--lime2) 55%, var(--teal) 100%);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { background: var(--bg); }
html, body { margin: 0; color: var(--text); font: 15px/1.5 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
body { min-height: 100vh; padding-bottom: calc(96px + env(safe-area-inset-bottom));
  background: radial-gradient(600px 380px at 100% -5%, rgba(198, 255, 61, .10), transparent 70%), radial-gradient(520px 420px at -10% 30%, rgba(62, 230, 196, .07), transparent 70%), var(--bg); background-attachment: fixed; }
main { max-width: 560px; margin: 0 auto; padding: 0 16px; }
h1 { font-size: 19px; margin: 0; letter-spacing: -.02em; font-weight: 800; }
h2 { font-size: 16px; margin: 0 0 10px; letter-spacing: -.01em; font-weight: 750; }
h3 { margin: 16px 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
strong, b { font-variant-numeric: tabular-nums; }
.small { font-size: 13px; } .muted { color: var(--muted); } .error { color: var(--danger); margin: 8px 0 0; }
em { color: var(--text); font-style: normal; background: rgba(198, 255, 61, .08); padding: 0 4px; border-radius: 4px; }
a { color: var(--lime); }

/* top bar */
.topbar { position: sticky; top: 0; z-index: 5; display: flex; gap: 12px; align-items: center; padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  background: rgba(7, 9, 13, .7); backdrop-filter: saturate(160%) blur(18px); -webkit-backdrop-filter: saturate(160%) blur(18px); border-bottom: 1px solid var(--line); }
.topbar p { margin: 0; } .logo { width: 40px; height: 40px; object-fit: contain; filter: drop-shadow(0 0 8px rgba(198, 255, 61, .25)); }
.badge { margin-left: auto; font-size: 11px; font-weight: 600; padding: 5px 10px 5px 20px; border-radius: 99px; background: rgba(198, 255, 61, .08); color: var(--lime); position: relative; }
.badge::before { content: ""; position: absolute; left: 9px; top: 50%; width: 6px; height: 6px; margin-top: -3px; border-radius: 50%; background: currentColor; box-shadow: 0 0 8px currentColor; }
.badge.off { color: var(--c); background: rgba(255, 191, 92, .1); }

/* views and cards */
.view { display: none; padding-top: 16px; } .view.active { display: block; animation: rise .35s cubic-bezier(.2, .8, .2, 1); }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.card { position: relative; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 14px;
  box-shadow: var(--shadow); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
.card > h2:first-child { display: flex; align-items: center; gap: 8px; }
.card > h2:first-child::before { content: ""; width: 4px; height: 16px; border-radius: 4px; background: var(--grad); }
details.card summary { list-style: none; cursor: pointer; display: flex; align-items: center; } details.card summary::-webkit-details-marker { display: none; }
details.card summary h2 { display: inline; margin: 0; }
details.card summary::after { content: "+"; margin-left: auto; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: rgba(198, 255, 61, .1); color: var(--lime); font-size: 18px; line-height: 1; transition: transform .2s; }
details[open].card summary::after { transform: rotate(45deg); }

/* forms */
input, select, textarea { width: 100%; background: rgba(0, 0, 0, .28); color: var(--text); border: 1px solid var(--line2); border-radius: 14px; padding: 12px 14px; font: inherit; transition: border-color .15s, box-shadow .15s; }
input::placeholder, textarea::placeholder { color: #5d6678; }
input:focus, select:focus, textarea:focus { outline: none; border-color: rgba(198, 255, 61, .6); box-shadow: 0 0 0 4px rgba(198, 255, 61, .12); }
select { appearance: none; -webkit-appearance: none; padding-right: 34px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 52%, calc(100% - 13px) 52%; background-size: 5px 5px; background-repeat: no-repeat; }
input[type="datetime-local"] { color-scheme: dark; }
label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: .02em; } label input, label select { margin-top: 6px; }
textarea { resize: vertical; margin: 10px 0; min-height: 90px; }
.row { display: flex; gap: 8px; align-items: center; } .row select { width: 40%; } .grow { flex: 1; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px; } .span2 { grid-column: span 2; }

/* buttons */
.btn { display: inline-flex; justify-content: center; align-items: center; gap: 6px; border: 1px solid var(--line2); background: rgba(255, 255, 255, .05); color: var(--text);
  border-radius: 14px; padding: 12px 16px; font: inherit; font-weight: 700; cursor: pointer; text-decoration: none; transition: transform .12s, background .15s, box-shadow .2s; }
.btn:hover { background: rgba(255, 255, 255, .08); } .btn:active { transform: scale(.97); }
.btn.primary { background: var(--grad); color: #071006; border: 0; box-shadow: 0 8px 24px rgba(160, 255, 80, .22), inset 0 1px 0 rgba(255, 255, 255, .35); }
.btn.primary:hover { box-shadow: 0 10px 30px rgba(160, 255, 80, .32), inset 0 1px 0 rgba(255, 255, 255, .35); }
.btn.ghost { background: rgba(198, 255, 61, .05); border: 1.5px dashed rgba(198, 255, 61, .4); color: var(--lime); margin-top: 10px; }
.btn.small { padding: 7px 12px; font-size: 13px; border-radius: 11px; } .btn.danger { color: var(--danger); border-color: rgba(255, 107, 122, .3); background: rgba(255, 107, 122, .06); }
.btn:disabled { opacity: .45; } .full { width: 100%; margin-top: 12px; }
.icon-btn { background: rgba(255, 255, 255, .04); border: 0; color: var(--muted); font-size: 14px; width: 30px; height: 30px; border-radius: 50%; cursor: pointer; }
.icon-btn:hover { color: var(--danger); background: rgba(255, 107, 122, .1); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.chip { border: 1px solid var(--line2); background: rgba(255, 255, 255, .03); color: var(--text); border-radius: 99px; padding: 7px 13px; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; transition: all .15s; }
.chip.active, .chip:hover { border-color: transparent; background: rgba(198, 255, 61, .14); color: var(--lime); box-shadow: inset 0 0 0 1px rgba(198, 255, 61, .45); }

/* lists */
.item { border-top: 1px solid var(--line); padding: 12px 0; } .item:first-child { border-top: 0; padding-top: 4px; }
.item-head { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.item-name { font-weight: 700; } .item-sub { color: var(--muted); font-size: 13px; }
.item .row { margin-top: 8px; } .item input { width: 90px; padding: 8px 10px; }
.tag { font-size: 10.5px; font-weight: 700; letter-spacing: .03em; border-radius: 99px; padding: 2px 8px; background: rgba(255, 255, 255, .06); color: var(--muted); margin-left: 4px; vertical-align: 1px; }
.tag.ml { color: #071006; background: var(--grad); }
.macros { display: flex; gap: 12px; font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.macros b { color: var(--text); font-weight: 700; }
.totals-line { margin: 12px 0 0; padding-top: 12px; border-top: 1px solid var(--line); font-weight: 700; }

/* rings and bars */
.ring-wrap { display: flex; align-items: center; gap: 18px; }
.ring { --pct: 0; width: 132px; height: 132px; border-radius: 50%; flex: none; display: grid; place-items: center; position: relative;
  background: conic-gradient(from -90deg, var(--lime) 0%, var(--teal) calc(var(--pct) * 1%), var(--track) calc(var(--pct) * 1%));
  filter: drop-shadow(0 0 18px rgba(160, 255, 80, .18)); transition: --pct .6s; }
.ring.over { background: conic-gradient(from -90deg, var(--c), var(--danger) calc(var(--pct) * 1%), var(--track) 0); filter: drop-shadow(0 0 18px rgba(255, 107, 122, .2)); }
.ring > div { width: 112px; height: 112px; border-radius: 50%; background: radial-gradient(circle at 50% 30%, #1b2230, var(--card-solid)); display: grid; place-items: center; text-align: center; box-shadow: inset 0 2px 10px rgba(0, 0, 0, .5); }
.ring strong { font-size: 26px; display: block; line-height: 1.05; font-weight: 800; letter-spacing: -.02em; }
#fastRing strong { font-size: 21px; }
.bars { flex: 1; display: grid; gap: 12px; }
.bar { height: 8px; background: var(--track); border-radius: 99px; overflow: hidden; }
.bar span { display: block; height: 100%; width: 0; background: var(--grad); border-radius: 99px; transition: width .6s cubic-bezier(.2, .8, .2, 1); }
.bar.p span { background: linear-gradient(90deg, #3a8dff, var(--p)); } .bar.c span { background: linear-gradient(90deg, #ff9a3c, var(--c)); } .bar.f span { background: linear-gradient(90deg, #ff4f8b, var(--f)); }
.bar-label { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-bottom: 5px; font-weight: 600; }
.bar-label b, .bar-label span:last-child { color: var(--text); font-variant-numeric: tabular-nums; }
.meal-title { display: flex; justify-content: space-between; font-weight: 800; }
.meal-title span:first-child { text-transform: capitalize; }
.meal-title span:last-child { color: var(--lime); font-variant-numeric: tabular-nums; }

/* food log extras */
.mlstatus { margin-top: 12px; } .mlstatus p { margin: 6px 0 0; }
.photo-preview { width: 100%; max-height: 260px; object-fit: cover; border-radius: 16px; margin-bottom: 12px; }
.cand { display: flex; justify-content: space-between; align-items: center; width: 100%; text-align: left; margin-top: 8px; }
.cand .prob { color: var(--lime); font-variant-numeric: tabular-nums; }
.history-day { display: flex; justify-content: space-between; align-items: center; width: 100%; background: none; border: 0; color: var(--text); padding: 12px 0; border-top: 1px solid var(--line); font: inherit; cursor: pointer; text-align: left; }
.empty { text-align: center; color: var(--muted); padding: 22px 0; }

/* tab bar */
.tabbar { position: fixed; z-index: 5; left: 12px; right: 12px; bottom: calc(10px + env(safe-area-inset-bottom)); max-width: 536px; margin: 0 auto; display: grid; grid-template-columns: repeat(5, 1fr);
  padding: 6px; border-radius: 24px; background: rgba(18, 22, 31, .82); backdrop-filter: saturate(160%) blur(20px); -webkit-backdrop-filter: saturate(160%) blur(20px);
  border: 1px solid var(--line2); box-shadow: 0 12px 40px rgba(0, 0, 0, .55); }
.tabbar button { display: flex; flex-direction: column; align-items: center; gap: 3px; background: none; border: 0; color: var(--muted); padding: 8px 0 6px; border-radius: 18px;
  font: inherit; font-size: 11px; font-weight: 700; cursor: pointer; transition: color .2s, background .2s; }
.tabbar svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; transition: transform .2s; }
.tabbar button.active { color: var(--lime); background: rgba(198, 255, 61, .1); }
.tabbar button.active svg { transform: translateY(-1px) scale(1.06); filter: drop-shadow(0 0 6px rgba(198, 255, 61, .5)); }

.toast { position: fixed; left: 50%; bottom: calc(100px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--grad); color: #071006; padding: 11px 18px; border-radius: 99px;
  font-weight: 800; z-index: 10; box-shadow: 0 10px 30px rgba(160, 255, 80, .3); animation: toast .3s cubic-bezier(.2, .8, .2, 1); white-space: nowrap; }
@keyframes toast { from { opacity: 0; transform: translate(-50%, 12px); } }

/* body + fasting */
.spark { width: 100%; height: 64px; margin-top: 14px; display: block; }
.bmi-box { width: 112px; height: 112px; border-radius: 50%; display: grid; place-content: center; text-align: center; flex: none; position: relative;
  background: radial-gradient(circle at 50% 30%, #1b2230, var(--card-solid)) padding-box, var(--grad) border-box; border: 5px solid transparent; box-shadow: 0 0 24px rgba(160, 255, 80, .15); }
.bmi-box strong { font-size: 28px; line-height: 1; font-weight: 800; }
.result strong { font-size: 30px; font-weight: 800; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; text-align: center; }
.stats > div { background: rgba(255, 255, 255, .03); border: 1px solid var(--line); border-radius: 14px; padding: 10px 4px; }
.stats strong { display: block; font-size: 19px; font-weight: 800; } .stats span { font-size: 11px; color: var(--muted); }
.fast-line { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; padding: 10px 12px; border-radius: 14px; background: rgba(62, 230, 196, .07); border: 1px solid rgba(62, 230, 196, .2); }
.warn { color: var(--c); } .warn-card { border-color: rgba(255, 191, 92, .28); background: linear-gradient(180deg, rgba(255, 191, 92, .07), var(--card)); }
.warn-card ul { padding-left: 18px; margin: 6px 0; } .warn-card li { margin-bottom: 7px; }
.phase { border-top: 1px solid var(--line); padding: 12px 0; position: relative; } .phase summary { cursor: pointer; display: flex; gap: 10px; align-items: center; list-style: none; }
.phase summary::-webkit-details-marker { display: none; }
.phase summary::before { content: ""; width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--track); box-shadow: inset 0 0 0 1.5px var(--line2); }
.phase.done summary::before { background: rgba(198, 255, 61, .45); box-shadow: none; }
.phase.now summary::before { background: var(--lime); box-shadow: 0 0 0 4px rgba(198, 255, 61, .18), 0 0 12px var(--lime); }
.phase-time { font-size: 12px; color: var(--muted); width: 54px; flex: none; font-variant-numeric: tabular-nums; } .phase ul { margin: 6px 0; padding-left: 38px; color: var(--text); }
.phase.now summary b { color: var(--lime); } .phase.done summary b { color: var(--muted); } .phase p { margin: 6px 0 6px 20px; }

/* lock screen */
.lock { position: fixed; inset: 0; z-index: 50; overflow-y: auto; display: grid; place-items: center; padding: 24px 20px;
  background: radial-gradient(500px 400px at 50% 0%, rgba(198, 255, 61, .16), transparent 70%), radial-gradient(500px 400px at 50% 110%, rgba(62, 230, 196, .12), transparent 70%), var(--bg); }
.lock[hidden] { display: none; }
body.locked { overflow: hidden; } body.locked .tabbar, body.locked main, body.locked .topbar { display: none; }
.lock-card { width: 100%; max-width: 400px; text-align: center; animation: rise .5s cubic-bezier(.2, .8, .2, 1); }
.lock-card h1 { font-size: 28px; margin-bottom: 6px; }
.lock-card form { text-align: left; margin-top: 22px; padding: 20px; border-radius: var(--radius); background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow); }
.lock-logo { width: 230px; max-width: 70%; height: auto; margin-bottom: 18px; filter: drop-shadow(0 0 24px rgba(198, 255, 61, .22)); }

table { width: 100%; border-collapse: collapse; font-size: 14px; } td, th { text-align: left; padding: 10px 4px; border-top: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 700; border-top: 0; }
.member-history { margin-top: 10px; padding: 4px 12px; border: 1px solid var(--line); border-radius: 14px; background: rgba(0, 0, 0, .2); }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
.row .btn { white-space: nowrap; }
