/* =================================================================
   PIT WALL — component styles. All values come from tokens.css.
   ================================================================= */

html, body {
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* HTML5 [hidden] attribute should always win over component CSS that sets
   display (e.g. .dash-cta uses display:inline-flex). Without this, calling
   element.hidden = true is a no-op. */
[hidden] { display: none !important; }

a { color: var(--brand-primary); text-decoration: none; }
a:hover { color: var(--brand-primary-hover); text-decoration: underline; }
/* Links inside notification body text are always underlined so they read as links */
.notif-sub a,
.notif-ribbon a,
.admin-log-row__msg a,
.sched-row__msg a { text-decoration: underline; }

button { cursor: pointer; }

/* ---------- App header (compact 52px) ---------- */
.appheader {
  position: sticky; top: 0; z-index: 30;
  /* Add the status-bar inset ON TOP of the header height (mirrors .tabbar),
     so the native full-screen webview doesn't crush the lockup under the notch. */
  height: calc(var(--header-height) + env(safe-area-inset-top));
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 var(--s-4);
  padding-top: env(safe-area-inset-top);
  padding-left: max(var(--s-4), env(safe-area-inset-left));
  padding-right: max(var(--s-4), env(safe-area-inset-right));
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.brand-lockup { display: inline-flex; align-items: center; gap: var(--s-3); color: var(--text); }
.brand-lockup:hover { text-decoration: none; }
.brand-num {
  font-family: var(--f-display);
  color: var(--brand-primary);
  font-size: var(--fs-2xl);
  line-height: 1;
  letter-spacing: -0.02em;
}
.brand-rule {
  width: 2px; height: 18px; background: var(--brand-accent); display: inline-block;
  border-radius: 1px;
}
.brand-kicker {
  font-family: var(--f-mono);
  font-size: var(--fs-xs);
  letter-spacing: var(--ls-widest);
  text-transform: uppercase;
  color: var(--text);
  font-weight: var(--fw-semi);
}
.brand-sparkle {
  color: var(--brand-primary);
  font-size: 18px;
  line-height: 1;
}
.brand-logo {
  height: 47px;
  width: auto;
  display: block;
}
.brand-logo-link {
  display: inline-flex;
  align-items: center;
  line-height: 0;       /* avoid extra anchor-baseline whitespace */
  border-radius: var(--r-sm);
}
.brand-logo-link:hover { text-decoration: none; }
.brand-logo-link:focus-visible {
  outline: 2px solid var(--brand-primary);
  outline-offset: 3px;
}

/* ---------- Page container ---------- */
.page {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: var(--s-4) var(--s-4) calc(var(--nav-height) + var(--s-7));
  padding-left: max(var(--s-4), env(safe-area-inset-left));
  padding-right: max(var(--s-4), env(safe-area-inset-right));
  display: flex; flex-direction: column; gap: var(--s-4);
}

/* ---------- Bottom tab bar ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  height: calc(var(--nav-height) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--surface);
  border-top: 1px solid var(--border);
}
.tab {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--s-1);
  min-height: var(--tap-target);
  text-decoration: none;
  color: var(--text-muted);
  font-family: var(--f-mono);
  font-size: 9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.tab:hover { text-decoration: none; color: var(--text); }
.tab svg {
  width: 22px; height: 22px;
  fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round;
}
.tab.is-active { color: var(--brand-primary); }
.tab.is-active::before {
  content: "\2726";
  position: absolute; top: 4px; right: calc(50% - 18px);
  color: var(--brand-primary);
  font-size: 9px;
  line-height: 1;
}

/* ---------- Kickers / mono helpers (tokens defines .kicker / .mono baselines) ---------- */
.kicker--pink { color: var(--brand-primary); }
.kicker--success { color: var(--success); }
.kicker--warning { color: var(--warning); }
.kicker--danger  { color: var(--danger); }
.kicker--info    { color: var(--info); }
.muted { color: var(--text-muted); }

/* ---------- Dashboard ---------- */
.session-strip {
  display: flex; flex-direction: column; gap: var(--s-1);
}
.session-strip__top {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-3);
}
.session-strip__right {
  display: flex; align-items: center; gap: var(--s-3);
  flex: 0 0 auto;
}
.session-strip .session-name {
  font-family: var(--f-ui);
  font-size: var(--fs-md);
  font-weight: var(--fw-semi);
  line-height: 1.2;
  /* Long names wrap across the full width but cap at two lines so a verbose
     session title can't push the rest of the dashboard down. */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.session-strip .session-timer {
  font-family: var(--f-mono);
  color: var(--brand-primary);
  font-size: var(--fs-md);
  font-weight: var(--fw-bold);
  font-variant-numeric: tabular-nums;
}

.hero-pcard {
  background: var(--brand-primary);
  color: var(--text-inverse);
  border-radius: var(--r-xl);
  padding: var(--s-5);
  box-shadow: var(--shadow-lg);
  position: relative;
  overflow: hidden;
}
/* Keep card text in front of the optional driver photo background. */
.hero-pcard > *:not(.hero-driver-photo) {
  position: relative;
  z-index: 1;
}
/* Driver photo: bottom-flush right, full card height, native aspect.
   White outer glow is baked into the PNG -- no CSS shadow needed. */
.hero-driver-photo {
  position: absolute;
  right: 0;
  bottom: 0;
  height: 100%;
  width: auto;
  max-width: 60%;
  object-fit: contain;
  object-position: right bottom;
  z-index: 0;
  pointer-events: none;
  user-select: none;
}
/* When a driver photo is showing, reserve the right side for it so the
   position kicker + P-number never run under the driver's head, even on
   narrow phones. No effect when there's no photo. */
.hero-pcard.has-photo {
  padding-right: 42%;
}
.hero-pcard .hero-kicker {
  font-family: var(--f-mono);
  font-size: var(--fs-xs);
  letter-spacing: var(--ls-widest);
  text-transform: uppercase;
  opacity: 0.85;
}
.hero-pcard .hero-pnum {
  font-family: var(--f-display);
  font-size: 96px;
  line-height: 0.9;
  letter-spacing: -0.02em;
  margin-top: var(--s-2);
  font-variant-numeric: tabular-nums;
  color: var(--brand-accent);
}
/* Inline "P#" highlight used in mid-text positions (e.g. the hero kicker
   "Overall · P2 in PRO-AM"). Pairs with .hero-pnum so every position
   readout on the dashboard reads in the accent color. */
.pos-accent {
  color: var(--brand-accent);
  font-weight: var(--fw-bold);
}
.hero-pcard .hero-driver {
  display: inline-flex; align-items: baseline; gap: var(--s-2);
  margin-top: var(--s-2);
  font-family: var(--f-mono);
}
.hero-pcard .hero-driver__kicker {
  font-size: var(--fs-xs);
  letter-spacing: var(--ls-wider);
  text-transform: uppercase;
  opacity: 0.7;
}
.hero-pcard .hero-driver__name {
  font-size: var(--fs-md);
  font-weight: var(--fw-bold);
  letter-spacing: 0.04em;
}

.hero-pcard .hero-foot { display: flex; align-items: center; gap: var(--s-3); margin-top: var(--s-3); }
.hero-pcard .hero-foot .pill {
  display: inline-flex; align-items: center; gap: var(--s-1);
  background: var(--success); color: white;
  border-radius: var(--r-pill);
  padding: 2px var(--s-3);
  font-family: var(--f-mono); font-weight: var(--fw-bold); font-size: var(--fs-xs);
}
.hero-pcard .hero-foot .pill--down { background: var(--danger); }
.hero-pcard .hero-foot .meta {
  font-family: var(--f-mono);
  font-size: var(--fs-xs);
  letter-spacing: var(--ls-wide);
  opacity: 0.85;
}

/* ---------- Idle state: next-session countdown (swaps into the pink card) ---------- */
.hero-next { display: none; }
.hero-pcard.is-idle > .hero-kicker,
.hero-pcard.is-idle > .hero-pnum,
.hero-pcard.is-idle > .hero-driver,
.hero-pcard.is-idle > .hero-foot,
.hero-pcard.is-idle > .hero-driver-photo { display: none !important; }
.hero-pcard.is-idle > .hero-next { display: block; }
.hero-next .next-name {
  font-family: var(--f-display);
  font-size: 30px;
  line-height: 1.05;
  margin-top: var(--s-2);
  color: var(--text-inverse);
}
.hero-next .next-when {
  font-family: var(--f-mono);
  font-size: var(--fs-xs);
  letter-spacing: var(--ls-wide);
  opacity: 0.85;
  margin-top: var(--s-1);
}
.countdown { display: flex; gap: var(--s-2); margin-top: var(--s-4); }
.countdown[hidden] { display: none; }
.cd-cell {
  display: flex; flex-direction: column; align-items: center;
  flex: 1 1 0; min-width: 0; max-width: 76px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: var(--r-md);
  padding: var(--s-2) 0;
}
.cd-num {
  font-family: var(--f-mono); font-weight: var(--fw-bold);
  font-size: 26px; line-height: 1;
  color: var(--brand-accent);
  font-variant-numeric: tabular-nums;
}
.cd-lbl {
  font-family: var(--f-mono); font-size: 10px;
  letter-spacing: var(--ls-wider); text-transform: uppercase;
  opacity: 0.8; margin-top: 5px;
}
.media-cta {
  display: flex; align-items: center; gap: var(--s-3);
  margin-top: var(--s-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--s-3) var(--s-4);
  color: var(--text);
  text-decoration: none;
  font-size: var(--fs-md);
  line-height: 1.4;
}
.media-cta:hover { border-color: var(--brand-primary); text-decoration: none; }
.media-cta__icon { margin-left: auto; flex: 0 0 auto; display: inline-flex; color: var(--brand-primary); }

/* Loading shimmer on the stat values until the first /api/state arrives. */
.stat-grid.is-loading .stat-value {
  color: transparent;
  width: 70%;
  border-radius: 6px;
  background-color: #ece7ef;
  background-image: linear-gradient(90deg, rgba(255,255,255,0) 0%, rgba(255,255,255,0.75) 50%, rgba(255,255,255,0) 100%);
  background-size: 200% 100%;
  background-repeat: no-repeat;
  animation: skel-sweep 1.25s ease-in-out infinite;
}
@keyframes skel-sweep {
  0%   { background-position: 140% 0; }
  100% { background-position: -40% 0; }
}

.stat-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-3);
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--s-3) var(--s-4);
}
.stat-card .stat-kicker {
  font-family: var(--f-mono);
  font-size: var(--fs-xs);
  letter-spacing: var(--ls-wider);
  text-transform: uppercase;
  color: var(--text-muted);
}
.stat-card .stat-value {
  margin-top: var(--s-1);
  font-family: var(--f-ui);
  font-size: var(--fs-xl);
  font-weight: var(--fw-bold);
}
.stat-card .stat-value.is-mono { font-family: var(--f-mono); color: var(--brand-primary); font-size: var(--fs-lg); }
.stat-card .stat-value.is-success { color: var(--success); }
.stat-card .stat-value.is-danger { color: var(--danger); }
.stat-card .stat-sub { color: var(--text-muted); font-size: var(--fs-xs); margin-top: 2px; }

