: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; }

/* A ride left unfinished last time */
.unfinished { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; padding: 16px;
  background: rgba(5, 8, 12, 0.6); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.unf-card { background: var(--panel); border: 1px solid var(--border); border-radius: 16px; padding: 18px; max-width: 420px; width: 100%;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5); }
.unf-card h3 { margin: 0 0 6px; }
.unf-card p { margin: 0 0 14px; color: var(--muted); line-height: 1.45; }
.unf-actions { display: grid; gap: 8px; }
.unf-actions [data-unf="discard"] { color: var(--muted); border-color: transparent; }

/* Paused with no trainer connected: only the device rows, to reconnect before continuing */
#setup.only-devices .tab-panel[data-panel="ride"] { display: block !important; }
#setup.only-devices .tab-panel:not([data-panel="ride"]),
#setup.only-devices [data-panel="ride"] > :not(#devices) { display: none !important; }
#shell:has(#setup.only-devices) #tabs { display: none; }

/* A new version is out (updates.js) */
.update-note { position: fixed; left: 50%; transform: translateX(-50%); top: calc(12px + env(safe-area-inset-top));
  z-index: 60; display: flex; gap: 8px; align-items: center; padding: 8px 8px 8px 14px; width: max-content; max-width: calc(100vw - 24px);
  box-sizing: border-box;
  background: var(--panel); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--accent); border-radius: 14px; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.35); font-size: 14px; }
.update-note span { flex: 1; }
/* Mid-ride it sits above the bottom bar, clear of the numbers at the top. */
.update-note.riding { top: auto; bottom: calc(76px + env(safe-area-inset-bottom)); font-size: 13px; }
.update-note button { flex: none; }

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 .value .of { font-size: 0.5em; font-weight: 600; color: var(--muted); white-space: nowrap; }
.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; }
#account .fold-body p a { color: var(--accent); font-weight: 600; white-space: nowrap; }
#acct-google.google-btn { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%;
  margin: 8px 0 4px; padding: 10px 14px; border-radius: 10px; background: #fff; color: #1f1f1f; font-weight: 600; }
#acct-google svg { width: 18px; height: 18px; }
.acct-or { text-align: center; font-size: 12px; margin: 6px 0; }
.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-totals-head { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; justify-content: space-between; }
.seg.small { display: inline-flex; padding: 2px; }
.seg.small button { flex: none; padding: 4px 10px; font-size: 12px; text-transform: none; letter-spacing: 0; }
#pg-totals { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 480px) { #pg-totals { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.pg-ftp-summary { margin: -4px 0 6px; font-size: 13px; color: var(--muted); }
.pg-ftp-summary:empty { display: none; }
.ftp-changes { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 2px; font-size: 13px; font-variant-numeric: tabular-nums; }
.ftp-changes li { display: flex; flex-wrap: wrap; gap: 2px 12px; padding: 5px 6px; border-bottom: 1px solid var(--border); }
.ftp-changes .when { color: var(--muted); min-width: 130px; }
.ftp-changes em { font-style: normal; font-weight: 700; margin-left: 6px; }
.ftp-changes em.up { color: var(--ok); }
.ftp-changes em.down { color: var(--warn); }
#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 0; }

/* Trainer resistance: + / value / − on the right edge, in thumb reach */
.erg-ctl { position: fixed; right: 12px; top: 50%; transform: translateY(-50%); z-index: 6; pointer-events: auto;
  display: flex; flex-direction: column; gap: 6px; align-items: stretch; width: 64px; }
