/* ThrowCentral Analysis workspace.
   This stylesheet owns the Analysis route; legacy route styles stop at its root.
   Components, geometry and responsive rules live here, without override layers. */
@scope (.app.compare-active) {
  :scope.video-setup-collapsed:not(.phone-analysis) .workspace-layout { grid-template-columns: minmax(0,1fr) 248px; }
  :scope.video-setup-collapsed:not(.phone-analysis) .video-setup-sidebar { display: none; }
  .workspace-view-options { display: grid; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--ui-line); }
  .workspace-view-options select { font-size: 11px; }
  #toggleVideoSetup { font-size: 11px; }
  #projectMenuTitle[contenteditable] { cursor: text; border-bottom: 1px dashed var(--ui-muted); min-width: 48px; }
  #projectMenuTitle[contenteditable]:focus { outline: 1px solid var(--ui-accent); border-radius: 3px; }
  #projectSaveState { font-size: 10px; color: var(--ui-muted); white-space: nowrap; }
  .video-source-label small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .sync-next-step { color: var(--ui-muted); font-size: 11px; line-height: 1.5; }
  .sync-speed-toggle::before { content: ''; display: inline-block; width: 20px; height: 12px; margin-right: 6px; border-radius: 8px; background: radial-gradient(circle at 6px 6px, var(--ui-muted) 4px, transparent 4.5px), var(--ui-raised); vertical-align: middle; }
  .sync-speed-toggle[aria-pressed="true"]::before { background: radial-gradient(circle at 14px 6px, var(--ui-text) 4px, transparent 4.5px), var(--ui-accent); }
  @media(max-width:1000px) and (min-width:701px) { :scope.video-setup-collapsed:not(.phone-analysis) .workspace-layout { grid-template-columns: minmax(0,1fr) 212px; } }
  @media(max-width:700px) { :scope.video-setup-collapsed:not(.phone-analysis) .workspace-layout { grid-template-columns: minmax(0,1fr); } #projectSaveState { display:none; } }
  :scope.analysis-focus:not(.phone-analysis) .workspace-layout { grid-template-columns: minmax(0,1fr); }
  :scope.analysis-focus:not(.phone-analysis) .video-setup-sidebar, :scope.analysis-focus:not(.phone-analysis) .analysis-column { display:none; }
  .checkpoint-timeline { position:relative; width:100%; min-width:0; padding-top:18px; }
  #timelineCheckpoints { position:absolute; inset:0 8px auto; height:18px; }
  #timelineCheckpoints::before { content:""; position:absolute; left:var(--interval-start,0%); width:var(--interval-width,0%); height:2px; bottom:0; background:var(--ui-accent); opacity:.65; }
  #timelineCheckpoints button { position:absolute; transform:translateX(-50%); min-height:18px; height:18px; min-width:18px; padding:0 3px; font-size:10px; background:var(--ui-panel); }
  #timelineCheckpoints button.current-interval { color:var(--ui-accent-text); border-color:var(--ui-accent); }
  .checkpoint-phase-name { min-height:24px; height:24px; font-size:11px; padding:2px 6px; }
  #nameCheckpointPhases { justify-self:start; font-size:10px; min-height:24px; }
  .transport-playback [data-analysis-undo], .transport-playback [data-analysis-redo] { width:auto; font-size:10px; padding:4px 6px; }
  .workspace-command-bar { display: flex; align-items: center; min-width: 0; padding: 0 20px; border-bottom: 1px solid var(--ui-line); z-index: 20; }
  .compact-actions, .main-controls { display: flex; align-items: center; width: 100%; min-width: 0; gap: 12px; }
  .project-menu { position: relative; flex: 1; min-width: 140px; }
  .project-menu > summary { display: inline-flex; gap: 8px; max-width: 100%; height: 34px; padding: 0 8px 0 0; font-size: 14px; }
  .project-menu > summary:hover { background: transparent; }
  .project-menu-avatar { display: grid; place-items: center; width: 24px; height: 24px; border: 1px solid var(--ui-line); border-radius: 5px; color: var(--ui-accent); font-size: 11px; }
  .project-menu-copy { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
  .project-menu-label { color: var(--ui-muted); font-size: 12px; font-weight: 400; }
  #projectMenuTitle { max-width: min(38vw, 540px); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 14px; }
  .project-menu > summary::after { margin-left: 8px; flex: none; }
  .tool-panel { display: grid; gap: 12px; padding: 12px; }
  .project-tool-panel { position: absolute; top: calc(100% + 6px); left: 0; width: 300px; max-width: 90vw; border: 1px solid var(--ui-line); border-radius: 8px; background: var(--ui-panel); box-shadow: 0 12px 32px #0006; }
  .project-popover-heading { display: grid; gap: 2px; }
  .project-popover-heading span { color: var(--ui-muted); font-size: 12px; }
  .project-menu-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .project-menu-wide-action, #deleteProjectButton { grid-column: 1 / -1; }
  .danger-button { color: var(--danger, #eb6472); }
  .layout-toggle, .reference-speed-controls { display: flex; gap: 2px; padding: 2px; border: 1px solid var(--ui-line); border-radius: var(--ui-radius); background: var(--ui-bg); }
  .layout-toggle button, .reference-speed-controls button { min-height: 28px; padding: 3px 10px; border: 0; border-radius: 4px; background: transparent; color: var(--ui-muted); font-size: 12px; }
  .layout-toggle button.active, .reference-speed-controls button.active { background: var(--ui-selected); color: var(--ui-accent); }
  .sync-viewer-launch { display: flex; align-items: center; justify-content: center; gap: 6px; min-width: 132px; height: 32px; border-color: transparent; background: var(--ui-accent); color: #04180e; font-size: 12px; font-weight: 600; }
  .sync-viewer-launch:hover { background: color-mix(in srgb, var(--ui-accent) 86%, white); }
  .sync-viewer-launch svg { width: 16px; height: 16px; }
  .sync-viewer-launch-status { display: none; flex: 0 1 180px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: var(--ui-muted); font-size: 11px; }
  .sync-viewer-launch-status.visible { display: block; }
  .sync-viewer-launch-status[data-error="true"] { color: var(--danger, #eb6472); }

  /* The video area takes all remaining space; the two sidebars scroll within it. */
  .workspace-layout { display: grid; grid-template-columns: 208px minmax(0, 1fr) 248px; min-width: 0; min-height: 0; gap: 0; overflow: hidden; }
  .video-setup-sidebar, .analysis-column { min-width: 0; min-height: 0; overflow: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: var(--ui-line) transparent; background: var(--ui-panel); }
  .video-setup-sidebar { padding: 4px 12px 16px; border-right: 1px solid var(--ui-line); }
  .video-setup-card { padding: 16px 0; border-bottom: 1px solid var(--ui-line); }
  .video-setup-card:not(:has(~ .video-setup-card:not([hidden]))) { border-bottom: 0; }
  .file-picker { display: grid; gap: 12px; min-width: 0; }
  .video-setup-heading { display: grid; gap: 4px; min-width: 0; }
  .video-setup-heading strong { font-size: 13px; }
  .video-setup-heading span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ui-muted); font-size: 11px; }
  .setup-actions { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 6px; }
  .setup-actions button { min-width: 0; padding: 4px; font-size: 12px; line-height: 1.2; white-space: normal; }
  .setup-field { display: grid; gap: 4px; min-width: 0; }
  .pick-button { color: var(--ui-text); }
  .setup-field-label, .setup-field > span { font-size: 11px; color: var(--ui-muted); }
  .setup-field select { height: 32px; font-size: 12px; color: var(--ui-text); background: var(--ui-bg); }
  .video-column { display: grid; grid-template-rows: minmax(0, 1fr) auto 54px; min-width: 0; min-height: 0; overflow: hidden; padding: 12px 12px 0; background: var(--ui-bg); }
  .video-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: minmax(0, 1fr); gap: 10px; min-width: 0; min-height: 0; overflow: hidden; }
  .video-grid:not(.single-video):not(.ghost-mode)[data-two-video-layout="stacked"] { grid-template-columns: minmax(0, 1fr); grid-template-rows: repeat(2, minmax(0, 1fr)); }
  .video-panel { display: grid; grid-template-rows: auto minmax(0, 1fr); min-width: 0; min-height: 0; overflow: hidden; }
  .video-panel.crop-editing { grid-template-rows: auto minmax(80px, 1fr) auto; }
  .crop-time-editor { display: grid; gap: 6px; padding: 8px; border-top: 1px solid var(--ui-line); background: var(--ui-panel); }
  .crop-time-heading, .crop-time-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
  .crop-time-heading { font-size: 11px; }
  .crop-time-summary, .crop-time-row output { font-family: var(--ui-data); font-size: 10px; color: var(--ui-muted); }
  .crop-time-controls { display: grid; gap: 4px; }
  .crop-time-row { display: grid; grid-template-columns: 30px minmax(24px, 1fr) 54px auto; gap: 6px; align-items: center; font-size: 11px; }
  .crop-time-row input { padding: 0; accent-color: var(--ui-accent); }
  .crop-time-row button, .crop-time-actions button { min-height: 24px; padding: 3px 6px; font-size: 10px; }
  /* Source identity and optional save action share the existing header row.
     Neither may consume the grid row reserved for the video itself. */
  .video-source-header { display: flex; align-items: center; gap: 8px; width: 100%; min-width: 0; min-height: 24px; }
  .video-source-header > .video-source-label { flex: 1; min-width: 0; }
  .video-source-header > button { align-self: stretch; padding: 0 6px; }
  .video-source-header > .project-source-library-action { flex: none; white-space: nowrap; font-size: 10px; }
  .video-source-label { display: flex; flex-direction: column; justify-content: center; min-width: 0; color: var(--ui-text); font-size: 12px; line-height: 1.15; }
  .video-source-label strong { max-width: 100%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-weight: 600; }
  .video-source-label small { color: var(--ui-muted); font-size: 9px; margin-top: 2px; }
  .video-source-label [hidden] { display: none; }
  .video-stage { position: relative; min-width: 0; min-height: 0; width: 100%; height: 100%; overflow: hidden; border-radius: 4px; background: #030806; isolation: isolate; }
  .video-stage > video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; object-position: center; }
  .video-stage > canvas { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 3; touch-action: none; }
  .video-stage > .skeleton-canvas { z-index: 2; pointer-events: none; }
  .video-stage > .video-bg, .video-hud, .video-sync-pills { display: none; }
  .empty-state { position: absolute; inset: 0; z-index: 4; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; width: 100%; border: 1px dashed var(--ui-line); border-radius: 4px; background: transparent; color: var(--ui-muted); }
  .empty-state strong { color: var(--ui-text); font-size: 13px; }
  .empty-state span { font-size: 11px; }
  .has-video .empty-state, .has-external-video .empty-state { display: none; }
  .drop-status { pointer-events: none; position: absolute; left: 8px; right: 8px; bottom: 8px; z-index: 9; display: none; padding: 8px 10px; border-radius: 4px; background: #0e1b16ed; font-size: 12px; }
  .drop-status.visible { display: block; }
  .video-grid.single-video, .video-grid.ghost-mode { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); }
  .video-grid.single-video > .video-panel:nth-child(2), .video-grid.ghost-mode > .video-panel:nth-child(2) { display: none; }
  :scope.single-video-mode .video-two-only { display: none; }
  .video-grid:fullscreen { width: 100vw; height: 100dvh; padding: 12px; background: var(--ui-bg); }

  /* One compact transport, then a full-width scrubber with generous hit area. */
  .analysis-transport { display: flex; align-items: center; gap: 12px; min-width: 0; padding: 8px 0; margin-top: 12px; border-top: 1px solid var(--ui-line); }
  .transport-playback { display: flex; align-items: center; gap: 4px; }
  .transport-playback button { width: 30px; padding: 0; border: 0; background: transparent; }
  .play-icon-button { font-size: 0; }
  .play-icon-button::before { content: ""; display: block; width: 0; height: 0; margin: auto; border-top: 6px solid transparent; border-bottom: 6px solid transparent; border-left: 9px solid var(--ui-text); }
  .play-icon-button.is-playing::before { width: 10px; height: 12px; border: 0; border-left: 3px solid var(--ui-text); border-right: 3px solid var(--ui-text); }
  .reference-speed-controls { border: 0; padding: 0; background: transparent; }
  .reference-speed-controls button { min-height: 28px; padding: 4px 8px; font-variant-numeric: tabular-nums; font-size: 11px; }
  .floating-mark-toolbar { display: flex; align-items: center; gap: 2px; padding-left: 12px; border-left: 1px solid var(--ui-line); margin-left: auto; }
  .mark-tool-button { display: inline-grid; place-items: center; width: 28px; height: 28px; min-height: 28px; padding: 0; border: 0; background: transparent; color: var(--ui-muted); }
  .mark-tool-button svg { width: 16px; height: 16px; }
  .mark-tool-button.active { color: var(--ui-accent-text); background: var(--ui-selected); }
  .mobile-full-screen-button { min-height: 28px; height: 28px; padding: 4px 8px; font-size: 11px; border: 0; color: var(--ui-muted); background: transparent; }
  .control-strip { display: flex; align-items: center; gap: 12px; min-width: 0; border: 0; background: transparent; }
  .control-strip span { min-width: 52px; font-family: var(--ui-data); font-size: 11px; color: var(--ui-muted); font-variant-numeric: tabular-nums; }
  #durationReadout { text-align: right; }
  input[type="range"] { appearance: none; -webkit-appearance: none; height: 28px; padding: 0; border: 0; background: transparent; cursor: pointer; accent-color: var(--ui-accent); }
  input[type="range"]::-webkit-slider-runnable-track { height: 3px; border-radius: 2px; background: var(--ui-line); }
  input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 10px; height: 10px; border: 0; border-radius: 50%; margin-top: -3.5px; background: var(--ui-accent); }
  input[type="range"]::-moz-range-track { height: 3px; border-radius: 2px; background: var(--ui-line); }
  input[type="range"]::-moz-range-thumb { width: 10px; height: 10px; border: 0; border-radius: 50%; background: var(--ui-accent); }

  /* The inspector uses ruled rows instead of nested cards. */
  .analysis-column { border-left: 1px solid var(--ui-line); padding: 0 12px 16px; }
  .analysis-rail-toggle, .sync-disclosure-button { display: none; }
  /* Every inspector section owns one identical disclosure row. Its controls
     and descriptions live inside the expanded body, not the collapsed header. */
  .analysis-column .analysis-section { margin: 0; padding: 0; border: 0; border-bottom: 1px solid var(--ui-line); border-radius: 0; background: transparent; }
  .analysis-column .analysis-section > summary {
    display: flex; align-items: center; gap: 12px;
    height: 48px; min-height: 48px; width: 100%; padding: 0;
    border: 0; border-radius: 0; background: transparent; box-shadow: none;
    color: var(--ui-text); font-family: inherit; font-size: 13px; font-weight: 600; line-height: 20px;
    letter-spacing: 0; text-align: left; list-style: none; cursor: pointer;
  }
  .analysis-column .analysis-section > summary:hover { background: var(--ui-raised); }
  .analysis-column .analysis-section > summary::before { content: none; }
  .analysis-column .analysis-section > summary::after {
    content: ""; flex: 0 0 6px; width: 6px; height: 6px; margin-left: auto; margin-right: 2px;
    border: solid var(--ui-muted); border-width: 0 1px 1px 0; transform: rotate(-45deg);
  }
  .analysis-column .analysis-section[open] > summary::after { transform: rotate(45deg); }
  .analysis-column .analysis-section > summary > .analysis-section-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: inherit; font: inherit; }
  .sync-strip-body { padding: 0 0 12px; }
  .sync-checkpoint-intro { display: grid; gap: 12px; }
  #releaseStatus { display: block; padding: 0; min-height: 0; color: var(--ui-muted); font-size: 11px; line-height: 1.5; }
  .advanced-sync-count-controls { display: flex; align-items: center; gap: 2px; padding-bottom: 12px; }
  .advanced-sync-count-label { flex: 1; font-size: 11px; color: var(--ui-muted); }
  .advanced-sync-step { width: 26px; height: 28px; min-height: 28px; padding: 0; background: transparent; border-color: transparent; }
  .advanced-sync-count-value { min-width: 24px; text-align: center; font-family: var(--ui-data); font-size: 12px; }
  .sync-strip-body { --checkpoint-number-width: 20px; --checkpoint-action-width: 24px; --checkpoint-video-columns: 2; }
  :scope.single-video-mode .sync-strip-body { --checkpoint-video-columns: 1; }
  .advanced-sync-header, .advanced-sync-row { display: grid; grid-template-columns: var(--checkpoint-number-width) repeat(var(--checkpoint-video-columns), minmax(0, 1fr)) repeat(3, var(--checkpoint-action-width)); align-items: center; gap: 2px; }
  .advanced-sync-row > * { grid-row: 1; min-width: 0; }
  .advanced-sync-number { grid-column: 1; }
  .advanced-sync-time:nth-child(2) { grid-column: 2; }
  .advanced-sync-time:nth-child(3) { grid-column: 3; }
  .advanced-sync-insert { grid-column: calc(var(--checkpoint-video-columns) + 2); }
  .advanced-sync-clear { grid-column: calc(var(--checkpoint-video-columns) + 3); }
  .advanced-sync-remove { grid-column: calc(var(--checkpoint-video-columns) + 4); }
  .advanced-sync-header { min-height: 28px; border-top: 1px solid var(--ui-line); border-bottom: 1px solid var(--ui-line); color: var(--ui-muted); font-size: 10px; font-weight: 500; text-align: center; }
  .advanced-sync-row { min-height: 36px; border-bottom: 1px solid color-mix(in srgb, var(--ui-line) 55%, transparent); border-radius: 0; }
  .advanced-sync-row.checkpoint-just-edited { background: var(--ui-selected); }
  .checkpoint-order-conflict .advanced-sync-number { color: #edbd71; text-decoration: underline dotted; }
  .advanced-sync-row:hover { background: var(--ui-raised); }
  .advanced-sync-number { padding: 0; min-height: 28px; height: 28px; border: 0; background: transparent; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: center; color: var(--ui-muted); font-family: var(--ui-data); font-size: 10px; }
  .advanced-sync-number:hover, .advanced-sync-number:focus-visible { background: var(--ui-selected); color: var(--ui-accent-text); }
  .advanced-sync-time { height: 30px; min-height: 30px; padding: 4px 0; border: 0; border-radius: 4px; background: transparent; font-family: var(--ui-data); font-size: 11px; font-variant-numeric: tabular-nums; color: var(--ui-muted); }
  .advanced-sync-time.synced { color: var(--ui-text); }
  .advanced-sync-time:hover { background: var(--ui-selected); color: var(--ui-accent); }
  .advanced-sync-clear, .advanced-sync-insert, .advanced-sync-remove { min-width: 0; min-height: 28px; height: 28px; padding: 0; border: 0; background: transparent; color: var(--ui-muted); font-size: 13px; opacity: 1; }
  .advanced-sync-remove svg { width: 14px; height: 14px; vertical-align: middle; }
  .advanced-sync-clear:hover, .advanced-sync-remove:hover { color: var(--danger, #eb6472); opacity: 1; }
  .advanced-sync-insert:hover { color: var(--ui-accent); opacity: 1; }
  .sync-speed-toggle { justify-self: start; padding: 2px 6px; min-height: 24px; font-size: 10px; background: transparent; color: var(--ui-muted); }
  .sync-speed-toggle[aria-pressed="true"] { background: var(--ui-selected); color: var(--ui-accent-text); }
  .sync-speed-segment > summary { min-height: 20px; padding: 2px 4px; justify-content: center; font-size: 10px; font-weight: 400; color: var(--ui-accent-text); overflow-wrap: anywhere; }
  .sync-speed-segment > summary::after { display: none; }
  .sync-speed-segment > p { white-space: pre-line; font-size: 11px; color: var(--ui-muted); padding: 6px; line-height: 1.6; border-bottom: 1px solid var(--ui-line); }
  .sync-speed-total { display: grid; gap: 6px; padding: 12px 0; margin: 6px 0 12px; border-block: 1px solid var(--ui-line); overflow-wrap: anywhere; }
  .sync-speed-total[hidden] { display: none; }
  .sync-total-range { font-size: 11px; color: var(--ui-muted); }
  .sync-total-result { font-size: 14px; line-height: 1.4; color: var(--ui-accent-text); }
  .sync-speed-total .sync-total-durations { margin: 0; font-size: 12px; font-variant-numeric: tabular-nums; }
  .sync-speed-total .sync-total-help { margin: 0; font-size: 10px; line-height: 1.5; color: var(--ui-muted); }
  .sync-readouts { display: flex; gap: 8px; margin-top: 12px; }
  .sync-readouts button { flex: 1; min-height: 30px; padding: 4px 6px; font-size: 11px; }
  .analysis-tools-panel { display: grid; gap: 8px; padding-bottom: 12px; }
  .analysis-tools-panel .tool-menu { border-top: 1px solid var(--ui-line); }
  .analysis-tools-panel .tool-menu > summary { font-size: 12px; padding: 8px 0; }
  .analysis-tools-panel .tool-panel { padding: 8px 0; gap: 10px; }
  .toolbar-zone-label, .playback-cluster > .frame-controls { display: none; }
  .playback-cluster { padding: 4px 0; }
  .frame-controls, .mark-toolbar, .color-swatch-row, .zoom-controls { display: flex; align-items: center; gap: 6px; }
  .frame-controls > span, .zoom-controls > span { flex: 1; font-size: 11px; color: var(--ui-muted); text-align: center; }
  .color-swatch { min-height: 24px; width: 24px; height: 24px; padding: 0; border: 3px solid var(--ui-panel); background: var(--swatch); outline: 1px solid var(--ui-line); }
  .color-swatch.active { outline-color: var(--ui-accent); }
  .notes-panel-body, .distance-panel-body, .coach-analysis-body, .coach-chat-body, .library-grid { display: grid; gap: 12px; padding-bottom: 12px; }
  .distance-panel-body :is(.distance-stack, .distance-stat-card), .coach-output-grid { display: grid; gap: 8px; }
  .distance-panel-body button, .coach-panel button { white-space: normal; font-size: 11px; }
  .distance-checkpoints { display: grid; grid-template-columns: minmax(0, 1fr) 28px; gap: 4px; }
  .distance-checkpoints > :nth-child(1) { grid-area: 1 / 1; }
  .distance-checkpoints > :nth-child(2) { grid-area: 2 / 1; }
  .distance-checkpoints > :nth-child(3) { grid-area: 1 / 2; }
  .distance-checkpoints > :nth-child(4) { grid-area: 2 / 2; }
  .distance-checkpoints .sync-trash { padding: 0; color: var(--ui-muted); }
  .distance-stat-card, .coach-output-card { padding: 8px 0; border-bottom: 1px solid var(--ui-line); }
  .distance-model-hint, .distance-estimate-status { font-size: 11px; line-height: 1.5; color: var(--ui-muted); white-space: normal; overflow-wrap: anywhere; }
  .distance-estimate-status { margin: 0; }
  .coach-panel { display: block; margin: 0; padding: 0; border: 0; background: transparent; }
  .coach-output, .coach-chat-log { max-height: 240px; overflow: auto; white-space: pre-wrap; font-size: 12px; }
  .coach-chat-actions { display: flex; flex-wrap: wrap; gap: 6px; }
  .coach-frame-tray { display: flex; flex-wrap: wrap; }
  .coach-frame-tray img { max-width: 100%; }
  .library-section { min-width: 0; }
  .project-library { display: grid; gap: 8px; color: var(--ui-muted); font-size: 12px; }
  .library-item { display: grid; gap: 6px; padding: 8px 0; border-bottom: 1px solid var(--ui-line); }
  .library-item img { width: 100%; object-fit: contain; max-height: 120px; }
  .library-item button { white-space: normal; font-size: 11px; }
  .ghost-controls { display: none; }
  :scope.ghost-active .ghost-controls { display: grid; gap: 12px; padding: 12px 0; }
  .ghost-control-group { display: grid; gap: 8px; }
  .ghost-auto-alignment { display: grid; gap: 8px; padding-bottom: 12px; border-bottom: 1px solid var(--ui-line); }
  .ghost-auto-toggle { display: flex; align-items: center; gap: 8px; font-weight: 600; }
  .ghost-auto-toggle input { width: 14px; height: 14px; margin: 0; accent-color: var(--ui-accent); }
  .ghost-controls input:disabled, .ghost-controls select:disabled { opacity: .4; cursor: default; }
  .ghost-opacity-control { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; }
  .ghost-opacity-control input { grid-column: 1 / -1; width: 100%; min-width: 0; }
  .ghost-opacity-control output { color: var(--ui-muted); font-variant-numeric: tabular-nums; font-size: 11px; }
  .ghost-outline-controls { display: grid; grid-template-columns: minmax(0, 1fr) 44px; gap: 8px; }
  .ghost-outline-controls > label { display: grid; gap: 4px; min-width: 0; }
  .ghost-outline-controls select { width: 100%; min-width: 0; }
  .ghost-outline-controls .ghost-outline-color input { width: 100%; height: 30px; padding: 2px; border: 1px solid var(--ui-line); border-radius: 4px; cursor: pointer; }
  .ghost-outline-controls .ghost-outline-width { grid-column: 1 / -1; grid-template-columns: 1fr auto; }
  .ghost-cutout-status { margin: 0; font-size: 11px; line-height: 1.5; color: var(--ui-muted); }
  .video-stage > #ghostCompositeCanvas { z-index: 2; pointer-events: none; }
  .ghost-mode #leftVideo { visibility: hidden; }
  #ghostCompositeCanvas[hidden] { display: none; }
  .ghost-zoom-control { display: flex; align-items: center; gap: 4px; }
  .ghost-zoom-control button { padding: 0; width: 24px; }
  .ghost-group-label { color: var(--ui-muted); font-size: 11px; }
  .ghost-mode #leftCanvas { cursor: grab; }
  .skeleton-only video, .skeleton-only .empty-state { visibility: hidden; }
  .external-video { position: absolute; inset: 0; z-index: 4; }
  .external-video iframe { width: 100%; height: 100%; border: 0; }
  .has-external-video > canvas, .has-external-video > video { display: none; }
  .external-video-attribution { position: absolute; bottom: 8px; left: 8px; z-index: 5; font-size: 11px; }

  /* Non-Analysis routes remain owned by the legacy stylesheets. */
  .tips, .search-page, .settings-page, .coach-memory-view, .general-coach-view { display: none; }
  .compare-right-rail { display: none; }

  @media (max-width: 1250px) {
    .workspace-layout { grid-template-columns: 180px minmax(0, 1fr) 232px; }
    .workspace-command-bar { padding: 0 16px; }
    .analysis-transport { gap: 6px; flex-wrap: wrap; }
    .floating-mark-toolbar { padding-left: 6px; }
    .sync-viewer-launch-status { flex-basis: 128px; }
    .project-menu-label { display: none; }
  }
  @media (max-width: 1000px) and (min-width: 701px) {
    .workspace-layout { grid-template-columns: 164px minmax(0, 1fr) 212px; }
    .video-setup-sidebar, .analysis-column { padding-left: 8px; padding-right: 8px; }
    .video-column { padding: 8px 8px 0; }
    .setup-actions button { padding: 4px; font-size: 11px; white-space: normal; line-height: 1.2; }
    .floating-mark-toolbar { order: 3; flex-basis: 100%; margin-left: 0; padding: 0; border: 0; }
    .mobile-full-screen-button { margin-left: auto; }
    .sync-strip-body { --checkpoint-number-width: 16px; --checkpoint-action-width: 22px; }
    .advanced-sync-time { font-size: 10px; }
    .sync-viewer-launch-status { display: none; }
    .sync-viewer-launch-status.visible { position: absolute; top: 96px; right: 12px; max-width: 300px; padding: 6px 10px; background: var(--ui-panel); border: 1px solid var(--ui-line); border-radius: 6px; }
  }
  @media (max-width: 700px) {
    :scope { height: auto; min-height: 100dvh; grid-template-rows: auto auto auto; overflow: visible; }
    .workspace-command-bar { min-height: 88px; padding: 8px 12px; }
    .main-controls { display: flex; flex-wrap: wrap; gap: 8px; }
    .project-menu { flex: 1 0 calc(100% - 10px); }
    #projectMenuTitle { max-width: 70vw; }
    .layout-toggle { margin-right: auto; }
    .sync-viewer-launch-status { flex-basis: 100%; max-width: 100%; }
    .workspace-layout { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto auto; overflow: visible; }
    .video-column { grid-row: 1; height: min(72dvh, 760px); min-height: 420px; padding: 8px 8px 0; }
    .analysis-transport { gap: 6px; margin-top: 8px; }
    .transport-playback button { width: 28px; }
    .reference-speed-controls button { padding: 4px 6px; }
    .floating-mark-toolbar { order: 3; margin-left: 0; padding-left: 0; border: 0; }
    .mobile-full-screen-button { margin-left: auto; }
    .video-setup-sidebar { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; grid-row: 2; padding: 0 12px 12px; border-top: 1px solid var(--ui-line); border-right: 0; }
    .video-setup-card { border: 0; }
    .analysis-column { grid-row: 3; border-left: 0; border-top: 1px solid var(--ui-line); padding: 0 12px 16px; }
    :scope.single-video-mode .video-setup-sidebar { grid-template-columns: minmax(0, 1fr); }
    .crop-time-row { grid-template-columns: 26px minmax(24px, 1fr) 46px; }
    .crop-time-row button { grid-column: 2 / -1; }
    .analysis-column .advanced-sync-time { font-size: 12px; }
    .sync-strip-body { --checkpoint-number-width: 28px; --checkpoint-action-width: 28px; }
  }
  @media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none; } }
}

@media (max-width: 700px) {
  :root:has(> body > .app.compare-active:not(.experience)) > body { height: auto !important; overflow: auto !important; }
}

/* Crop editor interaction geometry is shared with the original workspace. */
@scope (.app.compare-active) {
.crop-editor {
  position: absolute;
  inset: 0;
  z-index: 8;
  overflow: hidden;
  pointer-events: none;
  touch-action: none;
}

.crop-editor[hidden] {
  display: none !important;
}

.video-panel.crop-editing .crop-editor {
  pointer-events: auto;
}

.crop-box {
  position: absolute;
  z-index: 1;
  min-width: 40px;
  min-height: 40px;
  border: 2px solid #fff;
  box-shadow:
    0 0 0 9999px rgb(2 6 23 / 0.58),
    0 0 0 1px rgb(15 23 42 / 0.55),
    0 12px 32px rgb(2 6 23 / 0.28);
  cursor: move;
  user-select: none;
  -webkit-user-select: none;
}

.crop-editor.is-dragging .crop-box {
  cursor: grabbing;
}

.crop-grid-line {
  position: absolute;
  z-index: 1;
  display: block;
  background: rgb(255 255 255 / 0.48);
  pointer-events: none;
}

.crop-grid-line.vertical {
  top: 0;
  bottom: 0;
  width: 1px;
}

.crop-grid-line.horizontal {
  right: 0;
  left: 0;
  height: 1px;
}

.crop-grid-line.vertical.crop-grid-one {
  left: 33.333%;
}

.crop-grid-line.vertical.crop-grid-two {
  left: 66.666%;
}

.crop-grid-line.horizontal.crop-grid-one {
  top: 33.333%;
}

.crop-grid-line.horizontal.crop-grid-two {
  top: 66.666%;
}

.crop-handle {
  position: absolute;
  z-index: 2;
  width: 24px;
  height: 24px;
  min-width: 24px;
  min-height: 24px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  touch-action: none;
}

.crop-handle::after {
  position: absolute;
  inset: 7px;
  border: 2px solid #fff;
  background: #111827;
  box-shadow: 0 1px 4px rgb(2 6 23 / 0.55);
  content: "";
}

.crop-handle-nw,
.crop-handle-ne,
.crop-handle-se,
.crop-handle-sw {
  width: 30px;
  height: 30px;
}

.crop-handle-nw { top: -2px; left: -2px; cursor: nwse-resize; }
.crop-handle-n { top: -2px; left: calc(50% - 12px); cursor: ns-resize; }
.crop-handle-ne { top: -2px; right: -2px; cursor: nesw-resize; }
.crop-handle-e { top: calc(50% - 12px); right: -2px; cursor: ew-resize; }
.crop-handle-se { right: -2px; bottom: -2px; cursor: nwse-resize; }
.crop-handle-s { bottom: -2px; left: calc(50% - 12px); cursor: ns-resize; }
.crop-handle-sw { bottom: -2px; left: -2px; cursor: nesw-resize; }
.crop-handle-w { top: calc(50% - 12px); left: -2px; cursor: ew-resize; }

.crop-handle-n::after,
.crop-handle-s::after {
  inset: 9px 4px;
  border-width: 1px;
  border-radius: 999px;
  background: #fff;
}

.crop-handle-e::after,
.crop-handle-w::after {
  inset: 4px 9px;
  border-width: 1px;
  border-radius: 999px;
  background: #fff;
}


}

/* Live, softly blurred surround beneath the sharp source video. */
.video-stage > canvas.video-backdrop {
  position: absolute; inset: 0; width: 100%; height: 100%; z-index: 0;
  pointer-events: none; transform: none;
  filter: none;
}
.video-stage:not(.has-video) > canvas.video-backdrop,
.ghost-mode .video-stage > canvas.video-backdrop,
.skeleton-only .video-stage > canvas.video-backdrop { display: none; }

.video-stage.has-video:has(>canvas.video-backdrop)::before {display:none;}

/* Shared quick actions retain the native controls and source-specific notes. */
.coaching-cue-actions, .ghost-starting-presets { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.coaching-cue-actions button, .ghost-starting-presets button { min-height: 44px; }
.coaching-cue-status, .ghost-starting-presets small { flex: 1 1 100%; font-size: .8125rem; line-height: 1.5; }
.coaching-cue-status:empty { display: none; }
.athlete-optional-fields, .athlete-quick-create-hint { grid-column: 1 / -1; min-width: 0; }
.athlete-quick-create-hint { margin: 0; line-height: 1.5; }
.athlete-optional-fields > summary { min-height: 44px; padding-block: .75rem; cursor: pointer; }
.athlete-optional-fields > .athlete-form-grid { margin-block: .75rem; }
.library-empty-action { display: block; margin-block-start: .75rem; min-height: 44px; }
.coaching-note-field { min-width: 0; display: grid; gap: .5rem; }
.coaching-note-field[hidden] { display: none; }
.automatic-playback-choices { display: flex; flex-wrap: wrap; gap: .5rem; }
.automatic-playback-choices button[aria-pressed="true"] { border-color: var(--accent, #d7f36b); background: color-mix(in srgb, var(--accent, #d7f36b) 15%, transparent); }

.app:is(.single-video-mode,.three-video-mode) #ghostStartingPresets { display: none; }
