:root {
  --bg: #faf7f2;
  --surface: #ffffff;
  --surface-2: #f4efe7;
  --border: #e6ded2;
  --text: #2a2320;
  --muted: #73675d;
  --accent: #b4513a;
  --accent-2: #c99a3d;
  --accent-text: #ffffff;
  --danger: #b3261e;
  --warn: #8a5a00;
  --ok: #2f6f4a;
  --stage-bg: linear-gradient(180deg, #f3eee6 0%, #ebe4d8 100%);
  --stage-text: #2a2320;
  --stage-muted: #73675d;
  --track: #e3d9cb;
  --radius: 14px;
  --font: "Inter", "Noto Sans SC", system-ui, -apple-system, "Segoe UI", sans-serif;
  --serif: "Fraunces", Georgia, serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #171412; --surface: #211d1a; --surface-2: #2a2521; --border: #3a332d;
    --text: #f3ece3; --muted: #b5a99c; --accent: #e0805f; --accent-2: #e2b85e; --accent-text: #1d120d;
    --danger: #ff8a80; --warn: #f2c14e; --ok: #8fd19e;
    --stage-bg: linear-gradient(180deg, #221d19 0%, #1b1714 100%); --stage-text: #f3ece3; --stage-muted: #b5a99c; --track: #40382f;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #171412; --surface: #211d1a; --surface-2: #2a2521; --border: #3a332d;
  --text: #f3ece3; --muted: #b5a99c; --accent: #e0805f; --accent-2: #e2b85e; --accent-text: #1d120d;
  --danger: #ff8a80; --warn: #f2c14e; --ok: #8fd19e;
  --stage-bg: linear-gradient(180deg, #221d19 0%, #1b1714 100%); --stage-text: #f3ece3; --stage-muted: #b5a99c; --track: #40382f;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.45 var(--font); }
button, input, select, textarea { font: inherit; color: inherit; }

.topbar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 10px 20px; background: var(--surface); border-bottom: 1px solid var(--border); flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; font: 600 22px var(--serif); color: inherit; text-decoration: none; }
.topbar-actions { display: flex; gap: 6px; flex-wrap: wrap; }

button, .button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; cursor: pointer;
  border-radius: 999px; border: 1px solid var(--border); background: var(--surface); padding: 7px 14px;
  text-decoration: none; font-weight: 500; font-size: 14px;
}
button:hover, .button:hover { background: var(--surface-2); }
button:focus-visible, .button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
.ghost { border-color: transparent; background: transparent; }
.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; padding: 11px 20px; font-size: 15px; }
.primary:hover { background: var(--accent); filter: brightness(1.06); }
.primary:disabled { opacity: 0.5; cursor: not-allowed; }
.icon { width: 40px; height: 40px; padding: 0; }
.small { padding: 4px 10px; font-size: 13px; }
.danger-text { color: var(--danger); }

.layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, 520px); gap: 0; min-height: calc(100vh - 57px); }
.editor { padding: 20px; display: flex; flex-direction: column; gap: 16px; max-width: 820px; width: 100%; justify-self: center; }
.stage { background: var(--stage-bg); color: var(--stage-text); }
.stage-inner { position: sticky; top: 57px; padding: 20px; display: flex; flex-direction: column; gap: 12px; max-height: calc(100vh - 57px); overflow: auto; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.card h2 { margin: 0 0 4px; font: 600 19px var(--serif); display: flex; align-items: center; gap: 10px; }
.card .hint { margin: 0 0 12px; color: var(--muted); font-size: 13px; }
.swatch { width: 14px; height: 14px; border-radius: 50%; display: inline-block; }

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px 12px; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field > span { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.field input[type="text"], .field input:not([type]), .field select, .field textarea {
  width: 100%; border: 1px solid var(--border); background: var(--bg); border-radius: 8px; padding: 8px 10px;
}
.field input.invalid { border-color: var(--danger); }
.field textarea { resize: vertical; min-height: 40px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; }
input[type="color"] { width: 44px; height: 32px; border: 1px solid var(--border); border-radius: 8px; padding: 2px; background: var(--bg); cursor: pointer; }
input[type="range"] { accent-color: var(--accent); }

.stops { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.stop { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; background: var(--surface-2); display: grid; grid-template-columns: 1fr auto; gap: 10px; }
.stop-fields { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 0.7fr); gap: 8px 10px; }
.stop-fields .wide { grid-column: 1 / -1; }
.stop-side { display: flex; flex-direction: column; gap: 6px; align-items: center; }
.stop-num { font: 600 13px var(--font); color: var(--muted); }

.photo { width: 72px; height: 72px; border-radius: 8px; border: 1px dashed var(--border); background: var(--bg) center/cover no-repeat;
  display: flex; align-items: center; justify-content: center; font-size: 11px; color: var(--muted); cursor: pointer; text-align: center; position: relative; }
.photo.has { border-style: solid; color: transparent; }
.photo input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

.preview-frame { position: relative; flex-shrink: 0; margin: 0 auto; width: 100%; background: #fff; border-radius: 18px; overflow: hidden; box-shadow: 0 24px 60px rgba(60, 40, 20, 0.16); }
.preview-frame canvas { display: block; width: 100%; height: 100%; }
.preview-loading { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--stage-muted); font-size: 14px; }
.transport { display: flex; align-items: center; gap: 10px; }
.transport .icon { background: var(--accent); color: var(--accent-text); border: 0; }
.transport .icon.mute { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.transport .icon.mute[aria-pressed="true"] { color: var(--muted); }
.transport input { flex: 1; }
.time { font-variant-numeric: tabular-nums; font-size: 13px; color: var(--stage-muted); min-width: 86px; text-align: right; }

.messages { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.messages .err { color: var(--danger); }
.messages .warn { color: var(--warn); }
.messages .ok { color: var(--ok); }
.notice { padding: 10px 12px; border-radius: 10px; background: var(--surface); border: 1px solid var(--border); }
.export { display: flex; flex-direction: column; gap: 10px; }
.job-row { display: flex; justify-content: space-between; font-size: 13px; color: var(--stage-muted); }
.bar { height: 8px; border-radius: 99px; background: var(--track); overflow: hidden; }
.bar-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width 0.4s; }
.result { display: flex; flex-direction: column; gap: 10px; }
.result video { width: 100%; max-height: 60vh; background: #000; border-radius: 10px; }

.checkout, .paid { background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.checkout h2 { margin: 0; font: 600 20px var(--serif); }
.fine { margin: 0; font-size: 12.5px; color: var(--muted); }
.tiers { display: grid; gap: 8px; }
.tier { position: relative; display: grid; gap: 2px; padding: 10px 12px 10px 38px; border: 1.5px solid var(--border); border-radius: 12px; cursor: pointer; background: var(--bg); }
.tier input { position: absolute; left: 12px; top: 13px; accent-color: var(--accent); }
.tier.on { border-color: var(--accent); background: var(--surface-2); }
.tier.off { opacity: 0.45; cursor: not-allowed; }
.tier-head { display: flex; justify-content: space-between; font-weight: 600; }
.tier-price { font: 600 17px var(--serif); }
.tier-feat { font-size: 12.5px; color: var(--muted); }
.tier-why { margin: 0; font-size: 13px; color: var(--accent); font-weight: 500; }
.tier-why:empty { display: none; }
.paid-badge { margin: 0; font-weight: 600; color: var(--ok); }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .stage { order: -1; }
  .stage-inner { position: static; max-height: none; padding: 16px; }
  .preview-frame { max-width: 360px; }
  .editor { padding: 16px; }
  .topbar { padding: 10px 16px; }
}
@media (max-width: 520px) {
  .stop-fields { grid-template-columns: 1fr; }
  .stop { grid-template-columns: 1fr; }
  .stop-side { flex-direction: row; justify-content: space-between; }
}
@media (max-width: 520px) {
  .topbar-actions { width: 100%; justify-content: space-between; }
  .topbar-actions .ghost { padding: 6px 8px; font-size: 13px; }
}

fieldset.plain { border: 0; padding: 0; margin: 0; min-width: 0; }
fieldset.plain:disabled { opacity: 0.45; }
.card h2.with-switch { justify-content: space-between; }
.switch { display: inline-flex; align-items: center; gap: 10px; font: 500 14px var(--font); cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-track { width: 44px; height: 26px; border-radius: 99px; background: var(--track); position: relative; transition: background 0.2s; flex: none; }
.switch-track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.25); transition: transform 0.2s; }
.switch input:checked + .switch-track { background: var(--accent); }
.switch input:checked + .switch-track::after { transform: translateX(18px); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--accent); outline-offset: 2px; }

#btn-new-video, #btn-cancel-new { align-self: flex-start; color: var(--muted); padding-left: 0; }

.packs { display: grid; gap: 8px; }
.pack { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px 10px 38px; border: 1.5px solid var(--border); border-radius: 12px; cursor: pointer; background: var(--bg); }
.pack input { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); accent-color: var(--accent); }
.pack.on { border-color: var(--accent); background: var(--surface-2); }
.pack-label { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; }
.pack-price { font: 600 17px var(--serif); }
.save { font-size: 11.5px; font-weight: 700; color: var(--accent-text); background: var(--accent-2); padding: 2px 8px; border-radius: 99px; }
.upsell { display: grid; gap: 6px; padding: 12px; border-radius: 12px; border: 1.5px dashed var(--accent-2); background: var(--surface-2); }
.upsell button { justify-self: start; }
.my-videos { background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; display: grid; gap: 8px; }
.my-videos h3 { margin: 0; font: 600 17px var(--serif); }
.video-row { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; background: var(--bg); }
.video-row.on { outline: 1.5px solid var(--accent); }
.video-name { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.optional { font: 500 12px var(--font); color: var(--muted); background: var(--surface-2); border: 1px solid var(--border); border-radius: 99px; padding: 2px 8px; }
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; }