.erg-ctl button { padding: 0; height: 48px; font-size: 26px; font-weight: 700; border-radius: 12px; line-height: 1;
  background: var(--panel); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.erg-ctl .erg-mid { height: auto; padding: 6px 2px; font-size: 13px; display: flex; flex-direction: column; align-items: center; gap: 1px; }
.erg-ctl .erg-mid b { font-size: 20px; font-variant-numeric: tabular-nums; }
.erg-ctl .erg-mid small { font-size: 11px; color: var(--muted); }
.erg-ctl .erg-mid .state { font-size: 11px; font-weight: 800; letter-spacing: 0.04em; white-space: nowrap; }
/* ERG on: solid green, dark text, the +/− edged in green */
.erg-ctl.on .erg-mid { background: var(--ok); border: 2px solid var(--ok); color: #06210f; box-shadow: 0 0 14px rgba(61, 220, 132, 0.55); }
.erg-ctl.on .erg-mid small, .erg-ctl.on .erg-mid .state { color: #06210f; }
.erg-ctl.on [data-erg="up"], .erg-ctl.on [data-erg="down"] { border: 1px solid var(--ok); }
/* ERG off: grey and dashed, the trainer follows the road */
.erg-ctl.off .erg-mid { border: 2px dashed rgba(255, 255, 255, 0.35); }
.erg-ctl.off .erg-mid .state { color: var(--text); opacity: 0.85; }
.erg-ctl.off .erg-mid small:not(.state) { font-size: 10px; line-height: 1.15; text-align: center; }
.erg-ctl.off [data-erg="up"], .erg-ctl.off [data-erg="down"] { opacity: 0.7; }
.erg-ctl.flash .erg-mid { animation: erg-flash 1.2s ease-out; }
#hud.view-workout .erg-ctl, #hud.view-watch:has(#watch-view.narrow) .erg-ctl { display: none !important; }
@media (max-height: 420px) { .erg-ctl button { height: 38px; } .erg-ctl { width: 56px; } }

/* Picking a way at the next junction */
.junction { align-self: center; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; justify-content: center;
  pointer-events: auto; background: var(--panel); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--border); border-radius: 14px; padding: 6px 8px; max-width: calc(100vw - 32px); }
.junction .jn-what { font-size: 13px; font-weight: 600; padding: 0 6px; white-space: nowrap; }
.junction button.on { background: var(--accent); border-color: var(--accent); color: #fff; }
#hud.view-workout .junction, #hud.view-watch .junction { display: none !important; }
.junction .jn-mic.live { border-color: var(--ok); color: var(--ok); }
.junction .jn-heard { font-size: 12px; color: var(--ok); padding: 0 4px; }
.junction .jn-heard.warn { color: var(--accent); }
.junction .jn-heard.muted { color: var(--muted); }
.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; }

/* ---- World and sound settings ---- */
.sound-row { display: flex; gap: 10px; align-items: center; margin-top: 6px; }
.sound-row .seg { flex: 1; }
.sound-row input[type="range"] { width: 120px; padding: 0; accent-color: var(--accent); }
.bar-buttons { display: flex; gap: 8px; }
#btn-mute { padding: 10px 12px; }
.race-chip.weather { border-color: rgba(255, 255, 255, 0.35); transition: opacity 0.6s; }

/* ---- Random workout ---- */
.gen-top { display: flex; gap: 20px; align-items: center; margin-top: 12px; flex-wrap: wrap; }
.gen-side { flex: 1; min-width: 220px; display: flex; flex-direction: column; gap: 8px; }
.gen-side .row-label { margin: 0; }
.gen-side .muted { min-height: 3em; }
.wheel { width: 220px; height: 220px; flex: none; cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; outline: none; }
.wheel.turning { cursor: grabbing; }
.wheel:focus-visible .track { stroke: rgba(255, 255, 255, 0.35); }
.wheel .track { fill: rgba(255, 255, 255, 0.04); stroke: rgba(255, 255, 255, 0.12); stroke-width: 14; }
.wheel .arc { fill: none; stroke: var(--ok); stroke-width: 14; stroke-linecap: round; transition: stroke 0.3s; }
.wheel .knob { fill: #fff; stroke: var(--ok); stroke-width: 4; filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.5)); transition: stroke 0.3s; }
.wheel .tick { stroke: rgba(255, 255, 255, 0.25); stroke-width: 1.5; }
.wheel .tick.long { stroke: rgba(255, 255, 255, 0.5); stroke-width: 2; }
.wheel .tick-label { fill: var(--muted); font-size: 11px; text-anchor: middle; }
.wheel .value { fill: var(--text); font-size: 46px; font-weight: 800; text-anchor: middle; font-variant-numeric: tabular-nums; }
.wheel .unit { fill: var(--muted); font-size: 12px; text-anchor: middle; text-transform: uppercase; letter-spacing: 0.1em; }
#generator .card.hard .wheel .arc { stroke: var(--accent); }
#generator .card.hard .wheel .knob { stroke: var(--accent); }
.dice span { display: inline-block; }
.dice.spin span { animation: dice 0.5s ease-out; }
@keyframes dice { 50% { transform: rotate(200deg) scale(1.3); } 100% { transform: rotate(360deg); } }
.gen-name { display: block; font-size: 17px; margin-bottom: 4px; }
#gen-result { margin-top: 14px; }
@media (max-width: 640px) { .gen-top { justify-content: center; } }

/* ---- Ride screen views (hudview.js) ---- */
.metric { touch-action: manipulation; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; cursor: default; }
.scenery-bar { display: none; }
.wp-compact { display: none; font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; margin: -2px 0 6px; }
.wp-head { cursor: pointer; }
.panel.folded .wp-main, .panel.folded .wp-next, .panel.folded #wp-test { display: none; }
.panel.folded .wp-compact { display: block; }
.panel.folded .chart { height: 26px; }
.panel.folded .replay { display: none; }
.panel.folded .wp-head { margin-bottom: 2px; }

/* Focus: the four most useful tiles, bigger; everything else out of the way. */
#hud.view-focus .metric.extra { display: none; }
#hud.view-focus .metrics { gap: 8px; }
#hud.view-focus .metric { flex: 1 1 0; min-width: 0; max-width: 220px; }

/* Scenery: one slim bar, nothing else. */
#hud.view-scenery .metrics, #hud.view-scenery .race, #hud.view-scenery #workout-panel,
#hud.view-scenery #profile-panel, #hud.view-scenery .chips { display: none !important; }
#hud.view-scenery .scenery-bar {
  display: block; align-self: center; pointer-events: auto; cursor: pointer;
  background: var(--panel); backdrop-filter: blur(8px); border: 1px solid var(--border); border-radius: 999px;
  padding: 8px 18px; font-size: 17px; font-variant-numeric: tabular-nums; white-space: nowrap;
}
.scenery-bar > b { font-size: 22px; }
.scenery-bar .erg-badge { font-size: 13px; vertical-align: 2px; }
.scenery-bar .sep { color: var(--muted); margin: 0 4px; }
#hud.view-scenery .bottom { margin-top: auto; }

.tile-menu {
  position: fixed; z-index: 20; width: 210px; max-height: 70vh; overflow: auto; padding: 6px;
  background: var(--panel-solid); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  display: flex; flex-direction: column; gap: 2px;
}
.tm-title { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); padding: 6px 8px 4px; }
.tm-item, .tm-reset { background: transparent; text-align: left; padding: 9px 10px; font-weight: 500; border-radius: 8px; }
.tm-item:hover, .tm-reset:hover { background: rgba(255, 255, 255, 0.08); filter: none; }
.tm-item.active { color: var(--accent); font-weight: 700; }
.tm-reset { color: var(--muted); border-top: 1px solid var(--border); border-radius: 0 0 8px 8px; margin-top: 4px; }

.view-toast {
  position: fixed; left: 50%; top: 40%; transform: translate(-50%, -50%); z-index: 15; pointer-events: none; opacity: 0;
  background: var(--panel); backdrop-filter: blur(8px); border: 1px solid var(--border); border-radius: 999px;
  padding: 10px 20px; font-weight: 700; font-size: 16px;
}
.view-toast.show { animation: toast 1.4s ease-out; }
@keyframes toast { 10%, 70% { opacity: 1; } 100% { opacity: 0; } }

/* Phones: hide what's only noise on a small screen. */
@media (max-width: 640px) {
  #hud { padding: 10px 10px max(10px, env(safe-area-inset-bottom)); gap: 8px; }
  .chip.connected { display: none; }
  #mock-hint { display: none !important; }
  /* Four big tiles in a 2×2 grid: readable at a glance on a phone. */
  #hud.view-focus .metric { flex: 1 1 calc(50% - 8px); max-width: none; padding: 8px 12px; }
  #hud.view-focus .metric .value { font-size: 34px; }
  #hud.view-focus .metric.primary .value { font-size: 40px; }
  .wp-main { grid-template-columns: 1fr 1fr; gap: 10px; }
  .wp-head .wp-name { font-size: 15px; }
  .bottom-bar { flex-wrap: nowrap; }
  #hud.view-scenery .scenery-bar { font-size: 15px; padding: 7px 14px; max-width: 100%; }
  .scenery-bar > b { font-size: 19px; }
  .scenery-bar .sep { margin: 0 2px; }
  .scenery-bar.workout .sb-elapsed { display: none; }
  .bar-buttons button { padding: 10px 12px; }
}
/* Landscape phones: tiles in one row, panels side by side. */
@media (max-height: 500px) and (orientation: landscape) {
  #hud { padding: 8px 12px; gap: 6px; }
  .metrics { flex-wrap: nowrap; }
  .metric { flex: 1 1 0; min-width: 0; padding: 6px 10px; }
  .metric .value { font-size: 24px; }
  .metric.primary .value { font-size: 30px; }
  #hud.view-full .metric.extra { display: none; }
  .bottom { grid-template-columns: 1fr 1fr; }
  .chart { height: 44px; }
  .chip.connected { display: none; }
  #mock-hint { display: none !important; }
  .wp-main { gap: 12px; }
  .wp-next span:last-child { white-space: nowrap; }
}
/* Scenery bar: fixed-width number slots, so it stays still as power or time change. */
.scenery-bar .slot { display: inline-block; text-align: right; font-variant-numeric: tabular-nums; }
.scenery-bar .sb-power { min-width: 4ch; }
.scenery-bar .sb-time { min-width: 5ch; text-align: center; } /* up to 59:59 */
.scenery-bar .sb-watts { min-width: 3.6ch; }
.scenery-bar .sb-left { min-width: 4.6ch; }

/* ---- Coach tips (cues.js) ---- */
.cue {
  align-self: center; display: flex; align-items: center; gap: 10px; max-width: min(520px, 100%);
  margin: 0 0 auto; padding: 10px 16px; border-radius: 14px; pointer-events: none; /* sits under the metrics */
  background: rgba(16, 20, 28, 0.82); backdrop-filter: blur(8px); border: 1px solid var(--border);
  font-size: 15px; font-weight: 600; line-height: 1.35;
  opacity: 0; transform: translateY(-6px); transition: opacity 0.4s, transform 0.4s; visibility: hidden;
}
.cue.show { opacity: 1; transform: none; visibility: visible; }
.cue .cue-icon { font-size: 22px; flex: none; }
.cue.phase { border-color: rgba(255, 106, 43, 0.6); }
.cue.drink { border-color: rgba(61, 139, 253, 0.8); background: rgba(14, 32, 60, 0.88); }
.cue.cadence { border-color: rgba(255, 194, 61, 0.7); }
.cue.effort { border-color: rgba(61, 220, 132, 0.6); }
@media (max-width: 640px) { .cue { font-size: 14px; padding: 8px 12px; } }

/* ---- Your rider ---- */
.row-label b { color: var(--text); font-weight: 600; margin-left: 6px; }
.rider-pick { display: flex; gap: 12px; align-items: stretch; flex-wrap: wrap; }
#rider-preview { width: 150px; height: 170px; flex: none; border-radius: 12px;
  background: radial-gradient(circle at 50% 40%, rgba(159, 201, 238, 0.35), rgba(255, 255, 255, 0.03) 70%); }
