:root {
  --bg: #f4f2ee; --surface: #fcfcfb; --surface-2: #f0eee9; --line: #e4e1db;
  --ink: #1c1b19; --ink-2: #4a4641; --ink-3: #6f6a63;
  --accent: #e4572e;            /* run marks; validated vs --surface */
  --walk: #d3cfc7;              /* walk marks */
  --easy: #f2a586;              /* easy-run marks: between walk and hard */
  --btn: #c2410c; --btn-hover: #a8380a; --btn-ink: #fff;
  --good-bg: #e7f4ea; --good-ink: #1d6b35; --warn-bg: #fdf0e3; --warn-ink: #8a4a0c;
  --danger: #b42318;
  --shadow: 0 1px 2px rgb(0 0 0 / .04), 0 4px 16px rgb(0 0 0 / .05);
  --radius: 16px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121110; --surface: #1c1b19; --surface-2: #262421; --line: #302d2a;
    --ink: #f5f4f1; --ink-2: #cfcbc3; --ink-3: #a29d94;
    --accent: #ec6234; --walk: #4a4540; --easy: #9c4f33;
    --good-bg: #16301e; --good-ink: #8fdba5; --warn-bg: #36240f; --warn-ink: #f5c08a;
    --danger: #f97066;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
main { max-width: 760px; margin: 0 auto; padding: 8px 16px 112px; }
h1, h2 { line-height: 1.2; letter-spacing: -.02em; margin: 0 0 8px; }
h1 { font-size: 1.75rem; } h2 { font-size: 1.15rem; }
p { margin: 0 0 12px; }
code { background: var(--surface-2); padding: 1px 5px; border-radius: 6px; font-size: .9em; }
.muted { color: var(--ink-3); font-size: .925rem; }
[hidden] { display: none !important; }

/* Top bar + tabs (tabs move to a bottom bar on phones) */
.topbar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between;
  max-width: 760px; margin: 0 auto; padding: 14px 16px; background: var(--bg);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 750; font-size: 1.1rem; letter-spacing: -.02em; }
.tabs { display: flex; gap: 4px; background: var(--surface); padding: 4px; border-radius: 999px; box-shadow: var(--shadow); border: 1px solid var(--line); }
.tabs a {
  display: flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 999px;
  color: var(--ink-2); text-decoration: none; font-size: .9rem; font-weight: 600;
}
.tabs a svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tabs a[aria-current="page"] { background: var(--ink); color: var(--bg); }
@media (max-width: 600px) {
  .tabs {
    position: fixed; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); justify-content: space-around;
    border-radius: 20px; padding: 6px;
  }
  .tabs a { flex-direction: column; gap: 2px; font-size: .72rem; padding: 6px 10px; border-radius: 14px; flex: 1; }
  .tabs a svg { width: 22px; height: 22px; }
  h1 { font-size: 1.5rem; }
}