/* Car status value: render \n-separated labels (ON\nTRACK, IN\nPIT) on two
   stacked lines, sized up to fill the card and balance the Last Lap card
   (which carries the sector times) beside it. */
#stat-car-state {
  white-space: pre-line;
  font-size: var(--fs-2xl);
  line-height: 1.05;
}
/* Live sector times, shown above Last Lap while On Track. Spread across the
   card and sized to fit the half-width column (3 values would overflow at the
   larger lap-time size). */
.stat-sectors {
  display: flex;
  justify-content: space-between;
  gap: var(--s-1);
  margin-bottom: var(--s-2);
}
.stat-sectors .sector {
  display: flex; flex-direction: column; gap: 1px;
}
.stat-sectors .sector-lbl {
  font-family: var(--f-mono);
  font-size: 9px;
  letter-spacing: var(--ls-wide);
  text-transform: uppercase;
  color: var(--text-muted);
}
.stat-sectors .sector-t {
  font-family: var(--f-mono);
  font-size: var(--fs-xs);
  font-weight: var(--fw-bold);
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
/* Flash the brand colour each time a sector time updates, then fade to normal. */
@keyframes sector-flash {
  0%, 25% { color: var(--brand-primary); }
  100%    { color: var(--text); }
}
.stat-sectors .sector-t.is-flash { animation: sector-flash 0.8s ease-out; }

/* Two-section stat card (Best lap / Last lap stacked) */
.stat-card.stat-card--two { display: flex; flex-direction: column; }
.stat-card.stat-card--two .stat-section { flex: 0 0 auto; }
.stat-card.stat-card--two .stat-divider {
  height: 1px;
  background: var(--border);
  margin: var(--s-2) calc(-1 * var(--s-4));
}

/* Full-width Best lap card gives the per-driver list room to breathe. */
.stat-card--full { grid-column: 1 / -1; }
.stat-card--vcenter { display: flex; flex-direction: column; justify-content: center; }
.stat-grid > .stat-card { min-width: 0; }   /* keep long content from blowing out the grid tracks */
.stat-bestline { display: flex; align-items: baseline; gap: var(--s-2); flex-wrap: wrap; }

/* Per-driver best laps inside the Best lap card (shown for 2+ drivers). */
.stat-driver-bests { margin-top: var(--s-1); display: flex; flex-direction: column; gap: 6px; }
.dbest-row { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-3); }
.dbest-name {
  font-family: var(--f-mono);
  font-size: var(--fs-sm);
  letter-spacing: 0.01em;
  color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  min-width: 0;
}
.dbest-time {
  font-family: var(--f-mono);
  font-size: var(--fs-md);
  font-weight: var(--fw-bold);
  color: var(--brand-primary);
  font-variant-numeric: tabular-nums;
  flex: 0 0 auto;
}

/* Gap detail line under the time value */
.stat-gap-detail {
  margin-top: var(--s-1);
  font-family: var(--f-mono);
  font-size: var(--fs-xs);
  letter-spacing: var(--ls-wide);
  display: flex;
  gap: var(--s-2);
  flex-wrap: wrap;
  align-items: baseline;
  color: var(--text-muted);
  line-height: 1.3;
}
.stat-gap-detail .gap-car    { color: var(--text);          font-weight: var(--fw-bold); }
.stat-gap-detail .gap-driver { color: var(--text);          font-weight: var(--fw-semi); }
.stat-gap-detail .gap-class  { color: var(--brand-accent); }
.stat-gap-detail .gap-best   { color: var(--text-muted); }
.stat-gap-detail span:empty { display: none; }

