:root {
  --bg: #f4f6f5;
  --panel: #ffffff;
  --text: #15191c;
  --muted: #5e6871;
  --line: #dfe4e2;
  --chip: #eef2f0;
  --accent: #1f8f4e;
  --accent-ink: #ffffff;
  --accent-soft: #e3f3ea;
  --danger: #b3261e;
  --amber: #b26a00;
  --seg-0: #2f6fdf; --seg-1: #e2731b; --seg-2: #8a4fd6; --seg-3: #c23b6b; --seg-break: #8a949e; --seg-warm: #b0b7be;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.04);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1312; --panel: #171c1b; --text: #e8ecea; --muted: #9aa5a0; --line: #2a3230; --chip: #222a28;
    --accent: #2fb36a; --accent-soft: #173326; --amber: #f0a43a; --shadow: none;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1312; --panel: #171c1b; --text: #e8ecea; --muted: #9aa5a0; --line: #2a3230; --chip: #222a28;
  --accent: #2fb36a; --accent-soft: #173326; --amber: #f0a43a; --shadow: none;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); }
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.hidden { display: none !important; }

/* header */
.top { background: var(--panel); border-bottom: 1px solid var(--line); }
.top .wrap { display: flex; align-items: center; gap: 12px; height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; color: var(--text); text-decoration: none; }
.brand img { width: 32px; height: 32px; }
.top .spacer { flex: 1; }
.who { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--muted); min-width: 0; }
.who img { width: 28px; height: 28px; border-radius: 50%; }
.who .email { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; }

/* buttons */
button, .btn { font: inherit; border: 1px solid var(--line); background: var(--chip); color: var(--text); border-radius: 10px; padding: 8px 14px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 8px; }
button:hover, .btn:hover { filter: brightness(0.97); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn-big { padding: 12px 20px; font-size: 17px; border-radius: 12px; }
.btn-danger { color: var(--danger); }
button:disabled { opacity: .5; cursor: not-allowed; }
.chip { padding: 5px 10px; border-radius: 999px; font-size: 14px; }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }

/* cards and layout */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; margin: 24px auto 48px; }
@media (max-width: 860px) { .grid { grid-template-columns: 1fr; } }
h1 { font-size: 28px; line-height: 1.2; margin: 0 0 6px; }
h2 { font-size: 18px; margin: 0 0 12px; }

/* landing */
.hero { padding: 56px 0 24px; display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 32px; align-items: center; }
.hero h1 { font-size: 40px; letter-spacing: -0.02em; }
.hero p.lead { font-size: 18px; color: var(--muted); margin: 10px 0 24px; max-width: 32em; }
.hero .watch { justify-self: center; width: min(280px, 70vw); aspect-ratio: 1; border-radius: 50%; background: #000; border: 10px solid #2a2f2d; display: flex; flex-direction: column; align-items: center; justify-content: center; color: #fff; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.watch .lbl { color: #9a9a9a; font-size: 15px; }
.watch .clk { font-size: 64px; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.1; }
.watch .sub { color: #ffb020; font-size: 16px; }
.watch .pill { margin-top: 14px; background: #1f8f4e; border-radius: 999px; padding: 6px 22px; font-size: 15px; }
@media (max-width: 760px) { .hero { grid-template-columns: 1fr; padding-top: 32px; } .hero h1 { font-size: 32px; } }
.features { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin: 24px 0 56px; }
@media (max-width: 760px) { .features { grid-template-columns: 1fr; } }
.features h3 { margin: 0 0 6px; font-size: 16px; }
.features p { margin: 0; color: var(--muted); font-size: 15px; }
.signin { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.devlogin { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.devlogin input { font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); color: var(--text); }

/* matches list */
.matches { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.matches a { display: grid; grid-template-columns: 56px minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 14px 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); color: var(--text); text-decoration: none; }
.matches a:hover { border-color: var(--accent); }
.date { text-align: center; line-height: 1.1; }
.date .d { font-size: 22px; font-weight: 700; }
.date .m { font-size: 12px; text-transform: uppercase; color: var(--muted); letter-spacing: .05em; }
.matches .title { font-weight: 600; }
.badge { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); white-space: nowrap; }
.badge.grey { background: var(--chip); color: var(--muted); }
.empty { text-align: center; padding: 40px 16px; color: var(--muted); }

/* connect */
.code { font: 700 36px/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .18em; text-align: center; padding: 16px; background: var(--accent-soft); color: var(--accent); border-radius: 12px; margin: 12px 0 6px; }
.steps { padding-left: 20px; margin: 10px 0; color: var(--muted); font-size: 15px; }
.steps li { margin: 4px 0; }
.devices { list-style: none; padding: 0; margin: 0 0 12px; }
.devices li { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.devices li:last-child { border-bottom: 0; }
.devices .grow { flex: 1; min-width: 0; }

/* match page and viewer */
.mapgrid { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 0; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--panel); }
.mapgrid #map { min-height: 460px; }
.mapgrid aside { padding: 16px; border-left: 1px solid var(--line); }
@media (max-width: 860px) { .mapgrid { grid-template-columns: 1fr; } .mapgrid #map { height: 56vh; min-height: 320px; } .mapgrid aside { border-left: 0; border-top: 1px solid var(--line); } }
.row { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 12px; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 15px; }
th, td { text-align: right; padding: 6px 4px; border-bottom: 1px solid var(--line); }
th:first-child, td:first-child { text-align: left; white-space: nowrap; }
th { font-weight: 600; font-size: 13px; color: var(--muted); }
tr.total td { font-weight: 700; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; }
.facts { display: flex; flex-wrap: wrap; gap: 8px 20px; margin: 12px 0 20px; color: var(--muted); }
.facts b { color: var(--text); }
.page-head { margin: 24px 0 8px; display: flex; flex-wrap: wrap; gap: 12px; align-items: end; justify-content: space-between; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
footer { color: var(--muted); font-size: 13px; padding: 24px 0 40px; text-align: center; }
.brand, .who button { white-space: nowrap; }
@media (max-width: 520px) { .who .email { display: none; } }

/* viewer details */
.chip-quiet { background: transparent; border-style: dashed; color: var(--muted); }
tr.off td { opacity: .45; }
h3.sub { font-size: 14px; margin: 18px 0 8px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; margin: 8px 0 16px; }
.kpis .k { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.kpis .k small { font-size: 13px; font-weight: 500; color: var(--muted); }
table.zones td.bar { width: 30%; }
table.zones td.bar span { display: block; height: 8px; border-radius: 4px; min-width: 2px; }
.z-walk { background: #9aa5a0; }
.z-jog { background: #4f9ad8; }
.z-run { background: #f0a43a; }
.z-sprint { background: #e5322d; }
ol.sprints { list-style: none; padding: 0; margin: 0; }
ol.sprints li { border-bottom: 1px solid var(--line); }
ol.sprints button { all: unset; display: block; width: 100%; padding: 8px 2px; cursor: pointer; font-size: 15px; }
ol.sprints button:hover { color: var(--accent); }
.units { display: flex; gap: 6px; }
.version { color: var(--muted); }
