:root {
  color-scheme: light;
  --bg: #edf1f4;
  --panel: #ffffff;
  --panel-soft: #f6f8fa;
  --ink: #17202a;
  --muted: #6a7482;
  --line: #d7dde5;
  --accent: #128273;
  --accent-dark: #0b6b5f;
  --accent-soft: #def3ee;
  --warn: #b36b00;
  --danger: #c33f3c;
  --ok: #16774e;
  --shadow: 0 14px 36px rgba(32, 43, 55, 0.1);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

button, input, select { font: inherit; }

button, a { -webkit-tap-highlight-color: transparent; }

.preprocess-app {
  max-width: 1680px;
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px;
  display: grid;
  grid-template-rows: auto auto auto minmax(520px, 1fr) auto;
  grid-template-areas:
    "header"
    "import"
    "progress"
    "workspace"
    "next";
  gap: 14px;
}

.topbar { grid-area: header; }
.import-panel { grid-area: import; }
.progress-panel { grid-area: progress; }
.workspace { grid-area: workspace; }
.next-step-bar { grid-area: next; }

.topbar,
.import-panel,
.progress-panel,
.workspace,
.next-step-bar {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.topbar,
.next-step-bar,
.storyboard-header,
.panel-heading,
.progress-meta,
.dialog-header,
.dialog-actions,
.timeline-control {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.topbar {
  grid-template-columns: minmax(210px, 1fr) minmax(420px, 560px) minmax(210px, 1fr);
  padding: 15px 18px;
}

.workflow-steps {
  min-width: 420px;
  max-width: 560px;
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.workflow-steps > a,
.workflow-steps > span {
  min-width: 0;
  min-height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 5px 8px;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
}

.workflow-steps > a:hover { color: var(--ink); background: #fff; }
.workflow-steps > a.active { border-color: #a9d7ce; background: #fff; color: var(--accent-dark); }
.workflow-steps > a > span, .workflow-steps > span > span { flex: 0 0 auto; font-variant-numeric: tabular-nums; }

.brand-block p,
.brand-block h1,
.storyboard-header h2,
.dialog-header h2 { margin: 0; letter-spacing: 0; }

.brand-block p,
.storyboard-header small,
.panel-heading small,
.dialog-header small {
  color: var(--muted);
  font-size: 12px;
}

.brand-block h1 { margin-top: 3px; font-size: 23px; }
.storyboard-header h2, .dialog-header h2 { margin-top: 3px; font-size: 19px; }

.topbar-actions,
.storyboard-actions,
.next-step-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.topbar-actions { justify-content: flex-end; }

.workspace-command {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: #344054;
  font-size: 12px;
  font-weight: 750;
  text-decoration: none;
  white-space: nowrap;
}

.workspace-command:hover { border-color: #9da9b7; background: var(--panel-soft); }

.next-step-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.next-step-main-actions,
.next-step-later-action {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.next-step-later-action {
  padding-left: 14px;
  border-left: 1px solid var(--line);
}

.next-step-later-action > span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.next-step-later-action .next-step-video-button {
  background: var(--panel-soft);
  color: var(--muted);
}

.next-step-later-action .next-step-video-button:hover:not(:disabled) {
  color: var(--ink);
}

.status-pill,
.selection-summary {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.status-pill.running { color: var(--warn); border-color: #e5c17f; background: #fff7e8; }
.status-pill.ready { color: var(--ok); border-color: #b9ddcb; background: #edf9f2; }
.status-pill.failed { color: var(--danger); border-color: #e8b7b5; background: #fff2f2; }

.icon-button,
.icon-link {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: #344054;
  cursor: pointer;
  text-decoration: none;
}

.icon-button:hover, .icon-link:hover { border-color: #9da9b7; background: var(--panel-soft); }
.icon-button.danger { color: var(--danger); }
.icon-button:disabled { opacity: 0.45; cursor: not-allowed; }

[hidden] { display: none !important; }

.import-panel {
  min-width: 0;
  display: grid;
  gap: 14px;
  padding: 14px;
}

.import-panel-head,
.analysis-start-row {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.import-panel-title {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.import-panel-title small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.import-panel-title strong { font-size: 15px; }

.import-source-tabs {
  width: min(360px, 100%);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.import-source-tabs button {
  min-width: 0;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
}

.import-source-tabs button:hover { color: var(--ink); background: #fff; }
.import-source-tabs button.active { border-color: #a9d7ce; background: #fff; color: var(--accent-dark); }

.import-mode-panel { min-width: 0; }

#videoInput { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

.local-drop-zone {
  min-width: 0;
  min-height: 86px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 16px;
  border: 1px dashed #9ca9b8;
  border-radius: 7px;
  background: var(--panel-soft);
  color: var(--ink);
  cursor: pointer;
  transition: border-color 180ms ease, background-color 180ms ease;
}

.local-drop-zone:hover,
.local-drop-zone.dragging {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.drop-zone-icon {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  color: var(--accent-dark);
}

.drop-zone-icon svg { width: 26px; height: 26px; }

.drop-zone-copy {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.drop-zone-copy strong { font-size: 14px; }
.drop-zone-copy small { color: var(--muted); font-size: 12px; line-height: 1.4; }

.collector-panel {
  min-width: 0;
}

.collector-link-zone {
  min-width: 0;
  height: 86px;
  min-height: 86px;
  display: grid;
  grid-template-rows: 44px 16px;
  gap: 6px;
  padding: 9px 14px;
  border: 1px dashed #9ca9b8;
  border-radius: 7px;
  background: var(--panel-soft);
}

.collector-link-zone:focus-within {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.collector-main-row {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 168px 112px;
  grid-template-rows: 44px;
  align-items: stretch;
  gap: 8px;
}

.service-status,
.link-type-badge {
  min-height: 22px;
  display: inline-flex;
  align-items: center;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.service-status.ready,
.link-type-badge.recognized {
  border-color: #b9ddcb;
  background: #edf9f2;
  color: var(--ok);
}

.service-status.missing { border-color: #e5c17f; background: #fff7e8; color: var(--warn); }
.link-type-badge:not(.recognized):not(:empty) { color: var(--muted); }
.link-type-badge.invalid { border-color: #e8b7b5; background: #fff2f2; color: var(--danger); }

.collector-link-control {
  min-width: 0;
  display: block;
  grid-column: 1 / 3;
}

.collector-panel.profile-link .collector-link-control { grid-column: 1; }

.collector-link-control input {
  width: 100%;
  min-width: 0;
  height: 44px;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  outline: none;
  background: #fff;
  color: var(--ink);
  font-size: 14px;
}

.collector-panel input:focus { outline: none; }

.collector-main-row .secondary-button {
  grid-column: 3;
  height: 44px;
  min-height: 44px;
  padding: 0 16px;
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.collector-main-row .secondary-button:hover:not(:disabled) {
  border-color: var(--accent-dark);
  background: var(--accent-dark);
}

.collector-main-row .secondary-button:disabled {
  border-color: #a9b2bd;
  background: #a9b2bd;
  color: #fff;
  opacity: 1;
}

.collector-meta-row {
  min-width: 0;
  min-height: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.collector-meta-row > small {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  line-height: 16px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.collector-meta-badges {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex-wrap: wrap;
}

.collector-limit-control {
  min-width: 0;
  height: 44px;
  display: grid;
  grid-column: 2;
  grid-template-columns: auto minmax(48px, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  white-space: nowrap;
}

.collector-limit-control input {
  width: 100%;
  min-width: 48px;
  height: 40px;
  min-height: 40px;
  padding: 0 2px;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: 14px;
  font-weight: 800;
  text-align: right;
}

.collector-limit-suffix { color: var(--muted); font-size: 12px; }

.collector-meta-row .service-status,
.collector-meta-row .link-type-badge {
  min-height: 16px;
  padding: 0;
  border: 0;
  background: transparent;
  line-height: 16px;
}

.collector-meta-row .service-status.missing,
.collector-meta-row .link-type-badge.invalid {
  border: 0;
  background: transparent;
}

.analysis-start-row {
  align-items: flex-start;
  padding-top: 13px;
  border-top: 1px solid var(--line);
}

.analysis-status-area {
  min-width: 0;
  flex: 1 1 auto;
  display: grid;
  justify-items: end;
}

.analysis-status-pill {
  max-width: 100%;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-soft);
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 750;
  transition: border-color 180ms ease, background-color 180ms ease, color 180ms ease;
}

.analysis-status-pill:hover:not(:disabled) { border-color: #9da9b7; background: #fff; }
.analysis-status-pill:disabled { cursor: default; }
.analysis-status-pill:disabled .analysis-status-chevron { display: none; }

.analysis-status-pill.ready {
  border-color: #b9ddcb;
  background: #edf9f2;
  color: var(--ok);
}

.analysis-status-pill.running,
.analysis-status-pill.warning {
  border-color: #e5c17f;
  background: #fff7e8;
  color: var(--warn);
}

.analysis-status-pill.failed {
  border-color: #e8b7b5;
  background: #fff2f2;
  color: var(--danger);
}

.analysis-status-icon {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  color: #7a8491;
}

.analysis-status-icon svg { width: 16px; height: 16px; }
.analysis-status-pill.ready .analysis-status-icon { color: var(--ok); }
.analysis-status-pill.running .analysis-status-icon,
.analysis-status-pill.warning .analysis-status-icon { color: var(--warn); }
.analysis-status-pill.failed .analysis-status-icon { color: var(--danger); }
.analysis-status-pill.running .analysis-status-icon { animation: import-status-spin 900ms linear infinite; }

.analysis-status-chevron {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  transition: transform 180ms ease;
}

.analysis-status-chevron svg { width: 14px; height: 14px; }
.analysis-status-pill[aria-expanded="true"] .analysis-status-chevron { transform: rotate(180deg); }

.import-status-details {
  width: min(560px, 100%);
  margin-top: 8px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  text-align: left;
}

.import-status-details-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.import-status-details-head strong { font-size: 12px; }
.import-status-details-head span { color: var(--muted); font-size: 11px; }

.import-failure-list {
  max-height: 220px;
  display: grid;
  gap: 6px;
  overflow-y: auto;
}

.import-failure-item {
  min-width: 0;
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border: 1px solid #efd0ce;
  border-radius: 6px;
  background: #fff7f7;
}

.import-failure-icon { display: grid; place-items: center; color: var(--danger); }
.import-failure-icon svg { width: 16px; height: 16px; }
.import-failure-copy { min-width: 0; display: grid; gap: 3px; }
.import-failure-copy strong { overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.import-failure-copy small { color: #6f4a49; font-size: 11px; line-height: 1.4; }
.import-failure-action { color: var(--danger); font-size: 11px; font-weight: 800; white-space: nowrap; }
.analysis-start-actions {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

@keyframes import-status-spin {
  to { transform: rotate(360deg); }
}

.primary-button,
.secondary-button,
.mini-command {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 13px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 750;
  text-decoration: none;
  white-space: nowrap;
}

.primary-button {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
}

.primary-button:hover { background: var(--accent-dark); }
.primary-button:disabled { border-color: #a9b2bd; background: #a9b2bd; cursor: not-allowed; }

.secondary-button {
  border: 1px solid var(--line);
  background: #fff;
  color: #344054;
}

.secondary-button:hover { border-color: #9da9b7; background: var(--panel-soft); }
.secondary-button:disabled, .secondary-button.disabled { opacity: 0.45; pointer-events: none; }

.mini-command {
  min-height: 32px;
  padding: 0 9px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  font-size: 11px;
}

.mini-command:hover:not(:disabled) { border-color: #9da9b7; color: var(--ink); }
.mini-command:disabled { opacity: 0.45; cursor: not-allowed; }

.sensitivity-control {
  display: grid;
  grid-template-columns: auto auto;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

select {
  min-height: 38px;
  padding: 0 30px 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
}

.progress-panel { padding: 11px 14px; }
.progress-meta { margin-bottom: 8px; color: var(--muted); font-size: 12px; }
.progress-track { height: 7px; overflow: hidden; border-radius: 999px; background: #e8edf1; }
#progressFill { width: 0; height: 100%; background: var(--accent); transition: width 180ms ease; }

.workspace {
  min-height: 0;
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr);
  overflow: hidden;
}

.source-panel {
  min-width: 0;
  border-right: 1px solid var(--line);
  background: var(--panel-soft);
}

.panel-heading, .storyboard-header { min-height: 70px; padding: 13px 15px; border-bottom: 1px solid var(--line); }
.panel-heading > div { display: grid; gap: 3px; }

.source-list { max-height: calc(100vh - 300px); overflow-y: auto; padding: 8px; }

.source-item {
  width: 100%;
  min-height: 58px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 8px 9px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}

.source-item:hover { background: #fff; border-color: var(--line); }
.source-item.active { background: var(--accent-soft); border-color: #a9d7ce; }
.source-item-text { min-width: 0; display: grid; gap: 4px; }
.source-item strong, .source-item small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.source-item strong { font-size: 13px; }
.source-item small { color: var(--muted); font-size: 11px; }

.source-state { width: 8px; height: 8px; border-radius: 50%; background: #98a2b3; }
.source-state.analyzing, .source-state.queued { background: var(--warn); }
.source-state.ready { background: var(--ok); }
.source-state.failed { background: var(--danger); }

.storyboard-panel { min-width: 0; min-height: 0; }
.storyboard-header { align-items: flex-end; }
.storyboard-header > div:first-child,
.dialog-header > div:first-child { min-width: 0; }
.storyboard-header h2,
.dialog-header h2 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.storyboard-actions { flex-wrap: wrap; justify-content: flex-end; }

.empty-state {
  min-height: 380px;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 10px;
  color: var(--muted);
}

.empty-state svg { width: 38px; height: 38px; }

.shot-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
  padding: 14px;
}

.shot-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
}

.shot-card.excluded { opacity: 0.56; background: #f2f4f6; }
.shot-card.selected-frame { border-color: #8ac8bc; }

.shot-preview {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: #20252b;
  cursor: pointer;
  padding: 0;
}

.shot-preview img { width: 100%; height: 100%; display: block; object-fit: contain; }
.shot-number { position: absolute; top: 7px; left: 7px; min-width: 27px; min-height: 23px; display: grid; place-items: center; padding: 0 6px; border-radius: 4px; background: rgba(18, 24, 31, 0.78); color: #fff; font-size: 11px; }
.shot-frame-time { position: absolute; right: 7px; bottom: 7px; padding: 3px 6px; border-radius: 4px; background: rgba(18, 24, 31, 0.78); color: #fff; font-size: 11px; }

.shot-info { padding: 9px 10px 10px; display: grid; gap: 8px; }
.shot-meta, .shot-controls { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.shot-meta strong { font-size: 13px; }
.shot-meta span { color: var(--muted); font-size: 11px; }
.shot-tool-buttons { min-width: 0; display: inline-flex; align-items: center; gap: 5px; }

.include-toggle { display: inline-flex; align-items: center; gap: 6px; color: #344054; font-size: 12px; cursor: pointer; }
.include-toggle input { width: 16px; height: 16px; accent-color: var(--accent); }
.choose-frame-button { min-height: 30px; padding: 0 9px; border: 1px solid var(--line); border-radius: 5px; background: #fff; color: #344054; cursor: pointer; font-size: 12px; font-weight: 700; }
.choose-frame-button:hover { border-color: var(--accent); color: var(--accent-dark); }
.shot-tool-button {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
  color: #344054;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
}
.shot-tool-button svg { width: 14px; height: 14px; }
.shot-tool-button:hover:not(:disabled) { border-color: var(--accent); color: var(--accent-dark); }
.shot-tool-button:disabled { opacity: 0.45; cursor: not-allowed; }

.next-step-bar { position: sticky; bottom: 12px; padding: 12px 15px; z-index: 5; }
.next-step-copy { min-width: 0; display: grid; gap: 3px; }
.next-step-copy > span { color: var(--muted); font-size: 11px; font-weight: 800; }
.next-step-copy strong,
.next-step-copy small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.next-step-copy small { color: var(--muted); }
.next-step-actions .primary-button,
.next-step-actions .secondary-button { min-height: 38px; }

.frame-dialog {
  width: min(1080px, calc(100vw - 28px));
  max-height: calc(100vh - 28px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 26px 70px rgba(20, 28, 38, 0.3);
}

.frame-dialog::backdrop { background: rgba(22, 29, 38, 0.62); }
.dialog-shell { width: 100%; min-width: 0; display: grid; grid-template-rows: auto auto auto auto auto auto; max-height: calc(100vh - 30px); overflow-y: auto; overflow-x: hidden; }
.dialog-shell > * { min-width: 0; }
.dialog-header, .dialog-actions { padding: 13px 15px; }
.dialog-header { border-bottom: 1px solid var(--line); }
.dialog-actions { position: sticky; bottom: 0; z-index: 2; justify-content: flex-end; border-top: 1px solid var(--line); background: #fff; }

.frame-stage { position: relative; display: grid; place-items: center; min-height: 250px; background: #181d22; }
.frame-stage video { display: block; width: 100%; height: min(40vh, 360px); object-fit: contain; background: #181d22; }
.frame-time { position: absolute; right: 12px; bottom: 12px; padding: 5px 8px; border-radius: 4px; background: rgba(0, 0, 0, 0.72); color: #fff; font-variant-numeric: tabular-nums; font-size: 12px; }

.frame-mode { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px; margin: 12px 15px 8px; padding: 4px; border: 1px solid var(--line); border-radius: 7px; background: var(--panel-soft); }
.frame-mode button { min-height: 34px; border: 1px solid transparent; border-radius: 5px; background: transparent; color: #344054; cursor: pointer; font-weight: 700; }
.frame-mode button.active { border-color: #a9d7ce; background: #fff; color: var(--accent-dark); }

.filmstrip { width: calc(100% - 30px); min-width: 0; min-height: 94px; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(108px, 1fr); gap: 4px; margin: 0 15px; overflow-x: auto; background: #252b31; border: 1px solid #252b31; }
.filmstrip-button { position: relative; height: 90px; overflow: hidden; padding: 0; border: 2px solid transparent; background: #161a1e; cursor: pointer; }
.filmstrip-button.active { border-color: #43bea9; }
.filmstrip-button img { width: 100%; height: 100%; display: block; object-fit: cover; }
.filmstrip-button span { position: absolute; right: 4px; bottom: 4px; padding: 2px 4px; border-radius: 3px; background: rgba(0, 0, 0, 0.68); color: #fff; font-size: 10px; }
.filmstrip-loading { min-width: 100%; display: grid; place-items: center; color: #d4dae1; font-size: 12px; }

.timeline-control { padding: 11px 15px 14px; }
#frameSlider { width: 100%; accent-color: var(--accent); }

.split-timeline { min-width: 0; margin: 4px 15px 0; }
.split-ruler {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  min-height: 24px;
  align-items: start;
  padding-bottom: 4px;
  border-bottom: 1px solid #cbd5df;
  color: #667085;
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}
.split-ruler::after {
  position: absolute;
  right: 0;
  bottom: -4px;
  left: 0;
  height: 4px;
  border-left: 1px solid #cbd5df;
  border-right: 1px solid #cbd5df;
  content: "";
}
.split-ruler span:nth-child(2) { text-align: center; }
.split-ruler span:last-child { text-align: right; }
.split-timeline-track {
  position: relative;
  min-width: 0;
  height: 94px;
  overflow: hidden;
  background: #252b31;
  border: 1px solid #252b31;
}
.split-timeline .filmstrip {
  width: 100%;
  min-height: 92px;
  height: 92px;
  grid-auto-flow: initial;
  grid-auto-columns: auto;
  grid-template-columns: repeat(var(--split-frame-count, 8), minmax(0, 1fr));
  gap: 1px;
  margin: 0;
  overflow: hidden;
  border: 0;
}
.split-timeline .filmstrip-button { height: 92px; border: 0; }
.split-timeline .filmstrip-button.active { border-color: transparent; }
.split-timeline .filmstrip-button span { display: none; }
.split-timeline-input {
  display: block;
  width: 100%;
  min-width: 0;
  height: 28px;
  margin: 7px 0 0;
  padding: 0;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  accent-color: var(--accent);
  cursor: pointer;
}
.split-timeline-input::-webkit-slider-runnable-track {
  height: 4px;
  border: 0;
  border-radius: 999px;
  background: #d8dfe7;
}
.split-timeline-input::-webkit-slider-thumb {
  width: 16px;
  height: 16px;
  margin-top: -6px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 1px 3px rgba(13, 20, 28, 0.32);
  -webkit-appearance: none;
  appearance: none;
}
.split-timeline-input::-moz-range-track {
  height: 4px;
  border: 0;
  border-radius: 999px;
  background: #d8dfe7;
}
.split-timeline-input::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 1px 3px rgba(13, 20, 28, 0.32);
}
.split-playhead {
  position: absolute;
  z-index: 3;
  top: -4px;
  bottom: -1px;
  width: 2px;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(13, 20, 28, 0.55);
  pointer-events: none;
  transform: translateX(-1px);
  will-change: left;
}
.split-dialog.is-playing .split-playhead { transition: left 50ms linear; }
.split-playhead-cap {
  position: absolute;
  top: -3px;
  left: 50%;
  width: 10px;
  height: 10px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 1px 3px rgba(13, 20, 28, 0.45);
  transform: translate(-50%, -50%);
}
.split-timeline-controls { display: flex; justify-content: center; gap: 10px; padding-top: 7px; padding-bottom: 4px; }
.split-timeline-hint { padding: 0 15px 10px; color: var(--muted); font-size: 12px; }

.split-time-summary {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  margin: 12px 15px 8px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-soft);
}
.split-time-summary > div { display: grid; gap: 3px; }
.split-time-summary > div:last-child { text-align: right; }
.split-time-summary small { color: var(--muted); font-size: 11px; }
.split-time-summary strong { font-variant-numeric: tabular-nums; font-size: 14px; }
.split-time-point { justify-items: center; color: var(--accent-dark); }
.split-time-point strong svg { width: 17px; height: 17px; }

svg { width: 18px; height: 18px; stroke-width: 2; }

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
.local-drop-zone:focus-within {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (max-width: 900px) {
  .preprocess-app { padding: 10px; }
  .topbar { display: flex; flex-wrap: wrap; }
  .brand-block, .topbar-actions { flex: 1 1 200px; }
  .import-panel-head { align-items: flex-start; }
  .workspace { grid-template-columns: 1fr; }
  .source-panel { border-right: 0; border-bottom: 1px solid var(--line); }
  .source-list { max-height: 190px; }
  .workflow-steps { order: 3; width: 100%; min-width: 0; max-width: none; }
}

@media (max-width: 600px) {
  .topbar, .next-step-bar, .storyboard-header { align-items: stretch; flex-direction: column; }
  .brand-block, .topbar-actions { flex: 0 0 auto; }
  .topbar-actions { justify-content: space-between; }
  .workflow-steps { width: 100%; min-width: 0; max-width: none; }
  .import-panel-head,
  .analysis-start-row { align-items: stretch; flex-direction: column; }
  .import-source-tabs { width: 100%; }
  .local-drop-zone { min-height: 132px; align-items: flex-start; justify-content: flex-start; }
  .collector-link-zone { height: 132px; min-height: 132px; grid-template-rows: 96px 14px; gap: 4px; padding: 8px 14px; }
  .collector-main-row { grid-template-columns: minmax(0, 1fr) 132px; grid-template-rows: 44px 44px; gap: 8px; }
  .collector-link-control,
  .collector-panel.profile-link .collector-link-control { grid-row: 1; grid-column: 1 / -1; }
  .collector-limit-control { grid-row: 2; grid-column: 1; }
  .collector-main-row .secondary-button { grid-row: 2; grid-column: 2; width: 132px; }
  .collector-meta-row { min-height: 14px; }
  .collector-meta-row > small { line-height: 14px; white-space: nowrap; }
  .collector-meta-badges { justify-content: flex-start; }
  .analysis-status-area { width: 100%; justify-items: stretch; }
  .analysis-status-pill { width: 100%; justify-content: flex-start; }
  .analysis-status-chevron { margin-left: auto; }
  .import-status-details { width: 100%; }
  .import-failure-item { grid-template-columns: 20px minmax(0, 1fr); align-items: start; }
  .import-failure-action { grid-column: 2; }
  .analysis-start-row .sensitivity-control { grid-template-columns: minmax(0, 1fr); }
  .analysis-start-actions { display: grid; grid-template-columns: auto minmax(0, 1fr); }
  .analysis-start-row .primary-button { width: 100%; }
  .next-step-copy strong,
  .next-step-copy small { white-space: normal; }
  .next-step-actions,
  .next-step-main-actions,
  .next-step-later-action { display: grid; grid-template-columns: minmax(0, 1fr); }
  .next-step-later-action { padding-top: 12px; padding-left: 0; border-top: 1px solid var(--line); border-left: 0; }
  .next-step-actions .primary-button,
  .next-step-actions .secondary-button { width: 100%; padding: 0 8px; white-space: normal; }
  .sensitivity-control { grid-template-columns: 1fr; }
  .storyboard-actions { justify-content: flex-start; }
  .shot-grid { grid-template-columns: 1fr; padding: 10px; }
  .frame-stage { min-height: 220px; }
  .frame-mode { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .dialog-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dialog-actions .primary-button,
  .dialog-actions .secondary-button { padding: 0 8px; white-space: normal; }
  .shot-tool-buttons { gap: 4px; }
  .shot-tool-button, .choose-frame-button { padding: 0 7px; }
  .split-time-summary { gap: 7px; margin-left: 10px; margin-right: 10px; }
  .split-timeline { margin-right: 10px; margin-left: 10px; }
  .split-timeline-track, .split-timeline .filmstrip, .split-timeline .filmstrip-button { height: 68px; min-height: 68px; }
  .split-timeline-input { height: 26px; }
  .split-timeline-hint { padding-right: 10px; padding-left: 10px; font-size: 11px; }
}

@media (prefers-reduced-motion: reduce) {
  .analysis-status-pill.running .analysis-status-icon { animation: none; }
  .analysis-status-chevron { transition: none; }
  #progressFill { transition: none; }
  .split-dialog.is-playing .split-playhead { transition: none; }
}