/* ---------- Flag strip (Live dashboard) ---------- */
.flag-strip {
  display: flex; align-items: center; gap: var(--s-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 6px solid var(--text-muted);
  border-radius: var(--r-md);
  padding: var(--s-3) var(--s-4);
  transition: border-left-color .2s, background .2s;
}
.flag-strip[data-flag="green"]      { border-left-color: var(--success); background: var(--success-bg); }
.flag-strip[data-flag="yellow"]     { border-left-color: var(--warning); background: var(--warning-bg); }
.flag-strip[data-flag="red"]        { border-left-color: var(--danger);  background: var(--danger-bg); }
.flag-strip[data-flag="white"]      { border-left-color: var(--text-muted); background: var(--surface-2); }
.flag-strip[data-flag="chequered"]  { border-left-color: var(--brand-ink); background: var(--surface-2); }
.flag-strip[data-flag="unknown"]    { border-left-color: var(--border-strong); }

.flag-chip {
  width: 36px; height: 36px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  flex: 0 0 auto;
}
.flag-icon {
  height: 48px;
  width: auto;
  max-width: 72px;
  display: block;
  flex: 0 0 auto;
}
/* When a custom flag SVG is shown, drop the soft background tint so the
   icon reads as the primary visual without competing colour. The
   border-left bar still encodes state at a glance. */
.flag-strip[data-has-icon="true"] { background: var(--surface); }
.flag-strip[data-flag="green"]     .flag-chip { background: var(--success); border-color: var(--success); }
.flag-strip[data-flag="yellow"]    .flag-chip { background: var(--warning); border-color: var(--warning); }
.flag-strip[data-flag="red"]       .flag-chip { background: var(--danger);  border-color: var(--danger); }
.flag-strip[data-flag="white"]     .flag-chip { background: #FFFFFF; border-color: var(--border-strong); }
.flag-strip[data-flag="chequered"] .flag-chip {
  background:
    linear-gradient(45deg, var(--brand-ink) 25%, transparent 25%) 0 0,
    linear-gradient(-45deg, var(--brand-ink) 25%, transparent 25%) 0 0,
    linear-gradient(45deg, transparent 75%, var(--brand-ink) 75%) 0 0,
    linear-gradient(-45deg, transparent 75%, var(--brand-ink) 75%) 0 0,
    #FFFFFF;
  background-size: 12px 12px;
  background-position: 0 0, 0 6px, 6px -6px, -6px 0;
  border-color: var(--brand-ink);
}

.flag-meta { min-width: 0; }
.flag-strip .flag-label {
  font-family: var(--f-display);
  font-size: var(--fs-lg);
  letter-spacing: var(--ls-tight);
  margin-top: 2px;
  color: var(--text);
}
.flag-strip[data-flag="green"]     .flag-label { color: var(--success); }
.flag-strip[data-flag="yellow"]    .flag-label { color: var(--warning); }
.flag-strip[data-flag="red"]       .flag-label { color: var(--danger); }

/* ---------- Notification ribbon (latest-on-dashboard) ---------- */
.notif-ribbon {
  background: var(--brand-blush);
  border-radius: var(--r-md);
  padding: var(--s-3) var(--s-4);
  border-left: 6px solid var(--brand-primary);
}
.notif-ribbon[data-cat="position"]  { border-left-color: var(--brand-primary); }
.notif-ribbon[data-cat="car_state"] { border-left-color: var(--info); }
.notif-ribbon[data-cat="timer"]     { border-left-color: var(--warning); }
.notif-ribbon[data-cat="session"]   { border-left-color: var(--success); }
.notif-ribbon[data-cat="flag"]      { border-left-color: var(--danger); }
.notif-ribbon[data-cat="driver"]    { border-left-color: var(--brand-pink-soft); }
.notif-ribbon[data-cat="info"]      { border-left-color: var(--text-muted); }
.notif-ribbon .ribbon-kicker {
  font-family: var(--f-mono); font-size: var(--fs-xs); letter-spacing: var(--ls-wider); text-transform: uppercase;
  color: var(--text-muted);
}
.notif-ribbon .ribbon-title { font-weight: var(--fw-semi); margin-top: 2px; font-size: var(--fs-base); }

/* ---------- Section headings ---------- */
.h-section {
  font-family: var(--f-display);
  font-size: var(--fs-xl);
  letter-spacing: var(--ls-tight);
  margin: 0;
}

/* ---------- History ---------- */
.filter-chips {
  display: flex; gap: var(--s-2); overflow-x: auto;
  margin: 0 calc(-1 * var(--s-4)); padding: 0 var(--s-4) var(--s-1);
  scrollbar-width: none;
}
.filter-chips::-webkit-scrollbar { display: none; }
.chip-btn {
  flex: 0 0 auto;
  display: inline-flex; align-items: center; gap: var(--s-1);
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  padding: 6px var(--s-3);
  font-family: var(--f-mono);
  font-size: var(--fs-xs);
  letter-spacing: var(--ls-wider);
  text-transform: uppercase;
  font-weight: var(--fw-semi);
  cursor: pointer;
  white-space: nowrap;
}
.chip-btn .count { opacity: 0.7; font-weight: var(--fw-regular); }
.chip-btn:hover { background: var(--surface-2); }
.chip-btn.is-active { background: var(--brand-primary); color: var(--text-inverse); border-color: var(--brand-primary); }
.chip-btn.is-active .count { opacity: 0.9; }

.notif-list { display: flex; flex-direction: column; gap: var(--s-2); list-style: none; padding: 0; margin: 0; }
.notif-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--brand-primary);
  border-radius: var(--r-md);
  padding: var(--s-3) var(--s-4);
}
.notif-card[data-cat="position"]  { border-left-color: var(--brand-primary); }
.notif-card[data-cat="car_state"] { border-left-color: var(--info); }
.notif-card[data-cat="timer"]     { border-left-color: var(--warning); }
.notif-card[data-cat="session"]   { border-left-color: var(--success); }
.notif-card[data-cat="flag"]      { border-left-color: var(--danger); }
.notif-card[data-cat="driver"]    { border-left-color: var(--brand-pink-soft); }
.notif-card[data-cat="info"]      { border-left-color: var(--text-muted); }
.notif-card .notif-meta {
  display: flex; justify-content: space-between; align-items: baseline;
  font-family: var(--f-mono); font-size: var(--fs-xs); letter-spacing: var(--ls-wider); text-transform: uppercase;
}
.notif-card[data-cat="position"]  .notif-cat { color: var(--brand-primary); }
.notif-card[data-cat="car_state"] .notif-cat { color: var(--info); }
.notif-card[data-cat="timer"]     .notif-cat { color: var(--warning); }
.notif-card[data-cat="session"]   .notif-cat { color: var(--success); }
.notif-card[data-cat="flag"]      .notif-cat { color: var(--danger); }
.notif-card[data-cat="driver"]    .notif-cat { color: var(--brand-pink-soft); }
.notif-card .notif-ts { color: var(--text-muted); }
.notif-card .notif-title { font-weight: var(--fw-semi); margin-top: 2px; font-size: var(--fs-base); }
.notif-card .notif-sub   { color: var(--text-muted); font-size: var(--fs-xs); margin-top: 2px; white-space: pre-wrap; }

.pager { display: flex; justify-content: center; padding: var(--s-3) 0; }

