:root {
  --bg: #0E1013; --card: #171A1F; --card2: #1F2329; --line: #2A2F37; --text: #ECEEF1; --muted: #8C94A0;
  --accent: #8BE38F; --accent-ink: #0B1A0C; --warn: #FFB547; --bad: #FF6B6B; --good: #8BE38F;
  --r: 16px; color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root { --bg: #F3F4F6; --card: #FFFFFF; --card2: #F0F2F4; --line: #E2E5E9; --text: #14171B; --muted: #69717C;
    --accent: #23A34A; --accent-ink: #FFFFFF; --warn: #C27803; --bad: #D63B3B; --good: #23A34A; color-scheme: light; }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif; -webkit-text-size-adjust: 100%; }
h1 { font-size: 30px; margin: 2px 0 0; letter-spacing: -0.02em; }
h2 { font-size: 22px; margin: 2px 0 10px; }
h3 { font-size: 17px; margin: 0; }
p { margin: 4px 0; }
b { font-weight: 600; }
.muted { color: var(--muted); }
.small, small { font-size: 13px; }
.center { text-align: center; }
.accent-t { color: var(--accent); }
.warn-t { color: var(--warn); }
.good-t { color: var(--good); }

.page { max-width: 560px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 12px) 16px calc(env(safe-area-inset-bottom) + 110px); }
.top { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 8px 0 14px; }
.top .muted { font-size: 14px; }

.card { background: var(--card); border-radius: var(--r); padding: 14px 16px; margin: 0 0 12px; }
.lbl { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 0 0 6px; }

.btn { appearance: none; border: 0; border-radius: 12px; background: var(--card2); color: var(--text); font: 600 15px/1 -apple-system, system-ui, sans-serif; font-family: inherit;
  padding: 12px 16px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; cursor: pointer; min-height: 44px; }
.btn:active { transform: scale(0.97); }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.danger { color: var(--bad); width: 100%; margin-top: 8px; }
.btn.sm { padding: 8px 12px; min-height: 38px; font-size: 14px; border-radius: 10px; }
.btn.big { width: 100%; min-height: 52px; font-size: 17px; margin-top: 12px; }
.btn.round { width: 44px; height: 44px; border-radius: 50%; font-size: 22px; padding: 0; }
.btns { display: flex; gap: 8px; margin-top: 12px; }
.btns .btn { flex: 1; }
.ic { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

.chip { display: inline-block; font-style: normal; font-size: 12px; font-weight: 600; padding: 3px 8px; border-radius: 99px; background: var(--card2); color: var(--muted); white-space: nowrap; }
.chip.accent, .chip.good { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); }
.chip.warn { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }

.seg { display: flex; background: var(--card); border-radius: 12px; padding: 4px; gap: 4px; margin: 0 0 12px; }
.seg button, .seg label { flex: 1; appearance: none; border: 0; background: transparent; color: var(--muted); font: 600 14px/1.2 -apple-system, system-ui, sans-serif; font-family: inherit; padding: 10px 6px; border-radius: 9px; text-align: center; cursor: pointer; }
.seg button.on, .seg label:has(input:checked) { background: var(--card2); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25); }
.seg input { display: none; }
.seg.small { margin: 10px 0 0; background: transparent; padding: 0; }
.seg.small button { background: var(--card2); }

.banner { border-radius: 12px; padding: 12px 14px; margin: 0 0 12px; background: var(--card2); font-size: 15px; }
.banner.warn { background: color-mix(in srgb, var(--warn) 16%, var(--card)); }

/* today */
.snus { display: flex; align-items: center; justify-content: space-between; gap: 12px; border-left: 4px solid var(--good); }
.snus.no { border-left-color: var(--bad); }
.snus.no b:first-child { color: var(--bad); }
.counter { display: flex; align-items: center; gap: 10px; }
.counter div { text-align: center; min-width: 34px; }
.counter b { display: block; font-size: 22px; }
.counter small { color: var(--muted); font-size: 11px; }
.totals .tot b { font-size: 28px; }
.totals .tot span { color: var(--muted); margin-left: 4px; }
.bar { height: 8px; background: var(--card2); border-radius: 99px; overflow: hidden; margin: 8px 0 6px; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width 0.3s; }

