[hidden] { display: none !important; }
:root {
  --bg: #101312; --panel: #171b1a; --line: #262c2a; --text: #e8ece9; --muted: #8a948f;
  --accent: #7fc8a9; --good: #7fc8a9; --bad: #e0876a; --warn: #e2b866;
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); padding-bottom: 76px; }
header { display: flex; align-items: center; gap: 12px; padding: 14px 16px; position: sticky; top: 0;
  background: var(--bg); border-bottom: 1px solid var(--line); z-index: 2; }
h1 { font-size: 17px; margin: 0; font-weight: 600; letter-spacing: .2px; }
h2 { font-size: 15px; margin: 0 0 10px; font-weight: 600; }
h3 { font-size: 14px; margin: 22px 0 8px; color: var(--muted); font-weight: 500; }
.date-nav { display: flex; align-items: center; gap: 6px; margin: 0 auto; font-variant-numeric: tabular-nums; }
.date-nav button { background: none; border: 0; color: var(--text); font-size: 20px; padding: 0 8px; cursor: pointer; }
main { max-width: 760px; margin: 0 auto; padding: 16px; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.primary { background: var(--accent); color: #0d1411; border: 0; border-radius: 8px; padding: 9px 16px; font-weight: 600; }
.ghost { background: none; border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px; }
.ghost-link { color: var(--accent); }
input, select, textarea { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; width: 100%; }
.row { display: flex; gap: 8px; align-items: center; margin: 10px 0; }
.row button { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 9px 14px; }
.muted { color: var(--muted); } .small { font-size: 13px; } .hint { color: var(--muted); margin-top: 0; }
#banner { margin: 12px 16px 0; padding: 10px 12px; border-radius: 8px; background: #2a2416; color: var(--warn); font-size: 14px; }

.hero { display: grid; grid-template-columns: 132px 1fr; gap: 18px; align-items: center; margin-bottom: 18px; }
.ring-score { position: relative; width: 132px; height: 132px; }
.ring-score span { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 38px; font-weight: 600; line-height: 1.1; font-variant-numeric: tabular-nums; }
.ring-score small { font-size: 12px; font-weight: 400; color: var(--muted); }
.parts { list-style: none; padding: 0; margin: 0; font-size: 14px; }
.parts li { display: flex; justify-content: space-between; padding: 4px 0; border-bottom: 1px solid var(--line); }
.parts li:last-child { border: 0; }
.pos { color: var(--good); } .neg { color: var(--bad); }

.alert { border-left: 3px solid var(--warn); background: var(--panel); padding: 10px 12px; border-radius: 6px; margin-bottom: 10px; }
.alert b { display: block; margin-bottom: 2px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: 10px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.metric { cursor: pointer; }
.metric .lbl { color: var(--muted); font-size: 13px; }
.metric .val { font-size: 24px; font-weight: 600; font-variant-numeric: tabular-nums; margin: 2px 0; }
.metric .val small { font-size: 13px; color: var(--muted); font-weight: 400; margin-left: 2px; }
.metric .cmp { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.metric svg { display: block; margin-top: 6px; }
.sleepbar { display: flex; height: 12px; border-radius: 6px; overflow: hidden; margin: 8px 0; background: var(--line); }
.sleepbar div { height: 100%; }
.legend { display: flex; gap: 14px; font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; }

.chart { width: 100%; } .chart.big { height: 240px; }
.chart svg { width: 100%; height: 100%; overflow: visible; }
.chart text { fill: var(--muted); font-size: 11px; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 12px; }
.stats div { background: var(--panel); border-radius: 8px; padding: 8px; font-size: 12.5px; color: var(--muted); }
.stats b { display: block; color: var(--text); font-size: 17px; font-variant-numeric: tabular-nums; }
.seg { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; flex-shrink: 0; }
.seg button { background: none; border: 0; padding: 8px 12px; color: var(--muted); }
.seg button.on { background: var(--panel); color: var(--text); }

.tags { display: flex; flex-wrap: wrap; gap: 8px; }
.tags button { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 7px 13px; }
.tags button.on { background: var(--accent); color: #0d1411; border-color: var(--accent); }
textarea { margin: 6px 0 12px; resize: vertical; }

.impact { margin-bottom: 12px; }
.impact h2 { display: flex; justify-content: space-between; }
.impact h2 span:first-child { text-transform: capitalize; }
.impact table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.impact td { padding: 5px 0; border-top: 1px solid var(--line); }
.impact td:not(:first-child) { text-align: right; }
.bars { display: flex; align-items: flex-end; gap: 8px; height: 120px; }
.bars div { flex: 1; text-align: center; font-size: 12px; color: var(--muted); }
.bars span { display: block; background: var(--accent); border-radius: 4px 4px 0 0; margin-bottom: 4px; opacity: .85; }
.prose { white-space: pre-wrap; min-height: 60px; margin-top: 12px; }

nav { position: fixed; bottom: 0; left: 0; right: 0; display: flex; background: var(--panel);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
nav button { flex: 1; background: none; border: 0; padding: 14px 0; color: var(--muted); font-size: 13.5px; }
nav button.on { color: var(--accent); }
@media (max-width: 420px) { .hero { grid-template-columns: 1fr; justify-items: center; } .stats { grid-template-columns: repeat(2, 1fr); } }

/* v2: login, AI, chat, settings */
#login { position: fixed; inset: 0; background: var(--bg); z-index: 10; display: grid; place-items: center; padding: 20px; }
#login form { width: 100%; max-width: 340px; display: grid; gap: 12px; }
.icon { font-size: 16px; padding: 6px 10px; }
header .ghost { flex-shrink: 0; }
label { display: block; color: var(--muted); font-size: 13px; margin: 10px 0; }
label input, label textarea { margin-top: 4px; color: var(--text); font-size: 15px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
#settings h2 { margin-top: 18px; }
.ai-card { margin: 0 0 14px; border-color: #2f4a3f; }
.ai-head { display: flex; justify-content: space-between; align-items: baseline; }
.ai-head h2 { margin-bottom: 4px; }
.think { color: var(--muted); font-size: 13px; font-style: italic; margin: 8px 0; overflow: hidden; display: -webkit-box;
  -webkit-line-clamp: 3; -webkit-box-orient: vertical; }
.md { line-height: 1.55; }
.md h2 { font-size: 17px; margin: 22px 0 8px; color: var(--accent); }
.md h3, .md h4 { font-size: 15px; margin: 16px 0 6px; color: var(--text); }
.md p { margin: 6px 0; }
.md ul, .md ol { padding-left: 20px; margin: 6px 0; }
.md li { margin: 5px 0; }
.md b { color: #fff; }
.md table { width: 100%; border-collapse: collapse; font-size: 13.5px; margin: 8px 0; }
.md td { border-top: 1px solid var(--line); padding: 5px 4px; }
.md code { background: var(--panel); padding: 1px 4px; border-radius: 4px; }
#report-history { max-width: 55%; }
#report-out { margin-top: 8px; }
.msg { margin: 12px 0; padding: 10px 13px; border-radius: 12px; max-width: 92%; }
.msg.user { background: #24352e; margin-left: auto; white-space: pre-wrap; }
.msg.assistant { background: var(--panel); border: 1px solid var(--line); }
.msg.assistant .md > :first-child { margin-top: 0; }
#suggest { margin: 12px 0 90px; }
#suggest button { text-align: left; font-size: 14px; }
.chat-input { position: fixed; left: 0; right: 0; bottom: calc(50px + env(safe-area-inset-bottom)); display: flex; gap: 8px;
  padding: 10px 16px; background: var(--bg); border-top: 1px solid var(--line); max-width: 760px; margin: 0 auto; }
.chat-input textarea { margin: 0; resize: none; min-height: 42px; }
.chat-input button { width: 44px; flex-shrink: 0; font-size: 18px; padding: 0; }
body.chat-mode main { padding-bottom: 90px; }
#chat { min-height: 30vh; }
header { padding-top: max(14px, env(safe-area-inset-top)); }
.row button.primary { background: var(--accent); color: #0d1411; border-color: var(--accent); }
.row button:disabled { opacity: .5; }
.row button, .ghost { white-space: nowrap; }
