:root {
  --bg: #0f1115; --panel: #171a21; --panel2: #1f232c; --line: #2a2f3a;
  --text: #eef0f4; --muted: #9aa3b2; --accent: #7cc4ff; --accent-ink: #06121d;
  --green: #3fcf7f; --yellow: #f0c24b; --red: #ff6b6b; --star: #f0c24b;
  --radius: 14px;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f3f4f7; --panel: #ffffff; --panel2: #eef0f4; --line: #dde1e8;
    --text: #151821; --muted: #5d6675; --accent: #0a6fc2; --accent-ink: #ffffff;
    --green: #16a05a; --yellow: #b8860b; --red: #d64545; --star: #c48a00;
    color-scheme: light;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif; }
button, input, select, textarea { font: inherit; color: inherit; }
#app { max-width: 720px; margin: 0 auto; min-height: 100vh; padding-bottom: calc(140px + env(safe-area-inset-bottom)); }
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 8px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: var(--bg); border-bottom: 1px solid var(--line); }
.top .title { font-weight: 700; font-size: 18px; flex: 1; }
.net { font-size: 12px; color: var(--yellow); }
.icon-btn { background: none; border: 0; font-size: 22px; padding: 4px 8px; color: var(--muted); cursor: pointer; }
main { padding: 12px 16px; }
.tabs { position: fixed; bottom: 0; left: 0; right: 0; z-index: 6; display: flex; justify-content: center;
  background: var(--panel); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tabs button { flex: 1; max-width: 144px; background: none; border: 0; padding: 8px 2px 10px; font-size: 11px; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 2px; cursor: pointer; }
.tabs button span { font-size: 19px; line-height: 1.1; }
.tabs button.on { color: var(--accent); }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }
.card h2 { margin: 0 0 10px; font-size: 16px; }
.card h3 { margin: 0; font-size: 16px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.spread { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 8px; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: 999px;
  background: var(--panel2); border: 1px solid var(--line); font-size: 13px; white-space: nowrap; }
.btn { border: 1px solid var(--line); background: var(--panel2); border-radius: 12px; padding: 10px 14px; cursor: pointer; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.btn.big { width: 100%; padding: 14px; font-size: 17px; }
.btn.ghost { background: none; }
.btn.danger { color: var(--red); }
.btn.sm { padding: 6px 10px; font-size: 14px; border-radius: 10px; }
.btn:disabled { opacity: .5; }
input[type=text], input[type=number], input[type=date], input[type=time], input[type=password], select, textarea {
  background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 9px 10px; width: 100%; }
textarea { min-height: 70px; resize: vertical; }
label.field { display: block; font-size: 13px; color: var(--muted); }
label.field > * { margin-top: 4px; }
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 0; }

.ready { display: flex; gap: 14px; align-items: center; }
.ring { --c: var(--muted); width: 84px; height: 84px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: conic-gradient(var(--c) calc(var(--p) * 1%), var(--panel2) 0); }
.ring > div { width: 68px; height: 68px; border-radius: 50%; background: var(--panel); display: grid; place-items: center; font-weight: 700; font-size: 22px; }
.lv-green { --c: var(--green); } .lv-yellow { --c: var(--yellow); } .lv-red { --c: var(--red); }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; background: var(--c, var(--muted)); }
.notes { margin: 10px 0 0; padding-left: 18px; font-size: 14px; color: var(--muted); }
.notes li + li { margin-top: 4px; }

.week { display: flex; gap: 6px; }
.week div { flex: 1; text-align: center; font-size: 11px; color: var(--muted); }
.week i { display: block; height: 8px; border-radius: 4px; background: var(--panel2); margin-bottom: 4px; }
.week .on i { background: var(--accent); }
.week .today { color: var(--text); font-weight: 600; }

.feel { display: flex; gap: 6px; }
.feel button { flex: 1; padding: 8px 0; border-radius: 10px; border: 1px solid var(--line); background: var(--panel2); font-size: 20px; cursor: pointer; }
.feel button.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 20%, var(--panel2)); }