/* ---------- Sessions (grouped by day) ---------- */
.day-group { display: flex; flex-direction: column; gap: var(--s-2); }
.day-kicker {
  font-family: var(--f-mono);
  font-size: var(--fs-xs);
  letter-spacing: var(--ls-wider);
  text-transform: uppercase;
  color: var(--brand-primary);
  font-weight: var(--fw-semi);
}
.session-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: var(--s-3);
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--s-2) var(--s-3);
  /* Button reset so <button class="session-row"> still looks like a card */
  width: 100%;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
  transition: background-color 0.15s, transform 0.05s;
}
button.session-row:hover  { background: var(--surface-2); }
button.session-row:active { transform: scale(0.99); }
button.session-row:focus-visible { outline: 2px solid var(--brand-primary); outline-offset: 2px; }
.finish-pill {
  width: 52px; height: 44px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--brand-primary); color: var(--text-inverse);
  border-radius: var(--r-md);
  font-family: var(--f-display); font-size: var(--fs-lg);
  letter-spacing: -0.02em;
}
.finish-pill.is-muted { background: var(--surface-2); color: var(--text-muted); }
.session-row .row-name { font-weight: var(--fw-semi); font-size: var(--fs-base); }
.session-row .row-meta { font-family: var(--f-mono); font-size: var(--fs-xs); color: var(--text-muted); margin-top: 2px; }
.session-row .chev { color: var(--brand-accent); font-size: 22px; line-height: 1; }

/* ---------- Settings ---------- */
.settings-hero {
  background: var(--brand-primary);
  color: var(--text-inverse);
  border-radius: var(--r-xl);
  padding: var(--s-5);
  box-shadow: var(--shadow-lg);
}
.settings-hero .h {
  font-family: var(--f-display);
  font-size: 22px;
  line-height: 1;
}
.settings-hero .sub { margin-top: var(--s-2); font-size: var(--fs-sm); opacity: 0.9; }
.settings-hero .device {
  font-family: var(--f-mono);
  font-size: var(--fs-xs);
  letter-spacing: var(--ls-wider);
  margin-top: var(--s-2);
  opacity: 0.9;
  text-transform: uppercase;
}

/* "Notifications are off" state: reuses the hero card, adds numbered fix-it steps. */
.blocked-steps { display: flex; flex-direction: column; gap: var(--s-2); margin-top: var(--s-3); }
.blocked-step { display: flex; align-items: center; gap: var(--s-2); font-size: var(--fs-sm); }
.blocked-step-n {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 999px;
  background: var(--text-inverse);
  color: var(--brand-primary);
  font-family: var(--f-mono);
  font-weight: 700;
  font-size: var(--fs-xs);
}
.blocked-actions { display: flex; flex-direction: column; gap: var(--s-2); margin-top: var(--s-3); }

.cat-list { display: flex; flex-direction: column; gap: var(--s-2); }
.cat-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--s-3);
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--brand-primary);
  border-radius: var(--r-md);
  padding: var(--s-3) var(--s-4);
}
.cat-card[data-cat="position"]  { border-left-color: var(--brand-primary); }
.cat-card[data-cat="car_state"] { border-left-color: var(--info); }
.cat-card[data-cat="timer"]     { border-left-color: var(--warning); }
.cat-card[data-cat="session"]   { border-left-color: var(--success); }
.cat-card[data-cat="flag"]      { border-left-color: var(--danger); }
.cat-card[data-cat="driver"]    { border-left-color: var(--brand-pink-soft); }
.cat-card[data-cat="info"]      { border-left-color: var(--text-muted); }
.cat-card .cat-label { font-weight: var(--fw-semi); font-size: var(--fs-base); }
.cat-card .cat-sub   { color: var(--text-muted); font-size: var(--fs-xs); margin-top: 2px; }

/* iOS-style toggle */
.toggle { position: relative; width: 46px; height: 28px; flex: 0 0 auto; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle .track {
  position: absolute; inset: 0;
  background: var(--surface-2);
  border-radius: var(--r-pill);
  transition: background .15s;
}
.toggle .thumb {
  position: absolute; top: 3px; left: 3px;
  width: 22px; height: 22px;
  background: white;
  border-radius: 50%;
  box-shadow: var(--shadow-sm);
  transition: transform .15s;
}
.toggle input:checked ~ .track { background: var(--brand-primary); }
.toggle[data-cat="car_state"] input:checked ~ .track { background: var(--info); }
.toggle[data-cat="timer"]     input:checked ~ .track { background: var(--warning); }
.toggle[data-cat="session"]   input:checked ~ .track { background: var(--success); }
.toggle[data-cat="flag"]      input:checked ~ .track { background: var(--danger); }
.toggle[data-cat="driver"]    input:checked ~ .track { background: var(--brand-pink-soft); }
.toggle[data-cat="info"]      input:checked ~ .track { background: var(--text-muted); }
.toggle input:checked ~ .thumb { transform: translateX(18px); }

.unsub {
  text-align: center; padding: var(--s-3);
}
.unsub a {
  color: var(--text-muted);
  text-decoration: underline;
  font-size: var(--fs-sm);
}

/* Install accordion inside settings */
.install-accordion {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 0;
  overflow: hidden;
}
.install-accordion summary {
  list-style: none;
  cursor: pointer;
  padding: var(--s-3) var(--s-4);
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-2);
  font-weight: var(--fw-semi);
}
.install-accordion summary::-webkit-details-marker { display: none; }
.install-accordion summary .chev { color: var(--text-muted); font-size: 18px; transition: transform .15s; }
.install-accordion[open] summary .chev { transform: rotate(90deg); }
.install-accordion .install-body { padding: 0 var(--s-4) var(--s-4); }

.step-card {
  display: grid;
  grid-template-columns: 80px 1fr;
  gap: var(--s-3);
  align-items: center;
  padding: var(--s-3) 0;
  border-top: 1px solid var(--border);
}
.step-card:first-child { border-top: 0; padding-top: var(--s-3); }
.step-thumb {
  width: 80px; height: 100px;
  background: var(--brand-blush);
  border: 1.5px dashed var(--brand-primary);
  border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: center;
  color: var(--brand-primary);
  font-size: 32px;
}
.step-meta .step-kicker {
  font-family: var(--f-mono); font-size: var(--fs-xs);
  letter-spacing: var(--ls-wider); text-transform: uppercase;
  color: var(--text-muted);
}
.step-meta .step-name {
  font-family: var(--f-display); font-size: var(--fs-md);
  letter-spacing: -0.01em; margin-top: 2px;
}
.step-meta .step-hint {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  margin-top: 3px;
}

/* ---------- Buttons (page-level) ---------- */
.btn-row { display: flex; gap: var(--s-2); flex-wrap: wrap; }
.btn-primary {
  background: var(--brand-primary); color: var(--text-inverse);
  border: 0; border-radius: var(--r-md);
  min-height: var(--tap-target);
  padding: 0 var(--s-5);
  font-family: var(--f-ui); font-weight: var(--fw-semi); font-size: var(--fs-base);
}
.btn-primary:hover { background: var(--brand-primary-hover); }
.btn-ghost {
  background: transparent; color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--r-md);
  min-height: var(--tap-target);
  padding: 0 var(--s-5);
  font-family: var(--f-ui); font-weight: var(--fw-semi); font-size: var(--fs-base);
}
.btn-link {
  background: none; border: 0; padding: 0;
  color: var(--brand-primary);
  font-family: var(--f-ui); font-weight: var(--fw-semi); font-size: var(--fs-base);
  text-decoration: underline;
}
.btn-pop {
  background: var(--brand-primary); color: var(--text-inverse);
  border: 0; border-radius: var(--r-md);
  min-height: var(--tap-target);
  padding: 0 var(--s-5);
  font-weight: var(--fw-bold);
  box-shadow: var(--shadow-pop);
  transform: translateY(0); transition: transform .08s, box-shadow .08s;
}
.btn-pop:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--brand-primary-hover); }

