.workspace-stack { min-width: 0; min-height: 0; position: relative; }
.workspace-page { position: absolute; inset: 0; display: none; min-width: 0; min-height: 0; }
.workspace-page.active { display: block; }

/* Track workspace */
#trackWorkspace.active { display: grid; grid-template-rows: minmax(0, 1fr) 144px; }
.track-upper { min-width: 0; min-height: 0; display: grid; grid-template-columns: 60px minmax(380px, 1fr) 310px; }
.toolbar { padding: .85rem 0; display: flex; flex-direction: column; align-items: center; gap: .4rem; border-right: 1px solid var(--stroke); background: var(--panel); }
.tool {
  position: relative; width: 42px; height: 42px; display: grid; place-items: center;
  border: 1px solid transparent; border-radius: 9px; color: var(--muted); background: transparent; cursor: pointer; font-size: 1.15rem;
}
.tool:hover { color: var(--text); background: var(--panel-raised); }
.tool.active { border-color: rgba(157, 124, 255, .42); color: var(--primary-bright); background: rgba(157, 124, 255, .14); }
.tool::after {
  content: attr(data-tip); position: absolute; left: 50px; top: 8px; z-index: 30; pointer-events: none;
  opacity: 0; transform: translateX(-4px); white-space: nowrap; padding: .4rem .55rem;
  border: 1px solid var(--stroke); border-radius: 6px; color: var(--text); background: #2a2034; font-size: .75rem; transition: .15s;
}
.tool:hover::after { opacity: 1; transform: translateX(0); }
.tool-separator { width: 30px; height: 1px; margin: .35rem 0; background: var(--stroke); }

