/* RunLog — look and feel (from design mockup v2). Light + dark follow the device setting. */
:root {
  --bg: #F2F2F7; --surface: #FFFFFF; --ink: #000; --ink2: #6C6C70; --ink3: #AEAEB2; --rule: #E3E3E8;
  --lane: #5856D6; --lane-soft: rgba(88,86,214,.12); --heart: #E5316A; --step: #0E9AA7; --go: #34C759; --warn: #B25000;
  --bar: rgba(249,249,249,.94);
  --num: "SF Pro Display", -apple-system, "Segoe UI Variable Display", "Segoe UI", system-ui, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #000; --surface: #1C1C1E; --ink: #FFF; --ink2: #98989F; --ink3: #636366; --rule: #2C2C2E;
    --lane: #5E5CE6; --lane-soft: rgba(94,92,230,.22); --heart: #FF4F86; --step: #3CC8D3; --go: #30D158; --warn: #FF9F0A;
    --bar: rgba(22,22,24,.94); }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif; background: var(--bg); color: var(--ink);
  -webkit-text-size-adjust: 100%; }
button, input, select { font: inherit; color: inherit; }
a { color: var(--lane); }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid var(--lane); outline-offset: 2px; }
[hidden] { display: none !important; }

.app { max-width: 560px; margin: 0 auto; min-height: 100vh; padding: env(safe-area-inset-top) 0 calc(96px + env(safe-area-inset-bottom)); }

/* Top bar for sub-pages */
.navbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; height: 44px; padding: 0 8px; background: var(--bg); }
.back { background: none; border: 0; color: var(--lane); font-size: 17px; display: flex; align-items: center; gap: 2px; cursor: pointer; padding: 6px; text-decoration: none; }
.back svg { width: 12px; height: 20px; }

/* Tab bar */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: var(--bar); border-top: .5px solid var(--rule);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); padding-bottom: env(safe-area-inset-bottom); }
.tabbar nav { max-width: 560px; margin: 0 auto; display: grid; grid-template-columns: repeat(4, 1fr); padding: 6px 4px 4px; }
.tab { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 10.5px; font-weight: 500; color: var(--ink3); text-decoration: none; padding: 2px 0; }
.tab svg { width: 28px; height: 26px; }
.tab[aria-current="page"] { color: var(--lane); }

