:root {
  --bg: #f3f6fb; --card: #ffffff; --ink: #0a1830; --muted: #52627a; --line: #d8e1ee;
  --navy: #061a3a; --yellow: #ffdf27; --blue: #3977f6;
  --green: #1f8a4c; --amber: #c77700; --red: #c62828;
  --green-bg: #e3f4ea; --amber-bg: #fff1d6; --red-bg: #fde4e4; --chip: #eef1f5;
  --radius: 14px; --tabh: 64px;
  --safe-top: env(safe-area-inset-top, 0px); --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #050d1c; --card: #0d1a31; --ink: #e8eef8; --muted: #9fb0c8; --line: #1f3152;
    --green: #4cc382; --amber: #f0a43a; --red: #ff6b6b; --blue: #6b9bff;
    --green-bg: #12301f; --amber-bg: #33240a; --red-bg: #3a1515; --chip: #16253f;
  }
}
:root[data-theme="dark"] {
  --bg: #050d1c; --card: #0d1a31; --ink: #e8eef8; --muted: #9fb0c8; --line: #1f3152;
  --green: #4cc382; --amber: #f0a43a; --red: #ff6b6b; --blue: #6b9bff;
  --green-bg: #12301f; --amber-bg: #33240a; --red-bg: #3a1515; --chip: #16253f;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif; -webkit-text-size-adjust: 100%; min-height: 100vh; padding-bottom: calc(var(--tabh) + var(--safe-bottom)); overflow-x: hidden; }
h1, h2, h3 { font-family: "Barlow Condensed", -apple-system, sans-serif; letter-spacing: .01em; margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--blue); }

.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; padding: calc(12px + var(--safe-top)) 16px 12px; background: var(--navy); color: #fff; }
.kicker { font: 700 11px/1.2 -apple-system, sans-serif; letter-spacing: .14em; text-transform: uppercase; color: var(--yellow); }
.top h1 { font-size: 28px; line-height: 1.1; margin-top: 2px; }
.icon-btn { width: 44px; height: 44px; border-radius: 12px; border: 1px solid rgba(255,255,255,.25); background: transparent; color: #fff; font-size: 22px; cursor: pointer; }
.icon-btn.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .icon-btn.spin { animation: none; opacity: .6; } }

main { max-width: 720px; margin: 0 auto; padding: 14px 16px 24px; outline: none; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 0 0 14px; }
.card h2 { font-size: 15px; text-transform: uppercase; letter-spacing: .08em; color: var(--blue); margin-bottom: 10px; font-family: -apple-system, sans-serif; font-weight: 700; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; align-items: center; gap: 12px; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: 8px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; text-align: center; }
.grid4 b { display: block; font: 700 24px/1.1 "Barlow Condensed", sans-serif; }
.grid4 span { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }

.hero { display: flex; gap: 16px; align-items: center; }
.ring { flex: 0 0 auto; }
.ring text { font: 700 30px "Barlow Condensed", sans-serif; fill: var(--ink); }
.hero h3 { font-size: 24px; line-height: 1.15; }
.chip { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; background: var(--chip); color: var(--muted); white-space: nowrap; }
.chip.green { background: var(--green-bg); color: var(--green); }
.chip.amber { background: var(--amber-bg); color: var(--amber); }
.chip.red { background: var(--red-bg); color: var(--red); }

.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.list .val { text-align: right; font-weight: 700; white-space: nowrap; }
.score { font-weight: 800; }
.s-green { color: var(--green); } .s-amber { color: var(--amber); } .s-red { color: var(--red); }

.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); cursor: pointer; font-weight: 600; text-decoration: none; color: var(--ink); }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn:disabled { opacity: .5; }
.btns { display: flex; flex-wrap: wrap; gap: 8px; }

.bar { height: 10px; border-radius: 6px; background: var(--chip); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--blue); border-radius: 6px; transition: width .3s; }
.bar.green > i { background: var(--green); }
.zones { display: flex; height: 12px; border-radius: 6px; overflow: hidden; }

