:root {
  --bg: #f4f5f7; --card: #ffffff; --text: #14161a; --muted: #6a7078; --line: #e1e4e9;
  --cheap: #1f9d55; --mid: #d99a0b; --dear: #d6403a; --accent: #1f9d55;
  --bar-dim: .38;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115; --card: #181b21; --text: #f2f4f7; --muted: #8c93a0; --line: #272b33;
    --cheap: #3ddc84; --mid: #f2b632; --dear: #ff6b63; --accent: #3ddc84;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh; min-height: 100dvh;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
#app { max-width: 520px; margin: 0 auto; padding: 16px 16px 40px; }
.muted { color: var(--muted); font-size: .85rem; }

.top { display: flex; justify-content: space-between; align-items: center; min-height: 44px; }
.chip {
  padding: 10px 16px; border-radius: 999px; background: var(--card);
  border: 1px solid var(--line); font-weight: 600; font-size: .95rem;
}

.now { text-align: center; padding: 28px 0 12px; }
.status {
  display: inline-block; padding: 8px 22px; border-radius: 999px;
  font-size: 1.35rem; font-weight: 700; letter-spacing: .02em;
  background: color-mix(in srgb, var(--c, var(--muted)) 18%, transparent); color: var(--c, var(--muted));
}
.big {
  font-size: clamp(5rem, 28vw, 8.5rem); font-weight: 800; line-height: 1;
  margin-top: 18px; font-variant-numeric: tabular-nums; letter-spacing: -.03em;
  color: var(--c, var(--text));
}
.unit { margin-top: 10px; font-size: 1.15rem; color: var(--muted); }

.best { margin: 18px 0 8px; padding: 14px 16px; border-radius: 18px; background: var(--card); border: 1px solid var(--line); text-align: center; font-size: 1.2rem; }
.best:empty { display: none; }
.best .l { padding: 4px 0; font-weight: 600; }
.best .cheapl b { color: var(--cheap); }
.best .dearl b { color: var(--dear); }

.runs { margin-top: 18px; display: flex; flex-direction: column; gap: 8px; }
.run { display: grid; grid-template-columns: 14px 1fr auto 3.6em; align-items: center; gap: 12px; padding: 14px 16px; border-radius: 14px; background: var(--card); border: 1px solid var(--line); font-size: 1.05rem; }
.run i { width: 14px; height: 14px; border-radius: 50%; background: var(--c); }
.run .when { font-weight: 600; }
.run small { font-weight: 400; color: var(--muted); }
.run .lvl { color: var(--c); font-weight: 700; }
.run .avg { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.run.later { display: block; text-align: center; color: var(--muted); font-size: .9rem; background: none; border-style: dashed; }

footer { margin-top: 28px; text-align: center; }
.note { color: var(--muted); font-size: .85rem; line-height: 1.4; text-align: center; padding: 8px; text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 4px; }
.offline { color: var(--mid); }

.sheet { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: flex-end; justify-content: center; z-index: 10; }
.sheet[hidden] { display: none; }
.sheet-card { width: 100%; max-width: 520px; background: var(--card); border-radius: 24px 24px 0 0; padding: 24px 20px calc(24px + env(safe-area-inset-bottom)); }
.sheet-card h3 { margin: 0 0 6px; font-size: 1.3rem; }
.sheet-card p { margin: 0 0 16px; color: var(--muted); line-height: 1.4; }
.opt { display: block; width: 100%; padding: 18px; margin-top: 10px; border-radius: 16px; border: 2px solid var(--line); font-size: 1.15rem; font-weight: 600; text-align: left; }
.opt small { display: block; font-weight: 400; color: var(--muted); margin-top: 2px; }
.opt.on { border-color: var(--accent); }
.stepper { display: flex; align-items: center; justify-content: center; gap: 18px; margin: 14px 0; }
.stepper button { width: 64px; height: 64px; border-radius: 50%; border: 2px solid var(--line); font-size: 2rem; }
.stepper output { font-size: 2.2rem; font-weight: 700; min-width: 5ch; text-align: center; font-variant-numeric: tabular-nums; }
.done { display: block; width: 100%; margin-top: 8px; padding: 16px; border-radius: 16px; background: var(--accent); color: #0b0d10; font-weight: 700; font-size: 1.1rem; }

.pill {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(18px + env(safe-area-inset-bottom));
  z-index: 20; padding: 14px 20px; border-radius: 999px; background: var(--text); color: var(--bg);
  font-weight: 600; font-size: .95rem; box-shadow: 0 6px 24px rgba(0,0,0,.35); max-width: calc(100% - 32px);
}
.pill[hidden] { display: none; }