/* ====================================================================
   ADMIN PANEL
   ==================================================================== */
.admin-topbar {
  display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-3);
  margin-bottom: var(--s-2);
}

.admin-flash {
  border-radius: var(--r-md);
  padding: var(--s-3) var(--s-4);
  font-size: var(--fs-sm);
  border: 1px solid var(--border);
}
.admin-flash--ok     { background: var(--success-bg); border-color: var(--success);  color: var(--success); }
.admin-flash--warn   { background: var(--warning-bg); border-color: var(--warning);  color: var(--warning); }
.admin-flash--danger { background: var(--danger-bg);  border-color: var(--danger);   color: var(--danger); }
.admin-flash--info   { background: var(--info-bg);    border-color: var(--info);     color: var(--info); }

.admin-stats {
  display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-3);
}
.admin-stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--brand-primary);
  border-radius: var(--r-md);
  padding: var(--s-3) var(--s-4);
}
.admin-stat:nth-child(2) { border-left-color: var(--info); }
.admin-stat__num {
  font-family: var(--f-display);
  font-size: var(--fs-3xl);
  line-height: 1;
  letter-spacing: -0.02em;
  color: var(--brand-primary);
  margin-top: var(--s-1);
  font-variant-numeric: tabular-nums;
}
.admin-stat:nth-child(2) .admin-stat__num { color: var(--info); }
.admin-stat__num--text {
  font-family: var(--f-mono);
  font-size: var(--fs-lg);
  font-weight: var(--fw-bold);
  letter-spacing: 0;
}
.admin-stat__sub { font-size: var(--fs-xs); margin-top: var(--s-1); }

/* ---------- Admin tab strip + panels ----------
   Non-sticky for now: html/body use overflow-x:hidden, which makes the
   document the scroll container and prevents reliable position:sticky on
   iOS standalone (same root cause as the bottom-nav scroll bug). Revisit
   once the app-shell scroll refactor lands. */
.admin-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--s-1);
  padding: var(--s-2) 0;
}
.admin-tab {
  display: flex; align-items: center; justify-content: center;
  min-height: 40px;
  padding: 0 var(--s-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--text-muted);
  font-family: var(--f-mono);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semi);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
.admin-tab:hover { color: var(--text); }
.admin-tab.is-active {
  background: var(--brand-primary);
  border-color: var(--brand-primary);
  color: var(--text-inverse);
}
.admin-tab:focus-visible {
  outline: 2px solid var(--brand-primary);
  outline-offset: 2px;
}

.admin-tabpanel { display: flex; flex-direction: column; gap: var(--s-4); }
.admin-tabpanel[hidden] { display: none; }

/* Collapsible sections (Send + Logs tabs) */
.admin-section--collapsible > .admin-section__head {
  cursor: pointer;
  align-items: center;
  -webkit-tap-highlight-color: transparent;
}
.admin-head-right { display: flex; align-items: center; gap: var(--s-2); }
.admin-collapse-chev {
  background: none; border: 0; padding: 0;
  color: var(--text-muted);
  font-size: 22px; line-height: 1;
  cursor: pointer;
  flex: 0 0 auto;
  transform: rotate(90deg);            /* points down when expanded */
  transition: transform 0.15s ease, color 0.15s ease;
}
.admin-collapse-chev:hover { color: var(--text); }
.admin-section.is-collapsed .admin-collapse-chev { transform: rotate(0deg); }  /* points right when collapsed */
.admin-section.is-collapsed > :not(.admin-section__head) { display: none; }

.admin-section { display: flex; flex-direction: column; gap: var(--s-2); }
.admin-section__head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-3);
}
.admin-h {
  margin: 2px 0 0;
  font-family: var(--f-ui); font-weight: var(--fw-bold);
  font-size: var(--fs-md);
}
.admin-sub { font-size: var(--fs-xs); margin: 0; }
.admin-sub code { font-family: var(--f-mono); font-size: var(--fs-xs); }

.admin-meta {
  display: grid; grid-template-columns: auto 1fr; gap: var(--s-1) var(--s-3);
  background: var(--surface-2);
  border-radius: var(--r-sm);
  padding: var(--s-2) var(--s-3);
  margin-top: var(--s-2);
  align-items: center;
}
.admin-meta .kicker { color: var(--text-muted); }

.admin-pill {
  display: inline-flex; align-items: center;
  border-radius: var(--r-pill);
  padding: 2px var(--s-3);
  font-family: var(--f-mono);
  font-size: var(--fs-xs);
  letter-spacing: var(--ls-wider);
  text-transform: uppercase;
  font-weight: var(--fw-bold);
  white-space: nowrap;
}
.admin-pill--ok     { background: var(--success); color: white; }
.admin-pill--warn   { background: var(--warning); color: white; }
.admin-pill--bad    { background: var(--danger);  color: white; }
.admin-pill--muted  { background: var(--surface-2); color: var(--text-muted); }

.admin-label {
  display: block;
  margin-top: var(--s-2);
  font-family: var(--f-mono);
  font-size: var(--fs-xs);
  letter-spacing: var(--ls-wider);
  text-transform: uppercase;
  color: var(--text-muted);
}
.admin-input {
  width: 100%;
  min-height: var(--tap-target);
  padding: var(--s-2) var(--s-3);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  font-family: var(--f-ui);
  font-size: var(--fs-base);
  color: var(--text);
  outline: none;
  transition: border-color .12s, box-shadow .12s;
}
.admin-input:focus {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px var(--brand-blush);
}
textarea.admin-input { resize: vertical; min-height: 88px; }
select.admin-input { appearance: none; -webkit-appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%), linear-gradient(135deg, var(--text-muted) 50%, transparent 50%); background-position: right 14px center, right 9px center; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: var(--s-5); }

.admin-grid2 {
  display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-3);
}

.admin-logs {
  background: var(--surface-2);
  border-radius: var(--r-sm);
  padding: 0;
  overflow: hidden;
}
.admin-logs summary {
  list-style: none;
  cursor: pointer;
  padding: var(--s-2) var(--s-3);
  display: flex; align-items: center; justify-content: space-between;
  font-family: var(--f-mono);
  font-size: var(--fs-xs);
  letter-spacing: var(--ls-wider);
  text-transform: uppercase;
  color: var(--text-muted);
}
.admin-logs summary::-webkit-details-marker { display: none; }
.admin-logs[open] summary .chev { transform: rotate(90deg); }
.admin-logs summary .chev { transition: transform .12s; }
.admin-logs__pre {
  margin: 0;
  padding: var(--s-3);
  background: #0E0A18;
  color: #FFF6FA;
  font-family: var(--f-mono);
  font-size: 11px;
  line-height: 1.45;
  max-height: 320px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

/* ---------- Admin: log + scheduled ---------- */
.admin-log-list,
.sched-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex; flex-direction: column;
  gap: var(--s-2);
}