/* Cards */
.view { display: grid; gap: 16px; }
.view > div:not(.card) { display: grid; gap: 16px; }
.view > *, .view > div > * { min-width: 0; } /* let wide tables scroll inside their card instead of widening the page */
.narrow { max-width: 440px; margin: 0 auto; width: 100%; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.card.empty { text-align: center; padding: 40px 20px; }
.card.danger { border-color: color-mix(in srgb, var(--danger) 35%, var(--line)); }
.big-emoji { font-size: 3rem; }
.intro { text-align: center; padding: 24px 0 8px; }
.intro h1 { font-size: 2rem; }
.sub { color: var(--ink-2); font-size: 1.05rem; }
.eyebrow { text-transform: uppercase; letter-spacing: .08em; font-size: .75rem; font-weight: 700; color: var(--accent); margin-bottom: 4px; }

/* Forms */
label { display: block; margin: 0 0 14px; font-weight: 600; font-size: .925rem; }
input, textarea {
  display: block; width: 100%; margin-top: 6px; padding: 11px 12px; font: inherit; font-weight: 400;
  color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
}
textarea { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .95rem; }
input:focus-visible, textarea:focus-visible, .btn:focus-visible, .tabs a:focus-visible, .chips input:focus-visible + span, .plan input:focus-visible + .plan-body {
  outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 2px;
}
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.row.center { justify-content: center; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 10px 18px;
  font: inherit; font-weight: 650; text-decoration: none; cursor: pointer;
  background: var(--btn); color: var(--btn-ink); border: 1px solid transparent; border-radius: 12px;
}
.btn:hover { background: var(--btn-hover); }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.big { padding: 14px 26px; font-size: 1.05rem; }
.btn:disabled { opacity: .6; cursor: wait; }
.linkbtn { background: none; border: 0; padding: 0; margin-top: 14px; color: var(--ink-2); font: inherit; font-size: .9rem; text-decoration: underline; cursor: pointer; }

/* Chip radios */
fieldset { border: 0; padding: 0; margin: 0 0 16px; }
legend { font-weight: 600; font-size: .925rem; margin-bottom: 8px; padding: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips label { margin: 0; position: relative; }
.chips input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.chips label > span {
  display: inline-flex; align-items: center; justify-content: center; min-width: 48px; min-height: 44px; padding: 0 16px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--bg); cursor: pointer; font-weight: 600;
}
.chips input:checked + span { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.scale label { flex: 1; } .scale label > span { width: 100%; }
.ends { flex-basis: 100%; display: flex; justify-content: space-between; width: 100%; margin: 0; font-size: .8rem; color: var(--ink-3); }

/* Today */
.hero h1 { font-size: 1.9rem; }
.desc { color: var(--ink-2); }
.weekbar { display: flex; gap: 4px; margin: 14px 0 16px; }
.weekbar i { flex: 1; height: 6px; border-radius: 3px; background: var(--line); }
.weekbar i.done { background: var(--ink); }
.weekbar i.now { background: var(--accent); }
.strip { position: relative; display: flex; gap: 2px; height: 28px; margin: 4px 0 8px; }
.strip i { border-radius: 4px; background: var(--walk); min-width: 2px; }
.strip i.run { background: var(--accent); }
.strip i.easy { background: var(--easy); }
.legend { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; font-size: .8rem; color: var(--ink-3); margin-bottom: 14px; }
.legend > span { display: inline-flex; align-items: center; gap: 6px; }
.key { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.key.run { background: var(--accent); } .key.walk { background: var(--walk); } .key.easy { background: var(--easy); }
.pills { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.pill { display: inline-block; padding: 6px 12px; border-radius: 999px; font-size: .875rem; font-weight: 600; }
.pill.good { background: var(--good-bg); color: var(--good-ink); }
.pill.warn { background: var(--warn-bg); color: var(--warn-ink); }

.timer { text-align: center; }
.seg-label { font-size: 1.1rem; font-weight: 800; text-transform: uppercase; letter-spacing: .12em; margin: 0; }
.seg-label.run { color: var(--accent); }
.seg-label.easy { color: var(--ink-2); }
.clock { font-size: clamp(4rem, 22vw, 7rem); font-weight: 750; line-height: 1; letter-spacing: -.04em; font-variant-numeric: tabular-nums; margin: 8px 0; }
.timer .strip { margin: 16px 0 20px; }
.cursor { position: absolute; top: -4px; bottom: -4px; width: 3px; border-radius: 2px; background: var(--ink); box-shadow: 0 0 0 2px var(--surface); }

/* Stats */
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
@media (max-width: 600px) { .tiles { grid-template-columns: repeat(2, 1fr); } }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.tile .label { font-size: .8rem; color: var(--ink-3); font-weight: 600; }
.tile .value { font-size: 1.6rem; font-weight: 750; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.tile .value small { font-size: .9rem; font-weight: 600; color: var(--ink-3); margin-left: 2px; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart text { fill: var(--ink-3); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .bar { fill: var(--accent); }
.chart .hit { fill: transparent; cursor: default; }
.chart .hit:hover + .bar, .chart .hit:focus + .bar { opacity: .8; }
.tooltip {
  position: fixed; z-index: 20; pointer-events: none; padding: 6px 10px; border-radius: 8px; font-size: .85rem;
  background: var(--ink); color: var(--bg); transform: translate(-50%, calc(-100% - 8px)); white-space: nowrap;
}
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); font-weight: 650; padding: 8px 8px 8px 0; border-bottom: 1px solid var(--line); }
td { padding: 10px 8px 10px 0; border-bottom: 1px solid var(--line); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Plans */
.plan-list { display: grid; gap: 10px; margin-bottom: 18px; }
.plan { margin: 0; font-weight: 400; position: relative; }
.plan input { position: absolute; inset: 0; opacity: 0; margin: 0; width: 100%; height: 100%; pointer-events: none; }
.plan-body { display: block; padding: 14px 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); cursor: pointer; }
.plan input:checked + .plan-body { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.plan-head { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.plan-name { font-weight: 700; }
.plan-meta { font-size: .8rem; color: var(--ink-3); white-space: nowrap; }
.plan .strip { height: 10px; margin: 10px 0 0; }
.plan-actions { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: 10px; }
.plan-actions button { white-space: nowrap; }
.plan-actions button { background: none; border: 0; padding: 0; font: inherit; font-size: .85rem; font-weight: 600; color: var(--ink-2); cursor: pointer; text-decoration: underline; }
.plan-actions button.del { color: var(--danger); }
.share-offer { border-color: var(--accent); }

.toast {
  position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 30;
  max-width: calc(100% - 32px); padding: 12px 18px; border-radius: 12px; background: var(--ink); color: var(--bg);
  font-weight: 600; box-shadow: 0 8px 24px rgb(0 0 0 / .2);
}
@media (min-width: 601px) { .toast { bottom: 24px; } }
.logo-bg { fill: var(--accent); }

/* Personalized week */
.sessions { list-style: none; padding: 0; margin: 8px 0 12px; display: grid; gap: 2px; }
.sessions li { display: grid; grid-template-columns: 18px 1fr; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.sessions .name { display: block; }
.sessions li:last-child { border-bottom: 0; }
.sessions .dot { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--line); }
.sessions li.done .dot { background: var(--ink); border-color: var(--ink); }
.sessions li.done .name { color: var(--ink-3); text-decoration: line-through; }
.sessions li.now .dot { border-color: var(--accent); background: var(--accent); }
.sessions li.now .name { font-weight: 700; }
.sessions .amt { display: block; color: var(--ink-3); font-size: .85rem; font-variant-numeric: tabular-nums; }
details summary { cursor: pointer; font-weight: 650; padding: 6px 0; }
details[open] summary { margin-bottom: 6px; }

/* Imports + connections */
.pending { border-color: var(--accent); }
.badge { display: inline-block; margin-left: 6px; padding: 1px 6px; border-radius: 6px; font-size: .7rem; font-weight: 700; background: var(--surface-2); color: var(--ink-2); vertical-align: 1px; }
.connection { display: grid; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.connection:last-child { border-bottom: 0; padding-bottom: 0; }
.connection:first-child { padding-top: 0; }
.btn.strava { background: #fc4c02; color: #fff; } /* Strava brand orange */
.btn.strava:hover { background: #d94102; }
.btn.oura { background: var(--ink); color: var(--bg); }
.plan-desc { display: block; margin-top: 6px; font-size: .875rem; color: var(--ink-2); }

.divider { height: 1px; background: var(--line); margin: 20px 0; }
.help { margin: 6px 0 0; padding-left: 18px; color: var(--ink-2); font-size: .9rem; display: grid; gap: 8px; }
input[type=file] { padding: 9px; cursor: pointer; }

/* Weather */
.forecast { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; margin: 4px 0 12px; }
.fday { display: grid; justify-items: center; gap: 2px; padding: 10px 2px; border-radius: 12px; background: var(--bg); border: 1px solid var(--line); text-align: center; font-size: .8rem; }
.fday .wd { font-weight: 700; }
.fday .icon { font-size: 1.4rem; line-height: 1.3; }
.fday .hi { font-weight: 650; font-variant-numeric: tabular-nums; }
.fday .lo { color: var(--ink-3); font-variant-numeric: tabular-nums; }
.fday.today .wd { color: var(--accent); }
.fday .prob { color: var(--ink-3); font-size: .7rem; white-space: nowrap; }
.fday.run { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.fday .tag { margin-top: 4px; padding: 2px 6px; border-radius: 6px; background: var(--accent); color: #fff; font-size: .68rem; font-weight: 700; line-height: 1.25; max-width: 100%; }
@media (max-width: 420px) { .fday { padding: 8px 1px; } .forecast { gap: 4px; } }
.attrib { font-size: .75rem; color: var(--ink-3); margin: 0; }
.attrib a { color: inherit; }
.city { display: flex; gap: 8px; align-items: stretch; margin-bottom: 10px; }
.city input { margin: 0; flex: 1; min-width: 0; }
.city-results { display: grid; gap: 6px; }
.city-results .btn { justify-content: flex-start; text-align: left; }

.icon-btn { background: none; border: 0; padding: 6px 8px; border-radius: 8px; cursor: pointer; font-size: .95rem; opacity: .6; }
.icon-btn:hover, .icon-btn:focus-visible { opacity: 1; background: var(--surface-2); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
/* Keep the delete column visible while the history table scrolls sideways on phones */
#history td:last-child, #history th:last-child { position: sticky; right: 0; background: var(--surface); padding-right: 0; }
.small-link { font-size: .875rem; color: var(--ink-2); }
.strip i { cursor: default; }
.strip i:hover { filter: brightness(.9); }

/* Avatar + tokens */
.topbar { gap: 12px; }
.brand { margin-right: auto; white-space: nowrap; }
.wallet { flex: none; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px 3px 3px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); color: var(--ink); text-decoration: none; font-weight: 700; font-size: .9rem; font-variant-numeric: tabular-nums; box-shadow: var(--shadow); }
.mini-avatar { display: inline-flex; width: 30px; height: 30px; border-radius: 50%; overflow: hidden; }
.avatar-hero { display: flex; flex-wrap: wrap; align-items: center; gap: 20px; }
.big-avatar { flex: none; }
.big-avatar svg { display: block; }
.avatar-side { flex: 1; min-width: 200px; }
.token-balance { font-size: 2.4rem; font-weight: 800; letter-spacing: -.03em; margin: 0 0 8px; font-variant-numeric: tabular-nums; }
.pet-ring { fill: var(--surface); stroke: var(--line); stroke-width: 1.5; }
.shop-slot h3 { font-size: .95rem; margin: 16px 0 8px; }
.shop-slot:first-child h3 { margin-top: 0; }
.shop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 8px; }
.shop-item { display: grid; justify-items: center; gap: 2px; padding: 8px 4px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); font: inherit; cursor: pointer; }
.shop-item:hover { background: var(--surface-2); }
.shop-item.on { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.shop-item.locked { opacity: .55; }
.shop-item:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 2px; }
.shop-item .thumb { display: grid; place-items: center; width: 56px; height: 56px; }
.shop-item .thumb svg { display: block; }
.none-thumb { font-size: 1.5rem; color: var(--ink-3); }
.shop-item .iname { font-size: .8rem; font-weight: 650; text-align: center; }
.shop-item .iprice { font-size: .72rem; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.shop-item.on .iprice { color: var(--accent); font-weight: 700; }
.token-log { list-style: none; padding: 0; margin: 0; }
.token-log li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: .9rem; }
.token-log li:last-child { border-bottom: 0; }
.token-log .amt { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--good-ink); }
.token-log .amt.spent { color: var(--ink-3); }
@media (max-width: 600px) { .tabs a { padding: 6px 4px; } }
