/* The web app. Three sizes, one page (BRIEF, 2026-10-31):
     phone  (max-width: 767px)   the iPhone app in a browser: a top bar, full-width cards,
                                 the bottom tab bar on the tab roots;
     tablet (768 to 1099px)      the phone's frame, the content wider;
     computer (min-width: 1100px) a sidebar replaces the tab bar, content up to 1280 px.
   The frame is main.js shell(); the shared pieces (sheets, skeletons, states, toasts)
   are ui.js, styled further down. */
body { font-variant-numeric: tabular-nums; }
body.no-scroll { overflow: hidden; }
#app { min-height: 100vh; min-height: 100dvh; }
.ic { flex: none; }
.muted { color: var(--text-2); }
.small { font-size: 13px; }
.center { text-align: center; justify-content: center; }
.grow { flex: 1; min-width: 0; }
.gold { color: var(--gold) !important; }
.btn { position: relative; }
.btn.sm { min-height: 32px; padding: 0 12px; font-size: 14px; border-radius: 9px; }
/* a small button's target is still a finger's: 44 px tall */
.btn.sm::after { content: ""; position: absolute; inset: -6px 0; }
/* a map keeps its own layers inside it: its controls never climb over the bar or a sheet */
.mk-map-view, .map, .card-map, .rp-map { isolation: isolate; }

/* the boot screen (index.html), until main.js draws */
.boot { min-height: 70vh; min-height: 70dvh; display: grid; place-content: center; justify-items: center; gap: 14px; color: var(--text-2); }
.boot img { opacity: 0.95; animation: boot-in 0.5s var(--ease-out) both, boot-breathe 2.4s ease-in-out 0.5s infinite; }
.boot p { margin: 0; font-size: var(--fs-m); opacity: 0; animation: boot-in 0.4s ease-out 0.6s both; }
.boot .boot-slow { display: none; text-align: center; max-width: 300px; font-size: var(--fs-s); }
.boot.slow .boot-slow { display: grid; gap: 10px; justify-items: center; }
@keyframes boot-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@keyframes boot-breathe { 50% { opacity: 0.6; } }