.stage { min-width: 0; min-height: 0; padding: 1rem; display: grid; }
.viewport-shell { min-width: 0; min-height: 0; position: relative; overflow: hidden; border: 1px solid var(--stroke); border-radius: 13px; background: #030205; box-shadow: var(--shadow); }
.canvas-wrap { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; overflow: hidden; }
#videoCanvas { display: block; max-width: 100%; max-height: 100%; cursor: crosshair; background: #030205; }
#sourceVideo { position: fixed; left: -10px; top: -10px; width: 1px; height: 1px; opacity: .001; pointer-events: none; }
.empty-state { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; }
.empty-state.hidden { display: none; }
.empty-inner { max-width: 470px; padding: 2rem; }
.empty-icon { width: 70px; height: 70px; margin: 0 auto 1rem; display: grid; place-items: center; border: 1px solid var(--primary); border-radius: 50%; color: var(--primary-bright); background: rgba(157, 124, 255, .1); font-size: 1.45rem; }
.empty-inner h1 { margin-bottom: .65rem; font-size: 1.25rem; }
.empty-inner .btn { margin-top: .5rem; pointer-events: auto; }
.loading-state { position: absolute; inset: 0; z-index: 12; display: grid; place-items: center; background: rgba(3, 2, 5, .92); backdrop-filter: blur(6px); }
.loading-state.hidden { display: none; }
.loading-card { width: min(390px, calc(100% - 2rem)); display: grid; grid-template-columns: 42px 1fr auto; align-items: center; gap: .8rem; padding: 1rem; border: 1px solid var(--stroke); border-radius: 12px; background: var(--panel); box-shadow: var(--shadow); }
.loading-card strong { display: block; margin-top: .2rem; font-size: .9rem; }
.loading-spinner { width: 36px; height: 36px; border: 3px solid var(--stroke); border-top-color: var(--primary-bright); border-radius: 50%; animation: loadingSpin .8s linear infinite; }
.video-load-progress { grid-column: 1 / 4; height: 7px; overflow: hidden; border: 1px solid var(--stroke-soft); border-radius: 8px; background: var(--workspace); }
.video-load-progress > div { width: 0; height: 100%; background: linear-gradient(90deg, var(--primary-deep), var(--primary-bright)); transition: width .2s ease; }
#videoLoadPercent { color: var(--primary-bright); font: .75rem ui-monospace, monospace; }
@keyframes loadingSpin { to { transform: rotate(360deg); } }
.viewport-hud { position: absolute; left: .8rem; top: .8rem; display: flex; gap: .4rem; pointer-events: none; }
.hud-chip { padding: .38rem .48rem; border: 1px solid rgba(82, 61, 99, .75); border-radius: 6px; color: var(--muted); background: rgba(11, 7, 16, .84); font: .7rem ui-monospace, SFMono-Regular, Consolas, monospace; backdrop-filter: blur(7px); }
.hud-chip strong { color: var(--text); font-weight: 600; }
.selection-readout { position: absolute; left: .8rem; bottom: .8rem; display: none; padding: .4rem .55rem; border: 1px solid rgba(157, 124, 255, .4); border-radius: 6px; color: var(--primary-bright); background: rgba(20, 12, 28, .88); font: .7rem ui-monospace, monospace; }
.selection-readout.show { display: block; }

.context-panel { min-height: 0; overflow-y: auto; padding: 1rem; border-left: 1px solid var(--stroke); background: var(--panel); scrollbar-width: thin; scrollbar-color: var(--stroke) transparent; }
.panel-section { margin-bottom: .85rem; padding: 1rem; border: 1px solid var(--stroke-soft); border-radius: 10px; background: var(--panel-raised); }
.icon-btn { width: 30px; height: 30px; display: grid; place-items: center; border: 1px solid var(--stroke); border-radius: 7px; color: var(--primary-bright); background: var(--workspace); cursor: pointer; }
.icon-actions { display: flex; gap: .35rem; }
.icon-btn.danger { color: var(--danger); }
.track-list { display: grid; gap: .3rem; margin: .8rem 0; }
.track-row { display: grid; grid-template-columns: 11px 1fr auto; align-items: center; gap: .55rem; padding: .55rem; border: 1px solid transparent; border-radius: 7px; cursor: pointer; font-size: .82rem; }
.track-row:hover { background: var(--panel-hover); }
.track-row.active { border-color: rgba(157, 124, 255, .28); background: rgba(157, 124, 255, .1); }
.track-swatch { width: 9px; height: 9px; border-radius: 50%; }
.track-count { color: var(--muted); font-size: .75rem; }
.summary-line { display: flex; justify-content: space-between; gap: .4rem; margin-top: .75rem; font-size: .75rem; }
.summary-line strong { color: var(--text); }
.disclosure { padding: 0; }
.disclosure summary { padding: .9rem 1rem; cursor: pointer; color: var(--primary-bright); font-size: .8rem; font-weight: 730; letter-spacing: .04em; }
.disclosure-body { display: grid; gap: .7rem; padding: 0 1rem 1rem; }
.profile-description { margin: -.1rem 0 0; color: var(--primary-bright); font-size: .75rem; line-height: 1.45; }
.tracker-advanced { border: 1px solid var(--stroke-soft); border-radius: 8px; background: var(--workspace); }
.tracker-advanced summary { padding: .65rem .7rem; color: var(--muted); cursor: pointer; font-size: .76rem; font-weight: 650; }
.tracker-advanced > div { display: grid; gap: .65rem; padding: 0 .7rem .75rem; }
.progress { height: 6px; overflow: hidden; border: 1px solid var(--stroke-soft); border-radius: 8px; background: var(--workspace); }
.progress > div { width: 0; height: 100%; background: linear-gradient(90deg, var(--primary-deep), var(--primary-bright)); transition: width .1s; }
.tracking-controls { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: .45rem; }
.track-edit-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .4rem; padding-top: .15rem; border-top: 1px solid var(--stroke-soft); }
.track-edit-row .btn { padding-inline: .4rem; font-size: .75rem; }

.timeline-panel { min-width: 0; padding: .8rem 1rem; border-top: 1px solid var(--stroke); background: var(--panel); }
.timeline-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .5rem; }
.time-readout { color: var(--muted); font: .75rem ui-monospace, SFMono-Regular, Consolas, monospace; }
#timeline { width: 100%; }
.timeline-controls { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 1rem; margin-top: .65rem; }
.transport { display: flex; gap: .35rem; }
.transport .play { min-width: 48px; }
.range-controls { display: flex; gap: .6rem; }
.range-controls label { display: flex; align-items: center; gap: .35rem; color: var(--muted); font-size: .75rem; font-weight: 700; }
.range-controls input { width: 72px; height: 30px; }
.timeline-legend { display: flex; justify-content: flex-end; gap: .9rem; color: var(--faint); font-size: .72rem; }
.legend-dot { display: inline-block; width: 8px; height: 8px; margin-right: .25rem; border-radius: 50%; }
.legend-dot.anchor { background: var(--primary-bright); }
.legend-dot.automatic { background: var(--success); }
.legend-dot.review { background: var(--warning); }

