:root {
  --p-950: #072631; --p-900: #0b3340; --p-700: #0f5c6e; --p-600: #14788c; --p-500: #1e9bb0; --p-100: #dff1f4;
  --acc: #ff7a59; --acc-100: #ffe9e2;
  --bg: #f2f6f7; --card: #fff; --line: #e3eaec; --text: #10262d; --muted: #667a82;
  --good: #1f9d55; --warn: #d99413; --bad: #d1453b;
  --r: 20px; --ease: cubic-bezier(.2, .8, .2, 1);
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
  --shadow: 0 1px 2px rgba(11, 51, 64, .05), 0 6px 18px rgba(11, 51, 64, .06);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
body { overscroll-behavior-y: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; touch-action: manipulation; }
input, select, textarea { font: inherit; color: inherit; }
svg { display: block; }
.hidden { display: none !important; }

/* Lock */
.lock { position: fixed; inset: 0; z-index: 50; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; color: #fff;
  background: radial-gradient(120% 70% at 50% 0%, var(--p-600) 0%, var(--p-900) 55%, var(--p-950) 100%); }
.lock-logo img { width: 86px; height: 86px; border-radius: 24px; box-shadow: 0 10px 30px rgba(0, 0, 0, .35); }
.lock-brand { margin-top: 16px; font-size: 13px; letter-spacing: .18em; text-transform: uppercase; color: #ffc3b3; font-weight: 700; }
.lock-title { font-size: 22px; font-weight: 700; margin-top: 6px; }
.lock-sub { color: rgba(255, 255, 255, .65); font-size: 14px; min-height: 20px; margin-top: 4px; text-align: center; }
.dots { display: flex; gap: 20px; margin: 28px 0 10px; }
.dots i { width: 14px; height: 14px; border-radius: 50%; border: 2px solid #ffc3b3; transition: background-color .15s, transform .15s var(--ease); }
.dots i.on { background: #ffc3b3; transform: scale(1.15); }
.dots.shake { animation: shake .4s; }
@keyframes shake { 20%, 60% { transform: translateX(-10px); } 40%, 80% { transform: translateX(10px); } }
.lock-err { color: #ffb4a8; font-size: 14px; min-height: 20px; text-align: center; }
.keypad { display: grid; grid-template-columns: repeat(3, 74px); gap: 16px 26px; margin-top: 18px; }
.keypad button { width: 74px; height: 74px; border-radius: 50%; font-size: 28px; font-weight: 500; color: #fff; background: rgba(255, 255, 255, .08); border: 1px solid rgba(255, 255, 255, .18);
  user-select: none; -webkit-user-select: none; transition: transform .25s var(--ease), background-color .3s; }
.keypad button.pressed { background: rgba(255, 195, 179, .4); transform: scale(.9); transition: none; }
.keypad button.ghost { background: none; border: 0; font-size: 22px; color: rgba(255, 255, 255, .7); }

/* Layout */
main { padding: calc(var(--safe-t) + 14px) 16px calc(112px + var(--safe-b)); max-width: 640px; margin: 0 auto; }
main > * { animation: enter .3s var(--ease); }
@keyframes enter { from { opacity: 0; transform: translateY(8px); } }
.tabbar { position: fixed; left: 50%; bottom: calc(12px + var(--safe-b)); transform: translateX(-50%); width: min(calc(100% - 24px), 480px); z-index: 10;
  display: grid; grid-template-columns: repeat(5, 1fr); padding: 6px; border-radius: 26px; background: rgba(11, 51, 64, .95);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); box-shadow: 0 10px 30px rgba(7, 38, 49, .35); }
.tabbar button { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 6px; border-radius: 20px; color: rgba(255, 255, 255, .55); font-size: 11px; font-weight: 600; transition: background-color .2s, color .2s; }
.tabbar button svg { width: 23px; height: 23px; }
.tabbar button.active { color: #fff; background: rgba(255, 255, 255, .14); }

h1 { font-size: 26px; margin: 4px 0 2px; letter-spacing: -.02em; }
.sub { color: var(--muted); font-size: 14px; margin-bottom: 14px; }
.card { background: var(--card); border-radius: var(--r); padding: 16px; margin-bottom: 14px; box-shadow: var(--shadow); }
.card h2 { font-size: 16px; margin: 0 0 12px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card h2 small { font-weight: 500; color: var(--muted); font-size: 13px; }
.muted { color: var(--muted); font-size: 13px; }
.row { display: flex; align-items: center; gap: 12px; }
.grow { flex: 1; min-width: 0; }

.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.tile { background: var(--bg); border-radius: 14px; padding: 10px 10px 9px; }
.tile b { display: block; font-size: 18px; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.tile span { color: var(--muted); font-size: 12px; }

.score { display: flex; gap: 16px; align-items: center; }
.ring { position: relative; width: 108px; height: 108px; flex: none; }
.ring svg { transform: rotate(-90deg); }
.ring div { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ring b { font-size: 32px; line-height: 1; letter-spacing: -.03em; }
.ring span { font-size: 11px; color: var(--muted); }
.bar { height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 4px; background: var(--p-500); transition: width .5s var(--ease); }
.bar i.over { background: var(--acc); }
.part { margin-bottom: 9px; }
.part:last-child { margin-bottom: 0; }
.part .lbl { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 4px; }
.part .lbl span { color: var(--muted); font-variant-numeric: tabular-nums; }

.bmi { display: flex; gap: 14px; align-items: center; }
.bmi .fig { width: 128px; flex: none; }
.bmi .big { font-size: 40px; font-weight: 800; letter-spacing: -.03em; line-height: 1; }
.pill { display: inline-block; padding: 3px 10px; border-radius: 99px; font-size: 13px; font-weight: 700; color: #fff; margin-top: 6px; }
.gauge { margin-top: 14px; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 8px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 4px; }

.find { display: flex; gap: 11px; padding: 11px 0; border-top: 1px solid var(--line); }
.find:first-of-type { border-top: 0; padding-top: 0; }
.find:last-child { padding-bottom: 0; }
.find .ic { flex: none; width: 26px; height: 26px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 14px; font-weight: 800; }
.good .ic { background: var(--good); } .warn .ic { background: var(--warn); } .bad .ic { background: var(--bad); }
.find b { display: block; font-size: 15px; }
.find p { margin: 2px 0 0; font-size: 14px; color: #3d5059; }
.ref { color: var(--p-600); font-size: 12.5px; font-weight: 600; margin-top: 3px; display: inline-block; }

.datenav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.datenav button { width: 42px; height: 42px; border-radius: 50%; background: var(--card); box-shadow: var(--shadow); font-size: 20px; }
.datenav div { text-align: center; }
.datenav b { display: block; font-size: 18px; }

.fields { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.fields.two { grid-template-columns: repeat(2, 1fr); }
label.f { display: block; font-size: 12.5px; color: var(--muted); font-weight: 600; }
label.f.wide { grid-column: 1 / -1; }
.f input, .f select, .f textarea { display: block; width: 100%; margin-top: 4px; padding: 11px 12px; border: 1.5px solid var(--line); border-radius: 12px; background: #fff; font-size: 16px; outline: none; -webkit-appearance: none; appearance: none; }
.f input:focus, .f select:focus, .f textarea:focus { border-color: var(--p-500); }
.btn { display: block; width: 100%; padding: 13px; border-radius: 14px; background: var(--p-700); color: #fff; font-weight: 700; text-align: center; margin-top: 12px; transition: transform .15s var(--ease); }
.btn:active { transform: scale(.98); }
.btn.ghost { background: var(--p-100); color: var(--p-700); }
.btn.danger { background: #fdeceb; color: var(--bad); }
.btn.sm { display: inline-block; width: auto; padding: 7px 13px; border-radius: 10px; font-size: 13.5px; margin: 0; }
.x { color: var(--muted); font-size: 20px; width: 32px; height: 32px; flex: none; }

.slot { border-top: 1px solid var(--line); padding: 10px 0; }
.slot-h { display: flex; justify-content: space-between; align-items: center; font-weight: 700; font-size: 14.5px; }
.slot-h span { color: var(--muted); font-weight: 500; font-size: 13px; }
.item { display: flex; align-items: center; gap: 8px; padding: 6px 0 0; font-size: 14.5px; }
.item small { color: var(--muted); display: block; font-size: 12.5px; }
.tips { margin: 0; padding-left: 18px; font-size: 14.5px; }
.tips li { margin-bottom: 5px; }
.eq { background: var(--acc-100); border-radius: 12px; padding: 10px 12px; font-size: 14px; margin-top: 10px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 7px 12px; border-radius: 99px; background: var(--bg); font-size: 13.5px; font-weight: 600; color: var(--muted); border: 1.5px solid transparent; }
.chip.on { background: var(--p-100); color: var(--p-700); border-color: var(--p-500); }
.tag { display: inline-block; padding: 2px 8px; border-radius: 99px; background: var(--p-100); color: var(--p-700); font-size: 12px; font-weight: 700; margin-right: 4px; }
.plan { border-top: 1px solid var(--line); padding: 12px 0; }
.plan:first-of-type { border-top: 0; padding-top: 0; }
.plan b { font-size: 15.5px; }
.plan .acts { display: flex; gap: 8px; margin-top: 9px; }

.tl { position: relative; padding-left: 22px; }
.tl::before { content: ""; position: absolute; left: 6px; top: 6px; bottom: 6px; width: 2px; background: var(--line); }
.tl > div { position: relative; padding-bottom: 12px; }
.tl > div::before { content: ""; position: absolute; left: -22px; top: 4px; width: 14px; height: 14px; border-radius: 50%; background: #fff; border: 3px solid var(--line); box-sizing: border-box; }
.tl > div.done::before { border-color: var(--good); background: var(--good); }
.tl > div.now::before { border-color: var(--acc); }
.tl b { font-size: 14.5px; }
.tl b span { color: var(--muted); font-weight: 500; font-size: 13px; }
.tl p { margin: 1px 0 0; font-size: 13.5px; color: #3d5059; }

.exrow { display: grid; grid-template-columns: 1fr 58px 64px 30px; gap: 6px; align-items: end; margin-bottom: 8px; }
.exrow .m { grid-column: 1 / -1; }
.sets { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.sets input { width: 62px; text-align: center; padding: 10px 4px; border: 1.5px solid var(--line); border-radius: 12px; font-size: 16px; outline: none; }

.kn pre { margin: 6px 0; padding: 10px 12px; background: var(--bg); border-radius: 12px; font: 600 13.5px/1.5 ui-monospace, Menlo, monospace; white-space: pre-wrap; color: var(--p-700); }
.kn p { margin: 4px 0; font-size: 14.5px; }
.kn .src { font-size: 12.5px; color: var(--muted); font-style: italic; }
.kn h3 { margin: 14px 0 0; font-size: 15.5px; padding-top: 12px; border-top: 1px solid var(--line); }
.kn h3:first-of-type { border-top: 0; padding-top: 0; margin-top: 0; }
h4.grp { margin: 18px 4px 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }

.sheet { position: fixed; inset: 0; z-index: 30; display: flex; align-items: flex-end; justify-content: center; }
.sheet-bg { position: absolute; inset: 0; background: rgba(7, 38, 49, .45); animation: fade .25s; }
.sheet-body { position: relative; width: 100%; max-width: 640px; max-height: 90vh; overflow-y: auto; background: var(--card); border-radius: 24px 24px 0 0; padding: 20px 16px calc(20px + var(--safe-b)); animation: up .3s var(--ease); }
.sheet-body h2 { margin: 0 0 14px; font-size: 19px; }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.foodlist { max-height: 34vh; overflow-y: auto; margin: 10px 0; border: 1.5px solid var(--line); border-radius: 12px; }
.foodlist button { display: block; width: 100%; text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); font-size: 14.5px; }
.foodlist button:last-child { border-bottom: 0; }
.foodlist button.on { background: var(--p-100); }
.foodlist small { color: var(--muted); display: block; font-size: 12.5px; }

.toast { position: fixed; left: 50%; bottom: calc(104px + var(--safe-b)); transform: translate(-50%, 20px); z-index: 60; background: rgba(16, 38, 45, .94); color: #fff; padding: 10px 18px; border-radius: 99px; font-size: 14px; opacity: 0; pointer-events: none; transition: .25s var(--ease); max-width: 90%; text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.empty { text-align: center; color: var(--muted); font-size: 14px; padding: 10px 0; }