/* --- the top bar (SessionListView's banner; a pushed screen's back and title) --------- */
.bar {
  position: sticky; top: 0; z-index: var(--z-bar);
  display: flex; align-items: center; gap: 10px;
  min-height: calc(var(--bar-h) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) max(var(--gutter), env(safe-area-inset-right)) 0 max(var(--gutter), env(safe-area-inset-left));
  background: var(--bar-bg);
  backdrop-filter: saturate(160%) blur(16px); -webkit-backdrop-filter: saturate(160%) blur(16px);
  border-bottom: 1px solid var(--line);
}
.bar .brand { gap: 9px; font-size: 22px; font-weight: 700; letter-spacing: -0.01em; }
.bar .brand img { height: 24px; width: auto; }
.bar-page { display: none; }
.bar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; min-width: 0; }
.bar .back { color: var(--accent); display: grid; place-items: center; width: 44px; height: 44px; margin-left: -12px; margin-right: -6px; flex: none; border-radius: 50%; }
.bar-title { min-width: 0; display: flex; flex-direction: column; line-height: 1.2; }
.bar-title b { font-size: var(--fs-l); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-title span { font-size: 12px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rider-name { font-size: var(--fs-m); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 40vw; }
.rider-switch, .select { position: relative; display: inline-flex; align-items: center; gap: 6px; color: var(--text); min-width: 0; }
.rider-switch select, .select select {
  appearance: none; -webkit-appearance: none; background: transparent; border: 0;
  font-size: 15px; font-weight: 500; padding: 4px 18px 4px 0; cursor: pointer; max-width: 46vw;
  text-overflow: ellipsis; min-height: 36px;
}
.rider-switch .ic, .select > .ic:last-child { position: absolute; right: 0; pointer-events: none; color: var(--text-2); }
.select select option, .rider-switch select option { background: var(--card); color: var(--text); }
.me { position: relative; display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--card-2); color: var(--text-2); border: 1px solid rgba(255, 90, 42, 0.6); flex: none; }
.me::after { content: ""; position: absolute; inset: -6px; }
.me img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.badge { position: absolute; top: -5px; right: -6px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px; background: #e5352b; color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; font-variant-numeric: tabular-nums; }

/* offline: a thin line under the bar */
.netbar { display: flex; align-items: center; gap: 8px; padding: 8px var(--gutter); background: rgba(255, 176, 32, 0.12); border-bottom: 1px solid rgba(255, 176, 32, 0.25); color: var(--warn); font-size: var(--fs-s); }
.netbar[hidden] { display: none; }
.netbar span { color: var(--text); }

/* the demo's and the trial's banner (InboxViews.swift DemoBanner), at the top of the Feed */
.banner-slot:empty { display: none; }
.banner-slot { max-width: var(--view-max); margin: 0 auto; padding: 10px var(--gutter) 0; }
.demo-banner {
  display: grid; gap: 6px; padding: 14px;
  background: var(--accent-soft); border: 1px solid rgba(255, 90, 42, 0.3); border-radius: 12px;
  color: var(--text);
}
.db-head { display: flex; align-items: center; gap: 8px; }
.db-head b { font-size: var(--fs-l); font-weight: 600; }
.demo-banner .ic { color: var(--accent); }
.demo-banner p { margin: 0; font-size: var(--fs-s); color: var(--text-2); line-height: 1.4; }
.db-btns { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }

/* --- the bottom tab bar (RootTabView.swift MainTabBar) -------------------------------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: var(--z-tabbar);
  display: flex; justify-content: center;
  min-height: calc(var(--tab-h) + env(safe-area-inset-bottom));
  padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  background: var(--bar-bg);
  backdrop-filter: saturate(160%) blur(16px); -webkit-backdrop-filter: saturate(160%) blur(16px);
  border-top: 1px solid var(--line);
}
.tabbar[hidden] { display: none; }
.tabbar a {
  flex: 1; max-width: 168px; min-height: var(--tab-h);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  padding: 6px 0 2px; color: var(--text-2); font-size: 10px; font-weight: 500; text-decoration: none !important;
}
.tabbar a .ic { height: 22px; }
.tabbar a.on { color: var(--accent); font-weight: 600; }
.tabbar a.on .ic:not(.ic-mark) { stroke-width: 2.2; }
.tabbar a:active { opacity: 0.7; }
@media (hover: hover) { .tabbar a:not(.on):hover { color: var(--text); } }
/* room under the content for a bottom bar, wherever there is one */
@media (max-width: 1099px) {
  #app:has(> nav.tabbar:not([hidden])) { padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom)); }
  body:has(#app > nav.tabbar:not([hidden])) .toasts { bottom: calc(var(--tab-h) + 12px + env(safe-area-inset-bottom)); }
}

/* --- the sidebar (computer only) ---------------------------------------------------- */
.side { display: none; }

/* --- the page ------------------------------------------------------------------------ */
.view { max-width: var(--view-max); margin: 0 auto; padding: 12px max(var(--gutter), env(safe-area-inset-right)) 24px max(var(--gutter), env(safe-area-inset-left)); outline: none; }

@media (min-width: 768px) and (max-width: 1099px) {
  :root { --view-max: 1000px; --gutter: 24px; }
}

@media (min-width: 1100px) {
  :root { --view-max: 1280px; --gutter: 32px; }
  /* the sidebar's grid only around the frame (the sign-in page takes #app whole) */
  #app:has(> aside.side) {
    display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr);
    grid-template-rows: auto auto auto auto 1fr;
    grid-template-areas: "side bar" "side net" "side sub" "side banner" "side view";
  }
  .side {
    grid-area: side; display: flex; flex-direction: column;
    position: sticky; top: 0; height: 100vh; height: 100dvh; overflow-y: auto;
    padding: 16px 12px 14px; background: var(--bg-2); border-right: 1px solid var(--line);
  }
  .bar { grid-area: bar; height: var(--bar-h); min-height: 0; padding: 0 max(var(--gutter), calc((100% - var(--view-max)) / 2 + var(--gutter))); background: rgba(12, 15, 20, 0.86); }
  .bar .brand, .bar.root .bar-right { display: none; }
  .bar.root .bar-page { display: block; margin: 0; font-size: var(--fs-xl); font-weight: 700; letter-spacing: -0.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .bar .back { margin-left: -10px; }
  .netbar { grid-area: net; padding-left: max(var(--gutter), calc((100% - var(--view-max)) / 2 + var(--gutter))); }
  .banner-slot { grid-area: banner; width: 100%; padding: 16px var(--gutter) 0; }
  .demo-banner { grid-template-columns: minmax(0, 1fr) auto; column-gap: 20px; align-items: center; padding: 14px 16px; }
  .demo-banner p { grid-column: 1; }
  .db-btns { grid-column: 2; grid-row: 1 / span 2; margin: 0; }
  #view { grid-area: view; width: 100%; padding: 20px var(--gutter) 48px; }
  #app > nav.main-tabs { display: none; }
  /* a pushed screen's own tabs (a day's Overview, Runs, ...): a strip under the bar */
  #app > nav.tabbar:not(.main-tabs) {
    grid-area: sub; position: sticky; top: var(--bar-h); bottom: auto; left: auto; right: auto; z-index: calc(var(--z-bar) - 1);
    min-height: 0; justify-content: flex-start; gap: 4px;
    padding: 0 max(var(--gutter), calc((100% - var(--view-max)) / 2 + var(--gutter)));
    border-top: 0; border-bottom: 1px solid var(--line); background: rgba(12, 15, 20, 0.86);
    overflow-x: auto; scrollbar-width: none;
  }
  #app > nav.tabbar:not(.main-tabs) a {
    flex: none; max-width: none; min-height: 44px; flex-direction: row; gap: 7px;
    padding: 0 12px; font-size: 14px; color: var(--text-2);
    border-bottom: 2px solid transparent; margin-bottom: -1px;
  }
  #app > nav.tabbar:not(.main-tabs) a .ic { width: 18px; height: 18px; }
  #app > nav.tabbar:not(.main-tabs) a.on { color: var(--accent); border-bottom-color: var(--accent); }

  .side-brand { display: flex; align-items: center; gap: 10px; padding: 6px 10px 20px; color: var(--text); font-weight: 700; font-size: 21px; letter-spacing: -0.01em; text-decoration: none !important; }
  .side-brand img { height: 26px; width: auto; }
  .side-nav { display: grid; gap: 2px; }
  .side-nav a { display: flex; align-items: center; gap: 12px; min-height: 40px; padding: 0 12px; border-radius: 10px; color: var(--text-2); font-size: var(--fs-m); font-weight: 500; text-decoration: none !important; }
  .side-nav a.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
  .side-foot { margin-top: auto; display: grid; gap: 10px; padding-top: 16px; }
  .side-card { display: grid; gap: 8px; padding: 12px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; font-size: var(--fs-s); }
  .side-card b { display: flex; align-items: center; gap: 6px; font-size: 14px; }
  .side-card b .ic { color: var(--accent); }
  .side-card p { margin: 0; color: var(--text-2); line-height: 1.4; }
  .side-link { font-size: var(--fs-s); text-align: center; padding: 2px 0; }
  .side-picker-wrap { display: grid; gap: 4px; padding: 0 2px; }
  .side-picker-wrap .label { padding-left: 2px; }
  .side-picker { width: 100%; }
  .side-picker select { width: 100%; max-width: none; min-height: 38px; padding: 0 30px 0 12px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; }
  .side-picker .ic { right: 10px; }
  .side-me { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 12px; color: var(--text); text-decoration: none !important; border: 1px solid var(--line); background: var(--card); }
  .side-me.on { background: var(--accent-soft); border-color: rgba(255, 90, 42, 0.3); }
  .side-avatar { position: relative; flex: none; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--card-2); color: var(--text-2); border: 1px solid rgba(255, 90, 42, 0.6); }
  .side-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
  .side-who { flex: 1; min-width: 0; line-height: 1.25; }
  .side-who b { display: block; font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .side-who span { display: block; font-size: 12px; color: var(--text-2); }
  .side-go { color: var(--text-3); }
}
@media (min-width: 1100px) and (hover: hover) {
  .side-nav a:not(.on):hover { background: var(--hover); color: var(--text); }
  .side-me:not(.on):hover { border-color: #384152; }
  #app > nav.tabbar:not(.main-tabs) a:not(.on):hover { color: var(--text); }
}
@media (min-width: 1440px) { :root { --side-w: 260px; } }

.page-head h1 { margin: 6px 0 2px; font-size: 28px; }
.page-head p { margin: 0 0 14px; }
.empty { text-align: center; padding: 56px 12px; color: var(--text-2); display: grid; justify-items: center; gap: 10px; }
.empty.error { color: var(--bad); }
.empty.error p { color: var(--text); max-width: 32em; }
.empty.welcome h2 { margin: 6px 0 0; color: var(--text); }
.empty.welcome p { max-width: 30em; margin: 0; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.note.warn { color: var(--warn); font-size: 13px; display: flex; gap: 6px; align-items: center; }
.caption { color: var(--text-3); font-size: 12px; margin: 8px 0 0; }

/* the Feed */
.filter { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.filter .select { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 6px 12px; }
.filter .select > .ic:first-child { color: var(--text-2); }
.filter .select > .ic:last-child { right: 10px; }
.filter .select select { padding-right: 22px; }
.filter .clear { font-size: 14px; }
.cards { display: grid; gap: 12px; }
.card {
  display: block; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px; color: var(--text); text-decoration: none !important;
}
a.card { transition: border-color 0.15s, transform 0.15s; }
@media (hover: hover) { a.card:hover { border-color: #384152; } }
a.card:active { transform: scale(0.995); }
.who { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--card-2); display: grid; place-items: center; color: var(--text-2); overflow: hidden; flex: none; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.xl { width: 72px; height: 72px; }
/* the rider's own photo on the Profile: a button, with the phone's camera badge */
button.avatar.editable { position: relative; overflow: visible; border: 0; padding: 0; cursor: pointer; font: inherit; }
button.avatar.editable img { border-radius: 50%; }
button.avatar.editable:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.avatar-cam { position: absolute; right: -2px; bottom: -2px; width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; border: 2px solid var(--bg); }
.crop-stage { display: flex; justify-content: center; margin: 4px 0 12px; }
.crop-stage canvas { border-radius: 12px; cursor: grab; max-width: 100%; }
.crop-stage canvas:active { cursor: grabbing; }
.crop-zoom { display: flex; align-items: center; gap: 12px; margin: 0 0 8px; }
.crop-zoom input { flex: 1; accent-color: var(--accent); }
.who b { display: block; font-size: 15px; }
.who span { display: block; font-size: 12px; color: var(--text-2); }
.day-card .title h2 { margin: 0; font-size: 20px; line-height: 1.2; }
.day-card .title p { margin: 2px 0 0; color: var(--text-2); font-size: 13px; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 10px; }
.stats.hill:empty { display: none; }
.stat span { display: block; font-size: 10px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-2); }
.stat b { display: inline-flex; align-items: center; gap: 4px; font-size: 15px; font-weight: 600; white-space: nowrap; }
.rec { color: var(--gold); display: inline-flex; }
.card-img { margin-top: 12px; aspect-ratio: 16 / 9; border-radius: 12px; overflow: hidden; background: var(--card-2); }
.card-img img { width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity 0.25s; }
.card-img img.in { opacity: 1; }
.card-img.broken { display: none; }

/* Spots */
.spots { display: grid; gap: 12px; }
.spot { display: grid; grid-template-columns: 112px 1fr auto; gap: 14px; align-items: center; }
.spot-img { width: 112px; aspect-ratio: 1; border-radius: 12px; overflow: hidden; background: var(--card-2); }
.spot-img img { width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity 0.25s; }
.spot-img img.in { opacity: 1; }
.spot-body { min-width: 0; }
.spot-body h2 { margin: 0; font-size: 17px; }
.spot-body p { margin: 2px 0 0; }
.spot .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 10px; margin: 8px 0 6px; }
.spot .go { color: var(--text-3); transform: rotate(180deg); }
@media (min-width: 600px) {
  .spot { grid-template-columns: 150px 1fr auto; }
  .spot-img { width: 150px; aspect-ratio: 4 / 3; }
  .spot .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* a day */
.map-block { margin: 0 -16px 12px; }
.map { position: relative; height: 56vw; min-height: 240px; max-height: 520px; background: var(--card-2); overflow: hidden; }
.card-map { position: relative; width: 100%; height: 100%; }
.card-map img, .card-map svg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.no-card { display: grid; place-items: center; height: 100%; color: var(--text-3); }
.map-tools { display: flex; gap: 10px; align-items: center; padding: 10px 16px 0; flex-wrap: wrap; }
.chips { display: flex; gap: 6px; overflow-x: auto; flex: 1; min-width: 0; scrollbar-width: none; padding-bottom: 2px; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 1px solid var(--line); background: var(--card); color: var(--text-2); border-radius: 999px; padding: 5px 12px; font-size: 13px; cursor: pointer; }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.seg { display: inline-flex; background: var(--card); border: 1px solid var(--line); border-radius: 9px; padding: 2px; flex: none; }
.seg button { border: 0; background: transparent; color: var(--text-2); padding: 5px 11px; border-radius: 7px; font-size: 13px; cursor: pointer; }
.seg button.on { background: var(--card-2); color: var(--text); font-weight: 600; }
.legend { display: flex; align-items: center; gap: 8px; padding: 8px 16px 0; font-size: 12px; color: var(--text-3); }
.legend .ramp { width: 90px; height: 6px; border-radius: 3px; }
.legend .ramp.accel { background: linear-gradient(90deg, rgb(204,26,31), rgb(168,171,179), rgb(77,235,158)); }
.legend .ramp.speed { background: linear-gradient(90deg, rgb(47,107,255), rgb(46,230,166) 35%, rgb(255,209,102) 65%, rgb(255,90,42)); }
.legend .sp { flex: 0 0 4px; }
.weather { margin: 0 0 12px; color: var(--text-2); font-size: 14px; }
.grid6, .grid4 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px 10px; margin-bottom: 18px; }
.grid4 { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 8px; }
@media (min-width: 600px) { .grid4 { grid-template-columns: repeat(4, minmax(0, 1fr)); } .grid6 { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
.big span { display: block; font-size: 10px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-2); }
.big b { display: block; font-size: 21px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.block { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }
.block-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.block-head h3 { margin: 0; font-size: 16px; display: inline-flex; align-items: center; gap: 6px; }
.link { font-size: 13px; font-weight: 500; }
.best-row { display: flex; align-items: center; gap: 10px; padding: 7px 0; }
.best-row + .best-row { border-top: 1px solid var(--line); }
.best-row b { font-size: 15px; }
.best-row .grow b { display: block; font-weight: 500; }
.best-row .grow span { display: block; font-size: 12px; color: var(--text-2); }
.ic-cell { width: 22px; color: var(--text-2); display: grid; place-items: center; }
.run-row, .corner-row { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 0; background: none; border: 0; border-top: 1px solid var(--line); text-align: left; cursor: pointer; font-size: 15px; }
.run-row:first-of-type, .block-head + .run-row, .block-head + .corner-row { border-top: 0; }
.corner-row { cursor: default; }
@media (hover: hover) { .run-row:hover b { color: var(--accent); } }
.w82 { min-width: 86px; text-align: right; }
.warn-ic { color: var(--warn); display: inline-flex; vertical-align: -2px; }
.chart { position: relative; height: 190px; }
.chart.short { height: 150px; margin-top: 6px; }
.tag { display: inline-block; font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; padding: 1px 6px; border-radius: 6px; background: var(--card-2); color: var(--text-2); }

/* tables */
.table-tools { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 10px; }
.toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-2); cursor: pointer; }
.toggle input { accent-color: var(--accent); }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line); border-radius: 12px; background: var(--card); }
.block .table-wrap { border: 0; border-radius: 0; background: none; margin: 0 -14px; }
.tbl { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 14px; }
.tbl th { position: sticky; top: 0; text-align: right; font-size: 11px; font-weight: 600; letter-spacing: 0.03em; text-transform: uppercase; color: var(--text-2); padding: 10px 10px 8px; white-space: nowrap; background: var(--card); border-bottom: 1px solid var(--line); }
.tbl th[data-sort] { cursor: pointer; }
.tbl th.on { color: var(--accent); }
.tbl th:first-child, .tbl td:first-child { text-align: left; }
.tbl td { padding: 8px 10px; text-align: right; white-space: nowrap; border-bottom: 1px solid rgba(38, 45, 57, 0.6); }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr[data-run] { cursor: pointer; }
@media (hover: hover) { .tbl tbody tr[data-run]:hover td { background: rgba(255, 255, 255, 0.03); } }
.tbl td small { display: block; font-size: 11px; color: var(--text-3); }
.tbl td.best { color: var(--gold); font-weight: 700; }
.tbl .frozen { position: sticky; left: 0; background: var(--card); z-index: 1; }
.tbl th.frozen { z-index: 2; }
.tbl .dot { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 5px; vertical-align: 0; }
.tbl tr.optimal td { color: var(--text-2); font-style: italic; border-top: 1px solid var(--line); }

/* sheets (ui.js sheet): a bottom sheet on a phone and a tablet, a centred dialog or a
   right-hand panel on a computer */
.sheet-wrap {
  position: fixed; inset: 0; z-index: var(--z-sheet);
  display: flex; align-items: flex-end; justify-content: center;
  padding-top: max(24px, env(safe-area-inset-top));
  background: rgba(0, 0, 0, 0);
  transition: background-color var(--dur-2) var(--ease-out);
  overscroll-behavior: contain;
}
.sheet-wrap.open { background: rgba(0, 0, 0, calc(0.55 * var(--sheet-drag, 1))); }
.sheet {
  position: relative; width: 100%; max-width: 640px;
  max-height: 92vh; max-height: calc(100dvh - max(24px, env(safe-area-inset-top)));
  background: var(--bg-2); border: 1px solid var(--line); border-bottom: 0;
  border-radius: 16px 16px 0 0; box-shadow: var(--shadow-pop);
  display: flex; flex-direction: column; outline: none;
  transform: translateY(100%);
  transition: transform 280ms var(--ease-out), opacity var(--dur-2) var(--ease-out);
}
.sheet-wrap.open .sheet { transform: none; }
.sheet-wrap.closing .sheet { transition-duration: 200ms; transition-timing-function: cubic-bezier(0.4, 0, 1, 1); }
.sheet.wide { max-width: 760px; }
.sheet-grab { position: absolute; top: 0; left: 0; right: 0; height: 20px; z-index: 3; display: grid; place-items: center; touch-action: none; cursor: grab; }
.sheet-grab i { width: 36px; height: 5px; border-radius: 3px; background: rgba(255, 255, 255, 0.28); }
.sheet-head { flex: none; padding: 22px 56px 6px 16px; }
.sheet-head .sheet-title { margin: 0; }
.sheet-body {
  overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  padding: 18px 16px calc(20px + env(safe-area-inset-bottom));
}
.sheet-head ~ .sheet-body { padding-top: 8px; }
.sheet-x {
  position: absolute; top: 14px; right: 12px; z-index: 4;
  width: 30px; height: 30px; border-radius: 50%; border: 0;
  background: rgba(255, 255, 255, 0.09); color: var(--text-2);
  display: grid; place-items: center; cursor: pointer;
}
/* a bigger target than it looks: 44 px on a phone */
.sheet-x::after { content: ""; position: absolute; inset: -7px; }
.sheet-title { margin: 0 40px 8px 0; font-size: var(--fs-xl); font-weight: 700; line-height: 1.25; }
.sheet.s .sheet-title { font-size: 18px; }
.dialog-text { margin: 4px 0 0; font-size: var(--fs-m); line-height: 1.45; }
.dialog-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 20px; }
.dialog-btns.one { grid-template-columns: 1fr; }
.dialog-btns .btn { width: 100%; }
.sheet.s .form .field { margin: 14px 0 0; }
@media (hover: hover) { .sheet-x:hover { background: rgba(255, 255, 255, 0.15); color: var(--text); } }
@media (min-width: 768px) and (max-width: 1099px) {
  .sheet.s { max-width: 480px; }
}
@media (min-width: 1100px) {
  .sheet-wrap { align-items: center; padding: 32px; }
  .sheet {
    max-width: 600px; max-height: min(88vh, 960px);
    border-bottom: 1px solid var(--line); border-radius: 16px;
    transform: translateY(10px) scale(0.98); opacity: 0;
  }
  .sheet-wrap.open .sheet { opacity: 1; }
  .sheet.wide { max-width: 760px; }
  .sheet.s { max-width: 420px; }
  .sheet-grab { display: none; }
  .sheet-head { padding: 18px 56px 6px 20px; }
  .sheet-body { padding-bottom: 22px; }
  .sheet-head ~ .sheet-body { padding: 8px 20px 22px; }
  /* a panel from the right edge, full height */
  .sheet-wrap[data-desktop="panel"] { align-items: stretch; justify-content: flex-end; padding: 0; }
  .sheet-wrap[data-desktop="panel"] .sheet {
    max-width: 480px; height: 100vh; height: 100dvh; max-height: none;
    border-radius: 0; border-width: 0 0 0 1px; opacity: 1;
    transform: translateX(100%);
  }
  .sheet-wrap[data-desktop="panel"].open .sheet { transform: none; }
  .sheet-wrap[data-desktop="panel"] .sheet.wide { max-width: 720px; }
}
.rs-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; margin-right: 40px; }
.rs-head h2 { margin: 0; font-size: 24px; display: flex; align-items: center; gap: 6px; }
.rs-time { font-size: 26px; }
.rs-verdict { margin: 4px 0 14px; color: var(--text-2); font-weight: 500; }
.rs-verdict.lost { color: var(--bad); }
.rs-verdict.gained { color: var(--good); }
.sheet .block { background: var(--card); }
.bar-row { display: grid; grid-template-columns: minmax(70px, 120px) 1fr 58px; gap: 10px; align-items: center; padding: 4px 0; font-size: 13px; }
.bar-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
.bar-track { position: relative; height: 10px; background: var(--card-2); border-radius: 5px; }
.bar-track::after { content: ""; position: absolute; left: 50%; top: -3px; bottom: -3px; width: 1px; background: var(--text-3); }
.bar-track i { position: absolute; top: 0; bottom: 0; border-radius: 5px; }
.bar-track i.lost { background: var(--bad); }
.bar-track i.gained { background: var(--good); }
.bar-val { text-align: right; }
.bar-val.lost { color: var(--bad); }
.bar-val.gained { color: var(--good); }
.key { display: inline-block; width: 14px; height: 3px; border-radius: 2px; vertical-align: 3px; margin: 0 4px 0 8px; }
.key.me { background: #ff6b3b; }
.key.ref { background: #4da3ff; }
.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 14px; }
.facts span { display: block; font-size: 10px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-2); }
.facts b { font-size: 15px; }
@media (min-width: 600px) { .facts { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.row-btns { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.row-btns.spread { justify-content: space-between; }
.row-btns.center { justify-content: center; }
.flip { display: inline-flex; transform: rotate(180deg); }

/* profile */
.profile-head { display: flex; align-items: center; gap: 16px; margin: 8px 0 18px; }
.profile-head h1 { margin: 0; font-size: 24px; }
.profile-head p { margin: 2px 0 0; }
.tag-line { color: var(--accent) !important; font-size: 13px; display: inline-flex; gap: 4px; align-items: center; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); font-size: 15px; }
.block-head + .kv { border-top: 0; }
.kv span { color: var(--text-2); }
.kv b { font-weight: 500; text-align: right; overflow-wrap: anywhere; }
.stack { display: grid; gap: 8px; margin-top: 10px; }
.btn.wide { width: 100%; }
.btn.left { justify-content: flex-start; }
.danger-text { color: var(--bad) !important; }
.links { display: grid; gap: 2px; }
.links a { display: flex; align-items: center; gap: 10px; padding: 8px 0; color: var(--text); }
.links a .ic { color: var(--text-2); }
.note-item { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; padding: 10px 0; border-top: 1px solid var(--line); }
.block-head + .note-item { border-top: 0; }
.note-item b { display: flex; align-items: center; gap: 6px; font-weight: 500; }
.note-item span { display: block; font-size: 13px; color: var(--text-2); }
.note-item.unread b::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: none; }
.note-item .row-btns { margin-top: 0; }
/* a day's session note (day.js notesBlock) */
.notes-block { margin-top: 12px; }
.notes-text { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.45; }
.notes-edit { width: 100%; min-height: 120px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); color: var(--text); font: inherit; font-size: 16px; resize: vertical; }
.notes-edit:focus { outline: 2px solid rgba(255, 90, 42, 0.5); border-color: transparent; }
.msg { min-height: 1.2em; margin: 10px 0 0; font-size: 14px; color: var(--text-2); }
.msg:empty { display: none; }
.msg.bad { color: var(--bad); }
.msg.good { color: var(--good); }
.field { display: grid; gap: 6px; margin: 12px 0; font-size: 13px; color: var(--text-2); }
.field input, .field .select { width: 100%; min-height: 46px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); color: var(--text); font-size: 17px; }
.field .select select { width: 100%; max-width: none; font-size: 16px; }
.field .select > .ic:last-child { right: 14px; }
.field input:focus { outline: 2px solid rgba(255, 90, 42, 0.5); border-color: transparent; }
#code { letter-spacing: 0.3em; font-family: var(--mono); font-size: 22px; }