/* Analyze workspace */
#analyzeWorkspace { overflow: auto; }
.analysis-main { min-height: 100%; display: grid; grid-template-columns: minmax(480px, 1fr) 340px; }
.analysis-surface { min-width: 0; padding: 1.5rem 2rem 2rem; display: grid; grid-template-rows: auto auto auto auto; align-content: start; gap: 1rem; }
.workspace-heading { display: flex; align-items: end; justify-content: space-between; gap: 1rem; }
.workspace-heading h1 { margin-top: .25rem; }
.metric-cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .75rem; }
.metric-card { min-width: 0; padding: 1rem; border: 1px solid var(--stroke-soft); border-radius: 10px; background: var(--panel); }
.metric-card span { display: block; margin-bottom: .4rem; color: var(--muted); font-size: .75rem; }
.metric-card strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 1rem; font-variant-numeric: tabular-nums; }
.metric-card.accent { border-color: rgba(157, 124, 255, .34); background: linear-gradient(145deg, rgba(157, 124, 255, .12), var(--panel)); }
.metric-card.accent strong { color: var(--primary-bright); }
.chart-card { display: grid; gap: .65rem; padding: .85rem; border: 1px solid var(--stroke); border-radius: 11px; background: var(--panel); box-shadow: 0 12px 34px rgba(0, 0, 0, .16); }
.chart-toolbar { display: grid; grid-template-columns: minmax(145px, 1.1fr) minmax(125px, .8fr) minmax(125px, .8fr) auto; align-items: end; gap: .55rem; }
.chart-toolbar label { display: grid; gap: .25rem; color: var(--muted); font-size: .72rem; font-weight: 650; }
.chart-toolbar select { height: 32px; }
.graph-legend { min-height: 28px; display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; }
.legend-toggle { display: inline-flex; align-items: center; gap: .38rem; min-height: 27px; padding: .25rem .5rem; border: 1px solid var(--stroke-soft); border-radius: 6px; color: var(--muted); background: var(--workspace); cursor: pointer; font-size: .72rem; }
.legend-toggle:hover { border-color: var(--stroke); color: var(--text); }
.legend-toggle.hidden-series { opacity: .42; text-decoration: line-through; }
.legend-swatch { width: 14px; height: 3px; border-radius: 2px; }
.graph-shell { position: relative; width: 100%; height: clamp(270px, 36vh, 380px); overflow: hidden; border: 1px solid var(--stroke); border-radius: 9px; background: var(--workspace); }
#graphCanvas { width: 100%; height: 100%; display: block; cursor: crosshair; touch-action: none; }
#graphCanvas.dragging { cursor: grabbing; }
.graph-tooltip { position: absolute; z-index: 4; display: none; min-width: 170px; max-width: 230px; padding: .55rem .65rem; border: 1px solid rgba(157, 124, 255, .42); border-radius: 7px; color: var(--text); background: rgba(20, 12, 28, .95); box-shadow: var(--shadow); pointer-events: none; font-size: .72rem; line-height: 1.45; }
.graph-tooltip.show { display: block; }
.graph-tooltip strong { color: var(--primary-bright); }
.tooltip-row { display: flex; justify-content: space-between; gap: .8rem; }
.graph-instructions { margin: 0; color: var(--faint); font-size: .72rem; }
.method-note { margin: 0; color: var(--faint); font-size: .75rem; }
.method-assumptions { border: 1px solid var(--stroke-soft); border-radius: 9px; background: var(--panel); }
.method-assumptions summary { padding: .75rem .9rem; color: var(--muted); cursor: pointer; font-size: .8rem; font-weight: 650; }
.method-assumptions > div { padding: 0 .9rem .8rem; }
.method-assumptions p, .method-assumptions li { color: var(--faint); font-size: .75rem; line-height: 1.5; }
.method-assumptions ul { margin: .5rem 0 0; padding-left: 1.1rem; }
.analysis-settings { padding: 1rem; border-left: 1px solid var(--stroke); background: var(--panel); }
.settings-card { display: grid; gap: .85rem; margin-bottom: 1rem; padding: 1rem; border: 1px solid var(--stroke-soft); border-radius: 10px; background: var(--panel-raised); }
.readout-row { display: flex; justify-content: space-between; color: var(--muted); font-size: .82rem; }
.readout-row strong { color: var(--text); }
.calibration-actions { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }

/* Project workspace */
#projectWorkspace { overflow: auto; }
.project-shell { width: min(1120px, calc(100% - 2rem)); margin: 0 auto; padding: 2rem 0 3rem; }
.project-heading { margin-bottom: 1.5rem; }
.project-heading > p { max-width: 430px; margin: 0; text-align: right; }
.project-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.project-card { display: grid; align-content: start; gap: .8rem; min-height: 250px; padding: 1.35rem; border: 1px solid var(--stroke); border-radius: 12px; background: var(--panel); box-shadow: 0 12px 38px rgba(0, 0, 0, .16); }
.project-card.primary-card { border-color: rgba(157, 124, 255, .38); background: linear-gradient(145deg, rgba(157, 124, 255, .11), var(--panel)); }
.card-icon { width: 42px; height: 42px; display: grid; place-items: center; border: 1px solid var(--stroke); border-radius: 10px; color: var(--primary-bright); background: var(--panel-raised); }
.project-card p { margin-bottom: .25rem; }
.shortcut-list { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem 1rem; margin: .2rem 0 0; }
.shortcut-list div { display: flex; gap: .55rem; align-items: center; }
.shortcut-list dt { min-width: 62px; padding: .2rem .4rem; border: 1px solid var(--stroke); border-radius: 5px; color: var(--primary-bright); background: var(--workspace); text-align: center; font: .75rem ui-monospace, monospace; }
.shortcut-list dd { margin: 0; color: var(--muted); font-size: .8rem; }
.danger-zone { border-color: rgba(255, 113, 139, .18); }