.admin-log-row,
.sched-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--s-2);
  align-items: flex-start;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--text-muted);
  border-radius: var(--r-sm);
  padding: var(--s-2) var(--s-3);
}
.admin-log-row[data-cat="position"]  { border-left-color: var(--brand-primary); }
.admin-log-row[data-cat="car_state"] { border-left-color: var(--info); }
.admin-log-row[data-cat="timer"]     { border-left-color: var(--warning); }
.admin-log-row[data-cat="session"]   { border-left-color: var(--success); }
.admin-log-row[data-cat="info"]      { border-left-color: var(--text-muted); }

.admin-log-row__meta {
  display: flex; gap: var(--s-2); align-items: baseline;
  font-family: var(--f-mono);
  font-size: var(--fs-xs);
  letter-spacing: var(--ls-wider);
  text-transform: uppercase;
  color: var(--text-muted);
  flex-wrap: wrap;
}
.admin-log-row__cat   { color: var(--text); }
.admin-log-row__id    { opacity: 0.5; }
.admin-log-row__title { font-weight: var(--fw-semi); margin-top: 2px; font-size: var(--fs-sm); }
.admin-log-row__msg   { color: var(--text-muted); font-size: var(--fs-xs); margin-top: 2px; white-space: pre-wrap; }

.admin-x {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text-muted);
  width: 32px; height: 32px;
  border-radius: var(--r-sm);
  font-size: 20px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
  flex: 0 0 auto;
}
.admin-x:hover {
  background: var(--danger-bg);
  border-color: var(--danger);
  color: var(--danger);
}
/* Armed state: first click on per-row delete turns into a confirm.
   Bright red so it reads as "tap me to actually delete". Reverts on
   any other click or after a 4s timeout (see armInlineConfirm). */
.admin-x--armed,
.admin-x--armed:hover {
  background: var(--danger);
  border-color: var(--danger);
  color: white;
  font-weight: var(--fw-bold);
}

.sched-row__head {
  display: flex; gap: var(--s-2); align-items: center; flex-wrap: wrap;
  font-family: var(--f-mono);
  font-size: var(--fs-xs);
  letter-spacing: var(--ls-wide);
}
.sched-row__when  { color: var(--text); }
.sched-row__title { font-weight: var(--fw-semi); margin-top: var(--s-1); font-size: var(--fs-sm); }
.sched-row__msg   { color: var(--text-muted); font-size: var(--fs-xs); margin-top: 2px; white-space: pre-wrap; }
.sched-row__url   { font-size: var(--fs-xs); margin-top: var(--s-1); font-family: var(--f-mono); }
.sched-row__url a { text-decoration: underline; }

/* ---------- Page footer (Privacy link) ---------- */
.page-footer {
  text-align: center;
  margin-top: var(--s-5);
  padding-top: var(--s-3);
}
.page-footer a {
  color: var(--text-muted);
  font-family: var(--f-mono);
  font-size: var(--fs-xs);
  letter-spacing: var(--ls-wider);
  text-transform: uppercase;
  text-decoration: none;
}
.page-footer a:hover { color: var(--brand-primary); text-decoration: underline; }

/* ---------- Privacy document ---------- */
.privacy-doc h1 { margin-top: var(--s-1); }
.privacy-doc h2.privacy-h2 {
  margin-top: var(--s-5);
  margin-bottom: var(--s-2);
  font-family: var(--f-ui);
  font-weight: var(--fw-bold);
  font-size: var(--fs-md);
}
.privacy-doc p {
  margin: var(--s-2) 0;
  font-size: var(--fs-sm);
  line-height: 1.55;
}
.privacy-doc ul, .privacy-doc ol {
  margin: var(--s-2) 0;
  padding-left: var(--s-5);
  font-size: var(--fs-sm);
  line-height: 1.55;
}
.privacy-doc li { margin: var(--s-1) 0; }
.privacy-doc code {
  background: var(--surface-2);
  padding: 1px 6px;
  border-radius: var(--r-xs);
  font-family: var(--f-mono);
  font-size: 0.92em;
}

/* ---------- Admin: push fanout toggle ---------- */
.admin-push-card[data-paused="true"] {
  border-left: 4px solid var(--warning);
  background: var(--warning-bg);
}
.admin-push-card[data-paused="true"] .admin-h { color: var(--warning); }
.admin-push-card[data-paused="true"] #push-status { color: var(--warning); font-weight: var(--fw-semi); }

/* iOS-style switch (slightly bigger than the settings cat-toggle) */
.admin-switch {
  position: relative;
  width: 54px; height: 32px;
  flex: 0 0 auto;
  display: inline-block;
  cursor: pointer;
}
.admin-switch input { opacity: 0; width: 0; height: 0; }
.admin-switch__track {
  position: absolute; inset: 0;
  background: var(--surface-2);
  border-radius: var(--r-pill);
  transition: background .15s;
}
.admin-switch__thumb {
  position: absolute; top: 3px; left: 3px;
  width: 26px; height: 26px;
  background: white;
  border-radius: 50%;
  box-shadow: var(--shadow-sm);
  transition: transform .15s;
}
.admin-switch input:checked ~ .admin-switch__track { background: var(--success); }
.admin-switch input:checked ~ .admin-switch__thumb { transform: translateX(22px); }

/* ---------- Admin: feed probe ---------- */
.probe-input-row {
  display: flex; gap: var(--s-2); align-items: stretch;
}
.probe-input-row .admin-input { flex: 1; min-width: 0; }
.probe-input-row .btn-primary { flex: 0 0 auto; min-height: 44px; padding: 0 var(--s-4); }

.probe-results {
  list-style: none; padding: 0; margin: var(--s-2) 0 0 0;
  display: flex; flex-direction: column; gap: var(--s-1);
}
.probe-row {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: var(--s-2) var(--s-3);
  gap: var(--s-2);
}
.probe-row__main { flex: 1; min-width: 0; }
.probe-row__short { font-weight: var(--fw-semi); font-size: var(--fs-sm); }
.probe-row__full  { font-size: var(--fs-xs); margin-top: 2px; }
.sched-row__err   { color: var(--danger); font-size: var(--fs-xs); margin-top: var(--s-1); font-family: var(--f-mono); }

.admin-add {
  background: var(--surface-2);
  border-radius: var(--r-sm);
  margin-top: var(--s-2);
}
.admin-add > summary {
  list-style: none;
  cursor: pointer;
  padding: var(--s-2) var(--s-3);
  display: flex; align-items: center; justify-content: space-between;
  font-family: var(--f-mono);
  font-size: var(--fs-xs);
  letter-spacing: var(--ls-wider);
  text-transform: uppercase;
  color: var(--brand-primary);
  font-weight: var(--fw-semi);
}
.admin-add > summary::-webkit-details-marker { display: none; }
.admin-add[open] > summary .chev { transform: rotate(90deg); }
.admin-add > summary .chev { transition: transform .12s; color: var(--text-muted); }
.admin-add-body { padding: 0 var(--s-3) var(--s-3); }

