:root {
  --panel: rgba(16, 20, 28, 0.72);
  --panel-solid: #141a24;
  --border: rgba(255, 255, 255, 0.10);
  --text: #f2f4f8;
  --muted: #9aa4b5;
  --accent: #ff6a2b;
  --ok: #3ddc84;
  --warn: #ffc23d;
  --off: #5b6475;
  --hr: #ff4d6a;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0b0e14; color: var(--text); font-family: var(--font); }
#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }

button {
  font: inherit; color: var(--text); background: var(--accent); border: 0; border-radius: 10px;
  padding: 10px 18px; font-weight: 600; cursor: pointer;
}
button:hover { filter: brightness(1.1); }
button:disabled { opacity: 0.4; cursor: default; filter: none; }
button.ghost { background: rgba(255, 255, 255, 0.08); border: 1px solid var(--border); }
button.small { padding: 5px 12px; font-size: 13px; border-radius: 8px; }
kbd { font: 11px var(--font); opacity: 0.6; border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px; margin-left: 6px; }

#ble-banner {
  position: fixed; top: 12px; left: 16px; right: 16px; margin: 0 auto; width: fit-content; z-index: 10; max-width: 640px;
  background: #3a2a06; color: #ffe2a3; border: 1px solid var(--warn); border-radius: 12px; padding: 10px 16px; font-size: 14px; line-height: 1.5;
}
#ble-banner a { color: #ffd27a; font-weight: 600; }

/* ---- HUD ---- */
#hud { position: fixed; inset: 0; pointer-events: none; display: flex; flex-direction: column; justify-content: space-between; padding: 16px; gap: 10px; }
.metrics { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.metric {
  background: var(--panel); backdrop-filter: blur(8px); border: 1px solid var(--border); border-radius: 14px;
  padding: 10px 14px; min-width: 96px; display: grid; grid-template-areas: "label label" "value unit"; align-items: baseline; column-gap: 4px;
}
.metric .label { grid-area: label; font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.metric .value { grid-area: value; font-size: 34px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; }
.metric .unit { grid-area: unit; font-size: 13px; color: var(--muted); }
.metric.primary { border-color: rgba(255, 106, 43, 0.5); }
.metric.primary .value { font-size: 46px; color: var(--accent); }
.metric.hr .value { color: var(--hr); }

.bottom-bar { display: flex; justify-content: space-between; align-items: center; gap: 10px; pointer-events: auto; flex-wrap: wrap; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { background: var(--panel); border: 1px solid var(--border); border-radius: 999px; padding: 6px 12px; font-size: 13px; display: inline-flex; align-items: center; gap: 7px; }
.chip i, .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--off); display: inline-block; flex: none; }
.connected > i, .connected > .dot { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.connecting > i, .connecting > .dot { background: var(--warn); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: 0.3; } }

/* ---- Overlay card ---- */
#overlay { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(5, 8, 12, 0.45); padding: 16px; }
.card { background: var(--panel-solid); border: 1px solid var(--border); border-radius: 18px; padding: 24px; width: 100%; max-width: 520px; max-height: calc(100vh - 32px); overflow: auto; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5); }
.card h1 { margin: 0 0 4px; font-size: 26px; }
.card h2 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin: 22px 0 10px; display: flex; justify-content: space-between; align-items: center; }
.sub { margin: 0; color: var(--muted); }
.summary a { color: var(--accent); font-weight: 600; white-space: nowrap; }
.summary { margin: 14px 0 0; padding: 10px 12px; background: rgba(255, 255, 255, 0.05); border-radius: 10px; font-variant-numeric: tabular-nums; }

