/* A focused editor within the flight. Native dialog handles focus containment;
   the shared panel palette and controls keep it part of the workspace. */
dialog.timing-workspace {
  position: fixed; inset: 0; width: 100%; height: 100dvh;
  max-width: none; max-height: none; margin: 0; border: 0; border-radius: 0;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  color: var(--text); background: var(--surface); overflow: hidden;
}
.timing-workspace[open] { display: flex; flex-direction: column; }
.timing-workspace [hidden] { display: none !important; }
.timing-workspace button { min-height: 44px; font-size: 14px; }
.timing-workspace button:focus-visible,.timing-workspace input:focus-visible { outline: 2px solid var(--accent); outline-offset: -3px; }
.sync-heading { display: flex; align-items: center; gap: 20px; padding: 8px 24px; border-bottom: 1px solid var(--line); flex-shrink: 0; }
.sync-heading h2 { margin: 0; font-size: 18px; }
.sync-back { background: transparent; }
.sync-angle-choice { margin-left: auto; display: flex; align-items: center; gap: 12px; min-width: 0; }
.sync-angle-choice label { margin: 0; white-space: nowrap; }
.sync-angle-choice select { max-width: 280px; min-width: 0; }
#timing-matcher { flex: 1; min-height: 0; display: flex; flex-direction: column; width: 100%; max-width: 1600px; margin: 0 auto; }
.sync-body { flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; display: flex; flex-direction: column; padding: 0 24px; }
.sync-steps { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; flex-shrink: 0; }
.sync-steps button { display: flex; text-align: left; justify-content: flex-start; align-items: center; gap: 12px; padding: 12px 0; border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: transparent; min-width: 0; color: var(--muted); }
.sync-steps button[aria-pressed=true] { border-bottom-color: var(--accent); color: var(--text); }
.sync-step-number { font-size: 18px; font-variant-numeric: tabular-nums; color: var(--accent); }
.sync-step-copy { min-width: 0; }
.sync-step-copy strong { display: block; font-weight: 600; }
.sync-camera { margin-left: 10px; font-weight: 400; color: var(--muted); }
.sync-step-copy > span { display: block; font-variant-numeric: tabular-nums; font-size: 14px; }
.sync-guide { margin: 10px 0; font-size: 14px; color: var(--muted); flex-shrink: 0; }
.sync-stage { flex: 1; min-height: 160px; display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.sync-stage > section { position: relative; min-width: 0; min-height: 0; background: var(--input); overflow: hidden; }
.sync-stage video { position: absolute; width: 100%; height: 100%; inset: 0; object-fit: contain; }
.sync-video-label { position: absolute; left: 12px; top: 10px; font-size: 14px; color: var(--video-label); text-shadow: 0 1px 3px var(--video-label-shadow); pointer-events: none; padding: 3px 6px; background: color-mix(in srgb, var(--video-label-shadow) 75%, transparent); border-radius: 3px; }
.sync-edit-controls { display: flex; align-items: center; gap: 24px; flex-shrink: 0; padding: 10px 0; }
.sync-seek { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.sync-scrubber { width: 100%; min-width: 0; min-height: 44px; padding: 0; border: 0; accent-color: var(--accent); cursor: pointer; }
.sync-clock { font-size: 15px; font-variant-numeric: tabular-nums; min-width: 65px; text-align: right; }
.sync-transport { display: flex; gap: 8px; }
.sync-play { padding: 10px; min-width: 44px; }
.sync-play svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.sync-mark { min-width: 142px; }
.sync-compare-controls { display: none; align-items: center; justify-content: center; gap: 16px; flex-shrink: 0; padding: 10px 0; }
.sync-overlap,.sync-rotate { color: var(--muted); font-size: 14px; }
.sync-rotate { display: none; }
#timing-matcher[data-comparing=true] .sync-edit-controls { display: none; }
#timing-matcher[data-comparing=true] .sync-compare-controls { display: flex; }
.sync-feedback { flex-shrink: 0; }
.sync-feedback p:empty { display: none; }
.sync-feedback p { margin: 0 0 12px; padding: 0; font-size: 14px; }
.sync-status { color: var(--accent); }
.sync-load { margin-bottom: 12px; }
.sync-footer { display: flex; justify-content: flex-end; align-items: center; gap: 16px; flex-shrink: 0; padding: 12px 24px; border-top: 1px solid var(--line); }
/* Why Save is unavailable, or how the last save went, beside the buttons. */
.sync-why { margin: 0 auto 0 0; font-size: 13px; color: var(--muted); max-width: 60ch; }
.sync-why:empty { display: none; }
.sync-why.error { color: var(--danger); }
@media(max-width:700px) and (orientation:portrait) {
  .sync-heading { padding: 8px 12px; gap: 12px; flex-wrap: wrap; }
  .sync-heading h2 { font-size: 17px; }
  .sync-angle-choice { width: 100%; }
  .sync-angle-choice select { flex: 1; max-width: none; }
  .sync-body { padding: 0 12px; }
  .sync-steps { gap: 12px; }
  .sync-steps button { gap: 8px; padding: 10px 0; }
  .sync-step-copy strong { font-size: 14px; }
  .sync-camera { display: block; margin: 0; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .sync-step-number { display: none; }
  .sync-guide { line-height: 1.4; }
  .sync-stage { grid-template-columns: 1fr; }
  #timing-matcher[data-comparing=false][data-active="0"] [data-preview="1"],
  #timing-matcher[data-comparing=false][data-active="1"] [data-preview="0"] { display: none; }
  #timing-matcher[data-comparing=true] .sync-stage { grid-template-rows: 1fr 1fr; min-height: 240px; gap: 8px; }
  .sync-edit-controls { display: block; padding: 4px 0 10px; }
  .sync-seek { gap: 12px; }
  .sync-transport { gap: 6px; }
  .sync-transport button { padding: 10px 8px; }
  .sync-mark { flex: 1; min-width: 0; }
  .sync-compare-controls { flex-wrap: wrap; gap: 6px 12px; padding: 8px 0; }
  .sync-rotate { display: block; width: 100%; text-align: center; }
  .sync-footer { padding: 10px 12px; gap: 8px; flex-wrap: wrap; }
  .sync-footer button { flex: 1; padding: 10px 8px; }
  .sync-why { flex-basis: 100%; }
}
@media(max-height:550px) and (orientation:landscape) {
  .sync-heading { padding: 2px 330px 2px 12px; gap: 12px; flex-wrap: wrap; }
  .sync-heading h2 { font-size: 16px; }
  .sync-angle-choice label { display: none; }
  .sync-body { padding: 0 12px; }
  .sync-steps { gap: 12px; }
  .sync-steps button { padding: 4px 0; gap: 8px; }
  .sync-camera { display: none; }
  .sync-guide { margin: 4px 0; font-size: 13px; }
  .sync-stage { min-height: 110px; gap: 12px; }
  .sync-edit-controls { padding: 4px 0; gap: 16px; }
  .sync-transport { gap: 6px; }
  .sync-transport button { padding: 8px 10px; }
  .sync-mark { min-width: 130px; }
  .sync-compare-controls { padding: 4px 0; }
  .sync-footer { position: absolute; top: env(safe-area-inset-top); right: env(safe-area-inset-right); width: 310px; padding: 2px 12px 2px 0; border: 0; gap: 8px; }
  .sync-footer button { padding: 8px 10px; flex: 1; white-space: nowrap; }
  .sync-footer { flex-wrap: wrap; }
  .sync-why { flex-basis: 100%; order: 2; font-size: 12px; }
  .sync-angle-choice { margin: 0; }
  .sync-angle-choice select { max-width: 180px; }
}
@media(max-height:380px) and (orientation:landscape) {
  .sync-guide { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); margin: -1px; }
}

/* Evidence is a side rail on roomy desktops, an optional disclosure elsewhere. */
.sync-diagnostics { flex-shrink: 0; margin: 0 !important; border-top: 1px solid var(--line); }
.sync-diagnostics > summary { min-height: 44px; padding: 10px 0; font-weight: 600; cursor: pointer; }
.sync-diagnostic-content { font-size: 14px; padding-bottom: 16px; }
.sync-diagnostic-content p { margin: 0 0 12px; }
.sync-diagnostic-content h3 { font-size: 14px; margin: 0 0 4px; overflow-wrap: anywhere; }
.sync-diagnostic-content h4 { font-size: 14px; margin: 16px 0 8px; }
.sync-evidence-note,.sync-model-version { color: var(--muted); }
.sync-model-toolbar { display: flex; gap: 12px; align-items: end; margin-bottom: 12px; }
.sync-model-toolbar label { flex: 1; margin: 0; }
.sync-model-toolbar select { font-size: 14px; }
.sync-models { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.sync-models > section { min-width: 0; }
.sync-model-stage { position: relative; height: 190px; background: var(--input); }
.sync-model-stage canvas { width: 100%; height: 100%; display: block; touch-action: none; }
.sync-model-message { position: absolute; inset: 0; margin: 0 !important; padding: 12px; display: grid; place-items: center; color: var(--muted); background: var(--input); }
.sync-model-fit { margin: 8px 0; }
.sync-diagnostic-content dl { display: block; margin: 8px 0 12px; font-size: 13px; }
.sync-diagnostic-content dt { color: var(--muted); margin-top: 6px; }
.sync-diagnostic-content dd { margin: 0; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.sync-diagnostic-content details { margin: 12px 0 !important; }
.sync-diagnostic-content summary { min-height: 44px; padding: 10px 0; cursor: pointer; }
.sync-joints { width: 100%; max-height: 150px; background: var(--input); }
.sync-joints line { stroke: var(--accent); stroke-width: 2; vector-effect: non-scaling-stroke; }
.sync-joints circle { fill: var(--accent); }
.sync-anchor-offset { margin-top: 16px !important; }
.sync-inspect { margin-bottom: 12px; }
.sync-method ol { padding-left: 22px; }
.sync-method li { margin-bottom: 8px; }
@media(min-width:1200px) and (min-height:650px) {
 .sync-body:has(.sync-diagnostics[open]) { display: grid; grid-template-columns: minmax(0,1fr) 400px; grid-template-rows: auto auto auto minmax(180px,1fr) auto auto; grid-template-areas: 'steps evidence' 'guide evidence' 'quality evidence' 'stage evidence' 'controls evidence' 'feedback evidence'; column-gap: 24px; overflow: hidden; }
 .sync-body:has(.sync-diagnostics[open]) > .sync-steps { grid-area: steps; }
 .sync-body:has(.sync-diagnostics[open]) > .sync-guide { grid-area: guide; }
 .sync-body:has(.sync-diagnostics[open]) > .sync-stage { grid-area: stage; }
 .sync-body:has(.sync-diagnostics[open]) > .sync-edit-controls,.sync-body:has(.sync-diagnostics[open]) > .sync-compare-controls { grid-area: controls; }
 .sync-body:has(.sync-diagnostics[open]) > .sync-edit-controls { flex-wrap: wrap; gap: 0; }
 .sync-body:has(.sync-diagnostics[open]) .sync-seek { flex-basis: 100%; }
 .sync-body:has(.sync-diagnostics[open]) .sync-transport { margin-left: auto; }
 .sync-body:has(.sync-diagnostics[open]) > .sync-feedback { grid-area: feedback; }
 .sync-diagnostics[open] { grid-area: evidence; min-height: 0; overflow: auto; border-top: 0; border-left: 1px solid var(--line); padding-left: 20px; }
 .sync-diagnostics[open] > summary { position: sticky; top: 0; z-index: 1; background: var(--surface); }
}
@media(max-width:700px) { .sync-models { gap: 12px; } .sync-model-stage { height: 170px; } }
.sync-person-label { margin: 8px 0 12px; display: block; }
.sync-person { width: 100%; min-width: 0; }
.sync-pose-comparison { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); }
.sync-pose-comparison h3 { margin-bottom: 12px; }
.sync-bend-table { width: 100%; border-collapse: collapse; font-size: 14px; margin: 12px 0; font-variant-numeric: tabular-nums; }
.sync-bend-table caption { text-align: left; margin-bottom: 8px; }
.sync-bend-table th,.sync-bend-table td { padding: 8px 4px; border-bottom: 1px solid var(--line); text-align: right; }
.sync-bend-table th:first-child { text-align: left; }
.sync-bend-table th { font-weight: 500; font-size: inherit; white-space: normal; }
.sync-raw-models { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 16px; }
.sync-detection { border-top: 1px solid var(--line); margin-top: 16px; }
.sync-detection .sync-joints { height: 180px; max-height: none; }
.sync-pair-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; margin: 12px 0; }
.sync-pair-grid button { display: grid; gap: 4px; text-align: left; padding: 10px; }
.sync-pair-grid strong { font-size: 16px; }
.sync-pair-grid small { font-size: 13px; color: var(--muted); }

/* A labelled signal: color never carries the verdict alone. */
.sync-quality { grid-area: quality; flex-shrink: 0; display: flex; align-items: center; gap: 12px; padding: 10px 0; margin-bottom: 10px; border-block: 1px solid var(--line); }
.sync-quality > div { flex: 1; min-width: 0; }
.sync-quality strong { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); }
.sync-quality strong::before { content: ''; width: 10px; height: 10px; flex-shrink: 0; border-radius: 50%; background: currentColor; }
.sync-quality[data-tone=good] strong { color: var(--accent); }
.sync-quality[data-tone=warning] strong { color: var(--warning); }
.sync-quality[data-tone=bad] strong { color: var(--danger); }
.sync-quality p { margin: 4px 0 0; color: var(--muted); font-size: 13px; max-width: 75ch; overflow-wrap: anywhere; }
@media(max-height:500px) and (orientation:landscape) { .sync-quality { padding: 6px 0; margin-bottom: 6px; } }
/* 3D calculation reports use the same evidence disclosure and theme surfaces. */
.sync-quality:has(.body-timing-report){flex-wrap:wrap}
.body-timing-report{flex-basis:100%;min-width:0;color:var(--text);max-height:55vh;overflow:auto}
.body-timing-report>div{padding:.75rem 0;max-width:76ch}
.body-timing-report summary{cursor:pointer;min-height:44px;padding:.5rem 0}
.body-timing-report p{margin:.5rem 0;line-height:1.5}
.body-timing-report dl{overflow-wrap:anywhere}
.body-report-window{border-top:1px solid var(--line);padding:.25rem 0}
.body-report-window details{padding-left:.75rem}
.body-report-timeline{display:flex;flex-wrap:wrap;gap:3px;margin:1rem 0}
.body-report-timeline span{padding:.3rem;font-size:.75rem;border:1px solid var(--warning);border-radius:3px}
.body-report-timeline [data-state="supports"]{border-color:var(--accent)}
.body-report-timeline [data-state="contradicts"]{border-color:var(--danger)}
.body-report-skeleton,.body-report-curve{display:block;width:100%;max-width:340px;background:var(--surface);border:1px solid var(--line)}
.body-report-view-0{stroke:var(--accent);fill:none;stroke-width:2}
.body-report-view-1{stroke:var(--text);fill:none;stroke-width:2;stroke-dasharray:5 3}
.body-report-curve text{fill:var(--text);font-size:10px}
.body-report-table{overflow-x:auto}
.body-report-table table{border-collapse:collapse;width:100%;font-variant-numeric:tabular-nums}
.body-report-table th,.body-report-table td{padding:.4rem;text-align:left;border-bottom:1px solid var(--line)}
.sync-body:has(.body-timing-report[open]){overflow:auto}
.body-timing-report summary:focus-visible{outline:2px solid var(--accent);outline-offset:-2px}
.body-report-table tr[data-state="exceeds"] td:first-of-type{color:var(--warning);font-weight:600}