.rider-options { flex: 1; min-width: 220px; display: flex; flex-direction: column; gap: 8px; }
.animals { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.animal { display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 5px 2px; font-weight: 500;
  background: rgba(255, 255, 255, 0.05); border: 1px solid var(--border); border-radius: 10px; }
.animal span { font-size: 22px; line-height: 1.1; }
.animal small { font-size: 11px; color: var(--muted); }
.animal.active { border-color: var(--accent); background: rgba(255, 106, 43, 0.15); }
.animal.active small { color: var(--text); }
.swatch-row { display: flex; align-items: center; gap: 8px; }
.swatch-row span { width: 42px; font-size: 12px; color: var(--muted); flex: none; }
.swatch-row div { display: flex; gap: 4px; flex-wrap: wrap; }
.swatch { width: 18px; height: 18px; padding: 0; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.15); }
.swatch.active { border-color: #fff; box-shadow: 0 0 0 2px var(--accent); }
@media (max-width: 640px) { #rider-preview { width: 100%; height: 160px; } }

/* ---- Setup shell: header, tabs, scrolling panel, pinned Start (tabs.js) ---- */
.card.shell { display: flex; flex-direction: column; padding: 0; overflow: hidden; max-width: 560px;
  height: min(780px, calc(100vh - 32px)); }
.shell-head { padding: 20px 22px 4px; order: 0; }
.shell-head h1 { margin: 0; }
.panels { order: 1; flex: 1; min-height: 0; overflow: auto; padding: 6px 22px 18px; }
.shell-foot { order: 2; display: flex; align-items: center; gap: 12px; padding: 10px 22px;
  border-top: 1px solid var(--border); background: var(--panel-solid); }
.shell-foot .hint { flex: 1; margin: 0; text-align: left; }
.shell-foot .actions { margin: 0 0 0 auto; }
.tabs { order: 3; display: flex; border-top: 1px solid var(--border); background: rgba(255, 255, 255, 0.03);
  padding-bottom: env(safe-area-inset-bottom); }
.tabs button { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 8px 4px 9px;
  background: transparent; border-radius: 0; color: var(--muted); font-size: 12px; font-weight: 600; }
.tabs button .ti { font-size: 20px; line-height: 1.2; }
.tabs button.active { color: var(--text); box-shadow: inset 0 2px 0 var(--accent); }
.shell.paused { height: auto; max-width: 520px; }
.shell.paused .tabs { display: none; }
.shell.welcoming .tabs, .shell.welcoming #btn-start, .shell.welcoming #start-hint { display: none; }
.shell.welcoming #welcome-skip, .shell.welcoming #welcome-next { display: inline-block !important; }
.tab-panel > .row-label:first-child { margin-top: 10px; }

/* Ride tab */
.devices { margin-top: 4px; }
.ride-types { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 14px 0 4px; }
.contents { display: contents; }
.ride-type { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 10px 12px; text-align: left;
  background: rgba(255, 255, 255, 0.05); border: 1px solid var(--border); border-radius: 12px; font-weight: 600; }
.ride-type small { color: var(--muted); font-weight: 400; font-size: 12px; line-height: 1.25; }
.ride-type.active { border-color: var(--accent); background: rgba(255, 106, 43, 0.15); }
.ride-type.today-plan { grid-column: 1 / -1; }
#workout-picker { margin-top: 10px; }
.qmark { width: 18px; height: 18px; padding: 0; margin-left: 6px; border-radius: 50%; font-size: 11px; line-height: 1;
  background: rgba(255, 255, 255, 0.1); color: var(--muted); vertical-align: 1px; }
.link { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); text-decoration: underline; cursor: pointer; }

/* You / History / Settings */
details.fold { margin-top: 10px; border: 1px solid var(--border); border-radius: 12px; background: rgba(255, 255, 255, 0.03); }
details.fold > summary { list-style: none; display: flex; align-items: center; gap: 10px; padding: 12px 14px; cursor: pointer; font-weight: 600; }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary::after { content: '›'; color: var(--muted); font-size: 20px; line-height: 1; transition: transform 0.2s; }
details.fold[open] > summary::after { transform: rotate(90deg); }
.fold-value { margin-left: auto; color: var(--muted); font-weight: 500; font-size: 13px; text-align: right;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 60%; }
.fold-body { padding: 0 14px 14px; }
.history-head { display: flex; flex-direction: column; gap: 8px; margin: 12px 0 6px; }
.history-head .stat-grid { margin-top: 0; }

/* Level (levels.js) */
.level-card { background: rgba(255, 106, 43, 0.08); border: 1px solid rgba(255, 106, 43, 0.3); border-radius: 12px; padding: 10px 12px; margin-bottom: 12px; display: grid; gap: 8px; }
.level-card:empty { display: none; }
.lv-top { display: flex; gap: 10px; align-items: center; }
.lv-icon { font-size: 28px; line-height: 1; }
.lv-top b { display: block; font-size: 16px; }
.level-card small { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.lv-bar { height: 6px; background: rgba(255, 255, 255, 0.08); border-radius: 3px; overflow: hidden; }
.lv-bar i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.lv-climb { font-size: 13px; display: flex; flex-wrap: wrap; gap: 2px 8px; align-items: baseline; }
.lvl-badge { margin-left: 6px; font-size: 12px; font-weight: 700; color: var(--accent); white-space: nowrap; }
.lvl-badge:empty { display: none; }
.level-note { border: 1px solid var(--border); }
.level-note.up { border-color: rgba(255, 106, 43, 0.6); font-weight: 600; }
.history-head #btn-progress { align-self: flex-start; }
.empty-state { margin: 40px 10px; text-align: center; color: var(--muted); line-height: 1.5; }
.welcome-step { margin: 14px 0 2px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--accent); }
.welcome-title { margin: 0 0 6px; font-size: 22px; text-transform: none; letter-spacing: 0; color: var(--text); }
#welcome-slot { margin-top: 14px; }

/* Computers: tabs as a left rail. */
@media (min-width: 900px) {
  .card.shell { display: grid; grid-template-columns: 150px 1fr; grid-template-rows: auto 1fr auto; max-width: 820px; }
  .shell-head, .panels, .shell-foot { grid-column: 2; }
  .tabs { grid-column: 1; grid-row: 1 / span 3; flex-direction: column; justify-content: flex-start; gap: 2px;
    padding: 18px 8px; border-top: 0; border-right: 1px solid var(--border); }
  .tabs button { flex: none; flex-direction: row; justify-content: flex-start; gap: 10px; padding: 10px 12px;
    font-size: 14px; border-radius: 10px; }
  .tabs button .ti { font-size: 18px; }
  .tabs button.active { box-shadow: none; background: rgba(255, 255, 255, 0.08); }
  .shell.paused, .shell.welcoming { display: flex; }
}
/* Phones: the card fills the screen so Start sits at the bottom. */
@media (max-width: 640px) {
  #overlay { padding: 8px; }
  .card.shell { height: calc(100dvh - 16px); max-height: none; }
  .shell.paused { height: auto; }
  .shell-head { padding: 14px 16px 2px; }
  .panels { padding: 4px 16px 16px; }
  .shell-foot { padding: 8px 16px; }
  .ride-type { padding: 9px 10px; }
  .fields.three { grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
  .fields.three input { width: 100%; }
  .rider-pick { flex-wrap: nowrap; }
  #rider-preview { width: 110px; height: 150px; }
  .rider-options { min-width: 0; }
  .animals { gap: 4px; }
  .swatch-row span { width: 40px; }
  .swatch { width: 16px; height: 16px; }
}
.fields.three label > span { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.fields.three label > span input { flex: 1; min-width: 0; width: 100%; }
#welcome-slot .fold-body { padding: 0; }
details.fold > summary > span { white-space: nowrap; }
details.fold > summary .fold-value { max-width: none; min-width: 0; }

/* ---- Riding with others: riders per terrain, chat (chat.js) ---- */
.riders-badge { margin-left: 4px; font-size: 11px; font-weight: 600; color: var(--ok); white-space: nowrap; }
.chat-btn { position: relative; }
.chat-unread { position: absolute; top: -6px; right: -6px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; }
/* A light, see-through overlay: plain lines over the road, one row of quick phrases, a small box. */
.chat { position: fixed; right: 16px; bottom: 76px; z-index: 30; width: min(340px, calc(100vw - 32px));
  display: flex; flex-direction: column; gap: 6px; padding: 8px 10px; background: rgba(12, 15, 22, 0.45);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); border: 1px solid rgba(255, 255, 255, 0.08); border-radius: 14px; }
.chat-close { position: absolute; top: 4px; right: 4px; width: 28px; height: 28px; padding: 0; border-radius: 50%;
  background: rgba(255, 255, 255, 0.08); border: 0; color: var(--muted); font-size: 13px; line-height: 1; }
.chat-list { list-style: none; margin: 0; padding: 0 30px 0 0; overflow-y: auto; max-height: 132px; min-height: 20px;
  display: flex; flex-direction: column; gap: 2px; scrollbar-width: none; }
.chat-list::-webkit-scrollbar { display: none; }
.chat-list li { font-size: 14px; line-height: 1.35; overflow-wrap: anywhere; cursor: pointer;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9); }
.chat-list li b { margin-right: 5px; color: #9fd0ff; }
.chat-list li.mine { cursor: default; }
.chat-list li.mine b { color: var(--accent); }
.chat-list li.system { color: var(--muted); font-size: 12px; cursor: default; }
.chat-actions { display: flex; gap: 6px; margin: 4px 0 2px; }
.chat-actions button { padding: 4px 9px; font-size: 12px; }
.chat-muted { margin: 0; font-size: 12px; color: var(--muted); }
.chat-quick { display: flex; flex-wrap: nowrap; gap: 5px; overflow-x: auto; scrollbar-width: none; }
.chat-quick::-webkit-scrollbar { display: none; }
.chat-quick button { flex: none; padding: 4px 9px; font-size: 12px; background: rgba(255, 255, 255, 0.1); border: 0; }
.chat-form { display: flex; gap: 6px; }
.chat-form input { flex: 1; min-width: 0; padding: 6px 10px; font-size: 16px; background: rgba(0, 0, 0, 0.35); }
.chat-form button { padding: 6px 12px; }
#chat-hint { margin: 0; font-size: 12px; }
#chat-hint:empty { display: none; }
/* Closed chat: a new message shows for a few seconds as a line above the bar. */
.chat-toast { position: fixed; left: 50%; bottom: 76px; z-index: 29; transform: translateX(-50%); width: max-content;
  max-width: min(420px, calc(100vw - 24px));
  padding: 5px 12px; border-radius: 12px; background: rgba(12, 15, 22, 0.5); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  font-size: 14px; line-height: 1.35; overflow-wrap: anywhere; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9); cursor: pointer;
  opacity: 0; pointer-events: none; transition: opacity 0.3s; }
.chat-toast.show { opacity: 1; pointer-events: auto; }
.chat-toast b { margin-right: 5px; color: #9fd0ff; }
@media (max-width: 640px) {
  .chat { right: 8px; left: 8px; width: auto; bottom: 66px; }
  .chat-list { max-height: 96px; }
  .chat-toast { bottom: 66px; }
}
/* Phones: with the chat button too, keep every bar button on one line. */
@media (max-width: 640px) {
  .bar-buttons { gap: 6px; }
  .bar-buttons button { white-space: nowrap; padding: 10px; }
  .bar-buttons kbd { display: none; }
}

/* ---- World cards on the Ride tab (worlds.js) ---- */
.world-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.world-card { display: flex; flex-direction: column; align-items: stretch; gap: 2px; padding: 0 0 8px; overflow: hidden; text-align: left;
  background: rgba(255, 255, 255, 0.05); border: 1px solid var(--border); border-radius: 12px; }
.world-card svg { display: block; width: 100%; height: auto; margin-bottom: 4px; }
.world-card .world-name { padding: 0 10px; font-weight: 600; font-size: 14px; }
.world-card .world-blurb { padding: 0 10px; color: var(--muted); font-size: 12px; line-height: 1.25; }
.world-card .world-riders { padding: 2px 10px 0; margin: 0; }
.world-card .world-riders:empty { display: none; }
.world-card.active { border-color: var(--accent); background: rgba(255, 106, 43, 0.15); }
.seg button:disabled { opacity: 0.35; cursor: not-allowed; }
@media (max-width: 640px) {
  /* Phones: the cards scroll sideways. */
  .world-cards { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; margin: 0 -16px; padding: 0 16px; }
  .world-cards::-webkit-scrollbar { display: none; }
  .world-card { flex: 0 0 62%; scroll-snap-align: start; }
}

/* ---- Workout view (workoutview.js): only the workout, over a dimmed scenery ---- */
#hud.view-workout { background: rgba(8, 11, 16, 0.8); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
#hud.view-workout .metrics, #hud.view-workout .race, #hud.view-workout #workout-panel,
#hud.view-workout #profile-panel, #hud.view-workout .coach-live { display: none !important; }
#hud.view-workout #workout-view { display: grid !important; }
#hud.view-workout .bottom { grid-template-columns: 1fr; }
/* Coach cues float over the top instead of pushing the dashboard down. */
#hud.view-workout .cue { position: fixed; top: 12px; left: 16px; right: 16px; margin: 0 auto; width: fit-content; z-index: 8; }

.wv {
  flex: 1; min-height: 0; overflow: auto; pointer-events: auto; gap: 10px; align-content: start;
  grid-template-columns: repeat(4, minmax(0, 1fr)) 280px;
  grid-template-areas:
    "head head head head steps"
    "now  now  now  now  steps"
    "t1   t2   t3   t4   steps"
    "prof prof prof prof steps";
}
.wv-box { background: var(--panel); border: 1px solid var(--border); border-radius: 16px; min-width: 0; }
.wv-head { grid-area: head; display: flex; align-items: center; gap: 14px; }
.wv-head h2 { font-size: 18px; margin: 0; }
.wv-head .sub { color: var(--muted); font-size: 13px; }
.wv-times { margin-left: auto; display: flex; gap: 18px; font-variant-numeric: tabular-nums; text-align: right; }
.wv-times b { font-size: 20px; display: block; }
.wv-times span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }

.wv-now { grid-area: now; padding: 14px 20px; display: grid; gap: 12px 24px; grid-template-columns: auto auto 1fr; align-items: center;
  border-left: 6px solid var(--zone, var(--accent)); }
.wv-now .k { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.wv-step { grid-column: 1 / -1; font-size: 15px; font-weight: 600; display: flex; gap: 10px; align-items: center; }
.wv-zone { font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 999px; color: #0b0e14; background: var(--zone); }
.wv-zone:empty { display: none; }
.wv .big { font-size: 64px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.wv .big small { font-size: 18px; font-weight: 600; color: var(--muted); margin-left: 4px; }
.wv-target .big { color: var(--zone); }
.wv-now .pct { font-size: 13px; color: var(--muted); margin-top: 4px; }
.wv-gauge { display: flex; flex-direction: column; gap: 8px; padding-left: 12px; }
.wv-gauge .verdict { font-size: 22px; font-weight: 700; }
.verdict.ok { color: var(--ok); } .verdict.low { color: var(--warn); } .verdict.high { color: #ff8a3d; }
.wv-gauge .band { position: relative; height: 14px; border-radius: 7px; background: rgba(255, 255, 255, 0.07); }
.wv-gauge .band .ok { position: absolute; top: 0; bottom: 0; left: 37.5%; width: 25%; background: rgba(61, 220, 132, 0.35); border-radius: 4px; }
.wv-gauge .mark { position: absolute; top: -5px; width: 4px; height: 24px; border-radius: 2px; background: #fff; transform: translateX(-2px); transition: left 0.3s; }
.band-scale { display: flex; justify-content: space-between; font-size: 10px; color: var(--muted); }
.wv-intensity { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.wv-intensity b { color: var(--text); min-width: 42px; text-align: center; font-variant-numeric: tabular-nums; }
.wv-intensity button { padding: 2px 12px; }
.wv-now.done .wv-gauge .band, .wv-now.done .band-scale, .wv-now.done .wv-intensity { display: none; }
.wv-stepbar { grid-column: 1 / -1; height: 8px; border-radius: 4px; background: rgba(255, 255, 255, 0.08); overflow: hidden; }
.wv-stepbar div { height: 100%; width: 0; background: var(--zone); transition: width 0.3s linear; }

.wv-tile { padding: 12px 14px 0; display: flex; flex-direction: column; min-height: 160px; overflow: hidden; }
.wv-tile .top { display: flex; align-items: baseline; gap: 6px; }
.wv-tile .val { font-size: 40px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1; }
.wv-tile .unit { font-size: 12px; color: var(--muted); }
.wv-tile .stats { display: flex; gap: 12px; font-size: 12px; color: var(--muted); margin-top: 4px; font-variant-numeric: tabular-nums; flex-wrap: wrap; }
.wv-tile .stats b { color: var(--text); font-weight: 600; }
.wv-tile canvas { flex: 1; width: calc(100% + 28px); margin: 6px -14px 0; min-height: 60px; display: block; }
#wv-t-power { grid-area: t1; } #wv-t-cad { grid-area: t2; } #wv-t-hr { grid-area: t3; } #wv-t-speed { grid-area: t4; }
#wv-v-hr { color: var(--hr); }

.wv-prof { grid-area: prof; padding: 10px 14px 12px; }
.wv-prof .row { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-bottom: 6px; font-variant-numeric: tabular-nums; }
.wv-prof canvas { width: 100%; height: 120px; display: block; }

.wv-steps { grid-area: steps; padding: 12px; display: flex; flex-direction: column; min-height: 0; max-height: 100%; }
.wv-steps h3 { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin: 2px 6px 8px; font-weight: 600; }
.wv-steps ol { position: relative; list-style: none; margin: 0; padding: 0; overflow: auto; display: flex; flex-direction: column; gap: 4px; }
.wv-steps li { display: grid; grid-template-columns: 6px 1fr auto; gap: 10px; align-items: center; padding: 7px 10px 7px 0;
  border-radius: 10px; font-size: 13px; font-variant-numeric: tabular-nums; }
.wv-steps li i { align-self: stretch; min-height: 26px; border-radius: 3px; background: var(--zone); }
.wv-steps li .n { font-weight: 600; }
.wv-steps li .w { color: var(--muted); font-size: 12px; }
.wv-steps li.done { opacity: 0.35; }
.wv-steps li.cur { background: rgba(255, 255, 255, 0.08); outline: 1px solid rgba(255, 255, 255, 0.18); }
.wv-steps li.cur .d { font-weight: 700; }

/* Tablets: steps under the chart */
@media (max-width: 1100px) {
  .wv { grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-template-areas: "head head head head" "now now now now" "t1 t2 t3 t4" "prof prof prof prof" "steps steps steps steps"; }
  .wv-steps { min-height: 200px; max-height: 260px; }
}
/* Phones: one column, tiles two by two */
@media (max-width: 640px) {
  .wv { gap: 8px; grid-template-columns: 1fr 1fr;
    grid-template-areas: "head head" "now now" "t1 t2" "t3 t4" "prof prof" "steps steps"; }
  .wv-head h2 { font-size: 15px; }
  .wv-times { gap: 12px; }
  .wv-times b { font-size: 16px; }
  .wv-now { grid-template-columns: 1fr 1fr; padding: 12px 14px; gap: 10px; }
  .wv-gauge { grid-column: 1 / -1; padding-left: 0; }
  .wv-gauge .verdict { font-size: 17px; }
  .wv .big { font-size: 44px; }
  .wv-tile { min-height: 112px; padding: 10px 12px 0; }
  .wv-tile .val { font-size: 28px; }
  .wv-tile .stats { gap: 8px; font-size: 11px; }
  .wv-tile canvas { min-height: 40px; width: calc(100% + 24px); margin: 4px -12px 0; }
  .wv-prof canvas { height: 80px; }
  .wv-steps { min-height: 200px; max-height: 220px; }
}
/* Landscape phones: compact, steps on the side */
@media (max-height: 500px) and (orientation: landscape) {
  .wv { grid-template-columns: repeat(4, minmax(0, 1fr)) 200px;
    grid-template-areas: "now now now now steps" "t1 t2 t3 t4 steps" "prof prof prof prof steps"; }
  .wv-head { display: none; }
  .wv .big { font-size: 36px; }
  .wv-now { padding: 8px 14px; gap: 6px 16px; }
  .wv-tile { min-height: 90px; padding: 6px 10px 0; }
  .wv-tile .val { font-size: 22px; }
  .wv-tile .stats { display: none; }
  .wv-prof canvas { height: 56px; }
}

/* ---- Watch view (media.js): a video or playlist with your numbers on top ---- */
#watch-view { position: fixed; inset: 0; pointer-events: none; display: none; }
#hud.view-watch #watch-view { display: block; }
#hud.view-watch .metrics, #hud.view-watch .race, #hud.view-watch #workout-panel, #hud.view-watch #profile-panel,
#hud.view-watch .coach-live, #hud.view-watch .scenery-bar { display: none !important; }
#hud.view-watch .bottom { margin-top: auto; position: relative; z-index: 3; }
#hud.view-watch .cue { position: fixed; bottom: 128px; top: auto; left: 16px; right: 16px; margin: 0 auto; width: fit-content; z-index: 8; }

.wt-media { position: absolute; inset: 0 0 68px; }
#watch-view[data-source="youtube"], #watch-view.narrow { background: #000; } /* the 3D world isn't drawn behind it */
#watch-view[data-source="spotify"] .wt-media {
  inset: auto; left: 16px; bottom: 124px; width: min(380px, calc(100% - 32px)); height: 152px;
  border-radius: 12px; overflow: hidden; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}
.wt-media iframe { border: 0; width: 100%; height: 100%; display: block; pointer-events: auto; }

.wt-strip {
  position: absolute; display: flex; gap: 6px; padding: 8px; align-items: stretch; pointer-events: auto; z-index: 2;
  background: rgba(10, 13, 19, var(--alpha, 0.3)); backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px);
  border: 1px solid rgba(255, 255, 255, 0.06); border-radius: 14px; transition: opacity 0.35s;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9), 0 0 8px rgba(0, 0, 0, 0.5); /* readable on a bright video */
  max-width: calc(100% - 24px);
}
.wt-strip.pos-top { top: 12px; left: 50%; transform: translateX(-50%); }
.wt-strip.pos-bottom { bottom: 80px; left: 50%; transform: translateX(-50%); }
.wt-strip.pos-left { left: 12px; top: 50%; transform: translateY(-50%); flex-direction: column; }
.wt-strip.pos-right { right: 12px; top: 50%; transform: translateY(-50%); flex-direction: column; }
.wt-strip.pos-left, .wt-strip.pos-right { max-height: calc(100% - 100px); overflow: auto; }
.wt-strip.gone { opacity: 0; pointer-events: none; }
.wt-nums { display: flex; gap: 2px; flex-wrap: wrap; }
.wt-strip.pos-left .wt-nums, .wt-strip.pos-right .wt-nums { flex-direction: column; }
.wm { min-width: 64px; padding: 4px 8px; display: flex; flex-direction: column; justify-content: center; }
.wm .l { font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: #dfe4ec; }
.wm .v { font-size: 28px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.wm .v small { font-size: 0.45em; color: #dfe4ec; font-weight: 600; margin-left: 2px; }
.wm.hr .v { color: var(--hr); }
.wt-tools { display: flex; flex-direction: column; gap: 4px; justify-content: center; }
.wt-strip.pos-left .wt-tools, .wt-strip.pos-right .wt-tools { flex-direction: row; }
.wt-tools button { padding: 3px 8px; background: rgba(255, 255, 255, 0.06); border-color: rgba(255, 255, 255, 0.08); text-shadow: none; }
.wstep {
  min-width: 200px; padding: 6px 10px; border-radius: 10px; background: rgba(0, 0, 0, 0.12);
  border-left: 4px solid var(--zone, var(--ok)); display: grid; gap: 3px;
}
.wstep .row { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.wstep .name { font-weight: 700; font-size: 13px; }
.wstep .left { font-size: 24px; font-weight: 800; font-variant-numeric: tabular-nums; }
.wstep .tgt { font-size: 12px; color: #dfe4ec; }
.wstep .tgt b { color: var(--text); font-size: 14px; }
.wstep .next { font-size: 11px; color: #dfe4ec; }
.wpill { font-size: 11px; font-weight: 800; padding: 2px 8px; border-radius: 99px; color: #10131a; background: var(--ok); white-space: nowrap; text-shadow: none; }
.wpill.low { background: var(--warn); }
.wpill.high { background: #ff4d4d; color: #fff; }
.wbar { height: 4px; background: rgba(255, 255, 255, 0.15); border-radius: 2px; overflow: hidden; }
.wbar i { display: block; height: 100%; background: var(--zone, var(--ok)); }

.wt-show { position: absolute; top: 12px; right: 12px; pointer-events: auto; background: rgba(10, 13, 19, 0.6); }
.wt-src {
  position: absolute; left: 16px; bottom: 76px; display: flex; flex-wrap: wrap; gap: 4px; align-items: center; pointer-events: auto;
  background: rgba(10, 13, 19, 0.6); border: 1px solid var(--border); border-radius: 11px; padding: 4px; max-width: calc(100% - 32px); z-index: 2;
}
.wt-src button { padding: 4px 10px; border: 0; background: transparent; }
.wt-src button.active { background: var(--accent); }
.wt-src select { background: #0b0e14; color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 4px 6px; max-width: 220px; font: inherit; font-size: 13px; }
.wt-setup { font-size: 12px; color: var(--muted); padding: 0 6px; }
#watch-view[data-pos="bottom"] .wt-src { bottom: auto; top: 12px; }
#watch-view[data-pos="bottom"] .wt-show { top: 60px; }

/* The road in a small window over the video (Show road). */
body.road-window #scene {
  inset: auto; right: 16px; bottom: 84px; width: min(28vw, 360px); height: auto; aspect-ratio: 16 / 10; z-index: 1;
  border-radius: 12px; border: 1px solid var(--border); box-shadow: 0 8px 26px rgba(0, 0, 0, 0.6);
}

/* Narrow window (e.g. an iPad Slide Over next to Netflix): big numbers instead of media. */
.wt-compact { display: none; }
#watch-view.narrow .wt-strip, #watch-view.narrow .wt-src, #watch-view.narrow .wt-show, #watch-view.narrow .wt-media { display: none !important; }
#watch-view.narrow .wt-compact { display: block; position: absolute; inset: 0 0 64px; overflow: auto; pointer-events: auto; background: var(--panel-solid); }
.wt-back { position: absolute; right: 12px; top: 12px; pointer-events: auto; z-index: 3; display: none; }
#watch-view.narrow .wt-back { display: block; }
#watch-view.narrow .wt-back.hidden { display: none; }
/* A short, wide window (e.g. in the black band above or below a Netflix video): one row, no steps list. */
/* iPad windows have their buttons (•••) at the top left: keep the numbers clear of them. */
#watch-view.narrow .compact { padding-top: 44px; }
#watch-view.short .wt-compact { display: flex; align-items: center; }
#watch-view.short .compact { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 8px 12px 8px 92px; width: 100%; }
#watch-view.short .c-big .v { font-size: 40px; }
#watch-view.short .c-row { display: flex; gap: 6px; }
#watch-view.short .c-row > div { padding: 4px 8px; }
#watch-view.short .c-row .v { font-size: 18px; }
#watch-view.short .compact .wstep { flex: 1 1 220px; }
#watch-view.short .compact .wstep .left { font-size: 26px; }
#watch-view.short .c-steps, #watch-view.short .c-zone { display: none; }
#watch-view.short .wt-compact { inset: 0 0 52px; }
#hud.view-watch:has(#watch-view.narrow) .chips { display: none; } /* room for the numbers in a small window */
.compact { padding: 14px; display: grid; gap: 10px; }
.c-big { display: flex; align-items: center; gap: 6px; }
.c-big .v { font-size: 56px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.c-big small { color: var(--muted); font-weight: 600; font-size: 16px; }
.c-zone { margin-left: auto; font-size: 12px; font-weight: 800; padding: 3px 9px; border-radius: 99px; color: #10131a; }
.c-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.c-row > div { background: rgba(255, 255, 255, 0.05); border-radius: 8px; padding: 6px 8px; display: flex; flex-direction: column; }
.c-row .l { font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.c-row .v { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.c-row .hr .v { color: var(--hr); }
.compact .wstep { background: rgba(255, 255, 255, 0.05); }
.compact .wstep .left { font-size: 34px; }
.c-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; font-size: 13px; }
.c-steps li { display: flex; justify-content: space-between; gap: 8px; padding: 4px 8px; border-radius: 6px; color: var(--muted); }
.c-steps li span:last-child { font-variant-numeric: tabular-nums; white-space: nowrap; }
.c-steps li.cur { background: rgba(255, 255, 255, 0.08); color: var(--text); font-weight: 700; }
.c-steps li.done { opacity: 0.45; }
/* The pop-out window ("Pop out"): the same compact layout, on its own. */
html:has(body.pip-body), body.pip-body { height: auto; overflow: auto; }
body.pip-body { background: var(--panel-solid); }

/* Settings → Media */
.media-list { list-style: none; margin: 8px 0 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px; }
.media-list:empty { display: none; }
.media-list li { display: flex; gap: 8px; align-items: center; background: rgba(255, 255, 255, 0.04); border-radius: 8px; padding: 4px 4px 4px 10px; font-size: 13px; }
.media-list .n { font-weight: 600; flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-list .u { color: var(--muted); font-size: 12px; flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 35%; }
.media-list button { flex: none; }
#media-settings input[type="checkbox"] { width: auto; margin: 0; flex: none; }
#media-settings input[type="range"] { width: 140px; }
.media-list button { padding: 2px 8px; }
#media-settings .row-label { margin-top: 14px; }
#media-settings .row-label:first-child { margin-top: 0; }
#media-settings .hint { margin-top: 4px; }
.media-checks { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; margin-top: 6px; }
.media-checks label, .media-check { display: flex; gap: 6px; align-items: center; font-size: 13px; }
.media-check { margin-top: 8px; }
.media-row { display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center; margin-top: 8px; font-size: 13px; }
.media-row label { display: flex; gap: 8px; align-items: center; }
.media-row select { background: #0b0e14; color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 4px 6px; font: inherit; }
.ok-note { color: var(--ok); font-weight: 600; }
.warn-note { color: var(--warn); font-weight: 600; }

@media (max-width: 760px) {
  .wm { min-width: 52px; padding: 2px 5px; }
  .wm .v { font-size: 22px; }
  .wstep { min-width: 160px; }
}
