:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #15171a;
  --muted: #646b75;
  --line: #e2e5ea;
  --accent: #2f7cf6;
  --ok: #1e9e63;
  --warn: #c4462f;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1114;
    --panel: #171a1f;
    --text: #e9ecf0;
    --muted: #8e96a1;
    --line: #2a2f37;
    --accent: #5b9bff;
    --ok: #3cc488;
    --warn: #ff7a62;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
.wrap { max-width: 640px; margin: 0 auto; padding: 32px 16px 48px; }
header h1 { margin: 0; font-size: 28px; letter-spacing: -0.01em; }
.sub { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.sub b { color: var(--text); font-weight: 600; }

.gauge { position: relative; margin: 28px auto 8px; max-width: 360px; }
.dial { width: 100%; display: block; }
.dial path { fill: none; stroke-width: 14; stroke-linecap: round; }
.track { stroke: var(--line); }
.bar { stroke: var(--accent); stroke-dasharray: 251.3; stroke-dashoffset: 251.3; transition: stroke-dashoffset .25s linear, stroke .2s; }
.readout { position: absolute; left: 0; right: 0; bottom: 0; text-align: center; }
.value { font-size: 56px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1; }
.unit { color: var(--muted); font-size: 14px; margin-top: 4px; }
.phase { color: var(--muted); font-size: 13px; margin-top: 2px; min-height: 1.4em; }

.start {
  display: block; margin: 20px auto 28px; min-width: 180px; padding: 14px 28px;
  border: 0; border-radius: 999px; background: var(--accent); color: #fff;
  font: 600 18px/1 inherit; font-family: inherit; cursor: pointer;
}
.start:disabled { opacity: .55; cursor: default; }
.start:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 3px; }

.cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
@media (max-width: 520px) { .cards { grid-template-columns: repeat(2, 1fr); } }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.card.active { border-color: var(--accent); }
.label { color: var(--muted); font-size: 13px; }
.num { font-size: 22px; font-weight: 650; font-variant-numeric: tabular-nums; margin-top: 2px; white-space: nowrap; }
.num small { font-size: 12px; font-weight: 500; color: var(--muted); margin-left: 4px; }

.share { margin: 22px 0 0; font-size: 14px; color: var(--muted); word-break: break-all; }
.share a { color: var(--accent); }
.link-btn { background: none; border: 0; color: var(--accent); cursor: pointer; font: inherit; text-decoration: underline; padding: 0 0 0 6px; }
footer { margin-top: 28px; color: var(--muted); font-size: 13px; }
.err { color: var(--warn); }

/* stats page */
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 20px 0; }
@media (max-width: 520px) { .stats-grid { grid-template-columns: 1fr; } }
.tbl-wrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; }
table { border-collapse: collapse; width: 100%; font-size: 13px; font-variant-numeric: tabular-nums; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
th:first-child, td:first-child, th.l, td.l { text-align: left; }
th { color: var(--muted); font-weight: 500; position: sticky; top: 0; background: var(--panel); }
tr:last-child td { border-bottom: 0; }
td.ua { max-width: 260px; overflow: hidden; text-overflow: ellipsis; color: var(--muted); }
.stats-wrap { max-width: 1000px; }