@media (max-width: 1100px) {
  .track-upper { grid-template-columns: 56px minmax(320px, 1fr) 280px; }
  .analysis-main { grid-template-columns: minmax(430px, 1fr) 300px; }
  .metric-cards { grid-template-columns: repeat(2, 1fr); }
  .chart-toolbar { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .chart-toolbar .btn { grid-column: 1 / 4; }
}

@media (max-width: 820px) {
  html, body { overflow: auto; }
  .app { min-width: 760px; min-height: 720px; }
  .track-upper { grid-template-columns: 56px minmax(420px, 1fr); }
  .context-panel { position: absolute; z-index: 15; right: 0; top: 0; bottom: 144px; width: 300px; box-shadow: var(--shadow); }
  .analysis-main { grid-template-columns: 1fr; }
  .analysis-settings { border-left: 0; border-top: 1px solid var(--stroke); }
}

/* Batch-assisted editor banner */
.batch-editor-banner {
  position: absolute; z-index: 25; left: 76px; right: 326px; top: .75rem;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .7rem .8rem; border: 1px solid rgba(157, 124, 255, .45); border-radius: 10px;
  background: rgba(24, 16, 34, .96); box-shadow: var(--shadow); backdrop-filter: blur(8px);
}
.batch-editor-banner.hidden { display: none; }
.batch-editor-banner > div:first-child { min-width: 0; display: grid; grid-template-columns: auto 1fr; gap: .15rem .65rem; align-items: baseline; }
.batch-editor-banner .eyebrow { grid-column: 1; }
.batch-editor-banner strong { grid-column: 2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#batchEditorHint { grid-column: 1 / 3; color: var(--muted); font-size: .72rem; }
.batch-editor-actions { display: flex; flex: 0 0 auto; gap: .45rem; }

/* Multi-graph analysis dashboard */
.analysis-dashboard-toolbar {
  display: grid; grid-template-columns: minmax(220px, 1fr) auto auto auto; align-items: end; gap: .7rem;
  padding: .8rem .9rem; border: 1px solid var(--stroke-soft); border-radius: 10px; background: var(--panel);
}
.analysis-dashboard-toolbar > div { display: grid; gap: .18rem; }
.analysis-dashboard-toolbar strong { font-size: .88rem; }
.analysis-dashboard-toolbar > label:not(.check) { display: grid; gap: .25rem; color: var(--muted); font-size: .72rem; font-weight: 650; }
.analysis-dashboard-toolbar select { min-width: 110px; height: 32px; }
.compact-check { align-self: center; margin-bottom: .25rem; white-space: nowrap; }
.chart-grid { display: grid; grid-template-columns: 1fr; gap: 1rem; align-items: start; }
.chart-grid.layout-2, .chart-grid.layout-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.chart-grid.layout-2 .primary-chart-card, .chart-grid.layout-4 .primary-chart-card { min-width: 0; }
.chart-grid.layout-2 .graph-shell, .chart-grid.layout-4 .graph-shell { height: clamp(240px, 30vh, 330px); }
.dashboard-chart { min-width: 0; }
.dashboard-chart.hidden { display: none; }
.mini-chart-toolbar { display: flex; align-items: end; justify-content: space-between; gap: .7rem; }
.mini-chart-toolbar label { display: grid; gap: .25rem; color: var(--muted); font-size: .72rem; font-weight: 650; }
.mini-chart-toolbar select { min-width: 160px; height: 32px; }
.mini-chart-note { color: var(--faint); font-size: .68rem; }
.dashboard-canvas { width: 100%; height: clamp(240px, 30vh, 330px); display: block; border: 1px solid var(--stroke); border-radius: 9px; background: var(--workspace); cursor: crosshair; }
.quick-export-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .45rem; }
.quick-export-grid > :last-child:nth-child(odd) { grid-column: 1 / -1; }

/* Batch workspace */
#batchWorkspace { overflow: auto; }
.batch-shell { width: min(1560px, calc(100% - 2rem)); margin: 0 auto; padding: 1.4rem 0 3rem; }
.batch-heading { align-items: center; margin-bottom: 1rem; }
.batch-heading p { max-width: 780px; margin: .45rem 0 0; }
.batch-import-actions { flex: 0 0 auto; }
.batch-control-card {
  display: grid; grid-template-columns: minmax(340px, 1fr) auto; gap: .8rem 1rem; align-items: center;
  margin-bottom: 1rem; padding: .9rem 1rem; border: 1px solid var(--stroke); border-radius: 11px; background: var(--panel);
}
.batch-control-group { display: flex; align-items: end; gap: .8rem; min-width: 0; }
.batch-control-group label { display: grid; gap: .25rem; color: var(--muted); font-size: .72rem; font-weight: 650; }
.batch-control-group select { min-width: 140px; }
.batch-control-group .hint { margin: 0 0 .1rem; max-width: 580px; }
.batch-run-actions { display: flex; gap: .45rem; justify-content: flex-end; }
.batch-overall-progress { grid-column: 1 / -1; height: 7px; overflow: hidden; border: 1px solid var(--stroke-soft); border-radius: 8px; background: var(--workspace); }
.batch-overall-progress > div { width: 0; height: 100%; background: linear-gradient(90deg, var(--primary-deep), var(--primary-bright)); transition: width .2s; }
.batch-summary-strip { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 1rem; color: var(--muted); font-size: .75rem; }
.batch-summary-strip strong { color: var(--text); }
.batch-main-grid { display: grid; grid-template-columns: minmax(520px, 1.05fr) minmax(520px, .95fr); gap: 1rem; align-items: start; }
.batch-queue-panel { min-width: 0; padding: 1rem; border: 1px solid var(--stroke); border-radius: 11px; background: var(--panel); }
.batch-queue-panel h2, .batch-results-panel h2 { margin-top: .2rem; font-size: 1rem; }
.batch-job-list { display: grid; gap: .65rem; margin-top: .85rem; }
.batch-empty { padding: 2rem 1rem; border: 1px dashed var(--stroke); border-radius: 9px; color: var(--faint); text-align: center; }
.batch-job {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .65rem .8rem;
  padding: .8rem; border: 1px solid var(--stroke-soft); border-radius: 9px; background: var(--panel-raised);
}
.batch-job.running { border-color: rgba(157, 124, 255, .45); }
.batch-job.review { border-color: rgba(240, 185, 106, .42); }
.batch-job.complete { border-color: rgba(101, 214, 173, .32); }
.batch-job.error { border-color: rgba(255, 113, 139, .42); }
.batch-job-main { min-width: 0; display: grid; gap: .4rem; }
.batch-job-title { display: flex; align-items: baseline; gap: .55rem; min-width: 0; }
.batch-job-title strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.batch-status-pill { flex: 0 0 auto; padding: .18rem .4rem; border: 1px solid var(--stroke); border-radius: 999px; color: var(--muted); font-size: .65rem; text-transform: uppercase; letter-spacing: .06em; }
.batch-job.running .batch-status-pill { color: var(--primary-bright); border-color: rgba(157,124,255,.42); }
.batch-job.review .batch-status-pill { color: var(--warning); border-color: rgba(240,185,106,.4); }
.batch-job.complete .batch-status-pill { color: var(--success); border-color: rgba(101,214,173,.34); }
.batch-job.error .batch-status-pill { color: var(--danger); border-color: rgba(255,113,139,.38); }
.batch-job-meta { display: flex; flex-wrap: wrap; gap: .65rem; color: var(--faint); font-size: .7rem; }
.batch-job-meta strong { color: var(--muted); }
.batch-job-progress { height: 5px; overflow: hidden; border-radius: 6px; background: var(--workspace); }
.batch-job-progress > div { width: 0; height: 100%; background: linear-gradient(90deg, var(--primary-deep), var(--primary-bright)); }
.batch-job-message { min-height: 1em; color: var(--muted); font-size: .7rem; }
.batch-job-actions { display: grid; align-content: center; gap: .35rem; min-width: 125px; }
.batch-job-actions .btn { width: 100%; }
.batch-results-panel { min-width: 0; }
.batch-compare-card canvas { width: 100%; height: 270px; display: block; border: 1px solid var(--stroke); border-radius: 8px; background: var(--workspace); }
.batch-compare-card .section-head { align-items: end; }
.batch-compare-card label { display: grid; gap: .25rem; color: var(--muted); font-size: .7rem; font-weight: 650; }
.batch-table-wrap { overflow: auto; max-height: 390px; border: 1px solid var(--stroke-soft); border-radius: 8px; }
.batch-table { width: 100%; border-collapse: collapse; min-width: 690px; font-size: .72rem; }
.batch-table th { position: sticky; top: 0; z-index: 1; padding: .5rem .55rem; color: var(--muted); background: var(--panel); text-align: right; font-weight: 700; }
.batch-table th:first-child { text-align: left; }
.batch-table td { padding: .5rem .55rem; border-top: 1px solid var(--stroke-soft); text-align: right; font-variant-numeric: tabular-nums; }
.batch-table td:first-child { max-width: 190px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left; color: var(--text); }
.batch-table tr:hover td { background: rgba(157,124,255,.05); }
.batch-table .review-cell { color: var(--warning); }

@media (max-width: 1250px) {
  .analysis-dashboard-toolbar { grid-template-columns: 1fr auto auto; }
  .analysis-dashboard-toolbar > .btn { grid-column: 1 / -1; }
  .batch-main-grid { grid-template-columns: 1fr; }
}
@media (max-width: 980px) {
  .chart-grid.layout-2, .chart-grid.layout-4 { grid-template-columns: 1fr; }
  .batch-editor-banner { right: 296px; }
  .batch-control-card { grid-template-columns: 1fr; }
  .batch-run-actions { justify-content: flex-start; }
}

/* Batch comparison/QOL refinements */
.batch-compare-controls { display: flex; align-items: end; justify-content: flex-end; gap: .5rem; flex-wrap: wrap; }
.batch-compare-controls label { min-width: 140px; }
.batch-compare-controls select { min-width: 150px; }
#batchWorkspace.drag-active::after {
  content: 'Drop videos to add them to the batch queue';
  position: fixed; z-index: 90; inset: 70px 18px 18px; display: grid; place-items: center;
  border: 2px dashed rgba(157, 124, 255, .75); border-radius: 14px;
  color: var(--primary-bright); background: rgba(14, 10, 20, .88); backdrop-filter: blur(7px);
  font-size: 1.05rem; font-weight: 750; letter-spacing: .01em; pointer-events: none;
}