.inputs form.inline { display: flex; align-items: flex-end; gap: 10px; }
.inputs form.inline + form.inline { margin-top: 10px; }
.inline label { flex: 1; display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
input { font: 17px -apple-system, system-ui, sans-serif; font-family: inherit; color: var(--text); background: var(--card2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; width: 100%; min-height: 44px; }
input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.field { display: flex; flex-direction: column; gap: 6px; margin: 0 0 14px; font-size: 14px; color: var(--muted); }
.field .seg { margin: 0; background: var(--card2); }
.field .seg button.on, .field .seg label:has(input:checked) { background: var(--card); }

.timeline { list-style: none; margin: 0; padding: 0; }
.row { display: flex; gap: 12px; align-items: flex-start; background: var(--card); border-radius: 14px; padding: 12px 12px 12px 14px; margin: 0 0 8px; }
.row time { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--muted); font-size: 14px; width: 42px; flex: none; padding-top: 1px; }
.row .body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.row .body small { color: var(--text); opacity: 0.85; }
.row .body small.kc { color: var(--muted); opacity: 1; }
.row .acts { display: flex; flex-direction: column; gap: 6px; }
.row.note { background: transparent; padding-top: 6px; padding-bottom: 6px; }
.row.note .body small { color: var(--muted); }
.row.next { box-shadow: inset 0 0 0 2px var(--accent); }
.row.done { opacity: 0.55; }
.row.done time { color: var(--accent); }
.row.skipped { opacity: 0.5; }
.row.gym { background: color-mix(in srgb, var(--accent) 10%, var(--card)); align-items: center; }

/* train */
.exlist { list-style: none; padding: 0; margin: 0; }
.exlist li { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 15px; }
.exlist li:last-child { border: 0; }
.rules { margin: 0; padding-left: 18px; }
.rules li { margin: 0 0 8px; font-size: 15px; }
.hist { list-style: none; margin: 0; padding: 0; }
.hist li { display: flex; flex-wrap: wrap; gap: 6px; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--line); }
.hist li:last-child { border: 0; }
.ex .sets { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.set { display: flex; align-items: center; gap: 8px; }
.set .n { width: 20px; color: var(--muted); font-weight: 600; text-align: center; }
.set label { flex: 1; position: relative; }
.set label small { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; font-size: 12px; }
.set input { padding-right: 42px; text-align: left; }
.set.done input { border-color: color-mix(in srgb, var(--accent) 50%, transparent); }
.timer { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(env(safe-area-inset-bottom) + 78px); z-index: 20; display: flex; align-items: center; gap: 10px;
  background: var(--accent); color: var(--accent-ink); border-radius: 99px; padding: 6px 6px 6px 18px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35); font-weight: 600; }
.timer b { font-size: 20px; font-variant-numeric: tabular-nums; min-width: 48px; }
.timer .btn { background: rgba(0, 0, 0, 0.12); color: inherit; }

/* progress */
.chart { width: 100%; height: auto; display: block; }
.chart .g { stroke: var(--line); stroke-width: 1; }
.chart .t { fill: var(--muted); font-size: 10px; }
.chart .d { fill: var(--muted); }
.chart .l { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.legend { float: right; text-transform: none; letter-spacing: 0; font-weight: 500; }
.legend i { display: inline-block; vertical-align: middle; margin: 0 4px 0 10px; }
.legend .ld { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); }
.legend .ll { width: 14px; height: 3px; border-radius: 2px; background: var(--accent); }
.advice { border-left: 4px solid var(--line); }
.advice.up, .advice.down { border-left-color: var(--warn); }
.advice.keep { border-left-color: var(--good); }
.advice .btn { margin-top: 10px; width: 100%; white-space: normal; text-align: center; line-height: 1.3; }
.weeks { width: 100%; border-collapse: collapse; font-size: 15px; font-variant-numeric: tabular-nums; }
.weeks th { text-align: left; color: var(--muted); font-weight: 500; font-size: 12px; padding: 0 4px 6px 0; }
.weeks .nowrap { white-space: nowrap; }
.weeks td { padding: 8px 4px 8px 0; border-top: 1px solid var(--line); }
.snusdays { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.snusdays div { background: var(--card2); border-radius: 10px; text-align: center; padding: 8px 0; }
.snusdays b { display: block; font-size: 17px; }
.snusdays small { color: var(--muted); font-size: 11px; }
.snusdays .good b { color: var(--good); }
.snusdays .warn b { color: var(--warn); }
.checkin { white-space: pre-wrap; font: 13px/1.45 ui-monospace, Menlo, monospace; background: var(--card2); border-radius: 10px; padding: 10px 12px; margin: 8px 0 10px; max-height: 260px; overflow: auto; user-select: text; -webkit-user-select: text; }

/* plan */
.food { width: 100%; border-collapse: collapse; }
.food td { padding: 10px 0; border-top: 1px solid var(--line); vertical-align: top; font-size: 15px; }
.food tr:first-child td { border-top: 0; }
.num { text-align: right; font-weight: 600; white-space: nowrap; padding-left: 10px !important; }
.num small { color: var(--muted); font-weight: 400; margin-left: 2px; }
.recipe { list-style: none; padding: 0; margin: 0 0 8px; }
.recipe li { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px solid var(--line); }

/* setup */
.hero { text-align: center; padding: 30px 0 18px; }
.logo { width: 72px; height: 72px; border-radius: 20px; background: var(--accent); color: var(--accent-ink); font: 800 38px/72px -apple-system, system-ui, sans-serif; font-family: inherit; margin: 0 auto 12px; }
.hero p { max-width: 320px; margin: 6px auto 0; }

/* tab bar */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex; justify-content: center; gap: 4px;
  padding: 6px 8px calc(env(safe-area-inset-bottom) + 6px); background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); border-top: 1px solid var(--line); }
.tab { flex: 1; max-width: 130px; appearance: none; border: 0; background: transparent; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 3px;
  font: 600 11px/1 -apple-system, system-ui, sans-serif; font-family: inherit; padding: 6px 0; min-height: 50px; cursor: pointer; }
.tab .ic { width: 24px; height: 24px; }
.tab.on { color: var(--accent); }

#toast { position: fixed; left: 50%; top: calc(env(safe-area-inset-top) + 10px); transform: translate(-50%, -20px); opacity: 0; transition: 0.25s; z-index: 30;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 99px; font-weight: 600; font-size: 14px; pointer-events: none; max-width: calc(100% - 32px); }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
