/* Green Auto Voice — studio UI (one linear flow: 1 media → 2 script → 3 go) */

@font-face { font-family: StudioThai; src: local('Leelawadee UI'); }

:root {
  --bg: #0f1511;
  --panel: #171f1a;
  --panel-hi: #1d271f;
  --field: #111813;
  --line: #2a352d;
  --line-hi: #3d4c40;
  --text: #eef2ec;
  --soft: #c2ccc4;
  --muted: #8d9b91;
  --dim: #66756b;
  --lime: #bcf26c;
  --lime-lo: rgba(188, 242, 108, 0.14);
  --lime-mid: rgba(188, 242, 108, 0.38);
  --ok: #7dd98a;
  --warn: #e8c463;
  --err: #f0917e;
  --r: 12px;
  --r-sm: 8px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 StudioThai, 'Segoe UI', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .5; }
a { color: inherit; text-decoration: none; }
svg { display: block; }
[hidden] { display: none !important; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, summary:focus-visible, label:focus-within {
  outline: 2px solid var(--lime); outline-offset: 3px;
}

/* ── top bar ─────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: stretch; gap: 24px;
  min-height: 60px; padding: 0 22px;
  background: #121a15; border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 9px; font-size: 19px; font-weight: 650; letter-spacing: -.3px; white-space: nowrap; }
.brand svg { width: 26px; fill: var(--lime); }
.topbar nav { display: flex; gap: 4px; }
.tab {
  background: none; border: 0; border-bottom: 3px solid transparent;
  padding: 0 16px; font-weight: 600; color: var(--muted); white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--lime); border-color: var(--lime); }
.count { font-size: 11px; background: var(--line); border-radius: 99px; padding: 1px 7px; margin-left: 4px; color: var(--soft); }
.health { margin-left: auto; display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); flex: none; }
.health.ready .dot { background: var(--ok); }
.health.error .dot { background: var(--err); }

main { max-width: 1040px; margin: 0 auto; padding: 26px 20px 120px; }

/* ── notices ─────────────────────────────────────────────── */
.notice {
  padding: 12px 16px; border-radius: var(--r-sm); margin-bottom: 18px;
  font-size: 14px; line-height: 1.6; border: 1px solid var(--line);
  background: var(--panel); color: var(--soft);
}
.notice.error { background: #33211c; border-color: #7a4a3a; color: #f4b9a6; }
.notice.warn  { background: #322c18; border-color: #7a6a33; color: #f0dc9a; }
.notice.ok    { background: #1c2f20; border-color: #3f6a48; color: #bfe9c4; }

/* ── intro + mode ────────────────────────────────────────── */
.intro { margin-bottom: 20px; }
h1 { margin: 0 0 6px; font-size: 30px; font-weight: 650; letter-spacing: -.5px; }
.intro p { margin: 0; color: var(--muted); font-size: 15px; }
.mode-switch { display: flex; gap: 10px; margin-top: 16px; }
.mode-switch button {
  flex: 1; text-align: left; padding: 12px 16px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r);
  color: var(--soft); display: flex; flex-direction: column; gap: 2px;
}
.mode-switch button b { font-size: 15px; color: var(--text); }
.mode-switch button span { font-size: 12.5px; color: var(--muted); }
.mode-switch button.on { border-color: var(--lime); background: var(--lime-lo); }
.mode-switch button.on b { color: var(--lime); }

/* ── steps ───────────────────────────────────────────────── */
.step {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r);
  padding: 20px 22px 22px; margin-bottom: 14px;
}
.step-head { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 16px; }
.step-head h2 { margin: 0; font-size: 18px; font-weight: 600; }
.step-head p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.num {
  flex: none; width: 30px; height: 30px; border-radius: 50%;
  background: var(--lime); color: #1a2410; font-weight: 700; font-size: 15px;
  display: inline-flex; align-items: center; justify-content: center;
}
.step.done .num { background: var(--ok); }

/* drop zones */
.media-grid { display: grid; grid-template-columns: 1.3fr 1fr; gap: 12px; }
.drop {
  position: relative; min-height: 170px; padding: 18px 14px;
  border: 1.5px dashed var(--line-hi); border-radius: var(--r);
  background: var(--field); text-align: center; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  overflow: hidden;
}
.drop:hover, .drop.dragover { border-color: var(--lime); background: #182319; }
.drop.has-file { border-style: solid; border-color: var(--lime-mid); }
.drop svg { width: 34px; height: 34px; stroke: var(--lime); fill: none; stroke-width: 1.6; margin-bottom: 6px; }
.drop b { font-size: 16px; font-weight: 600; }
.drop span { color: var(--muted); font-size: 13px; }
.drop small { color: var(--dim); font-size: 11px; margin-top: 6px; }
.drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.drop.has-file b, .drop.has-file span, .drop.has-file small, .drop.has-file svg { position: relative; z-index: 1; }
.drop.has-file span, .drop.has-file small { color: var(--soft); }
.bg-preview { position: absolute; inset: 0; z-index: 0; }
.bg-preview img, .bg-preview video { width: 100%; height: 100%; object-fit: cover; opacity: .38; display: block; }
.drop.has-file svg { display: none; }

/* clip chips */
.clips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.clip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 5px 10px 5px 5px; border: 1px solid var(--line); border-radius: 99px;
  background: var(--panel-hi); font-size: 13px; max-width: 100%;
}
.clip video { width: 40px; height: 40px; object-fit: cover; border-radius: 50%; background: #000; flex: none; }
.clip b { font-weight: 600; color: var(--lime); }
.clip .name { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clip i { font-style: normal; color: var(--muted); font-size: 12px; }
.clip button { background: none; border: 0; color: var(--muted); font-size: 15px; padding: 0 2px; }
.clip button:hover { color: var(--err); }
.clips .note { width: 100%; font-size: 12.5px; color: var(--muted); }

/* inline rows */
.inline-row { display: flex; align-items: center; gap: 14px; margin-top: 16px; flex-wrap: wrap; }
.inline-label { font-size: 14px; color: var(--soft); min-width: 130px; display: flex; gap: 8px; align-items: baseline; }
.inline-label output { color: var(--lime); font-size: 13px; }
.segments { display: flex; gap: 8px; flex: 1; }
.segments button {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 10px 8px; background: var(--field); border: 1px solid var(--line); border-radius: var(--r-sm);
  font-size: 14px; color: var(--soft);
}
.segments button.selected { border-color: var(--lime); background: var(--lime-lo); color: var(--lime); }
.ratio { display: block; border: 1.5px solid currentColor; border-radius: 2px; }
.portrait { width: 11px; height: 18px; }
.landscape { width: 20px; height: 12px; }
.square { width: 15px; height: 15px; }
input[type=range] { flex: 1; min-width: 160px; accent-color: var(--lime); height: 6px; cursor: pointer; margin: 0; }

/* script */
.script-wrap { background: var(--field); border: 1px solid var(--line-hi); border-radius: var(--r-sm); overflow: hidden; }
.script-wrap:focus-within { border-color: var(--lime); }
textarea {
  display: block; width: 100%; min-height: 150px; resize: vertical;
  border: 0; background: none; padding: 14px 16px; color: var(--text);
  font-size: 16px; line-height: 1.8; outline: none !important;
}
textarea::placeholder { color: var(--dim); }
.counter { display: flex; justify-content: space-between; padding: 7px 12px; font-size: 12px; color: var(--dim); border-top: 1px solid var(--line); }

/* voice cards */
.voice-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 16px; }
.voice-card {
  position: relative; display: grid; grid-template-columns: 40px 1fr; grid-template-rows: auto auto;
  column-gap: 12px; align-items: center; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--field); cursor: pointer;
}
.voice-card:hover { border-color: var(--line-hi); }
.voice-card:has(input:checked) { border-color: var(--lime); background: var(--lime-lo); }
.voice-card input { position: absolute; opacity: 0; width: 0; height: 0; }
.voice-card .avatar {
  grid-row: 1 / span 2; width: 40px; height: 40px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 17px;
}
.avatar.f { background: #4a2c3d; color: #ffb3d4; }
.avatar.m { background: #22344c; color: #9cc6ff; }
.avatar.n { background: #34393a; color: #d6dbd8; }
.voice-card b { font-size: 15px; font-weight: 600; }
.voice-card small { color: var(--muted); font-size: 12px; }

/* subtitles */
.sub-row { justify-content: space-between; }
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 15px; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .knob { width: 44px; height: 24px; border-radius: 99px; background: #3b4a3f; position: relative; flex: none; transition: background .15s; }
.switch .knob:after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked + .knob { background: var(--lime); }
.switch input:checked + .knob:after { transform: translateX(20px); }
.style-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  position: relative; display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px 6px 8px; border: 1px solid var(--line); border-radius: 99px;
  background: var(--field); font-size: 13px; color: var(--soft); cursor: pointer;
}
.chip input { position: absolute; opacity: 0; width: 0; height: 0; }
.chip:has(input:checked) { border-color: var(--lime); background: var(--lime-lo); color: var(--text); }
.sample { font-weight: 700; font-size: 14px; text-shadow: 0 0 2px #000, 1px 1px 0 #000; padding: 1px 6px; border-radius: 4px; }
.sample.yellow { color: #ffec52; }
.sample.white { color: #fff; }
.sample.boxed { color: #fff; background: #000; text-shadow: none; }
.sub-row.off .style-chips { opacity: .35; pointer-events: none; }

/* advanced */
.advanced { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 12px; }
.advanced summary { cursor: pointer; color: var(--soft); font-size: 14px; list-style: none; display: flex; gap: 10px; align-items: baseline; }
.advanced summary::-webkit-details-marker { display: none; }
.advanced summary:before { content: '▸'; color: var(--lime); font-size: 12px; }
.advanced[open] summary:before { content: '▾'; }
.advanced summary span { color: var(--dim); font-size: 12px; }
.adv-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px 18px; margin-top: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--soft); }
.field output { color: var(--lime); margin-left: 6px; }
select, input[type=number] {
  background: var(--field); border: 1px solid var(--line-hi); border-radius: var(--r-sm);
  padding: 9px 10px; color: var(--text); width: 100%; font-size: 14px;
}
.color-row { display: flex; align-items: center; gap: 10px; }
.color-row input[type=color] { width: 44px; height: 34px; padding: 2px; border: 1px solid var(--line-hi); border-radius: 6px; background: var(--field); }
.color-row output { font-family: monospace; font-size: 13px; }
.own-audio { grid-column: 1 / -1; padding-top: 6px; border-top: 1px dashed var(--line); }
.own-audio input[type=file] { font-size: 13px; color: var(--soft); }
.own-audio small { color: var(--dim); font-size: 12px; }
.link-btn { background: none; border: 0; color: var(--lime); padding: 0; text-align: left; font-size: 13px; }

/* ── action bar (sticky) ─────────────────────────────────── */
.actionbar {
  position: sticky; bottom: 12px; z-index: 15;
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
  padding: 14px 18px; margin-top: 6px;
  background: #1a241d; border: 1px solid var(--line-hi); border-radius: var(--r);
  box-shadow: 0 10px 34px rgba(0,0,0,.45);
}
.readiness { display: flex; align-items: center; gap: 12px; min-width: 0; }
.readiness b { display: block; font-size: 15px; font-weight: 600; }
.readiness small { display: block; color: var(--muted); font-size: 12.5px; }
.actionbar.ready .readiness b { color: var(--lime); }
.actionbar.ready .num { background: var(--lime); }
.actionbar:not(.ready) .num { background: #3b4a3f; color: var(--soft); }
.go {
  display: inline-flex; align-items: center; gap: 12px;
  padding: 14px 28px; border-radius: 10px; border: 0;
  background: var(--lime); color: #1a2410; font-size: 17px; font-weight: 700; white-space: nowrap;
}
.go:hover:not(:disabled) { background: #d0ff8a; }
.go:disabled { background: #34413a; color: #93a297; opacity: 1; }
.go-ic { font-size: 14px; }

/* ── jobs ────────────────────────────────────────────────── */
.jobs { margin-top: 28px; }
.jobs-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.jobs-head h2 { margin: 0; font-size: 18px; font-weight: 600; }
.jobs-tools { display: flex; align-items: center; gap: 12px; }
.jobs-summary { font-size: 13px; color: var(--muted); }
.quiet { background: none; border: 1px solid var(--line); border-radius: var(--r-sm); color: var(--muted); padding: 7px 12px; font-size: 13px; }
.quiet:hover { color: var(--text); border-color: var(--line-hi); }
.empty { padding: 26px; text-align: center; border: 1px dashed var(--line); border-radius: var(--r); color: var(--dim); font-size: 14px; }

.job {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r);
  padding: 14px 16px; margin-bottom: 10px;
}
.job.completed { border-color: rgba(125, 217, 138, .45); }
.job.failed, .job.interrupted { border-color: rgba(240, 145, 126, .5); }
.job.running { border-color: var(--lime-mid); }
.job-head { display: flex; align-items: flex-start; gap: 12px; }
.job-title { flex: 1; min-width: 0; }
.job-title h3 { margin: 0; font-size: 15px; font-weight: 600; overflow-wrap: anywhere; }
.job-title small { color: var(--muted); font-size: 12.5px; }
.pill { flex: none; font-size: 12px; padding: 4px 10px; border-radius: 99px; border: 1px solid var(--line); color: var(--soft); background: var(--field); }
.pill.completed { color: var(--ok); border-color: rgba(125,217,138,.5); }
.pill.running, .pill.queued { color: var(--lime); border-color: var(--lime-mid); }
.pill.failed, .pill.interrupted { color: var(--err); border-color: rgba(240,145,126,.5); }
.pill.cancelled { color: var(--muted); }
.bar { height: 6px; border-radius: 99px; background: #2b3730; overflow: hidden; margin: 10px 0 6px; }
.bar i { display: block; height: 100%; width: 0; background: var(--lime); border-radius: 99px; transition: width .5s ease; }
.job.completed .bar i { background: var(--ok); }
.job.failed .bar i, .job.interrupted .bar i { background: var(--err); }
.job-msg { margin: 0; font-size: 13.5px; color: var(--soft); }
.job.failed .job-msg { color: #f4b9a6; }
.job-media { margin-top: 12px; }
.job-media video { width: 100%; max-height: 520px; background: #000; border-radius: var(--r-sm); display: block; }
.job-media audio { width: 100%; height: 40px; display: block; }
.job-acts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; align-items: center; }
.job-acts a, .job-acts button {
  font-size: 13px; padding: 7px 12px; border-radius: var(--r-sm);
  border: 1px solid var(--line-hi); background: var(--panel-hi); color: var(--text);
}
.job-acts a.main { border-color: var(--lime); color: var(--lime); }
.job-acts .danger { color: var(--err); }
.job-acts .ref { margin-left: auto; background: none; border: 0; color: var(--dim); font-size: 12px; }
.job-ref { margin: 8px 0 0; font: 12px/1.7 monospace; color: var(--dim); overflow-wrap: anywhere; }

.page-footer { margin-top: 30px; padding-top: 16px; border-top: 1px solid var(--line); font-size: 12px; color: var(--dim); text-align: center; }

/* ── modes ───────────────────────────────────────────────── */
body.voice-mode #step-media { display: none; }
body.history-mode #create-view, body.history-mode .actionbar { display: none; }
body.history-mode .jobs { margin-top: 6px; }

/* ── responsive ──────────────────────────────────────────── */
@media (max-width: 760px) {
  .topbar { padding: 0 14px; gap: 12px; min-height: 54px; }
  .brand { font-size: 17px; }
  .tab { padding: 0 10px; font-size: 14px; }
  .health { font-size: 11px; }
  main { padding: 18px 12px 130px; }
  h1 { font-size: 25px; }
  .mode-switch { flex-direction: column; }
  .media-grid { grid-template-columns: 1fr; }
  .drop { min-height: 130px; }
  .step { padding: 16px 14px 18px; }
  .voice-cards { grid-template-columns: 1fr; }
  .voice-card { grid-template-rows: auto; grid-template-columns: 40px 1fr auto; }
  .voice-card small { grid-column: 3; }
  .inline-label { min-width: 0; width: 100%; }
  .segments button { font-size: 13px; gap: 6px; }
  .actionbar { flex-direction: column; align-items: stretch; bottom: 8px; padding: 12px 14px; }
  .go { justify-content: center; }
  .job-media video { max-height: 70vh; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }

/* ── several backgrounds: chips + pairing tags ───────────── */
.clip img { width: 40px; height: 40px; object-fit: cover; border-radius: 50%; background: #000; flex: none; }
.bg-clips .clip b { color: #9cc6ff; }
.clip .tag { font-size: 11px; color: var(--muted); border: 1px solid var(--line); border-radius: 99px; padding: 1px 7px; white-space: nowrap; }
.clip .tag.bg { color: #9cc6ff; border-color: rgba(156, 198, 255, .35); }
.job-title .bgname { color: #9cc6ff; }

/* ── background library strip ────────────────────────────── */
.library { margin-top: 14px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--field); padding: 0 14px 4px; }
.library summary { cursor: pointer; padding: 11px 0; font-size: 14px; color: var(--soft); list-style: none; display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.library summary::-webkit-details-marker { display: none; }
.library summary:before { content: '▸'; color: var(--lime); font-size: 12px; }
.library[open] summary:before { content: '▾'; }
.library summary span { color: var(--dim); font-size: 12px; }
.lib-group { padding: 4px 0 12px; }
.lib-group h4 { margin: 0 0 8px; font-size: 13px; font-weight: 600; color: var(--muted); display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.lib-group h4 small { font-weight: 400; font-size: 11.5px; color: var(--dim); overflow-wrap: anywhere; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; }
.tile {
  position: relative; display: flex; flex-direction: column; gap: 4px; padding: 0; text-align: left;
  background: var(--panel-hi); border: 1px solid var(--line); border-radius: var(--r-sm); overflow: hidden; cursor: pointer;
}
.tile:hover { border-color: var(--line-hi); }
.tile.on { border-color: var(--lime); box-shadow: 0 0 0 1px var(--lime); }
.tile img, .tile video { width: 100%; aspect-ratio: 1 / 1; object-fit: cover; background: #000; display: block; }
.tile .tname { font-size: 11.5px; color: var(--soft); padding: 0 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile .tmeta { font-size: 10.5px; color: var(--dim); padding: 0 8px 7px; }
.tile .check { position: absolute; top: 6px; right: 6px; width: 22px; height: 22px; border-radius: 50%; background: var(--lime); color: #1a2410; font-size: 13px; font-weight: 700; display: none; align-items: center; justify-content: center; }
.tile.on .check { display: inline-flex; }
.tile.busy { opacity: .5; pointer-events: none; }
.empty-tiles { grid-column: 1 / -1; font-size: 12.5px; color: var(--dim); padding: 6px 0; overflow-wrap: anywhere; }

/* Sticky bars must never hide the element the page scrolls to (keyboard focus, anchors, automation). */
html { scroll-padding-top: 72px; scroll-padding-bottom: 150px; }
.tile, .clip, .voice-card, .chip, .segments button, .drop, .job { scroll-margin-bottom: 150px; }

/* ── background pairing (ordered / random / whole library) + library admin ── */
.bg-mode { align-items: center; }
.bg-mode .segments { flex: 1 1 280px; }
.switch.small { font-size: 13.5px; }
.switch.small .knob { width: 38px; height: 22px; }
.switch.small .knob:after { width: 16px; height: 16px; }
.switch.small input:checked + .knob:after { transform: translateX(16px); }
.switch small { color: var(--muted); font-weight: 400; margin-left: 4px; }
.hint-line { margin: 6px 0 0; font-size: 12.5px; color: var(--muted); min-height: 1.2em; }
.field small { display: block; color: var(--dim); font-size: 11.5px; }
.lib-admin { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin: -2px 0 10px; }
.admin-login { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.admin-login input { background: var(--field); border: 1px solid var(--line-hi); border-radius: var(--r-sm); padding: 7px 10px; color: var(--text); font-size: 13px; min-width: 220px; }
.admin-login small { color: var(--dim); font-size: 11.5px; overflow-wrap: anywhere; }
.admin-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.upload-lib { cursor: pointer; display: inline-flex; align-items: center; gap: 6px; color: var(--lime); border-color: var(--lime-mid); }
.admin-badge { font-size: 11px; color: #1a2410; background: var(--lime); border-radius: 99px; padding: 2px 8px; font-weight: 600; }
.tile .del { position: absolute; top: 6px; left: 6px; width: 22px; height: 22px; border-radius: 50%; border: 0; background: rgba(0,0,0,.65); color: #fff; font-size: 12px; line-height: 22px; text-align: center; padding: 0; cursor: pointer; }
.tile .del:hover { background: var(--err); }
.tile.dim { opacity: .55; }

/* ── two-stage flow: which steps each mode shows ─────────── */
body.composite-mode #step-script, body.composite-mode #step-source { display: none; }
body.dub-mode #step-media { display: none; }
body.voice-mode #step-source { display: none; }
.mode-switch button b { line-height: 1.3; }
.tile.src video { aspect-ratio: 9 / 16; max-height: 150px; object-fit: contain; }
.tile.src .tmeta { white-space: normal; }
.job-acts button.main { border-color: var(--lime); color: var(--lime); background: var(--lime-lo); }
@media (max-width: 760px) { .mode-switch { flex-direction: column; } }

/* ── one click for both stages, one script per video, AI draft, preview ── */
body.composite-mode.chain-on #step-script { display: block; }
.chain-row { gap: 10px 16px; }
.chain-row .hint-line { margin: 0; flex: 1 1 320px; }
.ai-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; margin-top: 10px; }
.ai-btn { border-color: var(--lime-mid); color: var(--lime); }
.ai-btn:disabled { opacity: .5; cursor: not-allowed; color: var(--muted); border-color: var(--line-hi); }
.ai-field { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); }
.ai-field input, .ai-field select { background: var(--field); border: 1px solid var(--line-hi); border-radius: var(--r-sm); color: var(--text); padding: 6px 8px; font-size: 13px; }
.ai-field input { width: 62px; }
.ai-row small { flex: 1 1 260px; color: var(--dim); font-size: 11.5px; overflow-wrap: anywhere; }
.per-clip { margin-top: 14px; display: grid; gap: 10px; }
.pc-head { margin: 0; font-size: 12.5px; color: var(--muted); }
.pc-item { border: 1px solid var(--line); border-radius: var(--r-sm); padding: 10px 12px; background: var(--field); }
.pc-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px; }
.pc-top b { font-size: 13px; font-weight: 600; overflow-wrap: anywhere; }
.pc-acts { display: inline-flex; gap: 12px; }
.pc-acts .ai { color: var(--lime); }
.pc-item textarea { width: 100%; margin-top: 8px; background: var(--bg); border: 1px solid var(--line-hi); border-radius: var(--r-sm); color: var(--text); padding: 8px 10px; font: inherit; font-size: 13.5px; line-height: 1.6; resize: vertical; }
.tile .play { position: absolute; left: 6px; bottom: 44px; width: 26px; height: 26px; border-radius: 50%; background: rgba(0,0,0,.66); color: #fff; font-size: 11px; line-height: 26px; text-align: center; cursor: pointer; }
.tile .play:hover { background: var(--lime); color: #1a2410; }
.preview { margin-top: 12px; border: 1px solid var(--line-hi); border-radius: var(--r-sm); padding: 10px; background: var(--field); }
.preview video { width: 100%; max-height: 46vh; background: #000; border-radius: var(--r-sm); display: block; }
.preview-meta { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 8px; font-size: 13px; }
.preview-meta b { overflow-wrap: anywhere; font-weight: 600; }
