:root,
:root[data-rh-theme="carbon"] {
  color-scheme: dark;
  --page: #050607;
  --background: #0b0c0d;
  --surface: #111314;
  --raised: #1b1d1f;
  --active: #2b2425;
  --text: #f6f8fa;
  --muted: #a7b3bd;
  --line: #424447;
  --accent: #ff8585;
  --primary: #a92329;
  --object: #ffffff;
  --brand-red: #a92329;
  --ok: #6de1ab;
  --warning: #ffd36f;
  --danger: #ff7383;
  --shadow: rgba(0, 0, 0, .48);
}
:root[data-rh-theme="light"] {
  color-scheme: light;
  --page: #e7eaee;
  --background: #f4f5f7;
  --surface: #ffffff;
  --raised: #e8ebef;
  --active: #dce1e6;
  --text: #111820;
  --muted: #56616b;
  --line: #bfc7cf;
  --accent: #9e2027;
  --primary: #a92329;
  --object: #242a30;
  --brand-red: #a92329;
  --ok: #08794b;
  --warning: #805900;
  --danger: #a60016;
  --shadow: rgba(26, 32, 38, .16);
}
* { box-sizing: border-box; }
html { min-height: 100%; background: var(--page); }
body {
  margin: 0; min-height: 100vh;
  background: radial-gradient(circle at 84% 0, color-mix(in srgb, var(--brand-red) 22%, transparent) 0, transparent 35%), linear-gradient(155deg, var(--page), var(--background));
  color: var(--text); font: 15px/1.45 Inter, "Segoe UI", Arial, sans-serif;
}
a { color: var(--accent); }
.shell { width: min(1180px, 100%); margin: auto; padding: 28px; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 40px; }
.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.brand-logo { width: 214px; height: 64px; object-fit: contain; object-position: left center; }
.brand h1 { margin: 0; font-size: 18px; }
.brand small, .muted { color: var(--muted); }
.theme-control { display: flex; align-items: center; gap: 8px; }
.theme-control label { margin: 0; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.theme-control select { width: auto; min-width: 112px; padding: 8px 31px 8px 10px; }
.card { background: color-mix(in srgb, var(--surface) 96%, transparent); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 24px 70px var(--shadow); }
.public-grid { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(360px, .78fr); gap: 24px; align-items: stretch; margin: 7vh auto 0; }
.public-intro { padding: 42px; display: flex; flex-direction: column; justify-content: space-between; min-height: 540px; }
.public-intro .hero-logo { width: min(390px, 100%); max-height: 154px; object-fit: contain; object-position: left center; }
.public-intro h1 { font-size: clamp(38px, 5vw, 66px); line-height: .98; margin: 30px 0 18px; letter-spacing: -.045em; }
.public-intro p { max-width: 570px; color: var(--muted); font-size: 17px; }
.public-links { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 30px; }
.login { max-width: 480px; padding: 32px; margin: 9vh auto; }
.public-grid .login { max-width: none; width: 100%; margin: 0; padding: 38px; }
.login-logo { display: block; width: min(280px, 86%); max-height: 110px; margin: 0 auto 28px; object-fit: contain; }
.eyebrow { color: var(--accent); font-weight: 900; font-size: 11px; letter-spacing: .16em; text-transform: uppercase; }
.login h2, .hero h2 { font-size: 31px; margin: 8px 0 8px; }
label { display: block; margin: 18px 0 7px; color: var(--muted); font-weight: 750; }
input, select, textarea { width: 100%; padding: 13px; border-radius: 8px; border: 1px solid var(--line); background: var(--page); color: var(--text); font: inherit; }
input:focus, select:focus, textarea:focus, button:focus-visible, .button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.password-wrap { position: relative; }
.password-wrap input { padding-right: 70px; }
.password-toggle { position: absolute; right: 6px; top: 6px; padding: 7px 10px; border: 0; background: transparent; color: var(--accent); }
.caps-hint { display: none; color: var(--warning); margin-top: 7px; font-size: 12px; }
.caps-hint.visible { display: block; }
button, .button { border: 1px solid var(--line); background: var(--raised); color: var(--text); font-weight: 850; border-radius: 8px; padding: 11px 15px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 7px; }
button:hover, .button:hover { background: var(--active); }
button:disabled { opacity: .58; cursor: wait; }
.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.primary:hover { background: color-mix(in srgb, var(--primary) 82%, #000); }
a:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
.legal-page { max-width: 820px; margin: 30px auto; padding: clamp(18px, 4vw, 42px); }
.legal-page h1 { font-size: clamp(26px, 5vw, 40px); }
.legal-page p { line-height: 1.7; }
.legal-warning { padding: 14px; border: 1px solid var(--warning); color: var(--warning); }
.portal-footer { display: flex; flex-wrap: wrap; gap: 20px; margin: 32px 0 12px; }
.danger { border-color: var(--danger); color: var(--danger); background: color-mix(in srgb, var(--danger) 8%, var(--surface)); }
.wide { width: 100%; margin-top: 22px; }
.links { display: flex; justify-content: space-between; gap: 15px; margin-top: 16px; }
.links button { padding: 0; border: 0; background: none; color: var(--accent); }
.error { min-height: 22px; color: var(--danger); margin-top: 12px; }
.success { color: var(--ok); font-weight: 750; margin-top: 12px; }
.loading-dot { width: 13px; height: 13px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.hidden { display: none !important; }
.hero { display: flex; align-items: end; justify-content: space-between; gap: 25px; margin: 30px 0; }
.hero p { color: var(--muted); max-width: 620px; }
.release-grid { display: grid; grid-template-columns: 1.5fr .8fr; gap: 18px; }
.release { padding: 26px; }
.version { font-size: 44px; font-weight: 900; margin: 8px 0; }
.meta { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0; }
.pill { border: 1px solid var(--line); border-radius: 999px; padding: 5px 9px; color: var(--muted); font-size: 12px; }
.pill.stable { color: var(--ok); }
.hash { word-break: break-all; font: 12px ui-monospace, Consolas; color: var(--muted); background: var(--page); padding: 10px; border-radius: 6px; }
.side { padding: 22px; }
.version-list { display: grid; gap: 9px; }
.version-row { display: flex; justify-content: space-between; gap: 14px; padding: 12px; border: 1px solid var(--line); border-radius: 8px; }
.nav-actions { display: flex; gap: 9px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.readonly-badge { padding: 6px 9px; border: 1px solid var(--accent); border-radius: 999px; color: var(--accent); font-size: 10px; font-weight: 950; letter-spacing: .12em; }
.admin-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.metric { padding: 18px; }
.metric strong { display: block; font-size: 28px; }
.table-card { padding: 18px; margin-top: 18px; overflow: auto; }
table { width: 100%; border-collapse: collapse; min-width: 700px; }
th, td { text-align: left; padding: 12px; border-bottom: 1px solid var(--line); }
th { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.notice { padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--raised); color: var(--muted); }
.device-code { margin: 8px 0; padding: 16px; border: 1px solid var(--accent); border-radius: 9px; background: var(--page); color: var(--accent); font-size: 28px; font-weight: 900; letter-spacing: .16em; text-align: center; }
.support { color: var(--muted); font-size: 12px; margin-top: 22px; }
.release-help { margin: 18px 0 0; padding: 14px; border-left: 3px solid var(--accent); background: var(--raised); color: var(--muted); }
.status-page { max-width: 680px; margin: 10vh auto; padding: 42px; text-align: center; }
.status-code { color: var(--accent); font-size: 14px; font-weight: 950; letter-spacing: .18em; }
.status-page h1 { font-size: 42px; margin: 12px 0; }

/* Existing read-only mobile race viewer: structure and navigation are intentionally unchanged. */
.portal-tabs, .race-tabs { display: flex; gap: 7px; overflow: auto; margin: 18px 0; }
.portal-tabs button, .race-tabs button { white-space: nowrap; }
.portal-tabs button.active, .race-tabs button.active { background: var(--active); border-color: var(--accent); }
.race-identity { display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 20px; }
.race-identity h2 { margin: 4px 0; font-size: 25px; }
.race-identity p { margin: 0; color: var(--muted); }
.live-state { padding: 9px 12px; border: 1px solid var(--line); border-radius: 7px; font-weight: 900; }
.live-state.live, .live-state.caught_up { color: var(--ok); }
.live-state.disconnected, .live-state.paused { color: var(--warning); }
.race-module { padding: 18px; min-height: 280px; }
.read-table { overflow: auto; }
.read-table table { min-width: 760px; }
.read-table td small { display: block; color: var(--muted); margin-top: 3px; }
.read-table tr.current td { background: var(--warning); color: var(--page); font-weight: 800; }
.plan-stack { display: grid; gap: 9px; }
.plan-stack article { border: 1px solid var(--line); background: var(--page); }
.plan-stack header { display: flex; justify-content: space-between; padding: 9px 11px; border-bottom: 1px solid var(--line); }
.web-timeline { display: flex; overflow: auto; gap: 3px; padding: 7px; }
.web-timeline div { min-width: 150px; flex: 1; padding: 10px; background: var(--raised); border-left: 3px solid var(--accent); }
.web-timeline small, .web-timeline b { display: block; }
.web-timeline small { color: var(--muted); margin-top: 4px; }
.web-timeline em { padding: 10px; color: var(--muted); }
.live-summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; margin-bottom: 12px; }
.live-summary article { padding: 11px; background: var(--page); border: 1px solid var(--line); }
.live-summary small, .live-summary strong { display: block; }
.live-summary small { color: var(--muted); font-size: 9px; }
.live-summary strong { font-size: 17px; }
.web-track { display: block; width: 100%; max-height: 520px; background: var(--page); border: 1px solid var(--line); }
.web-track polyline { fill: none; stroke: var(--object); stroke-width: 1; vector-effect: non-scaling-stroke; }
.track-markers { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.track-markers span { padding: 5px 7px; background: var(--raised); border-radius: 5px; }
.empty-state { padding: 30px; color: var(--muted); text-align: center; }
#race-content, .race-module, .plan-stack, .plan-stack article { min-width: 0; max-width: 100%; }
@media (max-width: 860px) {
  .public-grid { grid-template-columns: 1fr; margin-top: 2vh; }
  .public-intro { min-height: 0; padding: 28px; }
  .public-intro h1 { font-size: 42px; }
  .release-grid, .admin-grid { grid-template-columns: 1fr; }
  .hero { align-items: start; flex-direction: column; }
}
@media (max-width: 760px) {
  .shell { padding: 18px; }
  .top { margin-bottom: 24px; align-items: flex-start; }
  .brand-logo { width: 158px; height: 52px; }
  .login { margin: 4vh auto; padding: 24px; }
  .public-grid .login { padding: 25px; }
  .version { font-size: 35px; }
  .nav-actions .account-label { display: none; }
  .readonly-badge { font-size: 8px; }
  .race-identity { align-items: flex-start; flex-direction: column; }
  .race-identity h2 { font-size: 20px; }
  .race-tabs { margin-inline: -18px; padding-inline: 18px; }
  .race-module { margin-inline: -8px; padding: 10px; }
  .live-summary { grid-template-columns: 1fr 1fr; }
  .read-table table { min-width: 620px; font-size: 12px; }
  .web-timeline div { min-width: 135px; }
  .portal-tabs button { flex: 1; }
  .nav-actions { justify-content: flex-end; }
  .hero select { width: 100%; }
}
@media (prefers-reduced-motion: reduce) { .loading-dot { animation: none; } }
