  :root {
    --paper: #f7f1e6;
    --paper-deep: #efe6d4;
    --paper-card: #fbf7ef;
    --ink: #2e2519;
    --ink-soft: #6e5f4b;
    --ink-faint: #9a8b74;
    --gold: #ab8347;
    --gold-deep: #8a6730;
    --sage: #7c8a72;
    --hairline: rgba(46, 37, 25, 0.16);
    --hairline-soft: rgba(46, 37, 25, 0.09);
    --shadow: 0 24px 60px -28px rgba(46, 37, 25, 0.45);
    --arch: 999px 999px 14px 14px;
    --ease-gentle: cubic-bezier(0.22, 0.61, 0.36, 1);
  }

  * { margin: 0; padding: 0; box-sizing: border-box; }

  body {
    background: var(--paper);
    color: var(--ink);
    font-family: "Lora", Georgia, serif;
    font-size: 16px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
  }

  body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    /* Below the fullscreen overlays (player/paysheet/production are 1000+) so the
       grain textures the builder but never sits on top of the rendered video. */
    z-index: 900;
    opacity: 0.5;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3CfeColorMatrix values='0 0 0 0 0.18 0 0 0 0 0.14 0 0 0 0 0.09 0 0 0 0.05 0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
  }

  h1, h2, h3 {
    font-family: "Cormorant Garamond", Georgia, serif;
    font-weight: 500;
    line-height: 1.12;
  }

  .eyebrow {
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.3em;
    text-transform: uppercase;
    color: var(--gold);
  }

  button { font-family: "Lora", serif; cursor: pointer; }

  .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    border: none;
    font-size: 14.5px;
    font-weight: 600;
    letter-spacing: 0.05em;
    padding: 15px 28px;
    border-radius: 999px;
    background: var(--ink);
    color: var(--paper);
    transition: background 0.5s var(--ease-gentle), transform 0.5s var(--ease-gentle);
    box-shadow: 0 18px 40px -18px rgba(46,37,25,0.55);
  }
  .btn:hover { background: var(--gold-deep); transform: translateY(-2px); }
  .btn:disabled { opacity: 0.45; pointer-events: none; }
  .btn.ghost {
    background: transparent;
    color: var(--ink);
    border: 1px solid var(--hairline);
    box-shadow: none;
  }
  .btn.ghost:hover { background: var(--paper-deep); }

  /* ---------- chrome ---------- */

  .topbar {
    position: sticky;
    top: 0;
    z-index: 700;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px clamp(16px, 4vw, 32px);
    background: rgba(251,247,239,0.92);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--hairline-soft);
  }
  .topbar a.back {
    text-decoration: none;
    color: var(--ink-faint);
    font-size: 12px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
  }
  .topbar a.back:hover { color: var(--gold-deep); }
  .topbar .t-title { font-family: "Cormorant Garamond", serif; font-size: 19px; font-weight: 600; }
  .topbar .saved {
    font-size: 11px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--sage);
    opacity: 0;
    transition: opacity 0.6s;
  }
  .topbar .saved.show { opacity: 1; }

  .shell {
    max-width: 860px;
    margin: 0 auto;
    padding: clamp(18px, 3vh, 30px) clamp(14px, 4vw, 32px) 170px;
  }

  /* ---------- filmstrip ---------- */

  .strip-label {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 12px;
  }
  .strip-label .duration {
    font-size: 12px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--ink-faint);
  }

  .film-settings {
    background: var(--paper-card);
    border: 1px solid var(--hairline-soft);
    border-radius: 18px;
    padding: 24px 26px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 26px 40px;
    margin: 2px 0 30px;
  }
  .fs-group .chip-row { margin-top: 10px; }
  .look-hint {
    margin-top: 8px;
    font-size: 13px;
    font-style: italic;
    color: var(--ink-faint);
  }

  .pace-ctl {
    display: flex;
    align-items: center;
    gap: 14px;
    max-width: 420px;
    margin-top: 12px;
  }
  .pace-end {
    font-size: 10.5px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--ink-faint);
    flex-shrink: 0;
  }
  input[type="range"].dial {
    -webkit-appearance: none;
    appearance: none;
    flex: 1;
    height: 2px;
    background: var(--hairline);
    border-radius: 2px;
    outline: none;
  }
  input[type="range"].dial::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 22px; height: 22px;
    border-radius: 50%;
    background: var(--paper-card);
    border: 1.5px solid var(--gold);
    box-shadow: 0 4px 12px -4px rgba(46,37,25,0.5), inset 0 0 0 4px var(--paper-card), inset 0 0 0 9px var(--gold);
    cursor: pointer;
    transition: transform 0.3s var(--ease-gentle);
  }
  input[type="range"].dial::-webkit-slider-thumb:hover { transform: scale(1.15); }
  input[type="range"].dial::-moz-range-thumb {
    width: 20px; height: 20px;
    border-radius: 50%;
    background: var(--gold);
    border: 4px solid var(--paper-card);
    box-shadow: 0 0 0 1.5px var(--gold);
    cursor: pointer;
  }

  .filmstrip {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding: 6px 2px 16px;
    scrollbar-width: thin;
  }
  .frame-card {
    position: relative;
    flex: 0 0 auto;
    width: 92px;
    cursor: pointer;
  }
  .frame-card .fc-box {
    width: 92px;
    aspect-ratio: var(--ar, 4 / 5);
    border-radius: 10px;
    overflow: hidden;
    background: var(--paper-card);
    border: 1.5px solid var(--hairline-soft);
    transition: border-color 0.4s, box-shadow 0.4s, transform 0.4s var(--ease-gentle);
  }
  .frame-card:hover .fc-box { transform: translateY(-3px); }
  .frame-card.sel .fc-box {
    border-color: var(--gold);
    box-shadow: 0 12px 26px -14px rgba(138,103,48,0.55);
  }
  .frame-card .fc-label {
    margin-top: 7px;
    text-align: center;
    font-size: 10px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--ink-faint);
  }
  .frame-card.sel .fc-label { color: var(--gold-deep); font-weight: 600; }
  .frame-card .fc-del {
    position: absolute;
    top: -7px; right: -7px;
    width: 22px; height: 22px;
    border-radius: 50%;
    border: none;
    background: var(--ink);
    color: var(--paper);
    font-size: 11px;
    line-height: 1;
    display: none;
    z-index: 5;
  }
  .frame-card.sel.deletable:hover .fc-del,
  .frame-card.sel.deletable .fc-del { display: grid; place-items: center; }
  .frame-card.add-card .fc-box {
    display: grid;
    place-items: center;
    border-style: dashed;
    border-color: var(--hairline);
    color: var(--ink-faint);
    font-size: 26px;
    font-weight: 300;
    background: transparent;
  }
  .frame-card.add-card:hover .fc-box { border-color: var(--gold); color: var(--gold-deep); }

  /* mini canvas inside frame cards: scaled-down scene */
  .fc-box .scene-canvas { border-radius: 0; box-shadow: none; pointer-events: none; }

  /* ---------- scene canvas (shared editor / mini / player) ---------- */

  .scene-canvas {
    container-type: size;
    position: relative;
    width: 100%;
    aspect-ratio: var(--ar, 4 / 5);
    border-radius: 14px;
    overflow: hidden;
    background: #221c13;
  }
  .sc-photos { position: absolute; inset: 0; display: grid; gap: 1.2cqmin; background: #221c13; }
  .sc-photos.l-single { grid-template: 1fr / 1fr; }
  .sc-photos.l-pair { grid-template: 1fr / 1fr 1fr; }
  .sc-photos.l-trio { grid-template: 1.35fr 1fr / 1fr 1fr; }
  .sc-photos.l-trio .ph:first-child { grid-column: 1 / -1; }

  .sc-photos .ph { position: relative; overflow: hidden; }
  .sc-photos .ph img { width: 100%; height: 100%; object-fit: cover; display: block; }
  /* restoration is applied at render time, never simulated in the preview */

  .ph.empty {
    display: grid;
    place-items: center;
    background: rgba(251,247,239,0.06);
    border: 1.5px dashed rgba(244,236,220,0.3);
    border-radius: 1cqmin;
    color: rgba(244,236,220,0.55);
    cursor: pointer;
    transition: border-color 0.4s, color 0.4s;
  }
  .ph.empty:hover { border-color: var(--gold); color: var(--gold); }
  .ph.empty .plus { font-size: 9cqmin; font-weight: 300; line-height: 1; }
  .ph.empty .hint { font-size: 3.2cqmin; letter-spacing: 0.2em; text-transform: uppercase; margin-top: 1cqmin; }

  /* collage */
  .sc-photos.l-collage {
    display: block;
    background:
      radial-gradient(ellipse at 60% 20%, rgba(171,131,71,0.14), transparent 60%),
      #efe6d4;
  }
  .polaroid {
    position: absolute;
    width: 46cqmin;
    background: #fbf7ef;
    padding: 2.4cqmin 2.4cqmin 7cqmin;
    box-shadow: 0 3cqmin 6cqmin -2cqmin rgba(46,37,25,0.5);
    transform: translate(-50%, -50%) rotate(var(--rot, 0deg));
    cursor: grab;
    touch-action: none;
  }
  .polaroid:active { cursor: grabbing; }
  .polaroid .ph { aspect-ratio: 1/1.05; }
  .polaroid.empty-card {
    aspect-ratio: 1/1.18;
    display: grid;
    place-items: center;
    border: 1.5px dashed var(--hairline);
    background: rgba(251,247,239,0.7);
    color: var(--ink-faint);
    cursor: pointer;
  }
  .polaroid.empty-card .plus { font-size: 9cqmin; font-weight: 300; }

  /* text overlay: halo keeps lettering legible over any photograph */
  .sc-text {
    position: absolute;
    left: 6cqmin; right: 6cqmin;
    text-align: center;
    color: #f6efe0;
    text-shadow:
      0 0 0.5cqmin rgba(20,15,8,0.85),
      0 0 1.5cqmin rgba(20,15,8,0.65),
      0 0.4cqmin 3cqmin rgba(20,15,8,0.55);
    font-size: calc(6.4cqmin * var(--ts, 1));
    line-height: 1.25;
    pointer-events: none;
    z-index: 6;
  }
  .sc-text.pos-top { top: 7cqmin; }
  .sc-text.pos-mid { top: 50%; transform: translateY(-50%); }
  .sc-text.pos-low { bottom: 7cqmin; }
  .sc-text.st-engraved { font-family: "Cormorant Garamond", serif; font-weight: 500; letter-spacing: 0.04em; }
  .sc-text.st-hand { font-family: "Cormorant Garamond", serif; font-style: italic; font-weight: 500; font-size: calc(7cqmin * var(--ts, 1)); }
  .sc-text.st-simple { font-family: "Lora", serif; font-size: calc(5.2cqmin * var(--ts, 1)); letter-spacing: 0.06em; }
  .sc-text.st-script { font-family: "Great Vibes", cursive; font-size: calc(8.4cqmin * var(--ts, 1)); line-height: 1.35; }
  .sc-text.st-caps { font-family: "Cormorant SC", serif; font-weight: 600; font-size: calc(5.4cqmin * var(--ts, 1)); letter-spacing: 0.14em; }
  .sc-text.st-deco { font-family: "Poiret One", sans-serif; font-size: calc(6cqmin * var(--ts, 1)); letter-spacing: 0.12em; }
  .l-collage ~ .sc-text {
    color: var(--ink);
    text-shadow:
      0 0 0.5cqmin rgba(251,247,239,0.95),
      0 0 1.6cqmin rgba(251,247,239,0.9),
      0 0 3cqmin rgba(251,247,239,0.8);
  }

  /* film looks: grading on .ph composes with per-photo .restored on img */
  .scene-canvas.look-memory .ph { filter: saturate(0.8) contrast(0.98); }
  .scene-canvas.look-celebration .ph { filter: saturate(1.12) brightness(1.05) sepia(0.04); }
  .scene-canvas.look-remembrance .ph { filter: sepia(0.45) saturate(0.8); }
  .scene-canvas.look-remembrance::after {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at center, transparent 45%, rgba(20,15,8,0.55));
    pointer-events: none;
    z-index: 5;
  }

  /* title / closing cards */
  .scene-canvas.is-card {
    background: radial-gradient(ellipse at 50% 38%, #3a2f21 0%, #221b12 70%);
  }
  .card-inner {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 8cqmin;
    color: #f4ecdc;
  }
  .card-inner .tc-eyebrow { font-size: 3cqmin; letter-spacing: 0.4em; text-transform: uppercase; color: #c9a86a; margin-bottom: 5cqmin; }
  .card-inner .tc-name { font-family: "Cormorant Garamond", serif; font-size: 10cqmin; font-weight: 500; margin-bottom: 2cqmin; }
  .card-inner .tc-dates { font-family: "Cormorant Garamond", serif; font-style: italic; font-size: 5.6cqmin; color: #cdbb98; }
  .card-inner .tc-rule { width: 13cqmin; height: 1px; background: #c9a86a; margin: 5cqmin 0; opacity: 0.7; }
  .card-inner .tc-msg { font-style: italic; font-size: 4.4cqmin; color: #e8dec7; max-width: 70cqmin; }

  /* ---------- editor ---------- */

  .editor {
    margin-top: 6px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: clamp(18px, 3vw, 30px);
    align-items: start;
  }
  .editor .canvas-col .scene-canvas { box-shadow: var(--shadow), 0 0 0 1px var(--hairline-soft); }
  .canvas-caption {
    margin-top: 12px;
    text-align: center;
    font-size: 10.5px;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--ink-faint);
  }

  .panel h2 { font-size: 26px; font-weight: 400; margin-bottom: 4px; }
  .panel > p.sub { font-size: 13.5px; color: var(--ink-soft); margin-bottom: 20px; }

  .control-group { margin-bottom: 22px; }
  .control-group > label {
    display: block;
    font-size: 10.5px;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--ink-faint);
    margin-bottom: 10px;
  }

  .chip-row { display: flex; gap: 8px; flex-wrap: wrap; }
  .chip {
    border: 1.5px solid var(--hairline-soft);
    background: var(--paper);
    border-radius: 999px;
    padding: 7px 14px;
    font-size: 13px;
    color: var(--ink-soft);
    transition: border-color 0.4s, color 0.4s;
  }
  .chip .glyph {
    display: inline-block;
    border: 1.5px solid currentColor;
    border-radius: 2.5px;
    vertical-align: -2px;
    margin-right: 7px;
    opacity: 0.75;
  }
  .chip:hover { border-color: var(--hairline); }
  .chip.sel { border-color: var(--gold); color: var(--gold-deep); font-weight: 600; }
  .chip.f-engraved { font-family: "Cormorant Garamond", serif; }
  .chip.f-hand { font-family: "Cormorant Garamond", serif; font-style: italic; }
  .chip.f-script { font-family: "Great Vibes", cursive; font-size: 15px; }
  .chip.f-caps { font-family: "Cormorant SC", serif; font-weight: 600; }
  .chip.f-deco { font-family: "Poiret One", sans-serif; letter-spacing: 0.06em; }

  .field input, .field textarea {
    width: 100%;
    background: var(--paper-card);
    border: 1px solid var(--hairline-soft);
    border-radius: 10px;
    font-family: "Lora", serif;
    font-size: 15.5px;
    color: var(--ink);
    padding: 13px 15px;
    transition: border-color 0.4s;
  }
  .field input:focus, .field textarea:focus { outline: none; border-color: var(--gold); }
  .field textarea { resize: none; height: 78px; }
  .date-pair { display: flex; gap: 10px; }

  /* photo slot list */
  .slot-list { display: flex; flex-direction: column; gap: 10px; }
  .slot {
    display: flex;
    align-items: center;
    gap: 14px;
    background: var(--paper-card);
    border: 1px solid var(--hairline-soft);
    border-radius: 12px;
    padding: 10px 12px;
  }
  .slot .thumb {
    width: 52px; height: 62px;
    border-radius: 8px;
    overflow: hidden;
    flex-shrink: 0;
    background: var(--paper-deep);
    display: grid;
    place-items: center;
    color: var(--ink-faint);
  }
  .slot .thumb img { width: 100%; height: 100%; object-fit: cover; }
  .slot .s-body { flex: 1; min-width: 0; }
  .slot .s-name { font-size: 13.5px; }
  .slot .s-sub { font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-faint); }
  .slot .s-sub .ok { color: var(--sage); }
  .slot button.link {
    background: none; border: none;
    font-size: 12px;
    letter-spacing: 0.08em;
    color: var(--gold-deep);
    text-decoration: underline;
    text-underline-offset: 3px;
  }
  .slot button.x {
    background: none; border: none;
    color: var(--ink-faint);
    font-size: 15px;
    padding: 4px 6px;
  }
  .slot button.x:hover { color: var(--ink); }

  .toggle {
    width: 44px; height: 26px;
    border-radius: 999px;
    background: var(--hairline);
    position: relative;
    transition: background 0.5s;
    flex-shrink: 0;
    border: none;
  }
  .toggle::after {
    content: "";
    position: absolute;
    top: 3px; left: 3px;
    width: 20px; height: 20px;
    border-radius: 50%;
    background: var(--paper-card);
    box-shadow: 0 2px 6px rgba(46,37,25,0.3);
    transition: left 0.5s var(--ease-gentle);
  }
  .toggle.on { background: var(--sage); }
  .toggle.on::after { left: 21px; }
  .toggle-wrap { display: flex; align-items: center; gap: 8px; }
  .toggle-wrap .t-label { font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-faint); }

  .sample-btn {
    margin-top: 12px;
    background: none;
    border: none;
    font-size: 13px;
    font-style: italic;
    color: var(--ink-faint);
    text-decoration: underline;
    text-underline-offset: 3px;
  }
  .sample-btn:hover { color: var(--gold-deep); }

  .thumb { position: relative; }

  /* ---------- bottom dock ---------- */

  .dock {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    z-index: 600;
    padding: 14px clamp(14px, 4vw, 32px) calc(16px + env(safe-area-inset-bottom));
    background: linear-gradient(to top, var(--paper) 72%, rgba(247,241,230,0));
  }
  .dock-inner {
    max-width: 860px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 14px;
    background: var(--paper-card);
    border: 1px solid var(--hairline-soft);
    border-radius: 18px;
    box-shadow: var(--shadow);
    padding: 12px 14px;
  }
  .music-chips { display: flex; gap: 6px; flex: 1; min-width: 0; overflow-x: auto; }
  .m-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    border: 1.5px solid var(--hairline-soft);
    background: var(--paper);
    border-radius: 999px;
    padding: 8px 14px;
    font-size: 12.5px;
    color: var(--ink-soft);
    white-space: nowrap;
    transition: border-color 0.4s;
  }
  .m-chip .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--hairline); }
  .m-chip.sel { border-color: var(--gold); color: var(--ink); font-weight: 600; }
  .m-chip.sel .dot { background: var(--gold); box-shadow: 0 0 8px 1px rgba(171,131,71,0.7); }
  .m-chip.playing .dot { animation: flicker 1.2s ease-in-out infinite; }
  @keyframes flicker { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }

  /* ---------- player ---------- */

  .player {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: radial-gradient(ellipse at 50% 30%, #322a1d 0%, #16110a 75%);
    padding: 20px;
  }
  .player.open { display: flex; animation: fadein 1.2s var(--ease-gentle); }
  @keyframes fadein { from { opacity: 0; } to { opacity: 1; } }

  .player .stage-wrap { position: relative; }
  .player .stage {
    position: relative;
    aspect-ratio: var(--ar, 4 / 5);
    overflow: hidden;
    background: #221c13;
  }
  .player .stage.asp-portrait { width: min(340px, 80vw, calc(58vh * 4 / 5)); }
  .player .stage.asp-story { width: min(280px, 70vw, calc(58vh * 9 / 16)); }
  .player .stage.asp-landscape { width: min(680px, 92vw, calc(58vh * 16 / 9)); }
  .player .stage.asp-square { width: min(400px, 84vw, 58vh); }
  .player .stage.frame-clean {
    border-radius: 12px;
    box-shadow: 0 40px 90px -30px rgba(0,0,0,0.8);
  }
  .player .stage.frame-linen {
    border-radius: 8px;
    box-shadow: 0 40px 90px -30px rgba(0,0,0,0.85), 0 0 0 10px #efe6d4, 0 0 0 11px rgba(46,37,25,0.35);
  }
  .player .stage.frame-arch {
    border-radius: var(--arch);
    box-shadow: 0 40px 90px -30px rgba(0,0,0,0.8), 0 0 0 10px rgba(244,236,220,0.06), 0 0 0 11px rgba(244,236,220,0.14);
  }
  /* later siblings stack on top, so the incoming scene fades in OVER the
     outgoing one -- a true dissolve with no dip through the dark stage */
  .player .stage .scene-canvas { position: absolute; inset: 0; border-radius: 0; opacity: 0; transition: opacity 1.2s var(--ease-gentle); }
  .player .stage .scene-canvas.live { opacity: 1; }

  /* ken burns while playing */
  .scene-canvas.live .sc-photos.l-single img,
  .scene-canvas.live .sc-photos.l-pair img,
  .scene-canvas.live .sc-photos.l-trio img { animation: pkb var(--kb, 9s) var(--ease-gentle) forwards; }
  @keyframes pkb { from { transform: scale(1); } to { transform: scale(1.12); } }
  .scene-canvas.live .sc-photos.l-collage { animation: pkc var(--kb, 9s) var(--ease-gentle) forwards; }
  /* polaroids are laid into the frame one by one when the scene plays */
  .scene-canvas.live .l-collage .polaroid { animation: lay 1s var(--ease-gentle) both; }
  .scene-canvas.live .l-collage .polaroid:nth-child(2) { animation-delay: 0.3s; }
  .scene-canvas.live .l-collage .polaroid:nth-child(3) { animation-delay: 0.6s; }
  .scene-canvas.live .l-collage .polaroid:nth-child(4) { animation-delay: 0.9s; }
  @keyframes lay {
    from {
      opacity: 0;
      transform: translate(-50%, -58%) scale(1.32) rotate(calc(var(--rot, 0deg) - 8deg));
    }
    55% { opacity: 1; }
    to {
      opacity: 1;
      transform: translate(-50%, -50%) scale(1) rotate(var(--rot, 0deg));
    }
  }
  @keyframes pkc { from { transform: scale(1); } to { transform: scale(1.05); } }
  .scene-canvas.live .sc-text { animation: textin 1.6s var(--ease-gentle) both; animation-delay: 0.5s; }
  @keyframes textin { from { opacity: 0; transform: translateY(1.4cqmin); } to { opacity: 1; } }
  .sc-text.pos-mid { animation-name: textinmid; }
  @keyframes textinmid { from { opacity: 0; } to { opacity: 1; } }

  /* transition veil: scenes swap beneath it while it covers the stage */
  .player .stage .veil {
    position: absolute;
    inset: 0;
    z-index: 10;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.45s var(--ease-gentle);
  }
  .veil.v-celebration { background: radial-gradient(ellipse at 50% 40%, #fdf6e8, #f3e2c2); }
  .veil.v-remembrance { background: #0d0a06; }

  .player .watermark {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    pointer-events: none;
    z-index: 20;
  }
  .player .watermark span {
    font-family: "Cormorant Garamond", serif;
    font-size: 22px;
    color: rgba(244,236,220,0.34);
    letter-spacing: 0.18em;
    text-transform: uppercase;
    transform: rotate(-24deg);
    border: 1px solid rgba(244,236,220,0.22);
    padding: 7px 20px;
    border-radius: 999px;
  }

  .player .pbar {
    width: 100%;
    height: 2px;
    background: rgba(244,236,220,0.18);
    border-radius: 2px;
    margin-top: 26px;
    overflow: hidden;
  }
  .player .pbar i { display: block; height: 100%; width: 0; background: #c9a86a; }

  .player .p-controls {
    margin-top: 26px;
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
  }
  .player .btn.ghost { color: #e8dec7; border-color: rgba(244,236,220,0.3); }
  .player .btn.ghost:hover { background: rgba(244,236,220,0.1); }

  .player .weave {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    z-index: 30;
    background: radial-gradient(ellipse at 50% 38%, #3a2f21 0%, #221b12 70%);
    color: #e8dec7;
    text-align: center;
    transition: opacity 1s var(--ease-gentle);
  }
  .player .weave.gone { opacity: 0; pointer-events: none; }
  .weave .w-flame {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: #c9a86a;
    box-shadow: 0 0 18px 4px rgba(201,168,106,0.8);
    margin: 0 auto 18px;
    animation: flicker 2.4s ease-in-out infinite;
  }
  .weave .w-text { font-family: "Cormorant Garamond", serif; font-style: italic; font-size: 19px; }

  /* paywall sheet */
  .paysheet {
    position: fixed;
    left: 50%;
    bottom: 0;
    transform: translate(-50%, 105%);
    width: min(480px, 94vw);
    z-index: 1100;
    background: var(--paper-card);
    border-radius: 22px 22px 0 0;
    box-shadow: 0 -20px 70px rgba(0,0,0,0.5);
    padding: 28px 28px calc(28px + env(safe-area-inset-bottom));
    transition: transform 1s var(--ease-gentle);
  }
  .paysheet.up { transform: translate(-50%, 0); }
  .paysheet .ps-close {
    position: absolute;
    top: 14px; right: 14px;
    width: 32px; height: 32px;
    border-radius: 50%;
    border: 1px solid var(--hairline);
    background: transparent;
    color: var(--ink-faint);
    font-size: 13px;
    font-family: "Lora", serif;
    display: grid;
    place-items: center;
    transition: color 0.4s, border-color 0.4s;
  }
  .paysheet .ps-close:disabled { opacity: 0.55; cursor: default; }
  .paysheet .ps-close:not(:disabled):hover { color: var(--ink); border-color: var(--ink-soft); }
  .paysheet h3 { font-size: 24px; font-weight: 500; text-align: center; margin-bottom: 4px; }
  .paysheet .ps-sub { text-align: center; font-size: 13px; color: var(--ink-soft); margin-bottom: 18px; }
  .paysheet .pb-line {
    display: flex;
    justify-content: space-between;
    font-size: 14px;
    color: var(--ink-soft);
    padding: 10px 2px;
    border-bottom: 1px solid var(--hairline-soft);
  }
  .paysheet .pb-line strong { color: var(--ink); }
  .paysheet .btn { width: 100%; margin-top: 20px; }
  .paysheet .pb-note { margin-top: 12px; text-align: center; font-size: 12px; color: var(--ink-faint); }

  .toast {
    position: fixed;
    bottom: 28px;
    left: 50%;
    transform: translateX(-50%) translateY(80px);
    background: var(--ink);
    color: var(--paper);
    padding: 13px 24px;
    border-radius: 999px;
    font-size: 13.5px;
    z-index: 1500;
    opacity: 0;
    transition: all 0.7s var(--ease-gentle);
    pointer-events: none;
    max-width: 90vw;
    text-align: center;
  }
  .toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

  @media (max-width: 720px) {
    .film-settings { grid-template-columns: 1fr; padding: 20px; gap: 22px; }
    .editor { grid-template-columns: 1fr; }
    .editor .canvas-col { max-width: 340px; margin: 0 auto; width: 100%; }
    .dock-inner { flex-wrap: wrap; }
    .music-chips { flex-basis: 100%; order: 2; }
    .dock-inner .btn { flex: 1; order: 1; }
    .dock-inner .dur { order: 0; }
  }

  /* ---------- boot shell (SSR/loading) ---------- */

  .boot-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
  }
  .boot-card {
    text-align: center;
    color: var(--ink-soft);
    font-style: italic;
  }
  .boot-card .w-flame-boot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--gold);
    box-shadow: 0 0 18px 4px rgba(171,131,71,0.7);
    margin: 0 auto 16px;
    animation: flicker 2.4s ease-in-out infinite;
  }

  /* slot states for upload/restore lifecycle */
  .slot .s-sub .warn { color: #a05c2c; }
  .slot .spin {
    width: 16px; height: 16px;
    border: 2px solid var(--hairline);
    border-top-color: var(--gold);
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
    flex-shrink: 0;
  }
  @keyframes spin { to { transform: rotate(360deg); } }

  /* order status screen */
  .order-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
  }
  .order-card {
    max-width: 480px;
    text-align: center;
    background: var(--paper-card);
    border: 1px solid var(--hairline-soft);
    border-radius: 22px;
    padding: 44px 36px;
    box-shadow: var(--shadow);
  }
  .order-card h2 { font-size: 30px; font-weight: 400; margin: 18px 0 10px; }
  .order-card p { color: var(--ink-soft); font-size: 15px; }
  .order-card .w-flame-boot { margin-bottom: 0; }
  .order-card .btn { margin-top: 26px; }
  .order-card .field { margin-top: 22px; text-align: left; }

  /* ---------- production overlay (progress + result) ---------- */

  .production {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: radial-gradient(ellipse at 50% 30%, #322a1d 0%, #16110a 75%);
    padding: 24px;
    color: #e8dec7;
    text-align: center;
  }
  .production.open { display: flex; animation: fadein 1.2s var(--ease-gentle); }

  .prod-progress { max-width: 460px; }
  .prod-progress .w-flame {
    width: 9px; height: 9px;
    border-radius: 50%;
    background: #c9a86a;
    box-shadow: 0 0 20px 5px rgba(201,168,106,0.8);
    margin: 0 auto 22px;
    animation: flicker 2.4s ease-in-out infinite;
  }
  .prod-progress h2 {
    font-family: "Cormorant Garamond", serif;
    font-style: italic;
    font-weight: 400;
    font-size: clamp(24px, 4vw, 34px);
    color: #f4ecdc;
    margin-bottom: 24px;
  }
  .prod-bar {
    width: min(360px, 80vw);
    height: 2px;
    background: rgba(244,236,220,0.18);
    border-radius: 2px;
    overflow: hidden;
    margin: 0 auto;
  }
  .prod-bar i {
    display: block;
    height: 100%;
    background: #c9a86a;
    transition: width 0.8s var(--ease-gentle);
  }
  .prod-hint {
    margin-top: 22px;
    font-size: 14px;
    font-style: italic;
    color: rgba(232,222,199,0.7);
    line-height: 1.6;
  }
  .prod-actions {
    margin-top: 26px;
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
  }
  .production .btn.ghost {
    background: transparent;
    color: #e8dec7;
    border: 1px solid rgba(244,236,220,0.3);
    box-shadow: none;
  }
  .production .btn.ghost:hover { background: rgba(244,236,220,0.1); }

  /* result */
  .prod-result {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 460px;
  }
  .prod-result .eyebrow { margin-bottom: 14px; color: #c9a86a; }
  /* Show the film as it actually is — a clean rounded rectangle, no decorative
     arch (that motif is neither chosen here nor baked into the MP4). */
  .result-frame {
    width: min(360px, 82vw);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 40px 90px -30px rgba(0,0,0,0.8);
    background: #000;
  }
  .result-frame video { width: 100%; max-height: 72vh; display: block; }
  .result-actions {
    margin-top: 26px;
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
  }
  .result-delete {
    background: none;
    border: none;
    color: rgba(232,222,199,0.55);
    font-family: "Lora", serif;
    font-size: 13px;
    letter-spacing: 0.08em;
    text-decoration: underline;
    text-underline-offset: 3px;
    cursor: pointer;
  }
  .result-delete:hover { color: #d99; }
