:root {
  color-scheme: light;
  --bg: #edf1f4;
  --panel: #ffffff;
  --panel-soft: #f6f8fa;
  --ink: #17202a;
  --muted: #687586;
  --line: #d7dde5;
  --accent: #128273;
  --accent-dark: #0b6b5f;
  --accent-soft: #def3ee;
  --danger: #c33f3c;
  --warn: #ad6800;
  --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; }

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid rgba(18, 130, 115, 0.32);
  outline-offset: 2px;
}

.merge-app {
  max-width: 1680px;
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px;
  display: grid;
  grid-template-rows: auto minmax(620px, 1fr) auto;
  gap: 14px;
}

.topbar,
.editor-shell,
.export-bar {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.topbar {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(210px, 1fr) minmax(420px, 560px) minmax(210px, 1fr);
  align-items: center;
  gap: 16px;
  padding: 15px 18px;
}

.brand-block p,
.brand-block h1,
.panel-heading h2,
.panel-heading small,
.preview-heading h2,
.preview-heading small,
.sequence-heading h2,
.sequence-heading small { margin: 0; letter-spacing: 0; }

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

.brand-block h1 { margin-top: 3px; font-size: 23px; }
.panel-heading h2, .preview-heading h2 { margin-top: 3px; font-size: 19px; }
.sequence-heading h2 { font-size: 16px; }

.workflow-steps {
  min-width: 0;
  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 {
  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 { flex: 0 0 auto; font-variant-numeric: tabular-nums; }

.topbar-actions {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.status-pill,
.count-label,
.duration-label,
.service-pill {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: 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 { border-color: #efd29b; background: #fff7e6; color: var(--warn); }
.status-pill.done { border-color: #b7dfca; background: #edf9f2; color: var(--ok); }
.status-pill.failed { border-color: #edc2c0; background: #fff1f0; color: var(--danger); }
.service-pill.configured { border-color: #b7dfca; background: #edf9f2; color: var(--ok); }
.service-pill.unconfigured { border-color: #efd29b; background: #fff7e6; color: var(--warn); }

.icon-button,
.text-button,
.asset-action,
.sequence-action,
.primary-button,
.download-button {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: #344054;
  cursor: pointer;
  text-decoration: none;
}

.icon-button {
  width: 38px;
  height: 38px;
  display: inline-grid;
  place-items: center;
  padding: 0;
}

.icon-button.compact {
  width: 32px;
  height: 32px;
}

.icon-button:hover,
.text-button:hover,
.asset-action:hover,
.sequence-action:hover { border-color: #9ba7b5; background: var(--panel-soft); }

.editor-shell {
  min-width: 0;
  min-height: 620px;
  height: auto;
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
  overflow: visible;
}

.library-panel {
  min-width: 0;
  min-height: 0;
  height: min(calc(100vh - 100px), 800px);
  align-self: start;
  display: grid;
  grid-template-rows: auto auto auto auto minmax(0, 1fr);
  gap: 12px;
  padding: 16px;
  overflow: hidden;
  border-right: 1px solid var(--line);
  background: var(--panel-soft);
}

.panel-heading,
.preview-heading,
.sequence-heading {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel-heading-actions {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

#localVideoInput { display: none; }

.upload-command {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 12px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-size: 13px;
  font-weight: 750;
}

.upload-command:hover { background: var(--accent-dark); }

.library-filters {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
}

.library-filters button {
  min-width: 0;
  min-height: 32px;
  padding: 4px;
  overflow: hidden;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 11px;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.library-filters button.active { border-color: #b2d8d1; background: var(--accent-soft); color: var(--accent-dark); }

.search-field {
  min-width: 0;
  min-height: 38px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--muted);
}

.search-field input {
  min-width: 0;
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: 12px;
}

.asset-list {
  min-height: 0;
  display: grid;
  align-content: start;
  gap: 8px;
  padding-right: 3px;
  overflow-y: auto;
}

.asset-row {
  min-width: 0;
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.asset-row.selected { border-color: #9ed2c8; background: #f2fbf8; }
.asset-row.active { box-shadow: inset 3px 0 0 var(--accent); }

.asset-media {
  width: 76px;
  height: 58px;
  display: block;
  overflow: hidden;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: #161b22;
  cursor: pointer;
}

.asset-media video,
.asset-media img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.asset-copy { min-width: 0; display: grid; gap: 3px; }
.asset-copy strong,
.asset-copy span,
.asset-copy small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.asset-copy strong { font-size: 12px; }
.asset-copy span, .asset-copy small { color: var(--muted); font-size: 10px; }

.asset-controls { display: grid; gap: 5px; }
.asset-action,
.sequence-action,
.asset-protected {
  width: 30px;
  height: 30px;
  display: inline-grid;
  place-items: center;
  padding: 0;
}
.asset-action.added { border-color: #a9d7ce; background: var(--accent-soft); color: var(--accent-dark); }
.asset-action.danger, .text-button.danger { color: var(--danger); }
.asset-protected {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-soft);
  color: #7b8794;
  cursor: default;
}
.asset-protected svg { width: 15px; height: 15px; }

.library-empty,
.preview-empty,
.sequence-empty {
  color: var(--muted);
  text-align: center;
}

.library-empty {
  min-height: 220px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 7px;
  padding: 20px;
}

.library-empty small { line-height: 1.45; }

.assembly-panel {
  min-width: 0;
  min-height: 0;
  height: auto;
  display: grid;
  grid-template-rows: auto auto auto;
  align-content: start;
  gap: 14px;
  padding: 18px;
}

.tool-switch {
  width: min(100%, 360px);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-soft);
}

.tool-switch button {
  min-width: 0;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 5px 10px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 750;
}

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

.preview-stage {
  --preview-aspect: 16 / 9;
  min-width: 0;
  width: 100%;
  min-height: 220px;
  max-height: min(44vh, 520px);
  aspect-ratio: var(--preview-aspect);
  align-self: center;
  justify-self: stretch;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #171c23;
  border: 1px solid #171c23;
}

.preview-stage.is-portrait {
  width: min(100%, 32vh, 360px);
  min-height: 0;
  max-height: none;
  justify-self: center;
}

.preview-stage video {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  background: #171c23;
}

.preview-empty { display: grid; place-items: center; gap: 8px; color: #c8d0da; }

.sequence-section {
  min-width: 0;
  display: grid;
  gap: 10px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.sequence-heading-actions {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.text-button {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 700;
}

.sequence-list {
  min-width: 0;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 190px;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.sequence-item {
  min-width: 0;
  display: grid;
  grid-template-rows: 92px auto auto;
  gap: 7px;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-soft);
}

.sequence-item.active { border-color: var(--accent); background: #f2fbf8; }
.sequence-item.dragging { opacity: 0.45; }

.sequence-preview {
  position: relative;
  width: 100%;
  height: 92px;
  overflow: hidden;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: #171c23;
  cursor: pointer;
}

.sequence-preview video,
.sequence-preview img { width: 100%; height: 100%; display: block; object-fit: cover; }

.sequence-index {
  position: absolute;
  top: 5px;
  left: 5px;
  min-width: 23px;
  height: 23px;
  display: grid;
  place-items: center;
  border-radius: 4px;
  background: rgba(10, 16, 22, 0.78);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
}

.sequence-copy { min-width: 0; display: grid; gap: 2px; }
.sequence-copy strong, .sequence-copy small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sequence-copy strong { font-size: 12px; }
.sequence-copy small { color: var(--muted); font-size: 10px; }

.sequence-controls { display: grid; grid-template-columns: repeat(4, 30px); justify-content: end; gap: 4px; }
.sequence-action:disabled { opacity: 0.38; cursor: not-allowed; }

.sequence-empty {
  min-height: 132px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 7px;
  border: 1px dashed var(--line);
  border-radius: 6px;
  background: var(--panel-soft);
}

.voice-section {
  min-width: 0;
  display: grid;
  gap: 12px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.voice-heading,
.voice-service-actions,
.voice-step-heading,
.voice-file-row,
.voice-target-row,
.voice-status {
  min-width: 0;
  display: flex;
  align-items: center;
}

.voice-heading {
  justify-content: space-between;
  gap: 12px;
}

.voice-heading small,
.voice-heading h2,
.voice-step-heading h3 { margin: 0; letter-spacing: 0; }
.voice-heading small { color: var(--muted); font-size: 12px; }
.voice-heading h2 { margin-top: 3px; font-size: 16px; }
.voice-service-actions { flex: 0 0 auto; gap: 6px; }

.voice-workflow {
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-soft);
}

.voice-step {
  min-width: 0;
  display: grid;
  align-content: start;
  gap: 10px;
  padding: 14px;
}

.voice-step + .voice-step { border-left: 1px solid var(--line); }

.voice-step-heading { gap: 8px; }
.voice-step-heading > span {
  width: 24px;
  height: 24px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-size: 11px;
  font-weight: 800;
}
.voice-step-heading h3 { font-size: 14px; }

.voice-field { min-width: 0; display: grid; gap: 5px; }
.voice-field > span { color: var(--muted); font-size: 11px; font-weight: 700; }
.voice-field input,
.voice-field select {
  min-width: 0;
  width: 100%;
  height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
}

.sample-source-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.sample-source-tabs button {
  min-height: 30px;
  padding: 3px 8px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 11px;
  font-weight: 750;
}
.sample-source-tabs button.active { border-color: #b2d8d1; background: var(--accent-soft); color: var(--accent-dark); }
.sample-source-tabs button:disabled { cursor: not-allowed; opacity: 0.62; }

.voice-sample-test-note {
  min-width: 0;
  min-height: 30px;
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  padding: 6px 8px;
  border-left: 3px solid #d39a32;
  background: #fff7e6;
  color: #7a4d00;
  font-size: 10px;
  line-height: 1.4;
}
.voice-sample-test-note svg { width: 14px; height: 14px; flex: 0 0 auto; }

.voice-file-row,
.voice-target-row {
  gap: 8px;
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--muted);
}

.voice-file-row > span:last-child,
.voice-target-row strong {
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.voice-target-row > div { min-width: 0; display: grid; gap: 2px; }
.voice-target-row small { color: var(--muted); font-size: 10px; }
.gateway-voice-id-field small { color: var(--muted); font-size: 10px; line-height: 1.4; }

#voiceSampleInput { display: none; }
#uploadVoiceSample { min-width: 0; display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: start; gap: 8px; }
#uploadVoiceSample[hidden] { display: none; }
.voice-file-command {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: #344054;
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}
.voice-file-command:hover { border-color: #9ba7b5; background: var(--panel-soft); }
#voiceSampleFileName { min-width: 0; padding-top: 3px; color: var(--muted); font-size: 10px; line-height: 1.45; overflow-wrap: anywhere; }

.voice-recorder {
  min-width: 0;
  min-height: 146px;
  display: grid;
  align-content: start;
  gap: 7px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.voice-recorder-meta,
.voice-recorder-actions,
.recording-state,
.recording-range {
  min-width: 0;
  display: flex;
  align-items: center;
}

.voice-recorder-meta { justify-content: space-between; gap: 10px; }
.recording-state { gap: 6px; color: var(--muted); font-size: 11px; font-weight: 750; }
.recording-state > i {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #9ba5b2;
}
.recording-state.recording > i { background: var(--danger); box-shadow: 0 0 0 4px rgba(195, 63, 60, 0.12); }
.recording-state.ready > i { background: var(--ok); }
.recording-state.long > i,
.recording-state.processing > i { background: var(--warn); }
.recording-state.short > i,
.recording-state.error > i { background: var(--danger); }

#voiceRecordingTime {
  color: var(--ink);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
}

.recording-progress {
  position: relative;
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: #dfe5ea;
}
.recording-progress > span {
  width: 0;
  height: 100%;
  display: block;
  background: var(--accent);
  transition: width 0.2s linear;
}
.recording-progress > i {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: rgba(23, 32, 42, 0.36);
}
.recording-progress .minimum-marker { left: 33.333%; }
.recording-progress .recommended-marker { left: 66.667%; }

.recording-range { justify-content: space-between; gap: 5px; color: var(--muted); font-size: 9px; }
.recording-range > span:nth-child(2) { text-align: center; }
.recording-range > span:last-child { text-align: right; }
.recording-hint { min-height: 16px; margin: 0; color: var(--muted); font-size: 10px; line-height: 1.45; }
#voiceRecordingPreview { width: 100%; height: 34px; display: block; }
#voiceRecordingPreview[hidden] { display: none; }

.voice-recorder-actions { gap: 7px; }
.recording-command {
  min-width: 0;
  min-height: 36px;
  flex: 1 1 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 10px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-size: 11px;
  font-weight: 750;
}
.recording-command:hover { background: var(--accent-dark); }
.recording-command.stop { border-color: var(--danger); background: var(--danger); }
.recording-command.stop:hover { background: #a93331; }
.recording-command:disabled { border-color: #bbc4cf; background: #bbc4cf; cursor: not-allowed; }
.voice-recorder-actions .icon-button { width: 38px; height: 36px; flex: 0 0 auto; color: var(--danger); }
.voice-action { width: 100%; min-height: 38px; }

.voice-status {
  gap: 8px;
  min-height: 40px;
  padding: 6px 8px 6px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--muted);
  font-size: 11px;
}
.voice-status.running { border-color: #efd29b; background: #fff7e6; color: var(--warn); }
.voice-status.done { border-color: #b7dfca; background: #edf9f2; color: var(--ok); }
.voice-status.failed { border-color: #edc2c0; background: #fff1f0; color: var(--danger); }
#voiceStatusText { min-width: 0; flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.voice-status .text-button { flex: 0 0 auto; min-height: 30px; background: #fff; }
.voice-status .text-button.disabled { color: #9ba5b2; background: var(--panel-soft); pointer-events: none; }

.export-bar {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "fields actions"
    "status actions";
  align-items: end;
  gap: 10px 16px;
  padding: 13px 16px;
}

.output-fields {
  grid-area: fields;
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(150px, 1fr) minmax(170px, 1fr) minmax(120px, 0.75fr) minmax(130px, 0.7fr);
  align-items: end;
  gap: 10px;
}

.output-fields label { min-width: 0; display: grid; gap: 5px; }
.output-fields label > span { color: var(--muted); font-size: 11px; font-weight: 700; }
.output-fields input, .output-fields select {
  min-width: 0;
  width: 100%;
  height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
}

.clean-toggle {
  min-height: 38px;
  display: flex !important;
  grid-template-columns: none !important;
  align-items: center;
  gap: 8px !important;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.clean-toggle input {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.clean-toggle > span {
  min-width: 0;
  display: grid;
  gap: 0;
}

.clean-toggle strong {
  color: var(--ink);
  font-size: 12px;
  line-height: 1.2;
}

.clean-toggle small {
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.export-status { grid-area: status; min-width: 0; display: grid; gap: 7px; padding-bottom: 2px; }
.progress-meta { display: flex; justify-content: space-between; gap: 10px; color: var(--muted); font-size: 11px; }
.progress-track { height: 7px; overflow: hidden; border-radius: 999px; background: #dfe5ea; }
#mergeProgressFill { width: 0; height: 100%; background: var(--accent); transition: width 0.25s ease; }

.export-actions {
  grid-area: actions;
  display: grid;
  grid-template-columns: repeat(3, minmax(104px, auto));
  gap: 8px;
}
.primary-button,
.download-button {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 14px;
  font-size: 13px;
  font-weight: 750;
  text-decoration: none;
  white-space: nowrap;
}

.primary-button { border-color: var(--accent); background: var(--accent); color: #fff; }
.primary-button:hover { background: var(--accent-dark); }
.primary-button:disabled { border-color: #bbc4cf; background: #bbc4cf; cursor: not-allowed; }
.download-button.disabled { color: #9ba5b2; background: var(--panel-soft); pointer-events: none; }
.download-button:disabled { color: #9ba5b2; background: var(--panel-soft); cursor: not-allowed; }

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

[hidden] { display: none !important; }

@media (max-width: 1100px) {
  .topbar { display: flex; flex-wrap: wrap; }
  .brand-block, .topbar-actions { flex: 1 1 200px; }
  .workflow-steps { order: 3; width: 100%; }
  .editor-shell { grid-template-columns: minmax(250px, 310px) minmax(0, 1fr); }
  .export-bar { grid-template-columns: 1fr; grid-template-areas: "fields" "status" "actions"; }
  .output-fields { grid-column: 1 / -1; }
  .export-actions { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}

@media (max-width: 780px) {
  .merge-app { padding: 10px; grid-template-rows: auto auto auto; }
  .editor-shell { min-height: 0; height: auto; grid-template-columns: 1fr; overflow: visible; }
  .library-panel { min-height: 520px; height: min(70vh, 620px); max-height: 620px; border-right: 0; border-bottom: 1px solid var(--line); }
  .assembly-panel { min-height: 620px; }
  .export-bar { position: static; grid-template-columns: 1fr; }
  .output-fields { grid-column: auto; }
  .export-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .voice-workflow { grid-template-columns: 1fr; }
  .voice-step + .voice-step { border-top: 1px solid var(--line); border-left: 0; }
}

@media (max-width: 520px) {
  .topbar { align-items: stretch; }
  .brand-block, .topbar-actions { flex-basis: 100%; }
  .topbar-actions { justify-content: space-between; }
  .workflow-steps > a { padding: 5px 4px; font-size: 11px; }
  .library-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .assembly-panel { min-height: 0; padding: 12px; }
  .preview-heading, .sequence-heading { align-items: flex-start; flex-direction: column; }
  .sequence-heading-actions { width: 100%; }
  .preview-stage { min-height: 240px; max-height: 58vh; }
  .preview-stage.is-portrait { width: min(100%, 52vh, 440px); max-height: none; }
  .sequence-list { grid-auto-flow: row; grid-auto-columns: auto; overflow-x: visible; }
  .sequence-item { grid-template-columns: 120px minmax(0, 1fr); grid-template-rows: auto auto; }
  .sequence-preview { grid-row: 1 / 3; height: 104px; }
  .sequence-controls { justify-content: start; }
  .output-fields { grid-template-columns: 1fr; }
  .export-actions { grid-template-columns: 1fr; }
  .primary-button, .download-button { width: 100%; }
  .tool-switch { width: 100%; }
  .voice-heading { align-items: flex-start; }
  .recording-range { font-size: 8px; }
  #voiceStatusText { white-space: normal; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition-duration: 0.01ms !important; }
}
