
  :root {
    color-scheme: dark;
    --bg: #0e0b0c; --bg-2: #171213; --card: #1c1617; --card-2: #251c1d; --field: #2a2224;
    --line: rgba(255, 236, 214, .14); --line-strong: rgba(255, 236, 214, .28);
    --text: #f6eee6; --muted: #b3a8a1; --gold: #ecc48f; --gold-deep: #c98f55; --on-gold: #241509;
    --wine: #6e1b33; --wine-deep: #3a111f; --good: #8fd6a2; --bad: #ff9c9c;
    /* Not Playfair: the SDK adds it to the page when a video uses it, which would restyle these headings. */
    --serif: "Iowan Old Style", "Palatino Linotype", Georgia, serif;
    --preview-width: 360px;
  }
  * { box-sizing: border-box; }
  [hidden] { display: none !important; }
  html { background: var(--bg); }
  body {
    margin: 0; min-height: 100vh; color: var(--text); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
    background: radial-gradient(70vw 50vh at 100% 0, rgba(110, 27, 51, .28), transparent 70%), radial-gradient(40vw 60vh at 0 100%, rgba(110, 27, 51, .3), transparent 70%), var(--bg);
  }
  button, input, select { font: inherit; }
  button { cursor: pointer; }
  button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
  h1, h2, h3, p { margin: 0; }
  svg { display: block; }

  .topbar { display: flex; align-items: center; gap: 14px; min-height: 66px; padding: 10px 28px; border-bottom: 1px solid var(--line); background: linear-gradient(100deg, #151011, var(--wine-deep) 70%, #1a1012); }
  .brand { display: flex; align-items: center; gap: 10px; font: 700 28px/1 var(--serif); letter-spacing: -.01em; }
  .divider { width: 1px; height: 28px; background: var(--line-strong); }
  .topbar h1 { font: italic 400 22px/1 var(--serif); white-space: nowrap; }
  .chip { display: inline-flex; align-items: center; gap: 7px; padding: 3px 10px; color: var(--muted); font-size: 13px; white-space: nowrap; border: 1px solid var(--line); border-radius: 99px; }
  .chip i { width: 8px; height: 8px; background: var(--muted); border-radius: 50%; }
  .topbar .end { margin-left: auto; }

  /* Whole-pixel columns, so the frame never lands on a half pixel and blurs the canvas. */
  .shell { display: grid; grid-template-columns: 210px 400px minmax(0, 1fr); gap: 20px; padding: 18px 20px 24px 0; align-items: start; }

  .rail { position: relative; min-height: calc(100vh - 110px); padding: 0 0 0 16px; }
  #nav { display: grid; gap: 6px; }
  #nav button { display: flex; align-items: center; gap: 14px; width: 100%; padding: 14px; color: var(--text); text-align: left; background: transparent; border: 1px solid transparent; border-radius: 12px; }
  #nav button:hover { background: rgba(255, 236, 214, .05); }
  #nav button[aria-current="true"] { background: linear-gradient(100deg, var(--wine), var(--wine-deep)); border-color: rgba(236, 196, 143, .45); }
  #nav .glyph { flex: none; color: var(--gold); }
  #nav b { display: block; font-size: 17px; font-weight: 500; line-height: 1.25; }
  #nav small { display: block; color: var(--muted); font-size: 13px; line-height: 1.3; }
  .film { position: absolute; left: 0; right: 0; bottom: 0; width: 100%; opacity: .75; pointer-events: none; }

  #stage { display: grid; gap: 10px; justify-items: center; padding: 10px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 14px; }
  #frame { width: var(--preview-width); max-width: 100%; overflow: hidden; background: #000; border-radius: 10px; }
  /* The canvas takes no mouse or touch input. Playback runs from the buttons below it. */
  [data-shotstack-studio] { width: 100%; aspect-ratio: 9 / 16; overflow: hidden; background: #000; pointer-events: none; user-select: none; }
  /* The SDK fixes the canvas in pixels. Out of flow, it can't stretch the frame when the page resizes. */
  [data-shotstack-studio] canvas { position: absolute; inset: 0; }
  #transport { display: flex; align-items: center; gap: 12px; width: 100%; padding: 9px 12px; background: var(--card-2); border-radius: 10px; }
  #transport button { display: grid; place-items: center; flex: none; width: 36px; height: 36px; padding: 0; color: var(--text); background: transparent; border: 0; border-radius: 8px; }
  #transport button:hover:not(:disabled) { background: rgba(255, 236, 214, .1); }
  #transport button:disabled { opacity: .45; cursor: default; }
  #play .pause, #play[data-playing="true"] .start { display: none; }
  #play[data-playing="true"] .pause { display: block; }
  #time { flex: none; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
  #seek { flex: 1; min-width: 0; height: 20px; margin: 0; background: transparent; -webkit-appearance: none; appearance: none; }
  #seek::-webkit-slider-runnable-track { height: 4px; border-radius: 4px; background: linear-gradient(90deg, var(--gold) var(--fill, 0%), rgba(255, 236, 214, .25) var(--fill, 0%)); }
  #seek::-webkit-slider-thumb { width: 14px; height: 14px; margin-top: -5px; background: var(--gold); border-radius: 50%; -webkit-appearance: none; appearance: none; }
  #seek::-moz-range-track { height: 4px; border-radius: 4px; background: rgba(255, 236, 214, .25); }
  #seek::-moz-range-progress { height: 4px; border-radius: 4px; background: var(--gold); }
  #seek::-moz-range-thumb { width: 14px; height: 14px; background: var(--gold); border: 0; border-radius: 50%; }
  #status { min-height: 20px; color: var(--gold); font-size: 13px; text-align: center; }
  .fine { color: var(--muted); font-size: 12.5px; text-align: center; }
  #stage:fullscreen { align-content: center; padding: 8px; background: #000; border: 0; border-radius: 0; }
  #stage:fullscreen #frame { width: auto; height: calc(100vh - 76px); aspect-ratio: 9 / 16; }
  #stage:fullscreen #transport { width: min(560px, 100%); }
  #stage:fullscreen #status, #stage:fullscreen .fine { display: none; }

  .side { display: grid; gap: 16px; min-width: 0; }
  #form { min-width: 0; background: var(--card); border: 1px solid var(--line); border-radius: 18px; overflow: hidden; }
  .panel-head { display: flex; align-items: center; gap: 16px; padding: 16px 24px; background: linear-gradient(100deg, rgba(110, 27, 51, .55), rgba(58, 17, 31, .2)); border-bottom: 1px solid var(--line); }
  .panel-head .glyph { flex: none; color: var(--gold); }
  .panel-head h2 { font: 500 26px/1.2 var(--serif); }
  .panel-head p { color: var(--muted); }
  .panel-body { display: grid; gap: 16px; padding: 18px 24px 24px; }
  .row-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 12px; }
  .row-head h3 { font-size: 16px; font-weight: 500; }
  .row-head span { color: var(--muted); font-size: 13px; }

  .slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 10px; }
  .slot { display: grid; gap: 5px; min-width: 0; padding: 0; color: var(--text); text-align: left; background: transparent; border: 0; }
  .slot .thumb { display: block; width: 100%; aspect-ratio: 1; overflow: hidden; background: var(--field); border: 2px solid var(--line); border-radius: 10px; }
  .slot img { display: block; width: 100%; height: 100%; object-fit: contain; }
  .slot[aria-pressed="true"] .thumb { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold); }
  .slot b { font-size: 13px; font-weight: 500; }
  .slot small { display: block; color: var(--muted); font-size: 12px; line-height: 1.25; }
  .slot small.draft { color: var(--gold); }
  .slot small.done { color: var(--good); }
  .slot small.needs { color: var(--bad); }
  .note { color: var(--muted); font-size: 13px; }

  fieldset { display: grid; gap: 12px; min-width: 0; margin: 0; padding: 16px 0 0; border: 0; border-top: 1px solid var(--line); }
  legend { float: left; width: 100%; padding: 0; font-size: 16px; font-weight: 500; }
  legend + * { clear: both; }
  label { display: block; color: var(--muted); font-size: 13px; }
  input[type=text], select { display: block; width: 100%; min-height: 44px; margin-top: 5px; padding: 9px 12px; color: var(--text); background: var(--field); border: 1px solid var(--line-strong); border-radius: 10px; }
  select option { color: var(--text); background: var(--field); }
  input[type=range] { display: block; width: 100%; margin-top: 8px; accent-color: var(--gold); }
  .text-field .top { display: flex; justify-content: space-between; gap: 10px; }
  .text-field .count { font-variant-numeric: tabular-nums; }
  .text-field .count.over { color: var(--bad); }

  .look { display: grid; gap: 14px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
  .look-group { gap: 6px; padding: 0; border: 0; }
  .look-group legend { color: var(--muted); font-size: 13px; font-weight: 400; }
  .look-options { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .look-options.look-color { grid-template-columns: repeat(auto-fill, minmax(122px, 1fr)); }
  .look-option { position: relative; display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 6px 10px; color: var(--text); font-size: 14px; text-align: center; background: var(--field); border: 1px solid var(--line-strong); border-radius: 10px; cursor: pointer; }
  .look-option input { position: absolute; inset: 0; margin: 0; opacity: 0; cursor: pointer; }
  .look-option:hover { border-color: var(--gold); }
  .look-option:has(input:checked) { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold); }
  .look-option:has(input:focus-visible) { outline: 2px solid var(--gold); outline-offset: 2px; }
  .look-color .look-option { justify-content: flex-start; }
  .swatch { flex: none; width: 18px; height: 18px; border: 1px solid rgba(255, 255, 255, .6); border-radius: 50%; }
  .sample-bold { font-weight: 800; }
  .sample-elegant { font-family: var(--serif); font-weight: 700; }

  .adjust { display: grid; gap: 12px; padding-top: 14px; border-top: 1px solid var(--line); }
  .adjust-row { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; }
  .adjust-thumb { position: relative; flex: none; width: fit-content; overflow: hidden; background: #000; border-radius: 8px; }
  .adjust-thumb img { display: block; width: auto; max-width: 180px; height: 130px; }
  .crop-box { position: absolute; border: 2px solid var(--gold); box-shadow: 0 0 0 200px rgba(0, 0, 0, .55); }
  .adjust-controls { display: grid; gap: 10px; flex: 1 1 240px; min-width: 0; }
  .crop-actions { display: flex; flex-wrap: wrap; gap: 8px; }
  .crop-actions button { display: inline-flex; align-items: center; justify-content: center; min-height: 40px; padding: 8px 14px; font-weight: 500; border-radius: 9px; }
  .ghost { color: var(--text); background: transparent; border: 1px solid var(--line-strong); }
  .ghost:hover:not(:disabled) { border-color: var(--gold); }
  .gold { color: var(--on-gold); background: linear-gradient(180deg, var(--gold), var(--gold-deep)); border: 1px solid var(--gold); }
  button:disabled { cursor: default; }
  .crop-actions button:disabled { opacity: .5; }
  .state { color: var(--muted); font-size: 13px; }
  .error { color: var(--bad); font-size: 13px; }
  .error:empty, .state:empty { display: none; }

  .locked { display: flex; align-items: flex-start; gap: 12px; padding: 14px; background: var(--field); border: 1px solid var(--line); border-radius: 10px; }
  .locked .glyph { flex: none; color: var(--gold); }
  .locked b { display: block; font-weight: 500; }
  .locked span { color: var(--muted); font-size: 13.5px; }
  .review-group { display: grid; gap: 6px; }
  .review-group h3 { color: var(--gold); font-size: 14px; font-weight: 500; }
  .review-row { display: flex; justify-content: space-between; gap: 16px; padding: 7px 0; border-top: 1px solid var(--line); }
  .review-row span:first-child { flex: none; color: var(--muted); font-size: 13.5px; }
  .review-row span:last-child { min-width: 0; text-align: right; overflow-wrap: anywhere; }

  .actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 12px; }
  .actions button { display: inline-flex; align-items: center; justify-content: center; gap: 12px; min-height: 58px; padding: 12px 34px; font: 500 18px/1.2 var(--serif); border-radius: 12px; }
  .actions .ghost { background: rgba(14, 11, 12, .6); border-color: var(--gold); }
  .actions button:disabled { opacity: .55; }
  .actions p { flex-basis: 100%; color: var(--muted); font-size: 13px; text-align: right; }

  @media (min-width: 1300px) { .shell { grid-template-columns: 250px 480px minmax(0, 1fr); } }
  @media (min-width: 1500px) { .shell { grid-template-columns: 310px 570px minmax(0, 1fr); } }
  @media (min-width: 1400px) and (min-height: 900px) { :root { --preview-width: 412px; } }
  @media (max-height: 800px) and (min-width: 901px) { :root { --preview-width: 300px; } }
  @media (max-height: 620px) { .film { display: none; } }

  @media (max-width: 900px) {
    :root { --preview-width: clamp(200px, calc((100svh - 300px) * 9 / 16), 360px); }
    .topbar { flex-wrap: wrap; gap: 8px 12px; padding: 10px 16px; }
    .brand { font-size: 23px; }
    .topbar h1 { font-size: 18px; }
    .topbar .end { margin-left: 0; }
    .shell { grid-template-columns: minmax(0, 1fr); gap: 12px; padding: 12px 16px 0; }
    #stage { order: 1; }
    .rail { order: 2; min-height: 0; padding: 0; }
    .side { order: 3; }
    .film { display: none; }
    #nav { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
    #nav button { flex: none; width: auto; min-height: 44px; padding: 8px 14px; gap: 8px; border-color: var(--line); }
    #nav small { display: none; }
    #nav b { font-size: 15px; }
    #nav .glyph svg { width: 20px; height: 20px; }
    .panel-head { padding: 12px 16px; }
    .panel-head h2 { font-size: 22px; }
    .panel-body { padding: 14px 16px 18px; }
    .actions { position: sticky; bottom: 0; z-index: 2; margin: 0 -16px; padding: 10px 16px; background: rgba(14, 11, 12, .94); border-top: 1px solid var(--line); }
    .slots { grid-template-columns: repeat(auto-fill, minmax(66px, 1fr)); }
    .actions button { flex: 1 1 140px; gap: 8px; min-height: 48px; padding: 8px; font-size: 15px; white-space: nowrap; }
    .actions p { text-align: center; font-size: 12px; }
    .crop-actions button { flex: 1 1 auto; min-height: 44px; }
  }