.plan-item { padding: 10px 0; border-top: 1px solid var(--line); }
.plan-item:first-child { border-top: 0; padding-top: 0; }
.plan-item .name { font-weight: 600; }
.star { color: var(--star); }
.rx { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.why { font-size: 12px; color: var(--muted); margin-top: 4px; }
.tag { font-size: 11px; padding: 1px 6px; border-radius: 6px; background: var(--panel2); color: var(--muted); }
.tag.up { color: var(--green); } .tag.down { color: var(--red); }

.ex { padding: 0; overflow: hidden; }
.ex-head { padding: 12px 14px 8px; }
.ex-head .name { font-weight: 700; font-size: 17px; }
.ex-note { font-size: 13px; color: var(--muted); margin-top: 4px; }
.ex-actions { display: flex; gap: 6px; padding: 0 14px 10px; flex-wrap: wrap; }
.sets { border-top: 1px solid var(--line); }
.set { display: grid; grid-template-columns: 34px 1fr 1fr 52px; gap: 8px; align-items: center; padding: 8px 14px; border-bottom: 1px solid var(--line); }
.set:last-child { border-bottom: 0; }
.set .n { color: var(--muted); font-variant-numeric: tabular-nums; text-align: center; }
.set input { text-align: center; font-size: 18px; padding: 8px 4px; font-variant-numeric: tabular-nums; }
.set .ok { height: 42px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel2); font-size: 20px; cursor: pointer; }
.set.done { background: color-mix(in srgb, var(--green) 10%, transparent); }
.set.done .ok { background: var(--green); border-color: var(--green); color: #fff; }
.set.warm .n { font-size: 11px; }
.set-hdr { display: grid; grid-template-columns: 34px 1fr 1fr 52px; gap: 8px; padding: 6px 14px 0; font-size: 11px; color: var(--muted); text-align: center; }
.ex.complete .ex-head .name::after { content: " ✓"; color: var(--green); }

.timer { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(66px + env(safe-area-inset-bottom)); z-index: 7;
  display: flex; align-items: center; gap: 10px; background: var(--accent); color: var(--accent-ink); border-radius: 999px; padding: 8px 10px 8px 16px;
  box-shadow: 0 6px 24px rgba(0,0,0,.35); font-variant-numeric: tabular-nums; }
.timer b { font-size: 20px; min-width: 52px; }
.timer button { border: 0; background: rgba(0,0,0,.15); color: inherit; border-radius: 999px; padding: 6px 10px; cursor: pointer; }
.timer.over { background: var(--green); }

.sheet { position: fixed; inset: 0; z-index: 20; background: rgba(0,0,0,.5); display: flex; align-items: flex-end; justify-content: center; }
.sheet-body { background: var(--panel); width: 100%; max-width: 720px; max-height: 86vh; overflow: auto; border-radius: 18px 18px 0 0;
  padding: 16px 16px calc(20px + env(safe-area-inset-bottom)); }
.sheet-body h3 { margin: 0 0 12px; }
.opt { display: block; width: 100%; text-align: left; padding: 12px; border: 1px solid var(--line); background: var(--panel2); border-radius: 12px; margin-bottom: 8px; cursor: pointer; }
.opt small { color: var(--muted); }
.toast { position: fixed; left: 16px; right: 16px; bottom: calc(90px + env(safe-area-inset-bottom)); z-index: 30; margin: 0 auto; max-width: 480px;
  background: var(--text); color: var(--bg); padding: 12px 14px; border-radius: 12px; font-size: 14px; }

.chart { width: 100%; height: auto; display: block; }
.chart text { fill: var(--muted); font-size: 10px; }
.bars .bar { display: grid; grid-template-columns: 120px 1fr 54px; gap: 8px; align-items: center; font-size: 13px; margin-bottom: 6px; }
.bars .track { height: 10px; background: var(--panel2); border-radius: 5px; position: relative; overflow: hidden; }
.bars .fill { height: 100%; background: var(--accent); border-radius: 5px; }
.bars .fill.full { background: var(--green); }
.list-item { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); cursor: pointer; }
.list-item:first-child { border-top: 0; }
.big-num { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.seg { display: inline-flex; background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 2px; }
.seg button { border: 0; background: none; padding: 6px 12px; border-radius: 8px; cursor: pointer; color: var(--muted); }
.seg button.on { background: var(--panel); color: var(--text); }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
table.t td, table.t th { padding: 6px 4px; border-top: 1px solid var(--line); text-align: left; }
table.t th { color: var(--muted); font-weight: 500; font-size: 12px; }

.chat { display: flex; flex-direction: column; gap: 8px; }
.msg { padding: 10px 12px; border-radius: 14px; max-width: 88%; white-space: pre-wrap; font-size: 15px; }
.msg.user { align-self: flex-end; background: var(--accent); color: var(--accent-ink); }
.msg.assistant { align-self: flex-start; background: var(--panel); border: 1px solid var(--line); }
.chat-input { position: sticky; bottom: calc(66px + env(safe-area-inset-bottom)); background: var(--bg); padding: 8px 0; display: flex; gap: 8px; }
.chat-input textarea { min-height: 44px; height: 44px; }
.quick { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; }
.quick button { flex: none; }
code.token { word-break: break-all; font-size: 12px; background: var(--panel2); padding: 6px 8px; border-radius: 8px; display: block; }
.prog-item { display: grid; grid-template-columns: 26px 1fr; gap: 8px; align-items: start; padding: 10px 0; border-top: 1px solid var(--line); }
.prog-item > input[type=checkbox] { width: 20px; height: 20px; margin: 2px 0 0; }
.prog-item .nums { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 6px; }
.login { max-width: 360px; margin: 18vh auto 0; }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }
.review { white-space: pre-wrap; font-size: 15px; }
@media (max-width: 380px) { .bars .bar { grid-template-columns: 96px 1fr 48px; } }
.chip.on-chip { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 22%, var(--panel2)); }
button.chip { cursor: pointer; }