/* Keep the primary graph controls legible when the dashboard splits into columns. */
.chart-grid.layout-2 .primary-chart-card .chart-toolbar,
.chart-grid.layout-4 .primary-chart-card .chart-toolbar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.chart-grid.layout-2 .primary-chart-card .chart-toolbar .btn,
.chart-grid.layout-4 .primary-chart-card .chart-toolbar .btn { grid-column: auto; }

@media (max-width: 1320px) {
  .batch-compare-card .section-head { align-items: flex-start; }
}
.batch-import-actions { display: flex; gap: .45rem; align-items: center; flex-wrap: wrap; justify-content: flex-end; }

/* Batch collective cockpit v2 */
.batch-auto-check { align-self: center; margin-bottom: .15rem; white-space: nowrap; }
.batch-cockpit {
  display: grid; grid-template-columns: 250px minmax(520px, 1fr) 330px; gap: .9rem;
  margin-bottom: 1rem; min-height: 570px;
}
.batch-cockpit-rail, .batch-cockpit-editor, .batch-cockpit-controls {
  min-width: 0; border: 1px solid var(--stroke); border-radius: 11px; background: var(--panel); overflow: hidden;
}
.batch-cockpit-rail { padding: .8rem; display: flex; flex-direction: column; }
.batch-cockpit-rail h2 { margin-top: .15rem; font-size: .95rem; }
.batch-cockpit-list { margin-top: .7rem; display: grid; gap: .4rem; overflow: auto; max-height: 515px; padding-right: .1rem; }
.batch-cockpit-item {
  width: 100%; text-align: left; display: grid; gap: .28rem; padding: .62rem .65rem; border: 1px solid var(--stroke-soft); border-radius: 8px;
  background: var(--panel-raised); color: var(--text); cursor: pointer;
}
.batch-cockpit-item:hover, .batch-cockpit-item.active { border-color: rgba(157,124,255,.5); background: rgba(157,124,255,.07); }
.batch-cockpit-item.active { box-shadow: inset 3px 0 0 var(--primary-bright); }
.batch-cockpit-item-top { display: flex; align-items: center; gap: .45rem; min-width: 0; }
.batch-cockpit-item-top strong { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .76rem; }
.batch-cockpit-item-meta { display: flex; justify-content: space-between; gap: .4rem; color: var(--faint); font-size: .65rem; }
.batch-confidence-mini { font-variant-numeric: tabular-nums; font-weight: 750; }
.batch-confidence-mini.high { color: var(--success); }
.batch-confidence-mini.medium { color: var(--warning); }
.batch-confidence-mini.low { color: var(--danger); }
.batch-empty.compact { padding: 1rem .65rem; }