.meal { padding: 12px 0; border-bottom: 1px solid var(--line); }
.meal:last-child { border-bottom: 0; }
.meal label { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; }
.meal input[type=checkbox] { width: 24px; height: 24px; margin: 2px 0 0; accent-color: var(--green); flex: 0 0 auto; }
.meal.done .meal-name { text-decoration: line-through; color: var(--muted); }
.timeline-time { font: 700 18px/1 "Barlow Condensed", sans-serif; color: var(--blue); min-width: 48px; }
.session-card { border-left: 4px solid var(--yellow); padding-left: 12px; margin: 10px 0; }

.acts a { display: flex; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); color: inherit; text-decoration: none; min-height: 44px; }
.acts .badge { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; font: 700 18px "Barlow Condensed", sans-serif; border: 4px solid var(--line); flex: 0 0 auto; }

.chart { width: 100%; height: auto; display: block; }
.chart .ax { stroke: var(--line); stroke-width: 1; }
.chart text { fill: var(--muted); font-size: 20px; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 13px; color: var(--muted); }
.legend i { display: inline-block; width: 12px; height: 4px; border-radius: 2px; margin-right: 5px; vertical-align: middle; }

.chat { display: flex; flex-direction: column; gap: 10px; }
.msg { padding: 10px 14px; border-radius: 14px; max-width: 88%; white-space: pre-wrap; }
.msg.user { align-self: flex-end; background: var(--blue); color: #fff; }
.msg.assistant { align-self: flex-start; background: var(--card); border: 1px solid var(--line); }
.composer { display: flex; gap: 8px; margin-top: 12px; }
.composer textarea { flex: 1; min-height: 48px; max-height: 160px; padding: 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); resize: vertical; font-size: 16px; }
.suggest { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.suggest button { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 8px 12px; font-size: 14px; cursor: pointer; min-height: 40px; }

.field { display: grid; gap: 4px; margin: 0 0 12px; }
.field label { font-size: 13px; font-weight: 600; color: var(--muted); }
.field input, .field select, .field textarea { min-height: 44px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); font-size: 16px; width: 100%; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.toggle { display: flex; align-items: center; justify-content: space-between; min-height: 44px; border-bottom: 1px solid var(--line); }
.toggle input { width: 22px; height: 22px; accent-color: var(--blue); }

.report-frame { width: 100%; height: 75vh; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.warn { background: var(--amber-bg); color: var(--ink); border: 1px solid var(--amber); border-radius: 12px; padding: 10px 12px; margin: 0 0 12px; font-size: 14px; }
.empty { text-align: center; padding: 32px 12px; color: var(--muted); }
.skeleton { height: 120px; border-radius: var(--radius); background: linear-gradient(90deg, var(--card), var(--chip), var(--card)); background-size: 200% 100%; animation: sk 1.2s infinite; margin-bottom: 14px; }
@keyframes sk { to { background-position: -200% 0; } }

.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; display: grid; grid-template-columns: repeat(6, 1fr); background: var(--card); border-top: 1px solid var(--line); padding-bottom: var(--safe-bottom); }
.tabs a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; height: var(--tabh); font-size: 11px; font-weight: 600; color: var(--muted); text-decoration: none; }
.tabs a span { font-size: 20px; line-height: 1; }
.tabs a[aria-current="page"] { color: var(--blue); }

.login { position: fixed; inset: 0; z-index: 20; background: var(--navy); display: grid; place-items: center; padding: 24px; }
.login form { width: 100%; max-width: 340px; color: #fff; display: grid; gap: 10px; }
.login h2 { font-size: 40px; }
.login input { min-height: 48px; border-radius: 12px; border: 0; padding: 0 14px; font-size: 18px; color: #0a1830; background: #fff; }
.login .err { color: #ffb4b4; min-height: 1.5em; margin: 0; }

.toast { position: fixed; left: 16px; right: 16px; bottom: calc(var(--tabh) + var(--safe-bottom) + 12px); z-index: 30; background: var(--ink); color: var(--bg); padding: 12px 16px; border-radius: 12px; text-align: center; font-weight: 600; max-width: 520px; margin: 0 auto; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--yellow); outline-offset: 2px; }
@media (max-width: 360px) { .tabs a { font-size: 10px; } .grid4 b { font-size: 20px; } }