/* ---------- Dashboard: Get Notifications button ---------- */
.dash-cta-wrap {
  display: flex; align-items: center; gap: var(--s-2);
}
.dash-cta {
  display: inline-flex; align-items: center; gap: var(--s-1);
  background: var(--brand-primary);
  color: var(--text-inverse);
  border: 0;
  border-radius: var(--r-pill);
  padding: 6px var(--s-3);
  min-height: 32px;
  font-family: var(--f-mono);
  font-size: var(--fs-xs);
  letter-spacing: var(--ls-wider);
  text-transform: uppercase;
  font-weight: var(--fw-bold);
  box-shadow: var(--shadow-pop);
  text-decoration: none;
  white-space: nowrap;
}
.dash-cta:hover { background: var(--brand-primary-hover); color: var(--text-inverse); text-decoration: none; }
.dash-cta--subdued {
  background: var(--surface);
  color: var(--text-muted);
  border: 1px solid var(--border);
  box-shadow: none;
  font-weight: var(--fw-semi);
}
.dash-cta--subdued:hover { background: var(--surface-2); color: var(--text); }

/* ---------- Schedule page ---------- */
.sched-page-head { margin-bottom: var(--s-2); }
.sched-page-sub {
  font-family: var(--f-mono);
  font-size: var(--fs-xs);
  letter-spacing: var(--ls-wide);
  color: var(--text-muted);
  margin-top: 2px;
}
.sched-day { margin-top: var(--s-4); }
.sched-day__head {
  font-family: var(--f-mono);
  font-size: var(--fs-xs);
  letter-spacing: var(--ls-widest);
  text-transform: uppercase;
  color: var(--brand-primary);
  margin-bottom: var(--s-2);
}
.sched-sess {
  display: flex; align-items: center; gap: var(--s-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s-3);
  margin-bottom: var(--s-2);
}
.sched-sess.is-next { border-color: var(--brand-primary); box-shadow: var(--shadow-pop); }
.sched-sess.is-done { opacity: 0.5; }
.sess-badge {
  flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 64px;
  font-family: var(--f-mono);
  font-size: 9px;
  font-weight: var(--fw-bold);
  letter-spacing: var(--ls-wide);
  text-transform: uppercase;
  color: #fff;
  padding: 4px 8px;
  border-radius: var(--r-pill);
}
.sess-badge--practice   { background: #2563EB; }
.sess-badge--qualifying { background: #E0820A; }
.sess-badge--race       { background: var(--brand-primary); }
.sess-badge--warmup     { background: #0D9488; }
.sess-badge--session    { background: var(--text-muted); }
.sess-main { flex: 1 1 auto; min-width: 0; }
.sess-name {
  font-family: var(--f-ui);
  font-weight: var(--fw-semi);
  font-size: var(--fs-md);
  line-height: 1.2;
}
.sess-series {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  margin-top: 1px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sess-right { flex: 0 0 auto; text-align: right; }
.sess-time {
  font-family: var(--f-mono);
  font-weight: var(--fw-bold);
  font-size: var(--fs-md);
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.sess-rel {
  font-family: var(--f-mono);
  font-size: 10px;
  letter-spacing: var(--ls-wide);
  text-transform: uppercase;
  color: var(--text-muted);
  margin-top: 2px;
  min-height: 12px;
}
.sched-sess.is-next .sess-rel { color: var(--brand-primary); font-weight: var(--fw-bold); }
.sched-empty { text-align: center; padding: var(--s-7) var(--s-4); color: var(--text-muted); }
.sched-empty__title { font-weight: var(--fw-semi); font-size: var(--fs-md); color: var(--text); }
.sched-empty__sub { font-size: var(--fs-sm); margin-top: var(--s-1); }

/* Admin login standalone page */
.admin-login-page {
  min-height: 100dvh;
  display: flex; align-items: center; justify-content: center;
}
.admin-login-card {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s-5);
  box-shadow: var(--shadow-md);
}
.admin-login-card .h-section { margin-top: var(--s-1); }

/* ---------- Session detail modal ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  -webkit-tap-highlight-color: transparent;
}
.modal-sheet {
  position: relative;
  width: 100%;
  max-width: 520px;
  max-height: 88vh;
  overflow-y: auto;
  background: var(--surface);
  border-top-left-radius: var(--r-xl);
  border-top-right-radius: var(--r-xl);
  padding: var(--s-5);
  padding-bottom: calc(env(safe-area-inset-bottom, 0) + var(--s-5));
  box-shadow: var(--shadow-lg);
  animation: sheet-up 0.18s ease-out;
}
@keyframes sheet-up {
  from { transform: translateY(16px); opacity: 0.85; }
  to   { transform: translateY(0);    opacity: 1; }
}
@media (min-width: 640px) {
  .modal { align-items: center; }
  .modal-sheet { border-radius: var(--r-xl); }
}
.modal-close {
  position: absolute;
  top: var(--s-3);
  right: var(--s-3);
  width: 36px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface-2);
  border: none;
  border-radius: 999px;
  font-size: 22px;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
}
.modal-close:hover { color: var(--text); background: var(--border); }
.modal-head { padding-right: 40px; margin-bottom: var(--s-4); }
.modal-kicker {
  font-family: var(--f-mono);
  font-size: var(--fs-xs);
  letter-spacing: var(--ls-wider);
  text-transform: uppercase;
  color: var(--text-muted);
}
.modal-title {
  font-family: var(--f-display);
  font-size: var(--fs-xl);
  line-height: 1.1;
  margin: var(--s-1) 0 0;
}

/* Notification opt-in modal (dashboard) */
.notify-text {
  margin: 0 0 var(--s-4);
  color: var(--text-muted);
  line-height: 1.5;
  font-size: var(--fs-base);
}
.notify-actions {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}
.notify-actions .btn-primary { width: 100%; }
.notify-dismiss {
  background: none; border: 0;
  color: var(--text-muted);
  font-family: var(--f-ui); font-size: var(--fs-base);
  padding: var(--s-2);
  cursor: pointer;
}
.notify-dismiss:hover { color: var(--text); text-decoration: underline; }

.detail-list {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
}
.detail-row {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: var(--s-3);
  padding: var(--s-2) 0;
  border-bottom: 1px solid var(--border);
  align-items: baseline;
}
.detail-row:last-child { border-bottom: none; }
.detail-row dt {
  font-family: var(--f-mono);
  font-size: var(--fs-xs);
  letter-spacing: var(--ls-wider);
  text-transform: uppercase;
  color: var(--text-muted);
}
.detail-row dd {
  margin: 0;
  font-size: var(--fs-base);
  font-weight: var(--fw-semi);
}
.detail-row dd .muted { font-weight: var(--fw-regular); color: var(--text-muted); margin-left: var(--s-2); font-size: var(--fs-xs); }
.detail-extra { margin-left: var(--s-2); }
.pill { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 999px; font-size: var(--fs-xs); font-family: var(--f-mono); }
.pill--up   { background: rgba(34, 197, 94, 0.15);  color: var(--success); }
.pill--down { background: rgba(239, 68, 68, 0.15);  color: var(--danger); }

/* ---------- Theme toggle (admin only) ---------- */
.theme-toggle {
  display: flex;
  gap: var(--s-3);
  flex-wrap: wrap;
  margin-top: var(--s-2);
}
.theme-opt {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--s-2) var(--s-4);
  cursor: pointer;
  font: inherit;
  color: inherit;
  transition: border-color 0.15s, background 0.15s, transform 0.05s;
  min-height: var(--tap-target);
}
.theme-opt:hover  { background: var(--surface-2); }
.theme-opt:active { transform: scale(0.99); }
.theme-opt.is-active {
  border-color: var(--brand-primary);
  background: var(--surface-2);
  font-weight: var(--fw-bold);
}
.theme-swatch {
  width: 22px; height: 22px; border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.12);
  flex-shrink: 0;
}
/* Swatch colors are HARD-CODED (not via var) so each preview chip stays
   true to its theme even when the OPPOSITE theme is active. */
.theme-swatch--pink   { background: #FF1F8C; }
.theme-swatch--orange { background: #F26F0D; }
.theme-label { font-family: var(--f-ui); font-size: var(--fs-base); }

/* ---------- Schedule auto-import ---------- */
.schedule-cta {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--brand-primary);
  border-radius: var(--r-lg);
  padding: var(--s-4);
  margin-bottom: var(--s-4);
  text-decoration: none;
  color: inherit;
  transition: background 0.15s, transform 0.05s;
}
.schedule-cta:hover  { background: var(--surface-2); text-decoration: none; }
.schedule-cta:active { transform: scale(0.995); }
.schedule-cta__icon { font-size: 28px; line-height: 1; flex-shrink: 0; }
.schedule-cta__body { flex: 1; min-width: 0; }
.schedule-cta__title { font-weight: var(--fw-bold); font-size: var(--fs-md); }
.schedule-cta__sub { color: var(--text-muted); font-size: var(--fs-xs); margin-top: 2px; }
.schedule-cta__chev { color: var(--brand-accent); font-size: 28px; line-height: 1; flex-shrink: 0; }

.sched-draft-list { list-style: none; margin: var(--s-2) 0 0; padding: 0; display: flex; flex-direction: column; gap: var(--s-3); }
.sched-draft {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--s-3);
  background: var(--surface);
}
.sched-draft__head { display: flex; align-items: center; gap: var(--s-2); }
.sched-draft__type {
  font-family: var(--f-mono); font-size: var(--fs-xs);
  letter-spacing: var(--ls-wide); text-transform: uppercase;
  padding: 2px 8px; border-radius: var(--r-pill);
  background: var(--surface-2); color: var(--text-muted); flex-shrink: 0;
}
.sched-draft__type--practice   { background: rgba(27,127,227,0.14); color: var(--info); }
.sched-draft__type--qualifying { background: rgba(217,136,0,0.16);  color: var(--warning); }
.sched-draft__type--race       { background: rgba(31,169,116,0.16); color: var(--success); }
.sched-draft__headline { flex: 1; min-width: 0; font-weight: var(--fw-semi); font-size: var(--fs-base); }
.sched-draft__fire { color: var(--text-muted); font-family: var(--f-mono); font-size: var(--fs-xs); margin-top: var(--s-2); }
.sched-draft__fire strong { color: var(--text); }
.sched-draft__warn { color: var(--danger); margin-left: var(--s-2); }
.sched-draft__edit {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: var(--s-2);
  margin-top: var(--s-3);
}
.sched-draft__edit label {
  display: flex; flex-direction: column; gap: 3px;
  font-family: var(--f-mono); font-size: 10px; letter-spacing: var(--ls-wider);
  text-transform: uppercase; color: var(--text-muted);
}
.sched-draft__edit .admin-input { font-size: var(--fs-sm); padding: var(--s-2); min-height: 38px; }

.sched-paste { margin-top: var(--s-2); }
.sched-paste > summary {
  cursor: pointer;
  font-family: var(--f-mono);
  font-size: var(--fs-xs);
  letter-spacing: var(--ls-wide);
  color: var(--brand-accent);
  list-style: none;
  padding: var(--s-1) 0;
}
.sched-paste > summary::-webkit-details-marker { display: none; }
.sched-paste[open] > summary { color: var(--text-muted); }
.sched-paste textarea.admin-input { min-height: 120px; resize: vertical; font-family: var(--f-mono); font-size: var(--fs-sm); }

/* ---- Admin result-fix editor (inside the session detail modal) ---- */
/* Rendered only for a signed-in admin (see templates/sessions.html). Corrects
   the overall + in-class finishing positions when the timing feed was wrong. */
.modal-admin {
  margin-top: var(--s-4);
  padding-top: var(--s-3);
  border-top: 1px solid var(--brand-blush);
  text-align: right;
}
.pos-edit { display: flex; flex-direction: column; gap: var(--s-4); }
.pos-edit-note { margin: 0; font-size: var(--fs-sm); }
.pos-field { display: flex; flex-direction: column; gap: var(--s-2); }
.pos-lbl {
  font-family: var(--f-mono);
  font-size: var(--fs-xs);
  letter-spacing: var(--ls-wider);
  text-transform: uppercase;
  color: var(--text-muted);
}
.pos-hint { text-transform: none; letter-spacing: 0; color: var(--text-muted); }
.pos-input { display: inline-flex; align-items: center; gap: var(--s-2); }
.pos-input .pos-p {
  font-family: var(--f-display);
  font-size: 24px;
  line-height: 1;
  color: var(--brand-primary);
}
.pos-input input {
  width: 96px;
  padding: 8px 12px;
  font-family: var(--f-mono);
  font-size: 24px;
  font-weight: 700;
  color: var(--brand-ink);
  background: var(--bg);
  border: 2px solid var(--brand-pink-pale);
  border-radius: 12px;
  -moz-appearance: textfield;
}
.pos-input input:focus { outline: none; border-color: var(--brand-primary); }
.pos-msg { color: var(--danger); font-size: var(--fs-sm); }
.pos-actions { display: flex; align-items: center; gap: var(--s-4); margin-top: var(--s-2); }

/* "Import from official timing" block inside the editor. */
.pos-import {
  display: flex; flex-direction: column; gap: var(--s-2);
  padding: var(--s-3);
  border: 1px dashed var(--brand-pink-pale);
  border-radius: 12px;
  background: var(--brand-blush);
}
.pos-import-h {
  font-family: var(--f-mono); font-size: var(--fs-xs);
  letter-spacing: var(--ls-wider); text-transform: uppercase; color: var(--text-muted);
}
.pos-import-url {
  width: 100%; padding: 8px 10px;
  font-family: var(--f-mono); font-size: var(--fs-sm);
  color: var(--brand-ink); background: var(--bg);
  border: 2px solid var(--brand-pink-pale); border-radius: 10px;
}
.pos-import-url:focus { outline: none; border-color: var(--brand-primary); }
.pos-import-row { display: flex; align-items: center; gap: var(--s-3); }
.pos-import-car {
  display: inline-flex; align-items: center; gap: var(--s-2);
  font-family: var(--f-mono); font-size: var(--fs-xs);
  letter-spacing: var(--ls-wide); text-transform: uppercase; color: var(--text-muted);
}
.pos-import-car input {
  width: 64px; padding: 6px 10px;
  font-family: var(--f-mono); font-size: 18px; font-weight: 700;
  color: var(--brand-ink); background: var(--bg);
  border: 2px solid var(--brand-pink-pale); border-radius: 10px;
}
.pos-import-car input:focus { outline: none; border-color: var(--brand-primary); }
.pos-import-btn { padding: 8px 18px; }
.pos-import-preview { padding-top: var(--s-2); font-size: var(--fs-sm); line-height: 1.5; color: var(--brand-ink); }
.pos-import-preview .imp-penalty { color: var(--danger); font-size: var(--fs-xs); }
