.tasStudio, .tasTimelineDock {
  --tas-bg: #17191ff5;
  --tas-control: #24272f;
  --tas-hover: #30343e;
  --tas-border: #444652;
  --tas-text: #eef0f4;
  --tas-muted: #b2b7c4;
  --tas-accent: #d2b5f3;
  --tas-active: #41324f;
  position: absolute;
  top: 48px;
  left: 12px;
  z-index: 18;
  width: min(336px, calc(100% - 24px));
  color: var(--tas-text);
  font: 14px/1.4 Arial, sans-serif;
}
.tasStudio *, .tasStudio *::before, .tasStudio *::after { box-sizing: border-box; }
.tasStudio [hidden], .tasStudio[hidden], .settingsNudge[hidden] { display: none !important; }
.tasToolbar, .tasPanel, .tasStatus { background: var(--tas-bg); border: 1px solid var(--tas-border); border-radius: 14px; box-shadow: 0 6px 24px #0003; }
.tasToolbar { padding: 7px; }
.tasQuickRow, .tasPointRow, .tasDraftActions { display: flex; align-items: center; gap: 6px; }
.tasPointRow { margin-top: 5px; }
.tasBadge { color: var(--tas-accent); font-size: 12px; letter-spacing: .6px; padding: 0 5px; }
.tasStudio button, .tasStudio select, .tasStudio input[type=number] {
  min-width: 0;
  min-height: 44px;
  border: 1px solid var(--tas-border);
  border-radius: 9px;
  padding: 8px 10px;
  color: var(--tas-text);
  background: var(--tas-control);
  font: inherit;
}
.tasStudio button { display: inline-flex; justify-content: center; align-items: center; gap: 6px; cursor: pointer; }
.tasStudio button svg { flex: 0 0 18px; width: 18px; height: 18px; }
.tasStudio button:disabled, .tasStudio select:disabled, .tasStudio input:disabled { opacity: .45; cursor: default; }
@media (hover: hover) { .tasStudio button:hover:not(:disabled) { background: var(--tas-hover); } }
.tasStudio :focus-visible { outline: 2px solid var(--tas-accent); outline-offset: 2px; }
.tasQuickRow [data-speed] { width: 76px; padding-left: 9px; }
.tasQuickRow [data-pause] { flex: 1; font-weight: 600; }
.tasQuickRow [data-tools] { border-color: transparent; padding-inline: 8px; background: transparent; }
.tasPointRow button { flex: 1; font-size: 12px; border-color: transparent; background: transparent; }
.tasPointRow [data-checkpoint] { flex: 1.3; }
.tasPanel { display: flex; flex-direction: column; max-height: min(430px, calc(100dvh - var(--mobile-keypad-height, 0px) - 64px)); overflow: hidden; }
.tasStudio.isOpen .tasToolbar { display: none; }
.tasPanelHeader { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 10px 8px 16px; flex: 0 0 auto; }
.tasPanelHeader strong { display: block; font-size: 15px; }
.tasPanelHeader span { display: block; font-size: 12px; color: var(--tas-muted); margin-top: 2px; }
.tasPanelHeader [data-close] { width: 44px; flex-shrink: 0; background: transparent; border-color: transparent; }
.tasTabs { display: flex; gap: 4px; padding: 0 10px 8px; border-bottom: 1px solid var(--tas-border); flex: 0 0 auto; }
.tasTabs button { flex: 1; padding: 8px 4px; border-color: transparent; background: transparent; font-size: 13px; }
.tasTabs button[aria-selected=true] { color: var(--tas-accent); background: var(--tas-active); font-weight: 600; }
.tasPanelBody { padding: 12px 16px 14px; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: var(--tas-border) transparent; }
.tasHint { margin: 0 0 12px; color: var(--tas-muted); font-size: 12px; }
.tasStudio .tasPrimary { background: var(--tas-active); border-color: #806196; color: var(--tas-accent); font-weight: 600; }
.tasStudio .tasPrimary small { font-size: 12px; font-weight: 400; margin-left: 8px; }
.tasWide { width: 100%; }
.tasPanelFooter { padding: 10px 16px; border-top: 1px solid var(--tas-border); color: var(--tas-muted); font-size: 11px; flex: 0 0 auto; }
.tasTimelineLabel { display: flex; justify-content: space-between; align-items: center; gap: 6px; font-size: 12px; color: var(--tas-muted); }
.tasTimelineLabel output { color: var(--tas-text); font-variant-numeric: tabular-nums; }
.tasStudio input[type=range] { display: block; width: 100%; margin: 0 0 8px; min-height: 40px; accent-color: #af80d4; }
.tasSeekRow { display: flex; align-items: end; gap: 10px; margin-bottom: 10px; }
.tasSeekRow label { width: 92px; flex-shrink: 0; color: var(--tas-muted); font-size: 12px; }
.tasSeekRow input { width: 100%; display: block; margin-top: 4px; }
.tasSeekRow button { flex: 1; }
.tasInputDetails { color: var(--tas-muted); font-size: 12px; }
.tasInputDetails summary { cursor: pointer; padding: 6px 0; }
.tasInputDetails pre { font: 11px/1.6 monospace; white-space: pre-wrap; margin: 8px 0 0; }
.tasDraftLabel { display: block; margin: 14px 0 10px; font-size: 12px; color: var(--tas-muted); }
.tasDraftLabel select { display: block; width: 100%; margin-top: 5px; font-size: 12px; }
.tasDraftActions > button { flex: 1; font-size: 13px; }
.tasDraftActions > .tasDelete { flex: 0 0 44px; background: transparent; }
.tasStatus { padding: 10px 12px; margin: 8px 0 0; font-size: 12px; overflow-wrap: anywhere; }
.tasStatus.isError { border-color: #b97867; }
html[data-theme=light] .tasStudio, html[data-theme=light] .tasTimelineDock {
  --tas-bg: #fafbfff7;
  --tas-control: #f0f1f6;
  --tas-hover: #e4e5ee;
  --tas-border: #cdd0dc;
  --tas-text: #242b39;
  --tas-muted: #616979;
  --tas-accent: #694086;
  --tas-active: #eee3f7;
}
.settingsNudge { position: absolute; z-index: 19; bottom: 12px; left: 12px; right: 12px; margin: auto; max-width: 410px; padding: 12px 16px; border-radius: 12px; background: #112619f5; color: #e5f3e9; border: 1px solid #538064; font: 14px/1.45 Arial, sans-serif; box-shadow: 0 6px 24px #0003; }
.settingsNudge p { margin: 0 0 8px; }
.settingsNudge button { font: inherit; color: inherit; cursor: pointer; border: 1px solid #538064; background: #1d3b27; padding: 8px 12px; border-radius: 7px; margin-right: 8px; }
html[data-theme=light] .settingsNudge { background: #eff9f1f5; color: #183d23; }
html[data-theme=light] .settingsNudge button { background: #dbeede; }
@media (min-width: 1100px) {
  .settingsNudge { left: auto; width: 360px; }
}
@media (max-width: 1099px) {
  .settingsNudge { top: 12px; bottom: auto; }
}

.tasFrameControls { margin-top: 8px; border-top: 1px solid var(--tas-border); padding-top: 8px; }
.tasPositionRow { display: flex; justify-content: space-between; gap: 8px; color: var(--tas-muted); font-size: 11px; margin-bottom: 8px; }
.tasPositionRow output { font-variant-numeric: tabular-nums; color: var(--tas-text); }
.tasHeldInputs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.tasHeldInputs button { font-size: 13px; }
.tasHeldInputs button[aria-pressed=true] { background: var(--tas-active); border-color: #a481be; color: var(--tas-accent); box-shadow: inset 0 0 0 1px #a481be; font-weight: 600; }
.tasInputHelp { margin: 7px 0; color: var(--tas-muted); font-size: 10px; }
.tasStepRow { display: flex; gap: 6px; }
.tasStepRow button { flex: 1; }
/* On touch devices the paused workbench takes the keypad's place, leaving the bike visible. */
.stage.hasMobileKeypad .tasStudio.isPaused { top: auto; bottom: max(8px, env(safe-area-inset-bottom)); left: 8px; width: calc(100% - 16px); }
.stage.hasMobileKeypad.tasEditing .mobileKeypad { visibility: hidden; }
.stage.hasMobileKeypad .tasStudio.isPaused .tasStatus { position: absolute; bottom: calc(100% + 8px); width: 100%; margin: 0; }
.stage.hasMobileKeypad .tasStudio.isPaused .tasPanel { max-height: min(430px, calc(100dvh - 64px)); }
@media (orientation: landscape) and (max-height: 500px) {
  .tasToolbar { max-height: calc(100dvh - 60px); overflow-y: auto; }
  .stage.hasMobileKeypad .tasStudio.isPaused { top: auto; bottom: max(8px, env(safe-area-inset-bottom)); left: 8px; right: auto; width: calc(100% - 16px); }
  .stage.hasMobileKeypad .tasStudio.isPaused .tasToolbar { max-height: none; overflow: visible; display: grid; grid-template-columns: minmax(252px, .8fr) minmax(0, 1.2fr); column-gap: 14px; }
  .stage.hasMobileKeypad .tasQuickRow { grid-column: 1; grid-row: 1; align-self: start; }
  .stage.hasMobileKeypad .tasQuickRow [data-tools] span { display: none; }
  .stage.hasMobileKeypad .tasPointRow { grid-column: 1; grid-row: 2; align-self: end; }
  .stage.hasMobileKeypad .tasFrameControls { grid-column: 2; grid-row: 1 / 3; margin: 0; padding: 0; border: 0; }
  .stage.hasMobileKeypad .tasHeldInputs { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .stage.hasMobileKeypad .tasHeldInputs button { padding-inline: 4px; gap: 2px; font-size: 12px; }
  .stage.hasMobileKeypad .tasHeldInputs button svg { width: 14px; height: 14px; flex-basis: 14px; }
  .stage.hasMobileKeypad [data-input=throttle] svg { display: none; }
  .stage.hasMobileKeypad .tasInputHelp { margin-block: 4px; }
  .stage.hasMobileKeypad .tasStudio.isOpen { width: min(400px, calc(100% - 16px)); left: auto; right: 8px; }
  .stage.hasMobileKeypad .tasStudio.isOpen .tasToolbar { display: none; }
  .stage.hasMobileKeypad .tasStudio.isPaused .tasPanel { max-height: calc(100dvh - 72px); }
  .stage.hasMobileKeypad .tasStudio.isPaused .tasStatus { bottom: calc(100% + 8px); top: auto; margin: 0; }
}

.tasHasTimeline { --tas-timeline-space: 104px; }
.tasTimelineDock { top: auto; bottom: max(8px, env(safe-area-inset-bottom)); left: 12px; right: 12px; width: auto; padding: 6px 12px; background: var(--tas-bg); border: 1px solid var(--tas-border); border-radius: 12px; box-shadow: 0 6px 24px #0003; }
.tasTimelineDock[hidden] { display: none; }
.tasTimelineDock * { box-sizing: border-box; }
.tasScrubHeading { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 12px; line-height: 17px; }
.tasScrubModes { display: flex; flex-shrink: 0; border: 1px solid var(--tas-border); border-radius: 7px; overflow: hidden; }
.tasScrubModes button { min-height: 32px; padding: 4px 8px; border: 0; background: transparent; color: var(--tas-muted); font: inherit; cursor: pointer; }
.tasScrubModes button[aria-pressed=true] { color: var(--tas-accent); background: var(--tas-active); font-weight: 600; }
.tasScrubModes button:disabled { cursor: default; }
.tasScrubModes button:focus-visible { outline: 2px solid var(--tas-accent); outline-offset: -3px; }
.tasScrubHeading output { font-variant-numeric: tabular-nums; }
.tasScrubHeading [data-scrub-end] { color: var(--tas-muted); font-variant-numeric: tabular-nums; }
.tasTimelineDock input { display: block; width: 100%; height: 32px; margin: 0; padding: 0; appearance: none; background: transparent; cursor: ew-resize; touch-action: none; }
.tasTimelineDock input::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; background: linear-gradient(to right, var(--tas-accent) var(--tas-recorded, 0%), var(--tas-border) var(--tas-recorded, 0%)); }
.tasTimelineDock input::-moz-range-track { height: 6px; border-radius: 3px; background: linear-gradient(to right, var(--tas-accent) var(--tas-recorded, 0%), var(--tas-border) var(--tas-recorded, 0%)); }
.tasTimelineDock input::-webkit-slider-thumb { appearance: none; width: 18px; height: 18px; margin-top: -6px; border: 2px solid var(--tas-bg); border-radius: 50%; background: var(--tas-accent); box-shadow: 0 0 0 1px var(--tas-accent); }
.tasTimelineDock input::-moz-range-thumb { width: 14px; height: 14px; border: 2px solid var(--tas-bg); border-radius: 50%; background: var(--tas-accent); box-shadow: 0 0 0 1px var(--tas-accent); }
.tasTimelineDock input:disabled { opacity: .45; cursor: default; }
.tasTimelineDock input:focus-visible { outline: 2px solid var(--tas-accent); outline-offset: 2px; border-radius: 4px; }
.tasTimelineDock p { margin: 0; font-size: 10px; line-height: 14px; color: var(--tas-muted); }
.tasHasTimeline .tasPanel { max-height: min(430px, calc(100dvh - var(--tas-timeline-space) - 64px)); }
.stage.hasMobileKeypad.tasHasTimeline .tasStudio.isPaused { bottom: calc(max(8px, env(safe-area-inset-bottom)) + var(--tas-timeline-space)); }
.stage.hasMobileKeypad.tasHasTimeline .tasStudio.isPaused .tasPanel { max-height: min(430px, calc(100dvh - var(--tas-timeline-space) - 24px)); }
.stage.hasMobileKeypad .tasTimelineDock { left: 8px; right: 8px; }
.stage.tasHasTimeline:not(.hasMobileKeypad) .gameChat { bottom: calc(max(12px, env(safe-area-inset-bottom)) + var(--tas-timeline-space)); }
@media (orientation: landscape) and (max-height: 500px) {
  .stage.hasMobileKeypad.tasHasTimeline .tasInputHelp { display: none; }
  .stage.hasMobileKeypad.tasHasTimeline .tasStepRow { margin-top: 6px; }
}
@media (max-width: 480px) {
  .tasScrubHeading { gap: 6px; font-size: 11px; }
  .tasScrubHeading [data-scrub-end] { display: none; }
  .tasScrubModes button { padding-inline: 7px; }
}
