:root {
  --bg: #0f1115; --card: #181b22; --card2: #20242d; --line: #2a2f3a; --text: #e9ecf1; --muted: #8b93a3;
  --acc: #4f8cff; --ok: #34c37a; --warn: #f2a33a; --bad: #ef5b5b; --violet: #a77bff;
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
body { padding: calc(var(--safe-t) + 8px) 12px calc(var(--safe-b) + 140px); overscroll-behavior-y: none; }
h1 { font-size: 22px; margin: 6px 2px 12px; display: flex; align-items: center; gap: 8px; }
h2 { font-size: 17px; margin: 18px 2px 8px; color: var(--muted); font-weight: 600; }
h3 { font-size: 17px; margin: 0; }
button { font: inherit; color: inherit; border: 0; background: var(--card2); border-radius: 12px; padding: 10px 14px; cursor: pointer; }
button:active { filter: brightness(1.3); }
button.primary { background: var(--acc); color: #fff; font-weight: 600; }
button.ok { background: var(--ok); color: #06210f; font-weight: 700; }
button.ghost { background: transparent; color: var(--acc); padding: 6px 8px; }
button.danger { background: transparent; color: var(--bad); }
button.big { width: 100%; padding: 15px; font-size: 17px; margin-top: 10px; }
button:disabled { opacity: .45; }
input, select, textarea { font: inherit; color: var(--text); background: var(--card2); border: 1px solid var(--line); border-radius: 10px; padding: 10px; width: 100%; }
textarea { resize: vertical; min-height: 44px; }
label { display: block; color: var(--muted); font-size: 13px; margin: 10px 0 4px; }
.muted { color: var(--muted); font-size: 14px; }
.small { font-size: 13px; }
.row { display: flex; gap: 8px; align-items: center; }
.row > .grow { flex: 1; }
.wrap { flex-wrap: wrap; }
.card { background: var(--card); border-radius: 16px; padding: 14px; margin-bottom: 12px; border: 1px solid var(--line); }
.card.done { opacity: .75; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0; }
.chip { font-size: 13px; padding: 4px 10px; border-radius: 999px; background: var(--card2); color: var(--muted); }
.chip.sel { background: var(--acc); color: #fff; }
.chip.fresh { color: var(--ok); } .chip.tired { color: var(--warn); }
.badge { font-size: 12px; padding: 2px 8px; border-radius: 999px; font-weight: 600; white-space: nowrap; }
.b-increase { background: #173a27; color: var(--ok); } .b-fatigue { background: #3d2318; color: var(--warn); }
.b-stall { background: #2f2645; color: var(--violet); } .b-comeback { background: #172c47; color: var(--acc); }
.b-ok, .b-new { background: var(--card2); color: var(--muted); }
.advice { font-size: 14px; color: #c9d1de; margin: 6px 0 4px; }
.last { font-size: 14px; color: var(--muted); }
.sets { margin: 8px 0 4px; }
.set { display: flex; align-items: center; gap: 10px; padding: 8px 4px; border-top: 1px solid var(--line); }
.set .n { width: 22px; color: var(--muted); font-size: 13px; }
.set .v { flex: 1; font-weight: 600; font-variant-numeric: tabular-nums; }
.set .v small { color: var(--muted); font-weight: 400; }
.entry { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; margin-top: 10px; }
.stepper { min-width: 0; background: var(--card2); border-radius: 12px; padding: 6px; text-align: center; }
.stepper .lbl { font-size: 12px; color: var(--muted); }
.stepper .ctl { display: flex; align-items: center; justify-content: space-between; }
.stepper .ctl button { flex: none; width: 44px; height: 44px; padding: 0; font-size: 22px; background: var(--card); }
.stepper .val { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; min-width: 0; flex: 1; background: none; border: 0; text-align: center; padding: 0; width: 100%; }
.parts { display: flex; gap: 4px; justify-content: center; margin-top: 6px; }
.parts button { padding: 4px 0; width: 36px; font-size: 13px; background: var(--card); border-radius: 8px; }
.parts button.sel { background: var(--acc); color: #fff; }
.entry .full { grid-column: 1 / -1; }
.tabs { position: fixed; left: 0; right: 0; bottom: 0; display: flex; background: rgba(15,17,21,.96); backdrop-filter: blur(10px);
  border-top: 1px solid var(--line); padding-bottom: var(--safe-b); z-index: 20; }
.tabs button { flex: 1; background: none; border-radius: 0; padding: 8px 0 10px; font-size: 11px; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 2px; }
.tabs button .i { font-size: 21px; }
.tabs button.on { color: var(--acc); }
.timer { position: fixed; left: 10px; right: 10px; bottom: calc(var(--safe-b) + 66px); background: #1d2a44; border: 1px solid #2f4a7a;
  border-radius: 16px; padding: 10px 12px; display: flex; align-items: center; gap: 10px; z-index: 19; box-shadow: 0 6px 24px #0008; }
.timer .t { font-size: 28px; font-weight: 800; font-variant-numeric: tabular-nums; min-width: 84px; }
.timer.over { background: #1a3b2a; border-color: #2c6b48; }
.timer .ex { flex: 1; font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-bg { position: fixed; inset: 0; background: #000a; z-index: 30; display: flex; align-items: flex-end; }
.modal { background: var(--card); width: 100%; border-radius: 20px 20px 0 0; padding: 18px 16px calc(var(--safe-b) + 18px); max-height: 88vh; overflow: auto; }
.rate { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.rate button.sel { background: var(--acc); color: #fff; }
.banner { background: #3d2318; color: #ffd2a8; border-radius: 12px; padding: 10px 12px; font-size: 14px; margin-bottom: 12px; }
.banner.info { background: #172c47; color: #cfe0ff; }
.list-item { display: flex; align-items: center; gap: 10px; padding: 12px 4px; border-top: 1px solid var(--line); }
.list-item:first-child { border-top: 0; }
.chat { display: flex; flex-direction: column; gap: 10px; }
.msg { padding: 10px 12px; border-radius: 14px; max-width: 92%; white-space: pre-wrap; font-size: 15px; }
.msg.user { background: var(--acc); color: #fff; align-self: flex-end; }
.msg.assistant { background: var(--card); border: 1px solid var(--line); }
.chatbar { position: fixed; left: 0; right: 0; bottom: calc(var(--safe-b) + 58px); padding: 8px 12px; background: var(--bg); display: flex; gap: 8px; z-index: 18; }
.svgchart { width: 100%; height: 140px; display: block; }
.sync { font-size: 12px; color: var(--muted); margin-left: auto; font-weight: 400; }
.sync.off { color: var(--warn); }
.login { max-width: 360px; margin: 20vh auto 0; }
details summary { cursor: pointer; list-style: none; }
details summary::-webkit-details-marker { display: none; }
.toast { position: fixed; top: calc(var(--safe-t) + 10px); left: 50%; transform: translateX(-50%); background: #2a2f3a; padding: 10px 16px; border-radius: 12px; z-index: 40; font-size: 14px; }

.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; margin-top: 8px; }
.cal-h { text-align: center; font-size: 11px; color: var(--muted); }
.cal-d { display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 4px 0 3px; min-height: 58px; border-radius: 10px; background: var(--card2); border: 2px solid transparent; }
.cal-d .num { width: 26px; height: 26px; line-height: 26px; border-radius: 50%; font-size: 14px; font-weight: 600; }
.cal-d .marks { font-size: 11px; min-height: 14px; line-height: 14px; }
.cal-d .sl { font-size: 10px; color: var(--muted); }
.cal-d.sel { outline: 2px solid var(--text); }
.cal-d.today .num { text-decoration: underline; }
.legend { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 4px; vertical-align: -1px; }
.rate5 { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.rate5 button.sel { background: var(--acc); color: #fff; }
.tips { margin: 6px 0 0; padding-left: 18px; }
.bars { display: flex; gap: 3px; align-items: flex-end; height: 120px; margin: 8px 0; }
.bar { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; font-size: 9px; color: var(--muted); }
.bar div { width: 100%; border-radius: 4px 4px 0 0; min-height: 2px; }
.bar span { margin-top: 2px; } .bar small { font-size: 9px; }
details.lab summary { list-style: none; }
.ck { font-size: 18px; color: var(--acc); }
.pbar { height: 8px; background: var(--card2); border-radius: 99px; overflow: hidden; }
.pbar div { height: 100%; background: var(--ok); }
[data-meal] { cursor: pointer; }
