:root, html[data-theme="dark"] {
  --bg: #12140f;
  --bg2: #1a1d16;
  --card: #22261c;
  --ink: #e8edd8;
  --muted: #8b9378;
  --line: #343b2b;
  --lime: #c6f04d;
  --lime-ink: #14180c;
  --lime-dim: #8aad2a;
  --rust: #e07a3d;
  --sky: #7ec8c0;
  --bad: #e25b4a;
  --ok: #6fbf73;
  --danger-bg: #3a1c18;
  --danger-ink: #ffb4a8;
  --danger-line: #5a2a24;
  --banner-bg: #2a2414;
  --banner-line: #4a3c1c;
  --banner-ink: #e6d7a8;
  --drop-bg: #1b2014;
  --glow-a: #2a3318;
  --glow-b: #2a1c12;
  --chart: #c6f04d;
  --chart-rest: #3a4030;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
  color-scheme: dark;
}
html[data-theme="light"] {
  --bg: #f4f1e6;
  --bg2: #fffdf6;
  --card: #ffffff;
  --ink: #1c2114;
  --muted: #5d644c;
  --line: #d7d3c2;
  --lime: #5a7d12;
  --lime-ink: #f7ffe8;
  --lime-dim: #4d6b14;
  --rust: #c45a1f;
  --sky: #2f7d76;
  --bad: #c43c2e;
  --ok: #2f7a3a;
  --danger-bg: #fde8e4;
  --danger-ink: #8a2418;
  --danger-line: #f0c2ba;
  --banner-bg: #fff4d6;
  --banner-line: #e6d39a;
  --banner-ink: #5a4a18;
  --drop-bg: #eef3dc;
  --glow-a: #e4ecc4;
  --glow-b: #f3e0cc;
  --chart: #5a7d12;
  --chart-rest: #d5d0bc;
  --shadow: 0 10px 28px rgba(50, 48, 30, 0.08);
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--sans, "Outfit", system-ui, sans-serif); }
:root {
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --sans: "Outfit", system-ui, sans-serif;
  --pad: 16px;
}
body {
  min-height: 100vh;
  min-height: 100dvh;
  background:
    radial-gradient(1200px 500px at 10% -10%, var(--glow-a) 0%, transparent 55%),
    radial-gradient(800px 400px at 100% 0%, var(--glow-b) 0%, transparent 50%),
    var(--bg);
  -webkit-text-size-adjust: 100%;
}
.app {
  max-width: 860px;
  margin: 0 auto;
  padding: 20px var(--pad) calc(88px + env(safe-area-inset-bottom));
}
.top {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}
.brand { display: flex; gap: 12px; align-items: center; min-width: 0; }
.mark {
  width: 46px; height: 46px; border-radius: 12px; flex: 0 0 auto;
  background: var(--lime); color: var(--lime-ink);
  font-weight: 700; display: grid; place-items: center;
  letter-spacing: -0.04em;
}
h1 { margin: 0; font-size: 22px; letter-spacing: -0.03em; }
.brand p { margin: 0; color: var(--muted); font-size: 13px; }
.tabs {
  display: flex;
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px;
  max-width: 100%;
}
.tabs button {
  border: 0; background: transparent; color: var(--muted);
  font: 600 14px var(--sans); padding: 10px 14px; border-radius: 999px; cursor: pointer;
  min-height: 40px;
}
.tabs button.active { background: var(--lime); color: var(--lime-ink); }
.view { display: none; }
.view.active { display: block; }
.row { display: flex; gap: 12px; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 160px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > span { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.field em { font-style: normal; color: var(--muted); opacity: 0.8; text-transform: none; letter-spacing: 0; }
input[type="text"], input[type="number"], input[type="date"], input[type="password"], input[type="email"] {
  background: var(--bg2); border: 1px solid var(--line); color: var(--ink);
  border-radius: 10px; padding: 12px; font: 500 16px var(--mono);
  width: 100%; max-width: 100%;
}
input:focus { outline: 2px solid var(--lime); border-color: transparent; }
.seg { display: flex; background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.seg button {
  border: 0; background: transparent; color: var(--muted);
  font: 600 14px var(--sans); padding: 10px 14px; border-radius: 8px; cursor: pointer;
  flex: 1; min-height: 40px;
}
.seg button.on { background: var(--lime); color: var(--lime-ink); }
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 16px; padding: 16px; margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
h2 { margin: 0 0 8px; font-size: 16px; }
h2 small { color: var(--muted); font-weight: 500; }
.muted { color: var(--muted); font-size: 13px; margin: 0 0 12px; }
code { font-family: var(--mono); color: var(--lime); }
.splits {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(108px, 1fr));
  gap: 8px;
}
.split {
  background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 8px;
}
.split label { display: block; font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.split input { width: 100%; border: 0; background: transparent; padding: 8px 0; font-size: 16px; }
.split .read { font-family: var(--mono); font-size: 12px; color: var(--sky); min-height: 16px; }
.compare { grid-column: 1 / -1; font-family: var(--mono); font-size: 13px; color: var(--sky); }
.dual { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.dual .field { margin: 0; }
.hint { font-family: var(--mono); font-size: 13px; color: var(--lime-dim); min-height: 18px; margin-top: 6px; }
.preview { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; margin: 8px 0 16px; }
.stat {
  background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px;
}
.stat b { display: block; font-size: 11px; color: var(--muted); font-weight: 500; text-transform: uppercase; letter-spacing: 0.06em; }
.stat strong { font-family: var(--mono); font-size: 18px; }
.stat.gps strong { color: var(--lime); }
.stat.map strong { color: var(--rust); }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.primary, .ghost, .danger {
  border: 0; border-radius: 10px; padding: 12px 18px; font: 600 15px var(--sans); cursor: pointer;
  min-height: 44px;
}
.primary { background: var(--lime); color: var(--lime-ink); }
.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.danger { background: var(--danger-bg); color: var(--danger-ink); border: 1px solid var(--danger-line); }
.empty { color: var(--muted); padding: 40px 8px; text-align: center; }
.pb-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin-bottom: 16px; }
.pb { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.pb .d { font-size: 12px; color: var(--muted); }
.pb .t { font-family: var(--mono); font-size: 18px; color: var(--lime); }
.pb .s { font-size: 11px; color: var(--muted); }
.run-row {
  display: grid; grid-template-columns: 88px 1fr auto; gap: 10px; align-items: center;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px; margin-bottom: 8px; cursor: pointer;
}
.run-row:hover { border-color: var(--lime-dim); }
.run-row .date { font-family: var(--mono); font-size: 13px; color: var(--muted); }
.run-row .meta { font-size: 14px; }
.run-row .pace { font-family: var(--mono); color: var(--lime); }
.bars { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; }
.bar-row { display: grid; grid-template-columns: 72px 1fr 90px; gap: 8px; align-items: center; font-size: 13px; }
.bar { height: 10px; background: var(--bg2); border-radius: 99px; overflow: hidden; display: flex; }
.bar i { display: block; height: 100%; }
.bar i.gps { background: var(--lime); }
.bar i.map { background: var(--rust); }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 420px; }
.table th {
  color: var(--muted); font-weight: 500; padding: 6px 8px;
  border-bottom: 1px solid var(--line); text-align: right;
}
.table td {
  padding: 7px 8px; border-bottom: 1px solid var(--line);
  font-family: var(--mono); text-align: right;
}
.table th:first-child,
.table td:first-child { text-align: left; }
.heat-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 4px; }
.heat-cal {
  display: grid;
  grid-auto-flow: column;
  grid-template-rows: repeat(8, auto);
  gap: 3px;
  width: max-content;
}
.heat-dow {
  font-size: 9px; color: var(--muted); line-height: 12px;
  height: 12px; padding-right: 4px;
}
.heat-month {
  font-size: 10px; color: var(--muted); height: 14px;
  grid-row: 1;
}
.heat-cell {
  width: 12px; height: 12px; border-radius: 2px;
  background: var(--heat-0); border: 0;
  padding: 0; cursor: default;
}
.heat-cell.has { cursor: pointer; }
.heat-cell.l1 { background: var(--heat-1); }
.heat-cell.l2 { background: var(--heat-2); }
.heat-cell.l3 { background: var(--heat-3); }
.heat-cell.l4 { background: var(--heat-4); }
.heat-legend {
  display: flex; align-items: center; gap: 4px;
  margin-top: 10px; font-size: 11px; color: var(--muted);
}
.heat-legend i {
  width: 12px; height: 12px; border-radius: 2px; display: inline-block;
}
#heat-weekdays {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
  margin-top: 14px;
}
#heat-weekdays .muted { grid-column: 1 / -1; margin: 0 0 2px; }
.heat-wd {
  border-radius: 10px; padding: 8px 4px; text-align: center;
  background: var(--bg2); border: 1px solid var(--line);
  color: var(--ink);
}
.heat-wd .n { font-family: var(--mono); font-size: 13px; margin-top: 2px; color: inherit; }
.heat-wd .d { font-size: 10px; text-transform: uppercase; color: inherit; opacity: 0.8; }
.heat-wd.l3, .heat-wd.l4 { color: #14180c; }
html[data-theme="light"] .heat-wd.l3,
html[data-theme="light"] .heat-wd.l4 { color: #f7ffe8; }
.pager {
  display: flex; flex-wrap: nowrap; gap: 6px; align-items: center;
  justify-content: center; margin: 0 0 12px;
}
.pager-btn {
  border: 1px solid var(--line);
  background: var(--bg2);
  color: var(--ink);
  border-radius: 8px;
  width: 36px; min-width: 36px; height: 36px;
  padding: 0; font-size: 13px; line-height: 1;
  cursor: pointer; flex: 0 0 auto;
}
.pager-pos {
  display: inline-flex; align-items: center; justify-content: center;
  height: 36px; margin: 0; line-height: 1;
  font-variant-numeric: tabular-nums; min-width: 3.5em; text-align: center;
}
.pager button:disabled { opacity: 0.35; cursor: default; }
:root, html[data-theme="dark"] {
  --heat-0: #2a2f22;
  --heat-1: #3d4a22;
  --heat-2: #6a8a28;
  --heat-3: #a4d03a;
  --heat-4: #c6f04d;
}
html[data-theme="light"] {
  --heat-0: #e7e4d4;
  --heat-1: #c5d48a;
  --heat-2: #8eae3a;
  --heat-3: #5f7c14;
  --heat-4: #3e5608;
}
.delta.pos { color: var(--ok); }
.delta.neg { color: var(--bad); }
#trend, #week-chart, #month-chart { width: 100%; display: block; max-width: 100%; }
.auth-screen {
  min-height: 100vh; min-height: 100dvh;
  display: grid; place-items: center;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
}
.auth-card {
  width: min(440px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 22px;
  box-shadow: var(--shadow);
}
.auth-card .brand { margin-bottom: 18px; justify-content: space-between; }
.top-right { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: flex-end; }
.who { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.banner {
  background: var(--banner-bg); border: 1px solid var(--banner-line); color: var(--banner-ink);
  border-radius: 12px; padding: 10px 12px; margin-bottom: 16px;
  display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap;
}
.drop {
  border: 1px dashed var(--lime-dim); border-radius: 14px; padding: 18px;
  text-align: center; margin-bottom: 16px; background: var(--drop-bg); color: var(--muted);
}
.drop.over { border-color: var(--lime); }
.drop strong { display: block; color: var(--ink); margin-bottom: 4px; }
.drop em { display: block; margin-top: 8px; font-style: normal; color: var(--sky); font-family: var(--mono); font-size: 12px; }
.linkish { color: var(--lime); cursor: pointer; text-decoration: underline; }
.check { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; min-height: 40px; }
.vol-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; margin-bottom: 16px; }
.auth-card .seg { margin: 0 0 16px; flex-wrap: wrap; }
.auth-card:not([data-mode="reset"]) .auth-reset { display: none !important; }
.auth-card:not([data-mode="signup"]) .auth-signup { display: none !important; }
.auth-card[data-mode="reset"] #pass-field { display: none !important; }
.auth-screen[hidden],
.app[hidden],
#split-grid[hidden],
#map-split-grid[hidden],
[hidden] { display: none !important; }
.keybox { font-family: var(--mono); font-size: 18px; color: var(--lime); letter-spacing: 0.08em; margin: 8px 0; word-break: break-all; }
.icon-btn {
  border: 1px solid var(--line);
  background: var(--bg2);
  color: var(--ink);
  border-radius: 999px;
  min-width: 44px;
  min-height: 44px;
  padding: 0 12px;
  font: 600 13px var(--sans);
  cursor: pointer;
}
.theme-btn { min-width: 44px; padding: 0; font-size: 18px; line-height: 1; }
html[data-theme="dark"] .theme-btn::after { content: "☀"; }
html[data-theme="light"] .theme-btn::after { content: "☾"; }

@media (max-width: 720px) {
  .app { padding-top: 14px; }
  .top { align-items: flex-start; }
  .top-right { width: 100%; justify-content: space-between; }
  .tabs {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: calc(10px + env(safe-area-inset-bottom));
    z-index: 20;
    justify-content: space-between;
    box-shadow: var(--shadow);
  }
  .tabs button { flex: 1; padding: 10px 6px; font-size: 13px; }
  .actions { flex-direction: column; }
  .actions .primary, .actions .ghost, .actions .danger { width: 100%; }
  .dual { grid-template-columns: 1fr; }
  .run-row { grid-template-columns: 1fr auto; }
  .run-row .date { grid-column: 1 / -1; }
  .bar-row { grid-template-columns: 56px 1fr 72px; }
  .who { order: 2; }
  .theme-btn { order: 1; }
}
@media (max-width: 400px) {
  h1 { font-size: 19px; }
  .brand p { display: none; }
  .tabs button { font-size: 12px; padding: 10px 4px; }
}
@media (pointer: coarse) {
  .tabs button, .seg button, .icon-btn { min-height: 44px; }
}
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  object-fit: cover; border: 1px solid var(--line); background: var(--bg2);
  flex: 0 0 auto;
}
.avatar.lg { width: 88px; height: 88px; }
.avatar.fallback {
  display: grid; place-items: center;
  font-weight: 700; color: var(--lime-ink); background: var(--lime);
}
.avatar-row { display: flex; gap: 16px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.pass-wrap { display: flex; gap: 8px; align-items: stretch; }
.pass-wrap input { flex: 1; min-width: 0; }
.pass-toggle {
  border: 1px solid var(--line);
  background: var(--bg2);
  color: var(--ink);
  border-radius: 10px;
  padding: 0 12px;
  font: 600 13px var(--sans);
  cursor: pointer;
  min-width: 64px;
}