/* sign-in */
.signin { max-width: 420px; margin: 0 auto; padding: 40px 16px 32px; text-align: center; }
.signin .brand.big { display: inline-block; margin-bottom: 14px; }
.signin h1 { margin: 0 0 6px; font-size: 26px; }
.signin > p { margin: 0 0 20px; }
.signin .form { text-align: left; padding: 18px; }
.check { display: flex; align-items: center; gap: 10px; font-size: 16px; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }
.form > .small { margin: 8px 0 16px; }
.btn-google { width: 100%; background: #fff; color: #1f1f1f; border: 0; }
.btn-google:hover { background: #f1f1f1; }
.or { display: flex; align-items: center; gap: 10px; color: var(--text-3); font-size: 13px; margin: 16px 0 4px; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
#codeStep .btn { margin-top: 8px; }
.signin .switch { margin: 18px 0 0; color: var(--text-2); font-size: 15px; }
.signin .switch a { font-weight: 600; }
#noAccount { margin-top: 10px; }
#noAccount .btn, .signin .form #go, .signin .form #no { margin-top: 8px; }
.demo-offer { margin: 28px 0 0; display: grid; justify-items: center; gap: 8px; color: var(--text-2); }
.demo-offer p { margin: 0; }
.mini-links { display: flex; justify-content: center; gap: 18px; margin-top: 28px; font-size: 13px; }
.mini-links a { color: var(--text-3); }

/* toasts (ui.js toast): above the tab bar on a phone, bottom right on a computer */
.toasts {
  position: fixed; z-index: var(--z-toast); left: 50%; transform: translateX(-50%);
  bottom: calc(16px + env(safe-area-inset-bottom));
  display: grid; gap: 8px; justify-items: center;
  width: max-content; max-width: calc(100vw - 32px); pointer-events: none;
}
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 10px;
  max-width: 100%; padding: 11px 16px; border-radius: 14px;
  background: rgba(34, 40, 52, 0.96); border: 1px solid var(--line); color: var(--text);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  font-size: 14px; line-height: 1.35; box-shadow: var(--shadow-pop);
  opacity: 0; transform: translateY(12px) scale(0.98);
  transition: opacity var(--dur-2) var(--ease-out), transform var(--dur-2) var(--ease-out);
}
.toast.in { opacity: 1; transform: none; }
.toast.good .ic { color: var(--good); }
.toast.bad { border-color: rgba(255, 107, 90, 0.5); }
.toast.bad .ic { color: var(--bad); }
.toast-act { flex: none; background: none; border: 0; color: var(--accent); font-weight: 600; cursor: pointer; padding: 6px 2px; margin-left: 2px; }
/* with a sheet up, a toast comes from the top so it never covers the sheet's buttons */
@media (max-width: 1099px) {
  body.no-scroll .toasts, body.no-scroll:has(#app > nav.tabbar:not([hidden])) .toasts { top: calc(12px + env(safe-area-inset-top)); bottom: auto; }
}
@media (min-width: 1100px) {
  .toasts, body .toasts { left: auto; right: 24px; transform: none; bottom: 24px; justify-items: end; max-width: 420px; }
}

/* empty and error states (ui.js emptyState / errorState) */
.state { display: grid; justify-items: center; text-align: center; gap: 8px; max-width: 440px; margin: 0 auto; padding: 56px 16px; color: var(--text-2); }
.state-ic { width: 56px; height: 56px; margin-bottom: 4px; border-radius: 50%; background: var(--card); border: 1px solid var(--line); display: grid; place-items: center; color: var(--text-2); }
.state-ic img { width: 34px; height: auto; }
.state h2 { margin: 0; font-size: 19px; line-height: 1.25; color: var(--text); }
.state p { margin: 0; font-size: var(--fs-m); line-height: 1.45; }
.state-act { margin-top: 12px; display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.state.error .state-ic { color: var(--bad); border-color: rgba(255, 107, 90, 0.35); }

/* skeletons (ui.js skeleton): shaped like what is coming */
.sk { display: grid; gap: 12px; }
.sk-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: grid; gap: 9px; }
.sk-line, .sk-box, .sk-circle {
  display: block; border-radius: 6px;
  background: linear-gradient(90deg, var(--card-2) 0%, #252c38 45%, var(--card-2) 90%) 0 0 / 220% 100%;
  animation: sk-shimmer 1.5s ease-in-out infinite;
}
.sk-line { height: 12px; }
.sk-line.xs { height: 9px; }
.sk-line.lg { height: 16px; }
.sk-line.xl { height: 22px; margin-top: 4px; }
.sk-circle { width: 38px; height: 38px; border-radius: 50%; flex: none; }
.sk-who { display: flex; gap: 10px; align-items: center; }
.sk-grow { flex: 1; min-width: 0; display: grid; gap: 7px; }
.sk-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px 10px; margin: 6px 0; }
.sk-stats > div { display: grid; gap: 7px; }
.sk-img { aspect-ratio: 16 / 9; border-radius: 12px; margin-top: 4px; }
.sk-row { display: flex; gap: 14px; align-items: center; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.sk-thumb { width: 96px; aspect-ratio: 1; border-radius: 12px; flex: none; }
.sk-chart { height: 190px; border-radius: 10px; margin-top: 4px; }
.sk-map { height: 56vw; min-height: 240px; max-height: 460px; border-radius: var(--radius); }
.sk-pill { height: 40px; width: min(220px, 60%); border-radius: 10px; }
.sk-tr { display: grid; grid-template-columns: 2fr repeat(4, minmax(0, 1fr)); gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); }
.sk-text { display: grid; gap: 9px; }
@media (max-width: 767px) { .sk-bleed { margin: 0 calc(-1 * var(--gutter)); border-radius: 0; } }
@media (min-width: 768px) { .sk-stats { grid-template-columns: repeat(6, minmax(0, 1fr)); } .sk-card .sk-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@keyframes sk-shimmer { from { background-position: 100% 0; } to { background-position: -120% 0; } }

@media (min-width: 900px) {
  .map-block { margin: 0 0 12px; }
  .map { height: 460px; border-radius: var(--radius); }
  .map-tools, .legend { padding-left: 0; padding-right: 0; }
}
.signin .brand.big img { height: 80px; width: auto; }

/* the replay */
.replay-cta { padding: 10px 16px 0; }
.sheet-wrap .sheet.wide:has(.rp) { max-width: 980px; }
.rp { display: grid; gap: 10px; }
.rp-map { position: relative; height: min(58vh, 560px); margin: -18px -16px 0; background: var(--card-2); border-radius: 18px 18px 0 0; overflow: hidden; }
.rp-loading { display: grid; place-items: center; height: 100%; }
.rp-board { width: 48px; height: 48px; pointer-events: none; display: grid; place-items: center; }
.rp-deck { width: 20px; height: 48px; filter: drop-shadow(0 1px 3px rgba(0,0,0,.6)); }
.rp-deck svg { display: block; }
.rp-board.sliding rect { fill: #ffd166; }
.rp-hud { display: grid; grid-template-columns: 1.3fr repeat(3, minmax(0, 1fr)); gap: 10px; align-items: end; }
.rp-speed b { font-size: 40px; font-weight: 800; line-height: 1; }
.rp-speed span { margin-left: 4px; color: var(--text-2); font-size: 13px; }
.rp-stat span { display: block; font-size: 10px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rp-stat b { font-size: 20px; font-weight: 700; }
.rp-stat b.hot { color: #ffd166; }
.rp-stat b.lost, .rs-verdict.lost { color: var(--bad); }
.rp-stat b.gained { color: var(--good, #4ade80); }
.rp-strip { height: 70px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; touch-action: none; cursor: ew-resize; }
.rp-strip canvas { width: 100%; height: 100%; display: block; }
.rp-controls, .rp-pick { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.rp-play { width: 46px; height: 46px; border-radius: 50%; border: 0; background: var(--accent); color: #fff; display: grid; place-items: center; cursor: pointer; flex: none; }
.rp-pick .select { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 6px 12px; gap: 6px; font-size: 14px; }
.rp-pick .select select { font-size: 14px; max-width: 52vw; }
.rs-replay { margin: 6px 0 2px; }
@media (max-width: 560px) { .rp-hud { grid-template-columns: repeat(2, minmax(0, 1fr)); } .rp-map { height: 46vh; } }

/* the Device tab (box.js): the phone's Box tab, Downloads, settings and live sensors */
.box-head .link { display: inline-flex; align-items: center; gap: 2px; }
.box-note { display: flex; gap: 12px; align-items: flex-start; background: var(--accent-soft); border: 1px solid rgba(255, 90, 42, 0.35); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }
.box-note .ic { color: var(--accent); margin-top: 2px; }
.box-note b { display: block; }
.box-note p { margin: 4px 0 0; color: var(--text-2); font-size: 14px; }
.box-id { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 6px; }
.box-id h2 { margin: 0; font-size: 22px; overflow-wrap: anywhere; }
.box-id p { margin: 2px 0 0; }
.box-device .kv b small, .kv b small { display: block; font-size: 12px; color: var(--text-3); font-weight: 400; }
.good-text { color: var(--good) !important; }
.bad-text { color: var(--bad) !important; }
.warn-text { color: var(--warn) !important; }
.busy-text { color: var(--blue) !important; }
.note.bad { color: var(--bad); font-size: 13px; display: flex; gap: 6px; align-items: center; }
.btn-danger-ghost { background: transparent; color: var(--bad); border-color: var(--bad); }
.prog { height: 8px; background: var(--card-2); border-radius: 4px; overflow: hidden; }
.prog i { display: block; height: 100%; background: var(--accent); border-radius: 4px; transition: width 0.3s; }
.box-progress p { margin: 6px 0 0; }
.send-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 12px; font-size: 13px; color: var(--text-2); }
.send-line .ic { color: var(--warn); }
.send-line.good .ic { color: var(--good); }
.send-line span { flex: 1; min-width: 160px; }
.spinner.sm { width: 16px; height: 16px; border-width: 2px; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font-size: 13px; font-weight: 500; }
.box-log { display: grid; gap: 4px; font-size: 12px; color: var(--text-2); }
.box-log div { display: flex; gap: 8px; }
.box-log span { color: var(--text-3); flex: none; }
.dl-card { display: flex; gap: 14px; align-items: flex-start; padding: 12px 0; border-top: 1px solid var(--line); }
.block-head + .dl-card { border-top: 0; padding-top: 4px; }
.dl-card .grow > b, .dl-card .grow > span { display: block; }
.dl-card .grow > span { font-size: 13px; color: var(--text-2); }
.dl-card .row-btns { margin-top: 8px; }
.cal { flex: none; width: 52px; height: 62px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); display: grid; place-content: center; text-align: center; line-height: 1.1; }
.cal span { font-size: 11px; font-weight: 600; text-transform: uppercase; }
.cal b { font-size: 22px; }
.file-btn { margin-top: 4px; }
.check.setting { margin-top: 18px; }
.live svg { display: block; width: min(100%, 320px); margin: 4px auto 14px; }
.live .ring { fill: none; stroke: var(--text-3); stroke-width: 1.5; }
.live .ring.dash { stroke-dasharray: 3 4; }
.live .lbl { fill: var(--text-3); font-size: 11px; font-weight: 700; }
.live .dot { fill: var(--accent); }
.live-tbl td, .live-tbl th { text-align: right; }
.live-tbl td:first-child { color: var(--text-2); }
.view > .send-line { margin: 0 0 12px; }