.device-row { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.device-row .role { width: 84px; font-weight: 600; }
.device-row .name { flex: 1; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.hint.left { text-align: left; }

.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.fields label { font-size: 13px; color: var(--muted); display: flex; flex-direction: column; gap: 6px; }
.fields span { color: var(--muted); }
input { font: inherit; width: 80px; padding: 7px 9px; border-radius: 8px; border: 1px solid var(--border); background: rgba(255, 255, 255, 0.06); color: var(--text); }

.actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; }
.conn-error { color: var(--warn); font-size: 13px; margin: 12px 0 0; }

/* ---- Zones, panels, charts ---- */
.zone { font-weight: 700; letter-spacing: 0.04em; margin-left: 4px; padding: 1px 6px; border-radius: 6px; color: #10131a; background: transparent; }
.metric.primary .value { transition: color 0.3s; }

.bottom { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; align-items: end; }
.bottom-bar { grid-column: 1 / -1; }
.panel { background: var(--panel); backdrop-filter: blur(8px); border: 1px solid var(--border); border-radius: 14px; padding: 10px 14px; min-width: 0; }
#workout-panel.hidden + #profile-panel { grid-column: 1 / -1; max-width: 720px; justify-self: center; width: 100%; }
.panel .label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); display: block; }
.wp-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 6px; }
.wp-name { font-weight: 700; }
.wp-total, .profile-info { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.wp-main { display: grid; grid-template-columns: auto auto 1fr auto; gap: 18px; align-items: end; margin-bottom: 8px; font-variant-numeric: tabular-nums; }
.wp-target { font-size: 34px; font-weight: 700; line-height: 1; }
.wp-left { font-size: 26px; font-weight: 700; line-height: 1; }
.wp-next span:last-child, .wp-bias span:last-child { font-size: 15px; font-weight: 600; }
.wp-done { margin: 0 0 8px; color: var(--ok); font-weight: 600; }
.wp-test { margin: 0 0 8px; font-weight: 600; }
.wp-target.free { font-size: 28px; color: #fff !important; text-transform: uppercase; letter-spacing: 0.04em; }
.test-result { display: flex; align-items: center; justify-content: space-between; gap: 10px; border: 1px solid rgba(61, 220, 132, 0.4); }
#ed-blocks input[type="checkbox"] { width: auto; }
.chart { display: block; width: 100%; height: 64px; }
.chart.tall { height: 110px; margin: 14px 0 4px; }

/* ---- Setup controls ---- */
.fields.three { grid-template-columns: 1fr 1fr 1fr; }
.row-label { font-size: 13px; color: var(--muted); margin: 14px 0 6px; }
.seg + .seg { margin-top: 6px; }
.seg { display: flex; background: rgba(255, 255, 255, 0.05); border: 1px solid var(--border); border-radius: 10px; padding: 3px; gap: 3px; }
.seg button { flex: 1; background: transparent; padding: 7px 10px; font-weight: 500; font-size: 14px; border-radius: 8px; color: var(--muted); }
.seg button.active { background: rgba(255, 255, 255, 0.12); color: var(--text); font-weight: 600; }
.picker-row { display: flex; gap: 8px; }
select { font: inherit; flex: 1; min-width: 0; padding: 7px 9px; border-radius: 8px; border: 1px solid var(--border); background: #1d2430; color: var(--text); }
.workout-preview { margin-top: 10px; padding: 10px; border-radius: 10px; background: rgba(255, 255, 255, 0.04); }
.workout-meta { margin: 6px 0 0; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.workout-desc { margin: 4px 0 0; font-size: 13px; }
.picker-actions { display: flex; gap: 6px; margin-top: 8px; }
button.danger { color: #ff8080; }
.hint { font-size: 12px; color: var(--muted); margin: 10px 0 0; text-align: right; }
.hint:empty { display: none; }

#ride-list { list-style: none; margin: 0; padding: 0; }
#ride-list li { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; font-variant-numeric: tabular-nums; }
#ride-list .when { font-weight: 600; font-size: 14px; }
#ride-list .stats { color: var(--muted); grid-column: 1; }
#ride-list .fit { grid-row: 1 / span 2; grid-column: 2; align-self: center; color: var(--text); text-decoration: none; font-size: 13px; padding: 5px 10px; border: 1px solid var(--border); border-radius: 8px; background: rgba(255, 255, 255, 0.06); }
#ride-list .fit:hover { background: rgba(255, 255, 255, 0.12); }

/* ---- Workout editor ---- */
#editor { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(5, 8, 12, 0.6); padding: 16px; z-index: 5; }
.card.wide { max-width: 640px; }
.fields label.grow { grid-column: 1 / -1; }
.fields label.grow input, .desc-label input { width: 100%; }
.desc-label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); margin-top: 12px; }
#ed-blocks { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
#ed-blocks li { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 10px; background: rgba(255, 255, 255, 0.04); border-left: 4px solid var(--off); font-size: 13px; }
#ed-blocks .kind { font-weight: 700; width: 70px; }
#ed-blocks label { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); }
#ed-blocks input { width: 62px; padding: 5px 7px; }
#ed-blocks .tools { margin-left: auto; display: flex; gap: 4px; }
#ed-blocks .tools button { padding: 3px 8px; font-size: 12px; }
.add-row { display: flex; align-items: center; gap: 6px; margin-top: 10px; }
.add-row .row-label { margin: 0 6px 0 0; }

@media (max-width: 640px) {
  .metric { min-width: 0; flex: 1 1 calc(33% - 10px); padding: 8px 10px; }
  .metric .value { font-size: 24px; }
  .metric.primary .value { font-size: 30px; }
  .fields, .fields.three { grid-template-columns: 1fr; }
  .bottom { grid-template-columns: 1fr; }
  .wp-main { grid-template-columns: 1fr 1fr; }
}

/* ---- FTP test coaching ---- */
.coach-live {
  align-self: center; margin: 4px 0 auto; text-align: center; min-width: 300px; padding: 14px 28px 12px;
  background: rgba(16, 20, 28, 0.82); backdrop-filter: blur(10px); border: 2px solid var(--accent); border-radius: 22px;
  box-shadow: 0 10px 40px rgba(255, 106, 43, 0.25);
}
.coach-live.ahead { border-color: var(--ok); box-shadow: 0 10px 40px rgba(61, 220, 132, 0.3); }
.live-label { font-size: 13px; font-weight: 700; letter-spacing: 0.22em; text-transform: uppercase; color: var(--accent); }
.coach-live.ahead .live-label { color: var(--ok); }
.coach-live.done .live-label::after { content: " · result"; }
.live-value { font-size: 96px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.live-value small { font-size: 28px; font-weight: 600; color: var(--muted); margin-left: 6px; }
.live-value span { display: inline-block; }
.live-value span.bump { animation: bump 0.6s ease-out; }
@keyframes bump { 40% { transform: scale(1.12); color: var(--ok); } }
.live-sub { font-size: 15px; color: var(--muted); font-variant-numeric: tabular-nums; margin-top: 4px; }
.live-goal { font-size: 15px; font-weight: 700; margin-top: 4px; }
.coach-live.ahead .live-goal { color: var(--ok); }
.live-track { height: 5px; border-radius: 3px; background: rgba(255, 255, 255, 0.1); margin-top: 10px; overflow: hidden; }
.live-bar { height: 100%; width: 0; background: var(--accent); transition: width 0.3s linear; }
.coach-live.ahead .live-bar { background: var(--ok); }

.coach-prompt {
  position: fixed; left: 50%; top: 52%; transform: translate(-50%, -50%) scale(0.85); opacity: 0;
  text-align: center; pointer-events: none; z-index: 6; max-width: calc(100% - 32px);
  transition: opacity 0.35s, transform 0.35s cubic-bezier(.2, 1.4, .4, 1);
}
.coach-prompt.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.coach-prompt .title {
  font-size: 56px; font-weight: 900; text-transform: uppercase; letter-spacing: 0.02em; line-height: 1.05;
  color: #fff; text-shadow: 0 4px 24px rgba(0, 0, 0, 0.55), 0 0 2px rgba(0, 0, 0, 0.8);
}
.coach-prompt .sub { font-size: 20px; font-weight: 600; margin-top: 8px; color: #fff; text-shadow: 0 2px 12px rgba(0, 0, 0, 0.7); }
.coach-prompt.go .title { color: var(--accent); }
.coach-prompt.hot .title { color: #ff5a3c; }
.coach-prompt.win .title { color: var(--ok); }
.coach-prompt.info .title { font-size: 40px; }
.coach-prompt.count .title { font-size: 160px; color: var(--accent); }
.coach-prompt .sub:empty { display: none; }

.erg-badge { font-size: 13px; padding: 4px 12px; border-radius: 999px; white-space: nowrap; font-variant-numeric: tabular-nums;
  background: rgba(255, 106, 43, 0.18); border: 1px solid var(--accent); color: #ffd2bd; }
.erg-badge b { color: var(--accent); letter-spacing: 0.06em; margin-right: 2px; }
.erg-badge.on { background: rgba(61, 220, 132, 0.15); border-color: var(--ok); color: #c9f5dc; }
.erg-badge.on b { color: var(--ok); }
.erg-badge.flash { animation: erg-flash 1.2s ease-out; }
@keyframes erg-flash { 0%, 40% { transform: scale(1.25); box-shadow: 0 0 18px currentColor; } }
.wp-head .replay { margin-left: auto; padding: 3px 10px; font-size: 12px; pointer-events: auto; }

/* Explainer */
.coach-intro {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 7; pointer-events: auto;
  width: min(560px, calc(100% - 32px)); background: rgba(16, 20, 28, 0.94); border: 1px solid var(--border);
  border-radius: 20px; padding: 18px 22px 16px; box-shadow: 0 24px 70px rgba(0, 0, 0, 0.55);
}
.intro-head { display: flex; justify-content: space-between; font-size: 12px; text-transform: uppercase; letter-spacing: 0.14em; color: var(--accent); font-weight: 700; }
.intro-step { color: var(--muted); }
.intro-stage { min-height: 300px; }
.slide { animation: slide-in 0.5s ease-out; }
@keyframes slide-in { from { opacity: 0; transform: translateX(24px); } }
.slide h3 { font-size: 28px; margin: 6px 0 6px; }
.slide p { margin: 0; color: #c9d1de; font-size: 16px; line-height: 1.5; }
.slide .visual { height: 170px; display: flex; flex-direction: column; align-items: center; justify-content: center; margin-top: 8px; }
.slide .caption { font-size: 13px; color: var(--muted); margin-top: 4px; }
.slide .big-number { font-size: 40px; font-weight: 800; margin-top: -6px; }
.intro-track { height: 4px; background: rgba(255, 255, 255, 0.1); border-radius: 2px; overflow: hidden; margin-top: 14px; }
#intro-progress { height: 100%; width: 0; background: var(--accent); }
@keyframes intro-progress { to { width: 100%; } }
.intro-foot { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.intro-dots { display: flex; gap: 6px; margin-right: auto; }
.intro-dots i { width: 8px; height: 8px; border-radius: 50%; background: rgba(255, 255, 255, 0.18); }
.intro-dots i.on { background: var(--accent); }

.gauge { width: 200px; height: 120px; }
.gauge-track, .gauge-fill { fill: none; stroke-width: 16; stroke-linecap: round; }
.gauge-track { stroke: rgba(255, 255, 255, 0.1); }
.gauge-fill { stroke: var(--accent); stroke-dasharray: 100; stroke-dashoffset: 100; animation: gauge 2s 0.3s ease-out forwards; }
@keyframes gauge { to { stroke-dashoffset: 22; } }
.gauge-needle { stroke: #fff; stroke-width: 4; stroke-linecap: round; transform-origin: 100px 105px; transform: rotate(-90deg); animation: needle 2s 0.3s ease-out forwards; }
@keyframes needle { to { transform: rotate(50deg); } }
.gauge-hub { fill: #fff; }

.zone-bars { position: relative; display: flex; align-items: flex-end; gap: 8px; height: 150px; width: 320px; }
.zbar { flex: 1; height: var(--h); background: var(--c); border-radius: 6px 6px 2px 2px; transform-origin: bottom; transform: scaleY(0);
  animation: grow 0.6s var(--d) ease-out forwards; display: flex; align-items: flex-end; justify-content: center; }
.zbar span { font-size: 11px; font-weight: 800; color: #10131a; padding-bottom: 4px; }
@keyframes grow { to { transform: scaleY(1); } }
.ftp-line { position: absolute; left: -6px; right: -6px; bottom: 64%; border-top: 2px dashed #fff; opacity: 0; animation: fade 0.5s 1.5s forwards; }
.ftp-line span { position: absolute; right: 0; top: -20px; font-size: 12px; font-weight: 800; }
@keyframes fade { to { opacity: 1; } }

.timeline { position: relative; display: flex; gap: 3px; width: 100%; height: 56px; }
.timeline .seg { display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 600; border-radius: 6px;
  background: rgba(61, 139, 253, 0.35); color: #dbe6ff; overflow: hidden; white-space: nowrap; }
.timeline .seg.test { background: repeating-linear-gradient(-45deg, rgba(255,106,43,0.85) 0 8px, rgba(255,106,43,0.6) 8px 16px);
  color: #fff; font-size: 14px; font-weight: 800; }
.timeline .marker { position: absolute; top: -8px; bottom: -8px; width: 3px; background: #fff; border-radius: 2px;
  box-shadow: 0 0 10px #fff; animation: sweep 7s ease-in-out forwards; }
@keyframes sweep { from { left: 0; } to { left: calc(80% - 3px); } }

.chainring { width: 120px; height: 120px; animation: spin 2.4s linear infinite; }
.chainring .ring { fill: none; stroke: #b8bcc4; stroke-width: 10; }
.chainring .tooth { fill: #b8bcc4; }
.chainring .hub { fill: #5b6475; }
.chainring .crank { stroke: var(--accent); stroke-width: 8; stroke-linecap: round; }
@keyframes spin { to { transform: rotate(360deg); } }
.badge-row { display: flex; gap: 8px; margin-top: 10px; }
.badge { font-size: 12px; font-weight: 800; letter-spacing: 0.08em; padding: 4px 10px; border-radius: 999px; background: rgba(255,255,255,0.1); }
.badge.off { background: var(--accent); }

.pacing { width: 100%; max-width: 420px; height: 150px; }
.pacing .ref { stroke: rgba(255,255,255,0.2); stroke-dasharray: 4 4; }
.pacing polyline { fill: none; stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 100; stroke-dashoffset: 100; }
.pacing .bad { stroke: #ff4d4d; animation: draw 2.2s 0.2s ease-out forwards; }
.pacing .good { stroke: var(--ok); animation: draw 2.6s 1.6s ease-out forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
.pacing .lbl { font-size: 11px; font-weight: 700; opacity: 0; animation: fade 0.5s forwards; }
.pacing .bad-lbl { fill: #ff8080; animation-delay: 1.2s; }
.pacing .good-lbl { fill: var(--ok); animation-delay: 3.6s; }

.formula { display: flex; align-items: center; gap: 16px; font-variant-numeric: tabular-nums; }
.formula > div { font-size: 40px; font-weight: 800; text-align: center; }
.formula small { display: block; font-size: 12px; font-weight: 600; color: var(--muted); }
.formula .op { font-size: 22px; color: var(--muted); }
.formula .result { color: var(--ok); font-size: 52px; animation: bump 0.8s 1.7s ease-out; }

@media (max-width: 640px) {
  .live-value { font-size: 64px; }
  .coach-live { min-width: 0; padding: 10px 16px; }
  .coach-prompt .title { font-size: 36px; }
  .coach-prompt.count .title { font-size: 110px; }
  .slide .visual { height: 150px; }
  .formula > div { font-size: 28px; }
  .formula .result { font-size: 36px; }
}

/* ---- Ride summary and progress ---- */
.modal { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(5, 8, 12, 0.6); padding: 16px; z-index: 5; }
.modal .card.wide { max-width: 720px; }
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.muted { color: var(--muted); font-size: 13px; margin: 0; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; margin-top: 16px; }
h2 + .stat-grid { margin-top: 0; }
.stat { background: rgba(255, 255, 255, 0.05); border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; font-variant-numeric: tabular-nums; position: relative; }
.stat .label { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.stat b { font-size: 22px; }
.stat small { color: var(--muted); margin-left: 4px; font-size: 12px; }
.stat.accent b { color: var(--accent); }
.stat.pb { border-color: rgba(61, 220, 132, 0.6); }
.stat.pb::after { content: "PB"; position: absolute; top: 7px; right: 8px; font-size: 10px; font-weight: 800; color: #10131a; background: var(--ok); border-radius: 5px; padding: 1px 5px; }
.test-line { border: 1px solid rgba(61, 220, 132, 0.4); font-weight: 600; }
.chart.ride { height: 150px; }
.chart.curve { height: 130px; margin-top: 10px; }
.chart.weekly { height: 120px; }
.chart.ftp { height: 110px; }
.zone-row { display: grid; grid-template-columns: 28px 110px 1fr 52px 36px; gap: 8px; align-items: center; font-size: 13px; padding: 3px 0; font-variant-numeric: tabular-nums; }
.zone-row .zname { font-weight: 800; }
.zone-row .zlabel { color: var(--muted); }
.zone-row .ztrack { height: 10px; background: rgba(255, 255, 255, 0.05); border-radius: 5px; overflow: hidden; }
.zone-row .ztrack i { display: block; height: 100%; border-radius: 5px; }
.zone-row .ztime, .zone-row .zpct { text-align: right; }
.zone-row .zpct { color: var(--muted); }
a.button { display: inline-block; text-decoration: none; color: var(--text); border-radius: 10px; padding: 10px 18px; font-weight: 600; }
a.button.ghost { background: rgba(255, 255, 255, 0.08); border: 1px solid var(--border); }
a.button:hover { filter: brightness(1.2); }
.legend { font-size: 11px; text-transform: none; letter-spacing: 0; display: inline-flex; align-items: center; gap: 6px; }
.legend i { display: inline-block; margin-left: 8px; }
.ftp-line { width: 14px; height: 3px; background: var(--accent); }
.ftp-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
#pg-rides { list-style: none; margin: 0; padding: 0; }
#pg-rides li { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 8px 6px; border-bottom: 1px solid var(--border); font-size: 13px; font-variant-numeric: tabular-nums; cursor: pointer; border-radius: 6px; }
#pg-rides li:hover, #ride-list li.clickable:hover { background: rgba(255, 255, 255, 0.05); }
#pg-rides .when { font-weight: 600; font-size: 14px; }
#pg-rides .stats { color: var(--muted); grid-column: 1; }
#pg-rides .load { grid-row: 1 / span 2; grid-column: 2; align-self: center; color: var(--accent); font-weight: 600; }
#ride-list li.clickable { cursor: pointer; }
@media (max-width: 640px) {
  .zone-row { grid-template-columns: 28px 1fr 52px 36px; }
  .zone-row .zlabel { display: none; }
}
#ride-detail { z-index: 6; }
.hint.warn { color: var(--warn); }

/* ---- Account ---- */
.acct-row { display: flex; gap: 8px; margin-top: 10px; }
.acct-row input { flex: 1; width: auto; min-width: 0; }
.acct-who { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 0 0 4px; }
#acct-in.synced .dot { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
#acct-in.syncing .dot { background: var(--warn); animation: blink 1s infinite; }
#acct-in.error .dot { background: #ff6b6b; }
.hint a { color: var(--muted); }

/* ---- Ghost and drafting chips ---- */
.race { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin: -2px 0 auto; }
.race-chip { background: var(--panel); backdrop-filter: blur(8px); border: 1px solid var(--border); border-radius: 999px;
  padding: 6px 14px; font-size: 15px; font-variant-numeric: tabular-nums; }
.race-chip b { letter-spacing: 0.06em; text-transform: uppercase; font-size: 12px; color: #9fd4ff; margin-right: 4px; }
.race-chip.ahead { border-color: rgba(61, 220, 132, 0.6); }
.race-chip.ahead span { color: var(--ok); font-weight: 700; }
.race-chip.behind { border-color: rgba(255, 106, 43, 0.6); }
.race-chip.behind span { color: var(--accent); font-weight: 700; }
.race-chip.draft { border-color: rgba(159, 212, 255, 0.6); }
.lvl { display: inline-block; font-size: 10px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase;
  color: #10131a; border-radius: 6px; padding: 1px 6px; }
.lvl.easy { background: #3ddc84; }
.lvl.steady { background: #3d8bfd; }
.lvl.tempo { background: #ffb020; }
.lvl.hard { background: #ff5a4d; }