/* Banners */
.banner { margin: 10px 16px 0; padding: 10px 14px; border-radius: 12px; font-size: 14px; background: var(--surface); }
.banner.sample { background: var(--lane-soft); color: var(--ink); display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.banner.error { border: 1px solid var(--warn); color: var(--ink); }
.banner b { display: block; }
.banner button { border: 0; background: none; color: var(--lane); font-weight: 600; cursor: pointer; padding: 4px; white-space: nowrap; }

/* Common blocks */
.large-title { font-size: 34px; font-weight: 700; margin: 12px 20px 4px; }
.page-title { font-size: 28px; font-weight: 700; margin: 4px 20px 10px; }
.section-title { display: flex; justify-content: space-between; align-items: baseline; margin: 24px 20px 8px; }
.section-title h2 { font-size: 20px; margin: 0; }
.section-title a { font-size: 15px; text-decoration: none; }
.card { background: var(--surface); margin: 0 16px; border-radius: 14px; overflow: hidden; }
.muted { color: var(--ink2); }
.note { margin: 8px 20px 0; font-size: 13px; color: var(--ink2); }
.chev { color: var(--ink3); width: 8px; height: 14px; flex: none; }
.btn { border: 0; border-radius: 12px; padding: 12px 16px; font-size: 16px; font-weight: 600; cursor: pointer; background: var(--lane); color: #fff; text-align: center; text-decoration: none; display: inline-block; }
.btn.ghost { background: var(--lane-soft); color: var(--lane); }
.btn.danger { background: none; color: var(--heart); }
.btn:disabled { opacity: .45; cursor: default; }
.btn-row { display: flex; gap: 10px; margin: 16px; }
.btn-row .btn { flex: 1; }

/* Home */
.greet { display: flex; justify-content: space-between; align-items: center; margin: 14px 20px 0; gap: 12px; }
.greet p { margin: 0; color: var(--ink2); font-size: 15px; }
.greet h1 { margin: 0; font-size: 30px; }
.avatar { width: 42px; height: 42px; border-radius: 50%; background: var(--lane); color: #fff; display: grid; place-items: center; font-weight: 700; text-decoration: none; flex: none; }
.month-hero { margin: 18px 16px 0; background: var(--surface); border-radius: 18px; padding: 18px; }
.month-hero .label { font-size: 15px; color: var(--ink2); }
.month-hero .big { font-family: var(--num); font-stretch: condensed; font-weight: 700; font-size: 64px; line-height: .95; letter-spacing: -.02em; margin-top: 4px; }
.month-hero .big small { font-size: 22px; color: var(--ink2); margin-left: 4px; letter-spacing: 0; font-weight: 600; }
.track { height: 10px; border-radius: 5px; background: var(--lane-soft); margin: 14px 0 8px; overflow: hidden; }
.track i { display: block; height: 100%; background: var(--lane); border-radius: 5px; }
.row3 { display: grid; grid-template-columns: repeat(3, 1fr); margin-top: 14px; padding-top: 12px; border-top: .5px solid var(--rule); }
.row3 div { font-size: 13px; color: var(--ink2); }
.row3 b { display: block; font-family: var(--num); font-stretch: condensed; font-size: 22px; color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.quick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 14px 16px 0; }
.quick a { background: var(--surface); border-radius: 14px; padding: 12px 6px 10px; display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 13px; color: var(--ink); text-decoration: none; text-align: center; }
.quick svg { width: 24px; height: 24px; color: var(--lane); }
.empty { padding: 22px 18px; text-align: center; }
.empty h3 { margin: 0 0 6px; font-size: 18px; }
.empty p { margin: 0 0 14px; color: var(--ink2); font-size: 15px; }

/* Runs list */
.month { font-size: 13px; color: var(--ink2); margin: 18px 20px 6px; font-weight: 600; }
.row { display: grid; grid-template-columns: 44px 1fr auto 14px; align-items: center; gap: 12px; padding: 11px 14px 11px 16px; position: relative; color: inherit; text-decoration: none; }
.row + .row::before { content: ""; position: absolute; top: 0; left: 72px; right: 0; border-top: .5px solid var(--rule); }
.day { text-align: center; line-height: 1; }
.day b { display: block; font-family: var(--num); font-size: 22px; font-weight: 600; font-stretch: condensed; }
.day span { font-size: 12px; color: var(--ink2); }
.dist { font-family: var(--num); font-size: 28px; font-weight: 700; font-stretch: condensed; line-height: 1; }
.dist small { font-size: 15px; font-weight: 600; color: var(--ink2); margin-left: 3px; }
.sub { font-size: 14px; color: var(--ink2); margin-top: 4px; display: flex; gap: 12px; font-variant-numeric: tabular-nums; }
.tag { font-size: 12px; color: var(--ink2); border: 1px solid var(--rule); border-radius: 6px; padding: 2px 6px; white-space: nowrap; }

/* Run detail */
.detail-head { margin: 0 20px 12px; }
.detail-head h1 { font-size: 22px; margin: 0; }
.detail-head p { margin: 2px 0 0; color: var(--ink2); font-size: 15px; }
.routebox { margin: 0 16px; border-radius: 16px; overflow: hidden; background: var(--surface); position: relative; }
.routebox svg { width: 100%; height: auto; display: block; }
.routebox .cap { display: block; padding: 0 12px 10px; font-size: 12px; color: var(--ink2); }
.no-route { margin: 0 16px; padding: 22px 18px; border-radius: 16px; background: var(--surface); text-align: center; color: var(--ink2); font-size: 15px; }
.no-route b { display: block; color: var(--ink); font-size: 17px; margin-bottom: 4px; }
.hero { margin: 20px 20px 4px; font-family: var(--num); font-size: 72px; font-weight: 700; font-stretch: condensed; line-height: .9; letter-spacing: -.02em; }
.hero small { font-size: 24px; color: var(--ink2); font-weight: 600; letter-spacing: 0; margin-left: 4px; }
.stats { margin: 14px 16px 0; background: var(--surface); border-radius: 12px; display: grid; grid-template-columns: 1fr 1fr; }
.stat { padding: 13px 16px; border-top: .5px solid var(--rule); }
.stat:nth-child(-n+2) { border-top: 0; }
.stat:nth-child(odd) { border-right: .5px solid var(--rule); }
.stat .k { font-size: 13px; color: var(--ink2); display: flex; align-items: center; gap: 5px; }
.stat .k i { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.stat .v { font-family: var(--num); font-size: 26px; font-weight: 600; font-stretch: condensed; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat .v small { font-size: 14px; color: var(--ink2); font-weight: 500; margin-left: 2px; }
.foot { margin: 14px 20px 0; font-size: 13px; color: var(--ink2); }

/* Placeholder tabs (Map, Record) */
.soon { margin: 14px 16px 0; background: var(--surface); border-radius: 16px; padding: 22px 20px; }
.soon h2 { margin: 0 0 8px; font-size: 20px; }
.soon p { margin: 0 0 10px; color: var(--ink2); font-size: 15px; }
.soon ul { margin: 0 0 14px; padding-left: 20px; color: var(--ink2); font-size: 15px; }

/* Profile + settings */
.prof { display: flex; gap: 14px; align-items: center; margin: 14px 20px 0; }
.prof .avatar { width: 64px; height: 64px; font-size: 24px; }
.prof h1 { margin: 0; font-size: 24px; }
.prof p { margin: 2px 0 0; color: var(--ink2); font-size: 14px; word-break: break-all; }
.lifetime { display: grid; grid-template-columns: repeat(3, 1fr); margin: 16px 16px 0; background: var(--surface); border-radius: 14px; padding: 12px 0; text-align: center; }
.lifetime b { display: block; font-family: var(--num); font-stretch: condensed; font-size: 26px; font-weight: 600; }
.lifetime span { font-size: 12.5px; color: var(--ink2); }
.list .item { display: flex; align-items: center; gap: 12px; padding: 13px 16px; background: none; border: 0; width: 100%; text-align: left; font-size: 16px; cursor: pointer; position: relative; color: var(--ink); text-decoration: none; }
.list .item + .item::before { content: ""; position: absolute; top: 0; left: 16px; right: 0; border-top: .5px solid var(--rule); }
.list .item span { flex: 1; }
.list .item em { font-style: normal; color: var(--ink2); font-size: 15px; }
.switch { width: 51px; height: 31px; border-radius: 16px; border: 0; background: var(--rule); position: relative; cursor: pointer; flex: none; padding: 0; }
.switch i { position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: left .2s; }
.switch[aria-checked="true"] { background: var(--go); }
.switch[aria-checked="true"] i { left: 22px; }
.form .f { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 16px; position: relative; font-size: 16px; }
.form .f + .f::before { content: ""; position: absolute; top: 0; left: 16px; right: 0; border-top: .5px solid var(--rule); }
.form input { border: 0; background: none; text-align: right; color: var(--ink2); width: 55%; outline: none; padding: 4px 0; }
.form input:focus { color: var(--ink); }
.form .err { color: var(--heart); font-size: 13px; padding: 0 16px 10px; }
.status-row { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; position: relative; }
.status-row + .status-row::before { content: ""; position: absolute; top: 0; left: 16px; right: 0; border-top: .5px solid var(--rule); }
.status-row div { flex: 1; }
.status-row b { display: block; font-size: 16px; }
.status-row p { margin: 2px 0 0; font-size: 14px; color: var(--ink2); }
.pill { font-size: 12.5px; padding: 2px 8px; border-radius: 10px; background: var(--lane-soft); color: var(--lane); white-space: nowrap; }
.pill.off { background: var(--rule); color: var(--ink2); }
.toast { position: fixed; left: 50%; bottom: calc(100px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: rgba(30,30,32,.94); color: #fff;
  padding: 10px 16px; border-radius: 20px; font-size: 14px; z-index: 50; max-width: 90vw; text-align: center; }
.loading { text-align: center; color: var(--ink2); padding: 60px 20px; }

/* Passcode screen */
.lock { padding: 70px 0 20px; text-align: center; }
.lock .lock-icon { width: 76px; height: 76px; border-radius: 20px; margin: 0 auto 18px; }
.lock h1 { margin: 0; font-size: 30px; }
.lock > p.muted { margin: 4px 0 26px; }
.lock-form { text-align: left; }
.lock-form input { width: 60%; }
.lock-err { color: var(--heart); font-size: 14px; margin: 10px 20px 0; }
