/* Phone analysis is scoped by the presentation module. Desktop and saved
   legacy themes retain their controllers and supported color aliases. */
.tc-timeline-ruler,.tc-mobile-context,.tc-mobile-playback-options,.tc-mobile-checkpoints,.tc-phone-fullscreen-exit,.empty-state .tc-phone-add-video {display:none;}
#tcMobileFrameEditor[data-tc-frame-mode="automatic"] .tc-frame-controls {min-width:0;}
#tcMobileFrameEditor .studio-checkpoint-popover #autoSyncCheckpoints .auto-checkpoint-row {grid-template-columns:minmax(0,1fr);}
#tcMobileFrameEditor[data-tc-frame-source="0"] .auto-checkpoint-source:not([data-auto-slot="0"]),
#tcMobileFrameEditor[data-tc-frame-source="1"] .auto-checkpoint-source:not([data-auto-slot="1"]),
#tcMobileFrameEditor[data-tc-frame-source="2"] .auto-checkpoint-source:not([data-auto-slot="2"]) {display:none;}
.sync-studio-source-status {margin:0;color:var(--ui-muted);font-size:12px;line-height:1.5;}
html .app.experience.tc-mobile-analysis {
  --tc-phone-inset:12px;
  height:var(--tc-visible-height,100dvh);min-height:0;max-width:100%;
  grid-template-rows:0 56px minmax(0,1fr);
  padding:env(safe-area-inset-top) env(safe-area-inset-right) calc(58px + env(safe-area-inset-bottom)) env(safe-area-inset-left);
  overflow:hidden;

  .topbar {display:none;}
  .primary-nav {position:fixed;inset:auto 0 0;height:calc(58px + env(safe-area-inset-bottom));padding:0 8px env(safe-area-inset-bottom);display:grid;grid-auto-flow:column;grid-auto-columns:minmax(0,1fr);gap:0;z-index:40;background:var(--ui-panel);border-top:1px solid var(--ui-line);}
  .primary-nav-button {display:flex;flex-direction:column;justify-content:center;gap:3px;min-width:0;min-height:52px;height:auto;padding:4px;font-size:12px;}
  .primary-nav-button svg {width:20px;height:20px;}
  .workspace-command-bar {min-height:56px;padding:4px var(--tc-phone-inset);border-bottom:1px solid var(--ui-line);}
  .main-controls {min-width:0;width:100%;gap:8px;flex-wrap:nowrap;}
  .project-menu {flex:1 1 0;min-width:0;}
  .project-menu-copy {display:grid;gap:2px;min-width:0;}
  #projectMenuTitle {font-size:16px;max-width:100%;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
  #projectSaveState {display:block;font-size:11px;line-height:1.3;}
  .main-controls > button {min-height:44px;min-width:0;padding:6px 12px;white-space:nowrap;flex:0 0 auto;font-size:13px;}
  .main-controls > :is(#toggleVideoSetup,#focusAnalysis,.layout-toggle,#analysisPrivacy) {display:none;}
  .tc-mobile-playback-options {display:block;}
  .project-tool-panel {max-height:calc(var(--tc-visible-height,100dvh) * .65);overflow:auto;}
  .workspace-layout {display:flex;flex-direction:column;min-height:0;min-width:0;overflow:hidden;}
  .video-column:has(> #videoGrid) {
    flex:1 1 0;display:flex;flex-direction:column;min-width:0;min-height:0;height:auto;
    padding:0 var(--tc-phone-inset) 10px;gap:0;overflow:auto;overscroll-behavior:contain;
  }
  .video-column:has(> #videoGrid) > * {flex-shrink:0;}
  &[data-fix-sync-phone] .video-column:has(> #videoGrid) {
    padding-bottom:var(--tc-fix-inspector-height,0px);
  }
  &[data-fix-sync-phone] .studio-phase-strip .studio-pair-controls {display:none;}
  .video-column:fullscreen > .tc-phone-fullscreen-exit:not([hidden]) {
    position:absolute;top:calc(env(safe-area-inset-top) + 5px);right:var(--tc-phone-inset);z-index:6;display:block;min-height:44px;
  }
  .tc-mobile-context {display:block;min-width:0;order:0;}
  .tc-mobile-context [hidden] {display:none;}
  .tc-mobile-sources {display:grid;grid-template-columns:repeat(var(--tc-phone-source-count,2),minmax(0,1fr));gap:6px;}
  &[data-tc-mobile-count="1"] {--tc-phone-source-count:1;}
  &[data-tc-mobile-count="3"] {--tc-phone-source-count:3;}
  .tc-mobile-sources > button {
    display:flex;align-items:center;gap:7px;min-width:0;min-height:44px;
    padding:3px 5px;border:0;border-radius:6px;background:none;color:var(--ui-muted);font-size:13px;text-align:left;
  }
  .tc-mobile-sources > button[aria-pressed="true"] {color:var(--ui-text);}
  .tc-mobile-sources > button[aria-pressed="true"] .tc-source-letter {background:var(--ui-selected);color:var(--ui-accent);border-color:currentColor;}
  .tc-source-letter {display:grid;place-items:center;flex:none;width:21px;height:21px;border:1px solid var(--ui-line);border-radius:5px;font-size:11px;font-weight:700;}
  .tc-mobile-source-name {min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
  #videoGrid {
    flex:1 0 128px;height:0;order:1;grid-template-columns:minmax(0,1fr);grid-template-rows:minmax(0,1fr);
    gap:6px;overflow:hidden;
  }
  #videoGrid .video-stage {height:100%;min-height:0;aspect-ratio:auto;border-radius:8px;}
  #videoGrid > .video-panel {height:100%;align-self:stretch;min-width:0;min-height:0;grid-template-rows:minmax(0,1fr);}
  &[data-tc-mobile-view="focus"][data-tc-mobile-source="0"] #videoGrid > [data-tc-source]:not([data-tc-source="0"]),
  &[data-tc-mobile-view="focus"][data-tc-mobile-source="1"] #videoGrid > [data-tc-source]:not([data-tc-source="1"]),
  &[data-tc-mobile-view="focus"][data-tc-mobile-source="2"] #videoGrid > [data-tc-source]:not([data-tc-source="2"]) {display:none;}
  &[data-tc-mobile-view="overview"] #videoGrid:not(.ghost-mode):not(.single-video) {grid-template-columns:repeat(var(--tc-phone-source-count,2),minmax(0,1fr));}
  &[data-tc-mobile-view="overview"] #videoGrid[data-two-video-layout="stacked"]:not(.ghost-mode):not(.single-video) {grid-template-columns:minmax(0,1fr);grid-template-rows:repeat(var(--tc-phone-source-count,2),minmax(0,1fr));}
  #videoGrid .empty-state > :not(.tc-phone-add-video) {display:none;}
  #videoGrid .tc-phone-add-video {display:flex;flex-direction:column;align-items:center;gap:8px;font-size:13px;}
  .tc-phone-add-video::before {content:'+';display:grid;place-items:center;width:32px;height:32px;border-radius:50%;background:var(--ui-selected);color:var(--ui-accent);font-size:22px;line-height:1;font-weight:400;}
  #videoGrid .phone-source-transport {display:none;}
  .analysis-transport {display:flex;flex-wrap:nowrap;align-items:center;justify-content:center;gap:8px;overflow:visible;min-height:48px;margin:6px 0 0;padding:0;border:0;order:2;}
  .transport-playback {display:flex;gap:0;}
  .transport-playback > button {width:44px;min-width:44px;height:44px;min-height:44px;}
  #playPause {background:var(--ui-accent);color:var(--tc-accent-ink,#15200b);border-radius:8px;font-size:0;}
  #playPause::before {border-left-color:currentColor;}
  #playPause.is-playing::before {border-right-color:currentColor;}
  .control-strip {display:grid;grid-template-columns:max-content minmax(0,1fr) max-content;height:48px;min-height:48px;gap:8px;order:3;padding:0;}
  .checkpoint-timeline {position:relative;min-height:44px;padding:0;border-radius:8px;}
  .checkpoint-timeline:has(#timeline:focus-visible) {outline:2px solid var(--tc-focus,var(--ui-accent));outline-offset:2px;}
  #timeline {position:absolute;inset:0;width:100%;height:44px;margin:0;opacity:0;pointer-events:none;}
  .tc-timeline-ruler:not([hidden]) {
    position:absolute;inset:0;display:block;overflow:hidden;border:1px solid var(--ui-line);
    border-radius:8px;background:var(--ui-panel);cursor:ew-resize;touch-action:pan-y;
  }
  .tc-timeline-ruler::before {
    content:'';position:absolute;inset:0;
    background:
      linear-gradient(90deg,var(--ui-muted) 1px,transparent 1px) calc(50% + 20px - var(--timeline-offset,0px)) center / 40px 22px repeat-x,
      linear-gradient(90deg,color-mix(in srgb,var(--ui-muted) 55%,var(--ui-panel)) 1px,transparent 1px) calc(50% + 4px - var(--timeline-offset,0px)) center / 8px 12px repeat-x;
    mask-image:linear-gradient(90deg,transparent,black 11%,black 89%,transparent);
  }
  .tc-timeline-ruler::after {content:'';position:absolute;left:50%;top:6px;bottom:6px;border-left:2px solid var(--ui-accent);}
  .tc-timeline-ruler[data-dragging] {cursor:grabbing;}
  #timelineCheckpoints {display:none;}
  .control-strip > :is(#timeReadout,#durationReadout) {font:11px var(--tc-mono,monospace);min-width:0;white-space:nowrap;}
  .control-strip input[type="range"] {min-height:44px;accent-color:var(--ui-accent);}
  .tc-mobile-checkpoints {display:flex;align-items:center;order:4;}
  .tc-mobile-checkpoints > div {display:flex;align-items:baseline;flex-wrap:wrap;gap:3px 8px;min-width:0;font-size:13px;}
  [data-mobile-phase-name] {color:var(--ui-muted);font-size:11px;}
  .studio-phase-strip {order:5;display:grid;grid-template-columns:repeat(6,minmax(0,1fr));gap:4px;margin:0;padding:0;min-height:44px;}
  .studio-phase {min-width:0;min-height:44px;padding:4px;font-size:12px;}
  .studio-phase :is(strong,small) {display:none;}
  .video-column > .studio-phase-strip > :not(.studio-phase,.studio-checkpoint-popover,.studio-pair-controls,.studio-checkpoint-footer:has(.studio-checkpoint-timing[open])) {display:none;}
  .video-column > .studio-phase-strip > .studio-checkpoint-footer:has(.studio-checkpoint-timing[open]) #confirmAutomaticSync {display:none;}
  .video-column > #nativeFrameReadout {display:none;}
  .video-column > .analysis-activity {position:static;align-self:flex-start;order:7;min-height:44px;box-shadow:none;}
  &[data-mobile-has-footage] .video-column > .analysis-activity {margin-block-start:3px;}
  &:not([data-mobile-has-footage]) .video-column > :is(.tc-mobile-checkpoints,.studio-phase-strip,.control-strip,.analysis-transport) {display:none;}
  :is(#tcMobileTools,#tcMobileToolSheet) [hidden] {display:none;}
}
html .app.experience.tc-mobile-analysis :is(.analysis-column,.video-setup-sidebar) {
  flex:none;width:100%;min-height:0;max-height:none;height:auto;overflow:visible;
  padding:16px 12px 24px;border-top:1px solid var(--ui-line);
}
html .app.experience.tc-mobile-analysis[data-tool-open="false"] :is(.analysis-column,.video-setup-sidebar) {display:none;}
html .app.experience.tc-mobile-analysis :is(.analysis-column,.video-setup-sidebar) :is(button,summary,select) {min-height:44px;font-size:14px;}
html .app.experience.tc-mobile-analysis :is(.analysis-column,.video-setup-sidebar) :is(input:not([type="range"]),textarea,select) {font-size:16px;}
html .app.experience.tc-mobile-analysis .tool-heading-copy {display:block;min-width:0;}
html .app.experience.tc-mobile-analysis .tool-heading-copy p {font-size:14px;line-height:1.45;}
html .app.experience.tc-mobile-analysis .tool-close {font-size:14px;min-height:44px;}
html .app.experience.tc-mobile-analysis .sync-studio-source-heading {font-size:14px;gap:8px;flex-wrap:wrap;}
html .app.experience.tc-mobile-analysis .sync-studio-source-badge {width:24px;height:24px;font-size:14px;}
html .app.experience.tc-mobile-analysis .sync-studio-heading h3 {font-size:16px;line-height:1.4;}
html .app.experience.tc-mobile-analysis .sync-studio-eyebrow {font-size:12px;letter-spacing:0;}
html .app.experience.tc-mobile-analysis .sync-studio-sources {grid-template-columns:minmax(0,1fr);gap:16px;}
html .app.experience.tc-mobile-analysis .sync-studio-source-controls {grid-template-columns:48px minmax(0,1fr) 48px 76px;gap:8px;}
html .app.experience.tc-mobile-analysis .sync-studio-source-controls > :is(input,button) {grid-area:auto;min-height:48px;font-size:14px;}
html .app.experience.tc-mobile-analysis .sync-studio-navigation {grid-template-columns:48px minmax(0,1fr) 48px;gap:8px;}
html .app.experience.tc-mobile-analysis .sync-studio-chip {flex-basis:48px;min-width:48px;min-height:48px;font-size:14px;}
html .app.experience.tc-mobile-analysis .sync-studio-announcement {position:static;width:auto;height:auto;clip-path:none;white-space:normal;font-size:14px;line-height:1.5;margin:0;color:var(--ui-muted);}
html .app.experience.tc-mobile-analysis :is(button,a,input,summary,select,textarea):focus-visible,
#tcMobileFrameEditor :is(button,input):focus-visible {outline:3px solid var(--tc-focus,#b9dfff);outline-offset:2px;}

/* Top-layer precision sheet uses the same mounted video and native controls. */
#tcMobileFrameEditor {
  box-sizing:border-box;inset:0;margin:0;width:100%;max-width:none;
  height:var(--tc-visible-height,100dvh);max-height:none;min-height:0;
  padding:env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  background:var(--ui-bg,#101719);color:var(--ui-text,#f1f5ef);border:0;
  font-family:var(--tc-font,system-ui);overflow:auto;overscroll-behavior:contain;
}
#tcMobileFrameEditor[open] {display:grid;grid-template-rows:auto auto minmax(160px,1fr) auto auto;gap:8px;}
#tcMobileFrameEditor::backdrop {background:#080d0eed;}
#tcMobileFrameEditor [hidden] {display:none;}
#tcMobileFrameEditor button {min-width:44px;min-height:48px;padding:8px 12px;font-size:14px;border-radius:8px;}
#tcMobileFrameEditor .tc-frame-header {display:flex;align-items:center;gap:12px;justify-content:space-between;padding:12px;border-bottom:1px solid var(--ui-line);}
#tcMobileFrameEditor .tc-frame-header > div {min-width:0;}
#tcMobileFrameEditor .tc-frame-header p {font-size:12px;color:var(--ui-muted);margin:0 0 4px;}
#tcMobileFrameEditor h2 {font-size:16px;line-height:1.4;margin:0;overflow-wrap:anywhere;}
#tcMobileFrameEditor .tc-frame-source-tabs {display:flex;gap:8px;padding-inline:12px;}
#tcMobileFrameEditor .tc-frame-source-tabs button {flex:1;background:var(--ui-panel);border:1px solid var(--ui-line);color:var(--ui-text);}
#tcMobileFrameEditor .tc-frame-source-tabs button[aria-pressed="true"] {background:var(--ui-selected);border-color:var(--ui-accent);color:var(--ui-accent);}
#tcMobileFrameEditor .tc-frame-stage {min-width:0;min-height:160px;padding-inline:12px;display:grid;}
#tcMobileFrameEditor .tc-frame-stage > .video-panel {display:grid;grid-template-rows:minmax(0,1fr);min-width:0;min-height:160px;}
#tcMobileFrameEditor #ghostCompositeCanvas {display:none;}
#tcMobileFrameEditor .tc-frame-stage :is(.video-source-header,.phone-source-transport) {display:none;}
#tcMobileFrameEditor .video-stage {min-height:160px;aspect-ratio:auto;width:100%;height:100%;border-radius:12px;}
#tcMobileFrameEditor .tc-frame-controls {padding:4px 12px 0;min-width:0;}
#tcMobileFrameEditor .sync-studio {padding:0;border:0;gap:8px;}
#tcMobileFrameEditor .sync-studio-heading {display:none;}
#tcMobileFrameEditor .sync-studio-sources {grid-template-columns:minmax(0,1fr);}
#tcMobileFrameEditor[data-tc-frame-source="0"] .sync-studio-source:not([data-sync-studio-source="0"]),
#tcMobileFrameEditor[data-tc-frame-source="1"] .sync-studio-source:not([data-sync-studio-source="1"]),
#tcMobileFrameEditor[data-tc-frame-source="2"] .sync-studio-source:not([data-sync-studio-source="2"]) {display:none;}
#tcMobileFrameEditor .sync-studio-source-controls {grid-template-columns:56px minmax(0,1fr) 56px;gap:8px;}
#tcMobileFrameEditor .sync-studio-source-controls > input {grid-column:1/-1;grid-row:1;min-height:48px;}
#tcMobileFrameEditor .sync-studio-source-controls > [data-source-step="-1"] {grid-column:1;grid-row:2;font-size:20px;}
#tcMobileFrameEditor .sync-studio-source-controls > [data-source-step="1"] {grid-column:3;grid-row:2;font-size:20px;}
#tcMobileFrameEditor .sync-studio-source-controls > .sync-studio-set {grid-column:2;grid-row:2;background:var(--ui-accent);color:var(--tc-accent-ink,#15200b);font-size:16px;}
#tcMobileFrameEditor .tc-frame-help {margin:0;padding:0 12px 12px;font-size:12px;line-height:1.5;color:var(--ui-muted);}

@media (max-width:359px) {
  html .app.experience.tc-mobile-analysis {--tc-phone-inset:8px;}
  html .app.experience.tc-mobile-analysis .sync-studio-source-controls {grid-template-columns:48px minmax(0,1fr) 48px;}
  html .app.experience.tc-mobile-analysis .sync-studio-source-controls > .sync-studio-set {grid-column:1/-1;}
}
@media (orientation:landscape) and (min-width:560px) and (max-height:500px) {
  html .app.experience.tc-mobile-analysis {
    padding-bottom:env(safe-area-inset-bottom);
    .primary-nav {display:none;}
    .video-column:has(> #videoGrid) {
      display:grid;grid-template-columns:minmax(0,1fr) minmax(284px,34%);
      grid-template-rows:44px repeat(5,auto) minmax(0,1fr);column-gap:12px;padding-top:0;
    }
    .tc-mobile-context {grid-area:1 / 1;}
    #videoGrid {grid-area:2 / 1 / -1 / 2;min-height:128px;height:100%;}
    .analysis-transport {grid-area:2 / 2;margin:0;}
    .control-strip {grid-area:3 / 2;}
    .tc-mobile-checkpoints {grid-area:4 / 2;}
    .video-column > .studio-phase-strip {grid-area:5 / 2;}
    .video-column > .analysis-activity {grid-area:7 / 2;align-self:start;justify-self:start;}
    &:not([data-mobile-has-footage]) .video-column:has(> #videoGrid) {grid-template-columns:minmax(0,1fr);}
  }
  #tcMobileFrameEditor[open] {grid-template-columns:minmax(0,1.2fr) minmax(280px,1fr);grid-template-rows:auto auto minmax(160px,1fr) auto;}
  #tcMobileFrameEditor .tc-frame-header {grid-column:1/-1;padding-block:4px;}
  #tcMobileFrameEditor .tc-frame-source-tabs {grid-column:2;grid-row:2;}
  #tcMobileFrameEditor .tc-frame-stage {grid-column:1;grid-row:2/5;padding-right:0;}
  #tcMobileFrameEditor .tc-frame-controls {grid-column:2;grid-row:3;}
  #tcMobileFrameEditor .tc-frame-help {grid-column:2;grid-row:4;}
}
@media (prefers-reduced-motion:reduce) {
  .tc-mobile-context button,#tcMobileFrameEditor button {transition:none;transform:none;}
}

html .app.experience.tc-mobile-analysis #comparisonLayoutControl {padding:0 0 16px;justify-content:flex-start;}
html .app.experience.tc-mobile-analysis #comparisonLayoutControl button {min-height:44px;font-size:14px;}
html .app.experience.tc-mobile-analysis #nativeFrameReadout {font-size:12px;line-height:1.5;white-space:normal;overflow-wrap:anywhere;}
