.v4-studio {
  display: grid;
  gap: 18px;
  padding: 22px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.v4-studio-head,
.v4-panel-bar,
.v4-reference-row,
.v4-progress-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.v4-studio-head h2,
.v4-panel-bar h3 {
  margin: 0;
}

.v4-scope-controls,
.v4-route-controls {
  display: flex;
  align-items: end;
  gap: 8px;
}

.v4-scope-controls label {
  width: 260px;
  margin: 0;
}

.v4-stage-nav {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  min-height: 54px;
  border-block: 1px solid var(--line);
}

.v4-stage-nav button {
  min-width: 0;
  border: 0;
  border-right: 1px solid var(--line);
  padding: 9px 8px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  text-align: left;
}

.v4-stage-nav button:last-child { border-right: 0; }
.v4-stage-nav button:hover { color: var(--text); background: rgb(255 255 255 / 3%); }
.v4-stage-nav button.active { color: var(--text); background: rgb(53 210 180 / 9%); box-shadow: inset 0 -2px var(--cyan); }
.v4-stage-nav button span { display: block; margin-bottom: 3px; color: var(--cyan); font-size: 10px; }

.v4-progress-line {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) auto auto;
}

.v4-progress-line > div {
  height: 5px;
  overflow: hidden;
  border-radius: 3px;
  background: #263342;
}

#v4-progress-fill {
  display: block;
  width: 0;
  height: 100%;
  background: var(--cyan);
  transition: width .45s ease;
}

.v4-progress-line strong { min-width: 42px; color: var(--text); text-align: right; }
.v4-progress-line small { min-width: 92px; color: var(--muted); }

.v4-panel {
  display: none;
  min-height: 330px;
  animation: v4-panel-in .2s ease both;
}

.v4-panel.active { display: grid; align-content: start; gap: 16px; }

.v4-panel .toolbar-actions .primary,
.v4-panel-bar .primary {
  width: auto;
  min-height: 36px;
  padding: 8px 14px;
}

@keyframes v4-panel-in {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

.v4-form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.v4-field {
  position: relative;
}

.v4-field > label:first-child { margin: 0; }

.v4-lock {
  position: absolute;
  top: 0;
  right: 0;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin: 0;
  color: var(--muted);
  font-size: 11px;
}

.v4-lock input { width: auto; }

.v4-reference-row {
  min-height: 54px;
  padding-block: 10px;
  border-block: 1px solid var(--line);
}

.v4-reference-row strong,
.v4-reference-row small { display: block; }
.v4-reference-row small { margin-top: 4px; color: var(--muted); }

.v4-storyboard-meta {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 140px;
  gap: 12px;
}

.v4-storyboard-meta label { margin: 0; }

.v4-shot-timeline {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(280px, 360px);
  gap: 10px;
  overflow-x: auto;
  padding: 2px 2px 12px;
  scroll-snap-type: x proximity;
}

.v4-shot {
  display: grid;
  gap: 10px;
  min-height: 285px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel2);
  scroll-snap-align: start;
  transition: border-color .16s ease, background .16s ease, transform .16s ease;
}

.v4-shot:hover { border-color: var(--line-strong); background: #121c28; transform: translateY(-2px); }
.v4-shot.dragging { opacity: .55; border-color: var(--cyan); }
.v4-shot textarea { min-height: 118px; }

.v4-shot-head {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) 72px;
  align-items: center;
  gap: 8px;
}

.v4-shot-index {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgb(53 210 180 / 14%);
  color: var(--cyan);
  font-weight: 700;
}

.v4-shot-head input { min-width: 0; }
.v4-shot-actions { display: flex; justify-content: space-between; gap: 8px; }
.v4-shot-actions button { min-width: 36px; padding-inline: 9px; text-align: center; }

.v4-result-list,
.v4-pipeline-stages {
  display: grid;
  gap: 1px;
  overflow: hidden;
  border-block: 1px solid var(--line);
  background: var(--line);
}

.v4-result-row,
.v4-pipeline-stage {
  display: grid;
  grid-template-columns: minmax(130px, .45fr) minmax(220px, 1fr) auto;
  align-items: center;
  gap: 14px;
  min-height: 62px;
  padding: 12px 4px;
  background: var(--bg);
}

.v4-result-row strong,
.v4-result-row small,
.v4-pipeline-stage strong,
.v4-pipeline-stage small { display: block; }
.v4-result-row small,
.v4-pipeline-stage small { margin-top: 4px; color: var(--muted); line-height: 1.5; }

.v4-score {
  min-width: 54px;
  color: var(--cyan);
  font-size: 22px;
  font-weight: 700;
  text-align: right;
}

.v4-score.warn { color: var(--warning); }
.v4-score.bad { color: var(--danger); }

.v4-stage-state {
  min-width: 70px;
  color: var(--muted);
  font-size: 12px;
  text-align: right;
}

.v4-pipeline-stage.completed .v4-stage-state { color: var(--success); }
.v4-pipeline-stage.running { background: rgb(76 154 255 / 8%); }
.v4-pipeline-stage.running .v4-stage-state { color: #9fc2ff; }

.v4-empty {
  display: grid;
  place-items: center;
  min-height: 180px;
  color: var(--muted);
}

@media (max-width: 1100px) {
  .v4-stage-nav { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .v4-stage-nav button { border-bottom: 1px solid var(--line); }
  .v4-form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
  .v4-studio-head,
  .v4-panel-bar,
  .v4-reference-row { align-items: stretch; flex-direction: column; }
  .v4-scope-controls,
  .v4-route-controls { display: grid; grid-template-columns: 1fr; width: 100%; }
  .v4-scope-controls label { width: 100%; }
  .v4-stage-nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .v4-form-grid,
  .v4-storyboard-meta { grid-template-columns: 1fr; }
  .v4-progress-line { grid-template-columns: minmax(100px, 1fr) auto; }
  .v4-progress-line small { grid-column: 1 / -1; }
  .v4-shot-timeline { grid-auto-columns: minmax(260px, 88vw); }
  .v4-result-row,
  .v4-pipeline-stage { grid-template-columns: 1fr auto; }
  .v4-result-row > :nth-child(2),
  .v4-pipeline-stage > :nth-child(2) { grid-column: 1 / -1; }
}