.batch-cockpit-editor { position: relative; display: flex; flex-direction: column; background: #09070d; }
.batch-cockpit-empty { flex: 1; display: grid; place-items: center; align-content: center; text-align: center; padding: 2rem; color: var(--muted); }
.batch-cockpit-empty .empty-icon { margin-bottom: .5rem; }
.batch-cockpit-empty h2 { color: var(--text); font-size: 1rem; margin: .2rem 0; }
.batch-cockpit-empty p { max-width: 390px; }
.batch-cockpit-active { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.batch-cockpit-active.hidden, .batch-cockpit-empty.hidden, .batch-setup-controls.hidden, .batch-setup-placeholder.hidden, .batch-cockpit-loading.hidden, .batch-cockpit-selection.hidden { display: none; }
.batch-cockpit-titlebar { display: flex; justify-content: space-between; gap: 1rem; align-items: center; padding: .7rem .8rem; border-bottom: 1px solid var(--stroke-soft); background: var(--panel); }
.batch-cockpit-titlebar > div:first-child { min-width: 0; display: grid; grid-template-columns: auto 1fr; gap: .15rem .55rem; align-items: baseline; }
.batch-cockpit-titlebar .eyebrow { grid-column: 1; }
#batchCockpitName { grid-column: 2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#batchCockpitTiming { grid-column: 1 / 3; color: var(--muted); font-size: .68rem; }
.batch-cockpit-viewport { position: relative; flex: 1; min-height: 400px; display: grid; place-items: center; overflow: hidden; background: #050407; }
#batchSetupCanvas { display: block; width: auto; height: auto; max-width: 100%; max-height: 100%; cursor: crosshair; touch-action: none; }
.batch-cockpit-hud { position: absolute; left: .6rem; top: .6rem; display: flex; gap: .35rem; pointer-events: none; }
.batch-cockpit-hud span { padding: .25rem .4rem; border: 1px solid rgba(255,255,255,.13); border-radius: 5px; background: rgba(9,7,13,.78); color: var(--muted); font: 600 .62rem/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; }
.batch-cockpit-hud strong { color: var(--text); }
.batch-cockpit-loading { position: absolute; inset: 0; z-index: 4; display: grid; place-items: center; align-content: center; gap: .7rem; background: rgba(7,5,10,.83); color: var(--text); }
.batch-cockpit-selection { position: absolute; z-index: 5; border: 1px solid var(--primary-bright); background: rgba(157,124,255,.12); pointer-events: none; }
.batch-cockpit-transport { display: grid; grid-template-columns: auto auto minmax(120px,1fr) auto auto; gap: .35rem; align-items: center; padding: .55rem .7rem; border-top: 1px solid var(--stroke-soft); background: var(--panel); }
.batch-cockpit-transport input[type="range"] { width: 100%; }

.batch-cockpit-controls { padding: .8rem; overflow: auto; max-height: 570px; }
.batch-setup-placeholder { color: var(--muted); padding: .4rem; }
.batch-setup-controls { display: grid; gap: .7rem; }
.batch-step-card { display: grid; grid-template-columns: 28px 1fr; gap: .55rem .65rem; padding: .75rem; border: 1px solid var(--stroke-soft); border-radius: 9px; background: var(--panel-raised); }
.batch-step-card > :not(.batch-step-number):not(div:first-of-type) { grid-column: 1 / 3; }
.batch-step-card h3 { margin: .12rem 0 .2rem; font-size: .83rem; }
.batch-step-card p { margin: 0; color: var(--muted); font-size: .68rem; }
.batch-step-number { width: 26px; height: 26px; display: grid; place-items: center; border-radius: 999px; background: rgba(157,124,255,.13); border: 1px solid rgba(157,124,255,.32); color: var(--primary-bright); font-weight: 800; font-size: .72rem; }
.batch-step-status { padding: .45rem .55rem; border-radius: 6px; border: 1px solid var(--stroke-soft); color: var(--muted); font-size: .68rem; }
.batch-step-status.ready { color: var(--success); border-color: rgba(101,214,173,.25); }
.batch-step-status.warn { color: var(--warning); border-color: rgba(240,185,106,.28); }
.batch-ruler-row, .batch-range-row { display: grid; grid-template-columns: 1fr auto; gap: .4rem; }
.batch-range-row { grid-template-columns: 1fr 1fr; }
.batch-range-row label, .compact-step > label:not(.check) { display: grid; gap: .25rem; color: var(--muted); font-size: .67rem; font-weight: 650; }
.batch-ruler-row select { width: 70px; }
.batch-cockpit-save { display: grid; grid-template-columns: 1fr 1fr; gap: .4rem; }
.batch-cockpit-save .hint { grid-column: 1 / 3; margin: .1rem 0 0; }
.batch-results-grid { margin-top: 0; }

.batch-confidence-badge { display: inline-grid; place-items: center; min-width: 54px; padding: .25rem .45rem; border-radius: 7px; font-size: .72rem; font-weight: 800; font-variant-numeric: tabular-nums; border: 1px solid var(--stroke); }
.batch-confidence-badge.high { color: var(--success); border-color: rgba(101,214,173,.32); background: rgba(101,214,173,.06); }
.batch-confidence-badge.medium { color: var(--warning); border-color: rgba(240,185,106,.34); background: rgba(240,185,106,.06); }
.batch-confidence-badge.low { color: var(--danger); border-color: rgba(255,113,139,.36); background: rgba(255,113,139,.06); }
.batch-termination-note { color: var(--muted); font-size: .66rem; }
.batch-job-title .batch-confidence-badge { margin-left: auto; }
.batch-job.review { box-shadow: inset 3px 0 0 rgba(240,185,106,.65); }
.batch-job.complete.reviewed { border-color: rgba(101,214,173,.45); }

@media (max-width: 1380px) {
  .batch-cockpit { grid-template-columns: 220px minmax(470px,1fr) 300px; }
}
@media (max-width: 1120px) {
  .batch-cockpit { grid-template-columns: 210px minmax(480px,1fr); }
  .batch-cockpit-controls { grid-column: 1 / -1; max-height: none; }
  .batch-setup-controls { grid-template-columns: repeat(3, minmax(0,1fr)); align-items: start; }
  .batch-cockpit-save { grid-column: 1 / -1; }
}

.analysis-quality-strip { display:flex; flex-wrap:wrap; align-items:center; gap:.45rem .9rem; margin:.55rem 0 .7rem; padding:.48rem .65rem; border:1px solid var(--stroke-soft); border-radius:8px; background:rgba(157,124,255,.035); color:var(--muted); font-size:.68rem; }
.analysis-quality-strip strong { color:var(--text); font-variant-numeric:tabular-nums; }
.analysis-quality-note { margin-left:auto; color:var(--faint); }
@media (max-width:900px){ .analysis-quality-note{width:100%;margin-left:0;} }

/* Batch cockpit density: keep the setup surface visible on ordinary laptop displays. */
#batchWorkspace .batch-shell { padding-top: .8rem; }
#batchWorkspace .batch-heading { margin-bottom: .65rem; }
#batchWorkspace .batch-heading p { margin-top: .25rem; line-height: 1.35; }
#batchWorkspace .batch-control-card { margin-bottom: .7rem; padding: .65rem .8rem; gap: .55rem .8rem; }
#batchWorkspace .batch-summary-strip { gap: .8rem; }
#batchWorkspace .batch-cockpit { min-height: 540px; }
#batchWorkspace .batch-cockpit-controls { max-height: 540px; }
#batchWorkspace .batch-cockpit-list { max-height: 485px; }

/* Tracker Xtreme visual identity */
.branded-empty-inner { max-width: 500px; }
.empty-brand-image {
  width: 108px;
  height: 108px;
  display: block;
  margin: 0 auto 1rem;
  object-fit: cover;
  border: 1px solid rgba(183, 146, 255, .38);
  border-radius: 22px;
  box-shadow: 0 0 34px rgba(136, 68, 255, .23);
}
.workspace-brand-title { display: flex; align-items: center; gap: .85rem; min-width: 0; }
.workspace-brand-title > img {
  width: 54px;
  height: 54px;
  flex: 0 0 auto;
  object-fit: cover;
  border: 1px solid rgba(183, 146, 255, .34);
  border-radius: 13px;
  box-shadow: 0 0 22px rgba(136, 68, 255, .17);
}
.project-card-brand {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border: 1px solid rgba(183, 146, 255, .34);
  border-radius: 16px;
  box-shadow: 0 0 24px rgba(136, 68, 255, .17);
}
.branded-project-card { position: relative; overflow: hidden; }
.branded-project-card::after {
  content: "";
  position: absolute;
  right: -54px;
  bottom: -58px;
  width: 190px;
  height: 190px;
  background: url('../assets/trackerxtreme.jpg') center/cover no-repeat;
  border-radius: 50%;
  opacity: .035;
  pointer-events: none;
  filter: saturate(1.2);
}
@media (max-width: 820px) {
  .homepage-link { display: none; }
  .workspace-brand-title > img { width: 44px; height: 44px; }
}
