/* ============================================================
   Clips view (js/clips-view.js) — full-cover view above the canvas
   for a workflow tab: "Made from" cards wired into the preview, takes,
   the transport bar and the timeline of clips.
   Slate tokens only (css/slate.css).
   ============================================================ */

.clips-view {
    /* "Inside a clip": the parent clip's colour while a child is open. */
    --cv-inside: oklch(0.74 0.13 300);
    --cv-inside-tint: oklch(0.74 0.13 300 / 0.2);
    position: absolute;
    inset: 0;
    z-index: 9500;
    display: flex;
    flex-direction: column;
    background: var(--sl-app);
    color: var(--sl-text-1);
    font-family: var(--sl-font-ui);
    font-size: 13px;
}
.clips-view.hidden { display: none; }
:where(.clips-view button) { font: inherit; color: inherit; }
.clips-view .cv-ic { display: inline-flex; flex: none; }

/* toolbar toggle */
.canvas-view-toggle.hidden { display: none; }
.canvas-view-toggle .sl-seg-btn .cv-ic { display: inline-flex; }
.canvas-view-toggle .sl-seg-btn.hidden { display: none; }
/* Prompt · Clips · Nodes: a narrow web window keeps the workflow tabs; the
   labels go (the buttons keep their titles), as on a phone. */
@media (max-width: 1023px) {
    .canvas-view-toggle .sl-seg-btn { padding: 0 8px; font-size: 0; gap: 0; }
    .canvas-view-toggle .sl-seg-btn .cv-ic svg { width: 14px; height: 14px; }
}

/* ---- top: crumbs/info | preview | takes, then the prompt bar ---- */
.cv-top {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 12px 16px;
    /* a stage around a big preview: stage dots (slate.css §4, "Stage dots") */
    background-image: var(--sl-stage-dots);
    background-size: var(--sl-stage-dots-size) var(--sl-stage-dots-size);
}
/* Three columns with equal sides, so the preview is always centred. */
.cv-main { position: relative; flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); }
.cv-left { position: relative; z-index: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; gap: 10px; padding-right: 40px; }
.cv-stage { min-width: 0; min-height: 0; display: flex; align-items: center; justify-content: center; }
/* Takes, then "Goes into": left-aligned against the preview; the left padding
   is the room the outgoing wires need (it matches .cv-left's right padding). */
.cv-side {
    position: relative; z-index: 1; min-width: 0; min-height: 0;
    display: flex; flex-direction: column; justify-content: safe center; align-items: flex-start; gap: 14px;
    padding-left: 40px;
}

.cv-crumbs { display: flex; align-items: center; flex-wrap: wrap; gap: 2px; font-size: 12px; color: var(--sl-text-2); }
.cv-crumbs .cv-ic { color: var(--sl-text-3); }
.cv-cr { padding: 3px 7px; border: 0; border-radius: var(--sl-r-6); background: none; white-space: nowrap; cursor: pointer; }
button.cv-cr:hover { background: var(--sl-wash); color: var(--sl-text-1); }
.cv-cr.is-on { color: var(--sl-text-1); font-weight: 600; cursor: default; }

.cv-info { display: flex; flex-direction: column; gap: 4px; padding: 0 7px; }
.cv-kind, .cv-role {
    display: inline-flex; align-items: center; gap: 4px;
    font-size: 10px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--sl-text-3);
}
.cv-name { font-size: 15px; font-weight: 600; line-height: 1.25; overflow-wrap: anywhere; }
.cv-shared { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; color: var(--sl-text-2); }

/* status dot + label */
.cv-st { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; color: var(--sl-text-2); white-space: nowrap; }
.cv-st i { width: 6px; height: 6px; border-radius: 50%; background: var(--sl-text-3); flex: none; }
.cv-st-sent, .cv-st-done { color: var(--sl-success); }
.cv-st-sent i, .cv-st-done i { background: var(--sl-success); }
.cv-st-review, .cv-st-gen { color: var(--sl-accent-text); }
.cv-st-review i, .cv-st-gen i { background: var(--sl-accent); }
.cv-st-gen i { animation: cv-blink 1s infinite; }
.cv-st-err { color: var(--sl-danger-text); }
.cv-st-err i { background: var(--sl-red); }
.cv-st-ref i { background: var(--sl-text-2); }

/* preview frame — sized by fitPreview() to the media's aspect ratio */
.cv-frame {
    position: relative;
    flex: none;
    border-radius: var(--sl-r-12);
    overflow: hidden;
    background: var(--sl-app);
    box-shadow: var(--sl-shadow-float), inset 0 0 0 1px var(--sl-hairline);
}
.cv-frame.is-empty { border: 1px dashed var(--sl-border-strong); box-shadow: none; }
.cv-media { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; }
.cv-audio { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; color: var(--sl-text-2); background: var(--sl-app); }
.cv-audio audio { width: 80%; }
.cv-frame-empty {
    position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 8px; padding: 18px; text-align: center; color: var(--sl-text-2);
}
.cv-frame-empty b { color: var(--sl-text-1); font-size: 14px; }
.cv-frame-busy {
    position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
    display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px;
    background: oklch(0.12 0.004 250 / .75); color: var(--sl-accent-text); font-size: 12px; pointer-events: none;
}
.cv-pills { position: absolute; left: 10px; top: 10px; right: 10px; display: flex; gap: 6px; pointer-events: none; }
.cv-pill {
    height: 22px; padding: 0 8px; border-radius: 999px; display: inline-flex; align-items: center; gap: 5px;
    font-size: 11px; background: oklch(0.12 0.004 250 / .72); color: var(--sl-on-media); white-space: nowrap;
    backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.cv-pill-r { margin-left: auto; }
.cv-empty-ic { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--sl-quiet); color: var(--sl-text-2); }

/* takes beside the preview: the latest run's, then History (the earlier runs,
   closed until clicked); Send stays under the list. The takes keep their size;
   "Goes into" under them takes the rest and scrolls. */
.cv-side:has(.cv-out) .cv-takes { max-height: 60%; }
.cv-takes { flex: none; display: flex; flex-direction: column; gap: 8px; padding: 10px; border-radius: var(--sl-r-12); background: var(--sl-panel); border: 1px solid var(--sl-hairline); max-height: 100%; min-height: 0; max-width: 100%; box-sizing: border-box; }
.cv-takes-h { font-size: 10.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--sl-text-2); }
/* The scrollbar's gutter sits in the panel's right padding, so the tiles never move. */
.cv-takes-list { min-height: 0; overflow-y: auto; overflow-x: hidden; scrollbar-gutter: stable; margin-right: -9px; display: flex; flex-direction: column; gap: 10px; }
/* width 0 + min-width 100%: the button and run names never widen the column past its tiles */
.cv-hist {
    flex: none; width: 0; min-width: 100%; height: 28px; display: flex; align-items: center; gap: 6px; padding: 0 8px; box-sizing: border-box;
    border: 1px solid var(--sl-hairline); border-radius: var(--sl-r-8); background: var(--sl-control);
    color: var(--sl-text-2); font-size: 11.5px; font-weight: 600; white-space: nowrap; cursor: pointer;
    transition: background .12s ease, color .12s ease;
}
.cv-hist:hover, .cv-hist.is-open { background: var(--sl-control-hover); color: var(--sl-text-1); }
.cv-hist em { font-style: normal; font-weight: 500; color: var(--sl-text-3); }
.cv-hist .cv-ic:last-child { margin-left: auto; color: var(--sl-text-3); }
.cv-hist:focus-visible { outline: 2px solid var(--sl-focus); outline-offset: 2px; }
/* closed while the take on screen is from an earlier run */
.cv-hist-dot { flex: none; width: 6px; height: 6px; border-radius: 50%; background: var(--sl-accent); }
/* The head and Send keep their size when the list is long; only the list scrolls */
.cv-takes-h, .cv-send, .cv-sent { flex: none; }
/* phone: the earlier runs in the takes row */
.cv-run { display: flex; flex-direction: column; gap: 5px; }
.cv-run + .cv-run { padding-top: 10px; border-top: 1px solid var(--sl-hairline); }

/* ---- History panel (computer): every run of the clip, at the right edge ---- */
.cv-top { position: relative; --cv-hp-w: 292px; }
.cv-top.has-hp { padding-right: calc(var(--cv-hp-w) + 28px); }
/* closed: its button in the panel's top corner; the takes column keeps clear of it
   (the same space above and below, so the takes stay centered on the preview) */
.cv-hist.cv-hist-side {
    position: absolute; top: 12px; right: 16px; z-index: 2; width: auto; min-width: 0; height: 32px; padding: 0 12px; gap: 7px;
    font-size: 12.5px; background: var(--sl-panel); color: var(--sl-text-1);
}
.cv-hist.cv-hist-side:hover { background: var(--sl-control); }
.cv-top.has-hb .cv-side { padding-top: 40px; padding-bottom: 40px; }
.cv-hp {
    position: absolute; top: 12px; right: 16px; bottom: 12px; z-index: 2; width: var(--cv-hp-w);
    display: flex; flex-direction: column; min-height: 0; box-sizing: border-box;
    border-radius: var(--sl-r-12); background: var(--sl-panel); border: 1px solid var(--sl-hairline);
}
.cv-hp-h { flex: none; display: flex; align-items: center; gap: 7px; padding: 8px 8px 4px 14px; font-size: 13px; color: var(--sl-text-1); }
.cv-hp-h > .cv-ic { color: var(--sl-text-2); }
.cv-hp-h b { font-weight: 600; }
.cv-hp-h span { font-size: 11.5px; color: var(--sl-text-3); }
.cv-hp-x {
    margin-left: auto; width: 28px; height: 28px; display: inline-flex; align-items: center; justify-content: center;
    border: 0; border-radius: var(--sl-r-6); background: none; color: var(--sl-text-2); cursor: pointer;
}
.cv-hp-x:hover { background: var(--sl-wash); color: var(--sl-text-1); }
.cv-hp-x:focus-visible { outline: 2px solid var(--sl-focus); outline-offset: 2px; }
.cv-hp-help { flex: none; margin: 0; padding: 0 14px 10px; font-size: 11.5px; line-height: 1.4; color: var(--sl-text-3); border-bottom: 1px solid var(--sl-hairline); }
.cv-hp-list { flex: 1; min-height: 0; overflow-y: auto; scrollbar-gutter: stable; padding: 0 6px 6px 14px; }
.cv-hp-run { display: flex; flex-direction: column; gap: 4px; padding: 12px 0; }
.cv-hp-run + .cv-hp-run { border-top: 1px solid var(--sl-hairline); }
.cv-hp-run-h { display: flex; align-items: center; gap: 7px; font-size: 12.5px; }
.cv-hp-run-h b { font-weight: 600; color: var(--sl-text-2); }
.cv-hp-run.is-shown .cv-hp-run-h b { color: var(--sl-text-1); }
.cv-hp-run-h em {
    font-style: normal; font-size: 9.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
    padding: 2px 6px; border-radius: 999px; background: var(--sl-accent-tint); color: var(--sl-accent-text);
}
.cv-hp-run-h span { margin-left: auto; font-size: 11px; color: var(--sl-text-3); white-space: nowrap; }
.cv-hp-meta { font-size: 11px; color: var(--sl-text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cv-hp-prompt {
    font-size: 12px; line-height: 1.4; color: var(--sl-text-2); overflow-wrap: anywhere;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.cv-hp .cv-takes-g { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-top: 4px; }
.cv-hp .cv-tk { width: auto; }
.cv-hp-empty { margin: 16px 0; font-size: 12px; line-height: 1.5; color: var(--sl-text-3); }
.cv-run-h { width: 0; min-width: 100%; display: flex; align-items: baseline; justify-content: space-between; gap: 6px; font-size: 11px; white-space: nowrap; color: var(--sl-text-3); cursor: default; }
.cv-run-h b { font-weight: 600; color: var(--sl-text-2); }
.cv-run.is-shown .cv-run-h b { color: var(--sl-text-1); }
.cv-run-h span { min-width: 0; overflow: hidden; text-overflow: ellipsis; font-size: 10.5px; }
.cv-takes-g { display: grid; grid-template-columns: repeat(2, 54px); gap: 6px; }
.cv-tk {
    position: relative; width: 54px; aspect-ratio: 9 / 16; padding: 0; border: 0; border-radius: 7px; overflow: hidden;
    background: var(--sl-quiet); box-shadow: inset 0 0 0 1px var(--sl-hairline); opacity: .8; cursor: pointer;
    transition: opacity .15s ease, box-shadow .15s ease;
}
.cv-tk:hover { opacity: 1; }
.cv-tk.is-on { opacity: 1; box-shadow: 0 0 0 2px var(--sl-accent); }
.cv-tk img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cv-tk-ph { width: 100%; height: 100%; display: grid; place-items: center; color: var(--sl-text-3); }
.cv-tk-n { position: absolute; left: 3px; top: 3px; padding: 0 4px; border-radius: 4px; font-size: 9.5px; font-family: var(--sl-font-mono); background: oklch(0 0 0 / .55); color: var(--sl-on-media); }
.cv-tk-dot { position: absolute; right: 4px; bottom: 4px; width: 7px; height: 7px; border-radius: 50%; background: var(--sl-accent); box-shadow: 0 0 0 1.5px oklch(0 0 0 / .5); }
/* a take still generating, and a take that failed (its reason on hover) */
.cv-tk.is-pending, .cv-tk.is-err { opacity: 1; cursor: default; }
.cv-tk.is-pending i { position: absolute; inset: 0; background: var(--sl-wash); animation: cv-blink 1.4s ease-in-out infinite; }
.cv-tk.is-err { display: grid; place-items: center; color: var(--sl-danger-text); background: var(--sl-danger-wash); box-shadow: inset 0 0 0 1px var(--sl-danger-line); cursor: help; }

/* prompt bar: Studio's settings control on the left, the prompt, Generate on the right.
   The slot keeps one line of room in the layout; the bar sits on its bottom edge,
   so an opened prompt grows UP over the preview instead of pushing it. */
.cv-prompt-slot { position: relative; z-index: 5; flex: none; align-self: center; width: min(900px, 100%); height: 46px; }
.cv-prompt {
    position: absolute; left: 0; right: 0; bottom: 0;
    display: flex; align-items: flex-end; gap: 8px; padding: 7px;
    border-radius: var(--sl-r-14); background: var(--sl-raised); border: 1px solid var(--sl-line-pop);
    box-shadow: 0 24px 60px -18px oklch(0 0 0 / 0.9);
    transition: border-color .15s ease;
}
.cv-prompt:focus-within { border-color: var(--sl-accent-line); }
.cv-prompt-in {
    flex: 1; min-width: 80px; height: 30px; margin: 0; padding: 6px 6px; box-sizing: border-box;
    border: 0; background: transparent; resize: none; outline: none;
    color: var(--sl-text-1); font: inherit; font-size: 13.5px; line-height: 18px; text-align: left;
    white-space: nowrap; overflow: hidden;
    /* the rest of a long prompt fades out at the edge while it is closed */
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 36px), transparent);
    mask-image: linear-gradient(to right, #000 calc(100% - 36px), transparent);
    transition: height .22s cubic-bezier(.2, .8, .2, 1);
}
.cv-prompt-in.is-open { white-space: pre-wrap; overflow-y: auto; -webkit-mask-image: none; mask-image: none; }
.cv-prompt-in::placeholder { color: var(--sl-text-3); }
.cv-prompt-text { flex: 1; min-width: 0; align-self: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; padding: 0 8px; }
.cv-prompt-text.is-empty { color: var(--sl-text-3); }
.cv-gen {
    flex: none; height: 32px; padding: 0 12px 0 14px; border: 0; border-radius: var(--sl-r-8);
    display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; cursor: pointer;
    background: var(--sl-accent); color: var(--sl-on-accent); font-size: 12.5px; font-weight: 700;
    transition: filter .15s ease, background .15s ease;
}
.cv-gen:hover { filter: brightness(1.08); }
.cv-gen:active { transform: scale(.98); }
.cv-gen.is-stop { background: var(--sl-danger-wash); color: var(--sl-danger-text); box-shadow: inset 0 0 0 1px var(--sl-danger-line); }
.cv-gen.is-first { background: var(--sl-control); color: var(--sl-text-1); font-weight: 600; }
.cv-gen.is-first:hover { background: var(--sl-control-hover); filter: none; }
.cv-kbd { font-family: var(--sl-font-mono); font-size: 10px; font-weight: 500; padding: 1px 5px; border-radius: 6px; background: oklch(0.15 0.02 240 / 0.16); }
.cv-btn { flex: none; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.cv-edit-link {
    align-self: flex-start; display: inline-flex; align-items: center; gap: 5px; margin-top: 4px; padding: 3px 7px 3px 5px;
    border: 0; border-radius: var(--sl-r-6); background: transparent; color: var(--sl-text-2); font-size: 11.5px; cursor: pointer;
}
.cv-edit-link:hover { background: var(--sl-wash); color: var(--sl-text-1); }

/* settings — Studio's button + popover (studio.js settingsButton / settingsPopover) */
.cv-set { position: relative; flex: none; }
.cv-set-btn { max-width: 330px; }
.cv-set-btn.is-open { background: var(--sl-control-hover); }
.cv-set-sum { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.cv-set-btn .cv-ic:last-child { color: var(--sl-text-3); }
.cv-set-pop {
    position: absolute; bottom: calc(100% + 10px); left: -7px; z-index: 30;
    min-width: 230px; max-width: 340px; max-height: min(520px, calc(100vh - 170px)); overflow-y: auto;
    animation: cv-pop-in .16s ease-out;
}
.cv-set-box { display: flex; flex-direction: column; gap: 8px; padding: 6px; width: 292px; box-sizing: border-box; }
.cv-set-row { display: flex; flex-direction: column; gap: 4px; }
.cv-set-label { padding: 0 3px; }
.cv-set-note { font-size: 11px; line-height: 1.4; color: var(--sl-text-3); padding: 0 3px; }
/* segmented track (Standard .sl-seg look): panel inset, hairline, 3px pad */
.cv-seg { display: flex; gap: 2px; padding: 3px; background: var(--sl-panel); border: 1px solid var(--sl-hairline); border-radius: 8px; }
/* rows that fill the track: --cv-per-row cells a row, a shorter last row stretches */
.cv-seg-wrap { flex-wrap: wrap; }
.cv-seg-wrap > .cv-opt { flex: 1 1 calc((100% - (var(--cv-per-row, 3) - 1) * 2px) / var(--cv-per-row, 3) - 0.5px); min-width: 0; }
.cv-opt {
    flex: 1; display: flex; align-items: center; justify-content: center; gap: 7px; height: 26px; padding: 0 4px;
    border: 0; border-radius: 6px; background: transparent; color: var(--sl-text-2);
    font-size: 12px; font-weight: 600; cursor: pointer; white-space: nowrap; transition: background .12s ease, color .12s ease;
}
.cv-opt:hover { color: var(--sl-text-1); }
.cv-opt.is-on { background: var(--sl-segment-on); color: var(--sl-text-1); }
.cv-opt.is-mono { font-family: var(--sl-font-mono); font-size: 10.5px; }
.cv-opt.is-wide { padding: 0 6px; }
.cv-asp { flex: none; box-sizing: border-box; border: 1.5px solid currentColor; border-radius: 2px; }
/* Duration: a slider in the same track, the bounds at its ends, the value right */
.cv-range { align-items: center; gap: 10px; height: 34px; box-sizing: border-box; padding: 0 10px; }
.cv-range-in { flex: 1; min-width: 0; margin: 0; cursor: pointer; accent-color: var(--sl-accent); }
.cv-range-in:focus-visible { outline: 2px solid var(--sl-focus); outline-offset: 2px; }
.cv-range-end { font-family: var(--sl-font-mono); font-size: 10px; color: var(--sl-text-3); }
.cv-range-sep { width: 1px; align-self: stretch; margin: 7px 0; background: var(--sl-hairline); }
.cv-range-val { min-width: 30px; text-align: right; font-family: var(--sl-font-mono); font-size: 11px; font-weight: 600; color: var(--sl-text-1); }
.cv-set-model { display: flex; align-items: center; gap: 8px; width: 100%; cursor: pointer; text-align: left; color: var(--sl-text-3); }
.cv-set-model.is-open { border-color: var(--sl-focus); }
.cv-set-model-name { flex: 1; font-size: 12px; font-weight: 600; color: var(--sl-text-1); }
.cv-set-list { display: flex; flex-direction: column; gap: 1px; max-height: 196px; overflow-y: auto; background: var(--sl-panel); border: 1px solid var(--sl-hairline); border-radius: 8px; padding: 3px; }
.cv-set-item { flex: none; width: 100%; border: 0; background: transparent; color: var(--sl-text-1); text-align: left; cursor: pointer; }
.cv-set-item.is-on { background: var(--sl-wash); }
.cv-set-item .cv-ic { color: var(--sl-link); }
.cv-set-item:disabled { opacity: .45; cursor: not-allowed; }
.cv-set-item-name { flex: 1; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cv-set-item.is-on .cv-set-item-name { font-weight: 600; }
@keyframes cv-pop-in { from { opacity: 0; transform: translateY(6px) scale(.98); } }

/* Send under the takes */
.cv-send {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 30px; padding: 0 10px; border: 0;
    border-radius: var(--sl-r-8); background: var(--sl-accent); color: var(--sl-on-accent); font-size: 12px; font-weight: 700; cursor: pointer;
}
.cv-send:hover { filter: brightness(1.08); }
.cv-sent { display: inline-flex; align-items: center; justify-content: center; gap: 5px; height: 26px; font-size: 12px; color: var(--sl-success); }

/* "Made from": the focused node's children as cards, wired into the preview */
.cv-wires { position: absolute; left: 0; top: 0; z-index: 0; pointer-events: none; overflow: visible; }
.cv-w { fill: none; stroke-width: 2; }
.cv-w.ok { stroke: var(--sl-accent-line); }
.cv-w.pend { stroke: var(--sl-text-3); stroke-dasharray: 5 4; }
.cv-sk { fill: var(--sl-panel); stroke-width: 1.5; }
.cv-sk.ok { stroke: var(--sl-accent); }
.cv-sk.pend { stroke: var(--sl-text-3); }
/* Right beside the preview: the margin is the room the wires need. */
/* Right-aligned in the left column, against the preview; the column's right
   padding is the room the wires need. */
.cv-in {
    position: relative; z-index: 1; flex: 1; min-height: 0; width: 212px; max-width: 100%; align-self: flex-end;
    display: flex; flex-direction: column; justify-content: safe center;
    align-items: flex-end; gap: 8px; padding: 6px 2px 6px 0;
}
.cv-in-h {
    display: inline-flex; align-items: center; gap: 5px; font-size: 10.5px; font-weight: 600;
    letter-spacing: .06em; text-transform: uppercase; color: var(--sl-text-3);
}
.cv-hint { font-size: 12px; color: var(--sl-text-3); text-align: right; }
/* No references: just the Add reference button, under the node's name, not mid-column. */
.cv-in.is-empty { flex: none; justify-content: flex-start; }
.cv-card {
    position: relative; flex: none; width: 100%; max-width: 220px; display: flex; align-items: center; gap: 9px;
    padding: 7px 10px 7px 7px; border-radius: var(--sl-r-10); background: var(--sl-card); border: 1px solid var(--sl-hairline);
    text-align: left; cursor: pointer; transition: border-color .15s ease, background .15s ease;
}
.cv-card:hover { border-color: var(--sl-border-strong); background: var(--sl-quiet-hover); }
.cv-card-th { width: 46px; height: 46px; border-radius: 7px; object-fit: cover; flex: none; }
.cv-card.is-gen .cv-card-th { width: 32px; height: 56px; }
.cv-ph { display: grid; place-items: center; background: var(--sl-quiet); color: var(--sl-text-3); }
.cv-card-tx { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cv-card-tx b { font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cv-card-from { display: flex; align-items: center; gap: 3px; margin-top: 2px; }
.cv-av { width: 16px; height: 16px; border-radius: 50%; object-fit: cover; box-shadow: 0 0 0 1.5px var(--sl-card); }
.cv-card-from em { font-style: normal; font-size: 10.5px; color: var(--sl-text-3); margin-left: 3px; }
.cv-card-shared { display: inline-flex; align-items: center; gap: 4px; font-size: 10.5px; color: var(--sl-text-2); }
.cv-socket {
    flex: none; width: 100%; max-width: 220px; height: 38px; display: flex; align-items: center; justify-content: center; gap: 6px;
    border-radius: var(--sl-r-10); border: 1px dashed var(--sl-border-strong); background: var(--sl-app);
    color: var(--sl-text-2); font-size: 12px; cursor: pointer; transition: all .15s ease;
}
.cv-socket:hover { color: var(--sl-text-1); border-color: var(--sl-accent-line); background: var(--sl-accent-tint); }
.cv-frame.is-anchored { cursor: pointer; }

/* "Goes into": what the focused node feeds, wired out of the preview's right edge */
.cv-out {
    position: relative; z-index: 1; flex: 0 1 auto; min-height: 0; width: 212px; max-width: 100%;
    display: flex; flex-direction: column; align-items: flex-start; gap: 8px; padding: 6px 0 6px 2px;
    box-sizing: border-box;
}
.cv-out .cv-hint { text-align: left; }
.cv-out-h {
    display: inline-flex; align-items: center; gap: 5px; font-size: 10.5px; font-weight: 600;
    letter-spacing: .06em; text-transform: uppercase; color: var(--sl-text-3);
}
.cv-pcard {
    position: relative; flex: none; width: 100%; display: flex; align-items: center; gap: 9px; box-sizing: border-box;
    padding: 7px 10px 7px 7px; border-radius: var(--sl-r-10); background: var(--sl-card); border: 1px solid var(--sl-hairline);
    text-align: left; cursor: pointer; outline: none; transition: border-color .15s ease, background .15s ease;
}
.cv-pcard:hover { border-color: var(--sl-border-strong); background: var(--sl-quiet-hover); }
.cv-pcard .cv-card-th { width: 32px; height: 56px; }
/* The video: where a clip on the timeline ends up. Not a button. */
.cv-pcard.is-end { cursor: default; background: transparent; border-style: dashed; border-color: var(--sl-border-strong); }
.cv-pcard.is-end:hover { background: transparent; border-color: var(--sl-border-strong); }
.cv-pcard.is-end .cv-card-th { height: 32px; border-radius: 7px; }
/* Just connected with Use in…: it pops in with a glow that fades. */
.cv-pcard.is-new { animation: cv-pop-card .55s cubic-bezier(.2, .9, .3, 1.35), cv-glow 1.6s ease-out; }
@keyframes cv-pop-card { from { transform: scale(.86); opacity: 0; } }
@keyframes cv-glow { from { border-color: var(--sl-accent); box-shadow: 0 0 0 4px var(--sl-accent-tint); } }

/* ---- card lists (References, Goes into): scroll, soft edges, "N more" pills ---- */
@property --cv-fade-t { syntax: "<length>"; inherits: false; initial-value: 0px; }
@property --cv-fade-b { syntax: "<length>"; inherits: false; initial-value: 0px; }
.cv-list-wrap { position: relative; flex: 0 1 auto; min-height: 0; width: 100%; display: flex; flex-direction: column; }
.cv-list {
    position: relative; flex: 0 1 auto; min-height: 0; display: flex; flex-direction: column; gap: 8px;
    /* room for each card's × and focus ring, given back by the margin */
    padding: 9px 9px; margin: -9px -9px;
    overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain;
    scrollbar-width: none;
    scroll-snap-type: y proximity; scroll-padding-block: 30px;
    /* edges fade only where there is more to see; the fade eases in and out */
    --cv-fade-t: 0px; --cv-fade-b: 0px;
    -webkit-mask-image: linear-gradient(to bottom, transparent, #000 var(--cv-fade-t), #000 calc(100% - var(--cv-fade-b)), transparent);
    mask-image: linear-gradient(to bottom, transparent, #000 var(--cv-fade-t), #000 calc(100% - var(--cv-fade-b)), transparent);
    transition: --cv-fade-t .3s ease, --cv-fade-b .3s ease;
}
.cv-list::-webkit-scrollbar { display: none; }
.cv-in .cv-list { align-items: flex-end; }
.cv-out .cv-list { align-items: flex-start; }
.cv-list > * { scroll-snap-align: start; }
.cv-list-wrap.has-above .cv-list { --cv-fade-t: 34px; }
.cv-list-wrap.has-below .cv-list { --cv-fade-b: 34px; }
.cv-more {
    position: absolute; left: 50%; z-index: 3;
    display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 10px 0 7px; border-radius: 999px;
    border: 1px solid var(--sl-line-pop); background: oklch(0.24 0.008 250 / 0.9); color: var(--sl-text-1);
    backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 8px 22px -8px oklch(0 0 0 / .8);
    font-size: 11px; font-weight: 650; white-space: nowrap; cursor: pointer;
    opacity: 0; pointer-events: none; transform: translate(-50%, 0) scale(.85);
    transition: opacity .2s ease, transform .35s cubic-bezier(.2, .9, .3, 1.4), background .15s ease, color .15s ease, border-color .15s ease;
}
.cv-more.is-up { top: -4px; transform: translate(-50%, 6px) scale(.85); }
.cv-more.is-down { bottom: -4px; transform: translate(-50%, -6px) scale(.85); }
.cv-list-wrap.has-above .cv-more.is-up,
.cv-list-wrap.has-below .cv-more.is-down { opacity: 1; pointer-events: auto; transform: translate(-50%, 0) scale(1); }
.cv-more:hover { background: var(--sl-accent); border-color: var(--sl-accent); color: var(--sl-on-accent); }
.cv-list-wrap.has-above .cv-more.is-up:active,
.cv-list-wrap.has-below .cv-more.is-down:active { transform: translate(-50%, 0) scale(.92); transition-duration: .08s; }
.cv-list-wrap.has-above .cv-more.is-up .cv-ic { animation: cv-nudge-up 1.4s ease-in-out 2; }
.cv-list-wrap.has-below .cv-more.is-down .cv-ic { animation: cv-nudge-down 1.4s ease-in-out 2; }
@keyframes cv-nudge-down { 0%, 60%, 100% { transform: none; } 30% { transform: translateY(2px); } }
@keyframes cv-nudge-up { 0%, 60%, 100% { transform: none; } 30% { transform: translateY(-2px); } }
/* Cards grow in as they come into the list and shrink away as they leave
   (scroll-driven: runs off the main thread, so it stays smooth). */
@supports (animation-timeline: view()) {
    .cv-list > .cv-card, .cv-list > .cv-pcard {
        animation: cv-edge linear both;
        animation-timeline: view(block 0px);
    }
    .cv-list > .cv-pcard.is-new {
        animation: cv-edge linear both, cv-pop-card .55s cubic-bezier(.2, .9, .3, 1.35), cv-glow 1.6s ease-out;
        animation-timeline: view(block 0px), auto, auto;
    }
    @keyframes cv-edge {
        entry 0% { opacity: .2; scale: .86; }
        entry 100% { opacity: 1; scale: 1; }
        exit 0% { opacity: 1; scale: 1; }
        exit 100% { opacity: .2; scale: .86; }
    }
}

/* ---- Use in… menu ---- */
.cv-use-menu { width: 280px; max-height: min(420px, calc(100vh - 16px)); overflow-y: auto; overscroll-behavior: contain; }
.cv-use-h { padding: 6px 8px 4px; font-size: 12px; font-weight: 600; color: var(--sl-text-1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cv-use-item { display: flex; align-items: center; gap: 8px; }
.cv-use-item:disabled { opacity: .45; cursor: not-allowed; }
.cv-use-th { width: 22px; height: 22px; border-radius: 5px; object-fit: cover; flex: none; }
.cv-use-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cv-use-empty { padding: 8px; font-size: 12px; color: var(--sl-text-3); }

/* transport bar (where the "Made from" tray used to sit) */
.cv-bar {
    flex: none; height: 44px; display: flex; align-items: center; gap: 8px; padding: 0 12px;
    background: var(--sl-panel); border-top: 1px solid var(--sl-hairline);
}
.cv-transport { display: flex; align-items: center; gap: 2px; }
.cv-tbtn {
    flex: none; height: 30px; min-width: 30px; padding: 0 6px; border: 0; border-radius: var(--sl-r-8);
    display: inline-flex; align-items: center; justify-content: center; gap: 5px;
    background: transparent; color: var(--sl-text-2); cursor: pointer; transition: background .15s ease, color .15s ease;
}
.cv-tbtn:hover { background: var(--sl-wash); color: var(--sl-text-1); }
.cv-tbtn:active { transform: scale(.96); }
.cv-tbtn.is-on { color: var(--sl-accent-text); background: var(--sl-accent-tint); }
.cv-tbtn-play { width: 36px; height: 36px; border-radius: 50%; background: var(--sl-text-1); color: var(--sl-app); margin: 0 4px; }
.cv-tbtn-play:hover { background: #fff; color: var(--sl-app); }
.cv-tbtn-text { font-size: 12px; font-weight: 600; padding: 0 9px; }
.cv-clock { display: inline-flex; align-items: baseline; gap: 6px; margin-left: 6px; font-family: var(--sl-font-mono); font-size: 13px; }
.cv-clock-t { color: var(--sl-text-1); font-weight: 600; min-width: 62px; }
.cv-clock-sep, .cv-clock-total { color: var(--sl-text-3); }
.cv-rate { padding: 2px 6px; border-radius: 5px; background: var(--sl-accent-tint); color: var(--sl-accent-text); font-family: var(--sl-font-mono); font-size: 11px; }
.cv-rate.hidden { display: none; }
.cv-bar-gap { flex: 1; }
.cv-zoom { width: 110px; accent-color: var(--sl-accent); cursor: pointer; }
.cv-keys { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: var(--sl-r-8); color: var(--sl-text-3); cursor: help; }
.cv-keys:hover { color: var(--sl-text-1); background: var(--sl-wash); }
/* Open in Video Editor + Export, at the bar's right end */
.cv-bar-sep { flex: none; width: 1px; height: 20px; background: var(--sl-hairline); margin: 0 2px; }
.cv-tbtn-out { font-size: 12px; font-weight: 600; padding: 0 10px; white-space: nowrap; }
.cv-tbtn-export { background: var(--sl-accent); color: var(--sl-on-accent); }
.cv-tbtn-export:hover { background: var(--sl-accent); color: var(--sl-on-accent); filter: brightness(1.08); }
.cv-tbtn-export.is-busy, .cv-tbtn-export:disabled { opacity: .6; cursor: progress; filter: none; transform: none; }

/* timeline: clips end to end, width = length (timeline() in clips-view.js sets the px per second) */
.cv-timeline {
    flex: none; height: 118px; display: flex;
    background: var(--sl-app); border-top: 1px solid var(--sl-hairline);
}
.cv-tl-side {
    flex: none; width: 112px; display: flex; flex-direction: column; justify-content: center; gap: 2px;
    padding: 0 14px; border-right: 1px solid var(--sl-hairline);
}
.cv-tl-total { font-family: var(--sl-font-mono); font-size: 18px; font-weight: 600; color: var(--sl-text-1); }
.cv-tl-sub { font-size: 11px; color: var(--sl-text-3); white-space: nowrap; }
.cv-tl-scroll { flex: 1; min-width: 0; overflow-x: auto; overflow-y: hidden; padding: 0 16px; }
.cv-tl-inner { position: relative; height: 100%; display: flex; flex-direction: column; padding: 4px 0 10px; box-sizing: border-box; }

/* ruler: labelled major ticks + minor ticks drawn as a repeating background */
.cv-ruler {
    position: relative; flex: none; height: 22px; cursor: pointer;
    background-image: linear-gradient(to right, oklch(1 0 0 / .16) 1px, transparent 1px);
    background-repeat: repeat-x; background-position: 0 100%;
}
.cv-tick {
    position: absolute; top: 0; bottom: 0; padding: 1px 0 0 4px;
    border-left: 1px solid color-mix(in oklab, var(--sl-ink) 30%, transparent);
    font-family: var(--sl-font-mono); font-size: 10px; color: var(--sl-text-3); white-space: nowrap; pointer-events: none;
}

/* the track: segments touch — a cut is a 1px dark line, not a gap */
.cv-track { position: relative; flex: none; height: 72px; display: flex; border-radius: var(--sl-r-8); overflow: hidden; background: var(--sl-app); }
.cv-clip {
    position: relative; flex: none; height: 100%; min-width: 0; margin: 0; padding: 6px 8px;
    display: flex; flex-direction: column; justify-content: space-between;
    border: 0; border-radius: 0; overflow: hidden; text-align: left; cursor: pointer;
    background-color: var(--sl-card); background-repeat: repeat-x; background-size: auto 100%; background-position: 0 0;
    box-shadow: inset -1px 0 0 oklch(0 0 0 / .75);
}
/* legibility over the frames */
.cv-clip::before {
    content: ""; position: absolute; inset: 0; pointer-events: none;
    background: linear-gradient(to bottom, oklch(0 0 0 / .62), transparent 38%, transparent 52%, oklch(0 0 0 / .72));
}
.cv-clip > span { position: relative; z-index: 1; display: flex; align-items: center; gap: 6px; min-width: 0; }
.cv-clip-top b { font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-shadow: 0 1px 2px oklch(0 0 0 / .8); }
.cv-clip-bot { justify-content: space-between; }
.cv-clip-bot .cv-st { min-width: 0; overflow: hidden; text-overflow: ellipsis; text-shadow: 0 1px 2px oklch(0 0 0 / .8); }
.cv-clip-n {
    flex: none; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 5px; display: inline-grid; place-items: center;
    background: oklch(0 0 0 / .55); font-size: 10.5px; font-weight: 600; font-family: var(--sl-font-mono); color: var(--sl-on-media);
}
.cv-clip-dur {
    flex: none; padding: 1px 5px; border-radius: 4px; background: oklch(0 0 0 / .55);
    font-family: var(--sl-font-mono); font-size: 10.5px; color: var(--sl-on-media);
}
.cv-clip.is-planned .cv-clip-dur { color: var(--sl-on-media-2); }
.cv-clip.no-thumb {
    background-image: repeating-linear-gradient(135deg, oklch(1 0 0 / .035) 0 8px, transparent 8px 16px);
    background-size: auto; background-repeat: repeat;
}
.cv-clip:hover::before { background: linear-gradient(to bottom, oklch(0 0 0 / .45), transparent 38%, transparent 52%, oklch(0 0 0 / .6)); }
.cv-clip.is-on::after {
    content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 2;
    box-shadow: inset 0 0 0 2px var(--sl-accent);
}
.cv-track .cv-clip:first-child::after { border-radius: var(--sl-r-8) 0 0 var(--sl-r-8); }
.cv-track .cv-clip:last-child { box-shadow: none; }
.cv-track .cv-clip:last-child::after { border-radius: 0 var(--sl-r-8) var(--sl-r-8) 0; }
.cv-track .cv-clip:only-child::after { border-radius: var(--sl-r-8); }

/* playhead */
.cv-playhead {
    position: absolute; top: 4px; bottom: 10px; width: 2px; margin-left: -1px; z-index: 3; pointer-events: none;
    background: var(--sl-accent);
}
.cv-ph-t {
    position: absolute; top: 0; left: 1px; transform: translateX(-50%);
    padding: 1px 5px; border-radius: 4px; background: var(--sl-accent); color: var(--sl-on-accent);
    font-family: var(--sl-font-mono); font-size: 10px; font-weight: 600; white-space: nowrap;
}
/* Inside a child: the parent clip turns violet, and so does the playhead. */
.cv-clip.is-inside::after {
    content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 2;
    box-shadow: inset 0 0 0 2px var(--cv-inside);
}
.cv-clip.is-inside { background-color: color-mix(in oklab, var(--cv-inside) 16%, var(--sl-card)); }
.cv-clip.is-inside::before {
    background: linear-gradient(to bottom, oklch(0.3 0.1 300 / .75), oklch(0.3 0.1 300 / .25) 38%, oklch(0.3 0.1 300 / .25) 52%, oklch(0.2 0.06 300 / .8));
}
.cv-clip-inside {
    align-self: flex-start; padding: 1px 6px; border-radius: 4px; max-width: 100%;
    background: var(--cv-inside); color: oklch(0.18 0.04 300);
    font-size: 10px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cv-playhead.is-inside, .cv-playhead.is-inside .cv-ph-t { background: var(--cv-inside); color: oklch(0.18 0.04 300); }
/* At 0:00 a centred label would be cut off by the scroll edge. */
.cv-playhead.at-start .cv-ph-t { left: -1px; transform: none; }

/* empty tab */
.cv-empty { margin: auto; max-width: 360px; display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; padding: 24px; }
.cv-empty h2 { font-size: 17px; font-weight: 600; }
.cv-empty p { color: var(--sl-text-2); }

.cv-cr:focus-visible, .cv-card:focus-visible, .cv-pcard:focus-visible, .cv-socket:focus-visible, .cv-tk:focus-visible, .cv-tbtn:focus-visible, .cv-keys:focus-visible, .cv-gen:focus-visible, .cv-send:focus-visible, .cv-edit-link:focus-visible, .cv-opt:focus-visible, .cv-set-item:focus-visible { outline: 2px solid var(--sl-focus); outline-offset: 2px; }

.cv-clip:focus-visible { outline: 2px solid var(--sl-focus); outline-offset: -2px; }

@keyframes cv-blink { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .cv-st-gen i, .cv-set-pop, .cv-tk.is-pending i { animation: none; } .cv-prompt-in { transition: none; } }
@media (prefers-reduced-motion: reduce) {
    .cv-list > .cv-card, .cv-list > .cv-pcard, .cv-list > .cv-pcard.is-new, .cv-pcard.is-new, .cv-more .cv-ic,
    .cv-list-wrap.has-above .cv-more.is-up .cv-ic, .cv-list-wrap.has-below .cv-more.is-down .cv-ic { animation: none; }
    .cv-list, .cv-more { transition: none; }
}
@media (max-width: 1100px) {
    .cv-left { padding-right: 28px; }
    .cv-in { width: 170px; }
    .cv-side { padding-left: 28px; }
    .cv-out { width: 170px; }
}

/* ---- references: remove button on a card ---- */
.cv-card { outline: none; }
.cv-card-x {
    position: absolute; top: -7px; right: -7px; width: 20px; height: 20px; border-radius: 50%;
    display: grid; place-items: center; padding: 0; border: 1px solid var(--sl-border-strong);
    background: var(--sl-segment-on); color: var(--sl-text-1); cursor: pointer; opacity: 0; transition: opacity .15s ease, background .15s ease;
}
.cv-card:hover .cv-card-x, .cv-card:focus-within .cv-card-x, .cv-card:focus-visible .cv-card-x { opacity: 1; }
.cv-card-x:hover { background: var(--sl-danger-wash); color: var(--sl-danger-text); }

/* ---- timeline: New clip, Run all, reorder ---- */
.cv-track { align-self: flex-start; }
.cv-newclip {
    position: absolute; top: 30px; width: 120px; height: 72px; border-radius: var(--sl-r-8);
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
    border: 1px dashed var(--sl-border-strong); background: transparent; color: var(--sl-text-2); font-size: 12px; cursor: pointer;
    transition: all .15s ease;
}
.cv-newclip:hover { color: var(--sl-text-1); border-color: var(--sl-accent-line); background: var(--sl-accent-tint); }
.cv-runall {
    align-self: flex-start; margin-top: 6px; display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 8px;
    border: 1px solid var(--sl-border); border-radius: var(--sl-r-6); background: var(--sl-control); color: var(--sl-text-1);
    font-size: 11px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.cv-runall:hover { background: var(--sl-control-hover); }
.cv-runall.is-stop { background: var(--sl-danger-wash); color: var(--sl-danger-text); border-color: var(--sl-danger-line); }
.cv-clip { touch-action: pan-x; }   /* a finger scrolls the timeline; a mouse drag reorders */
.cv-clip.is-dragging { opacity: .55; z-index: 4; cursor: grabbing; }
.cv-drop-mark { position: absolute; top: -4px; bottom: -4px; width: 3px; margin-left: -1.5px; border-radius: 2px; background: var(--sl-accent); z-index: 5; pointer-events: none; }
.cv-track { overflow: visible; }

/* ---- dropping files or assets on the view ---- */
.clips-view.is-drop::after {
    content: attr(data-drop); position: absolute; inset: 10px; z-index: 40; pointer-events: none;
    display: flex; align-items: center; justify-content: center; text-align: center; padding: 20px;
    border: 2px dashed var(--sl-accent-line); border-radius: var(--sl-r-14); background: oklch(0.165 0.004 250 / .82);
    color: var(--sl-accent-text); font-size: 15px; font-weight: 600;
}

/* ---- right-click menu on a clip ---- */
.cv-menu { position: fixed; z-index: 10100; min-width: 180px; display: flex; flex-direction: column; animation: cv-pop-in .12s ease-out; }
.cv-menu-item { width: 100%; border: 0; background: transparent; color: var(--sl-text-1); text-align: left; cursor: pointer; font-family: var(--sl-font-ui); }

.cv-empty-acts { display: flex; gap: 8px; margin-top: 4px; }

/* ============================================================
   Reference picker (js/clips-ref-picker.js) — ComfyField's MediaPicker:
   one modal, tabs, a grid of square tiles, an Upload tile first.
   ============================================================ */
.rp {
    position: fixed; inset: 0; z-index: 10200; display: flex; align-items: center; justify-content: center; padding: 24px;
    background: oklch(0.1 0.004 250 / 0.6); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
    animation: rp-fade .16s ease-out;
}
.rp.is-closing { animation: rp-out .14s ease-in forwards; }
.rp-card {
    width: min(760px, 100%); height: min(640px, calc(100vh - 48px)); display: flex; flex-direction: column;
    background: var(--sl-raised); border: 1px solid var(--sl-line-pop); border-radius: 14px; box-shadow: var(--sl-shadow-modal);
    color: var(--sl-text-1); font-family: var(--sl-font-ui); outline: none; overflow: hidden;
    animation: rp-in .18s cubic-bezier(.2, .8, .2, 1);
    transition: border-color .15s ease, box-shadow .15s ease;
}
.rp-card.is-over { border-color: var(--sl-accent); box-shadow: var(--sl-shadow-modal), 0 0 0 3px var(--sl-accent-tint); }
.rp-head { flex: none; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 16px 16px 8px; }
.rp-titles { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.rp-titles h3 { margin: 0; font-size: 15px; font-weight: 600; }
.rp-sub { font-size: 12px; color: var(--sl-text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rp-x { flex: none; width: 30px; height: 30px; border: 0; border-radius: var(--sl-r-8); background: transparent; color: var(--sl-text-2); display: grid; place-items: center; cursor: pointer; }
.rp-x:hover { background: var(--sl-wash); color: var(--sl-text-1); }
.rp-bar { flex: none; display: flex; align-items: center; gap: 10px; padding: 0 16px 10px; }
.rp-tabs { flex: none; }
.rp-tab.is-on { background: var(--sl-segment-on); color: var(--sl-text-1); }
.rp-search { flex: 1; display: flex; align-items: center; gap: 6px; max-width: 280px; margin-left: auto; color: var(--sl-text-3); }
.rp-search[hidden] { display: none; }
.rp-search-in { flex: 1; min-width: 0; height: 30px; }
.rp-err { flex: none; margin: 0 16px 10px; padding: 8px 10px; border-radius: var(--sl-r-8); background: var(--sl-danger-wash); color: var(--sl-danger-text); font-size: 12px; }
.rp-err[hidden] { display: none; }
.rp-body { flex: 1; min-height: 0; overflow-y: auto; padding: 0 16px 12px; }
.rp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 10px; }
.rp-tile {
    position: relative; aspect-ratio: 1; padding: 0; border: 1px solid var(--sl-hairline); border-radius: 10px; overflow: hidden;
    background: var(--sl-card); color: var(--sl-text-2); cursor: pointer; font-family: inherit;
    animation: rp-tile .22s ease-out backwards; animation-delay: calc(var(--i, 0) * 18ms);
    transition: border-color .15s ease, transform .15s ease;
}
.rp-tile:hover { border-color: var(--sl-border-strong); transform: translateY(-1px); }
.rp-tile:focus-visible { outline: 2px solid var(--sl-focus); outline-offset: 2px; }
.rp-tile img, .rp-tile video { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.rp-badge { position: absolute; right: 6px; bottom: 6px; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: oklch(0 0 0 / .6); color: var(--sl-on-media); }
.rp-label { position: absolute; left: 6px; top: 6px; padding: 1px 5px; border-radius: 4px; background: oklch(0 0 0 / .6); font-family: var(--sl-font-mono); font-size: 10px; color: var(--sl-on-media); }
.rp-audio { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 10px; font-size: 11.5px; text-align: center; overflow-wrap: anywhere; }
.rp-up {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
    border: 1.5px dashed var(--sl-border-strong); background: transparent; animation: none;
}
.rp-up b { font-size: 13px; color: var(--sl-text-1); }
.rp-up span { font-size: 11px; color: var(--sl-text-3); }
.rp-up:hover { border-color: var(--sl-accent-line); background: var(--sl-accent-tint); }
.rp-up.is-busy { cursor: progress; opacity: .8; background: linear-gradient(110deg, var(--sl-card) 30%, var(--sl-quiet-hover) 50%, var(--sl-card) 70%); background-size: 200% 100%; animation: rp-shim 1.4s linear infinite; }
.rp-gen .rp-ic { color: var(--sl-link); }
.rp-file { display: none; }
.rp-empty { padding: 48px 12px; text-align: center; color: var(--sl-text-3); font-size: 13px; }
.rp-foot { flex: none; padding: 10px 16px; border-top: 1px solid var(--sl-hairline); font-size: 11px; color: var(--sl-text-3); }
@keyframes rp-fade { from { opacity: 0; } }
@keyframes rp-out { to { opacity: 0; } }
@keyframes rp-in { from { opacity: 0; transform: translateY(10px) scale(.98); } }
@keyframes rp-tile { from { opacity: 0; transform: translateY(6px); } }
@keyframes rp-shim { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .rp, .rp-card, .rp-tile, .rp.is-closing { animation: none; } }

/* ============================================================
   Phone (body.pw-mobile, js/mobile-mode.js): one column.
   Crumbs, the preview, its references in a row, its takes in a row,
   the prompt, a compact transport, the timeline. No wires.
   ============================================================ */
body.pw-mobile .canvas-view-toggle { display: inline-flex; }
body.pw-mobile .canvas-view-toggle.hidden { display: none; }
body.pw-mobile .canvas-view-toggle .sl-seg-btn { padding: 0 9px; font-size: 0; gap: 0; height: 30px; }
body.pw-mobile .canvas-view-toggle .sl-seg-btn .cv-ic svg { width: 15px; height: 15px; }

body.pw-mobile .cv-top { padding: 8px 10px; gap: 8px; }
body.pw-mobile .cv-main { display: flex; flex-direction: column; gap: 8px; }
body.pw-mobile .cv-left { display: contents; }
body.pw-mobile .cv-crumbs { order: 0; flex: none; }
body.pw-mobile .cv-info { display: none; }
body.pw-mobile .cv-stage { order: 1; flex: 1; min-height: 150px; }
body.pw-mobile .cv-in {
    order: 2; flex: none; width: auto; max-width: none; align-self: stretch;
    flex-direction: row; justify-content: flex-start; align-items: stretch;
    padding: 2px 2px 4px; gap: 8px;
}
/* A phone lists cards in a row that scrolls sideways; no pills, no fades. */
body.pw-mobile .cv-list-wrap { display: contents; }
body.pw-mobile .cv-list {
    flex: 0 1 auto; min-width: 0; flex-direction: row; align-items: stretch; gap: 8px;
    margin: 0; padding: 2px; overflow-x: auto; overflow-y: hidden;
    scroll-snap-type: x proximity; scroll-padding-block: 0; -webkit-mask-image: none; mask-image: none;
}
body.pw-mobile .cv-list > .cv-card, body.pw-mobile .cv-list > .cv-pcard { animation: none; }
body.pw-mobile .cv-more { display: none; }
body.pw-mobile .cv-in .cv-socket, body.pw-mobile .cv-out .cv-socket { flex: none; }
body.pw-mobile .cv-in-h, body.pw-mobile .cv-in .cv-hint { display: none; }
body.pw-mobile .cv-card { width: auto; max-width: 200px; padding: 5px 9px 5px 5px; }
body.pw-mobile .cv-card-th { width: 36px; height: 36px; }
body.pw-mobile .cv-card.is-gen .cv-card-th { width: 24px; height: 42px; }
body.pw-mobile .cv-card-x { opacity: 1; }
body.pw-mobile .cv-socket { width: auto; max-width: none; height: auto; min-height: 44px; padding: 0 14px; white-space: nowrap; }
body.pw-mobile .cv-side { order: 3; flex: none; padding-left: 0; gap: 8px; }
body.pw-mobile .cv-out {
    width: auto; max-width: 100%; align-self: stretch; flex: none;
    flex-direction: row; align-items: center; padding: 2px 2px 4px;
}
body.pw-mobile .cv-out-h { flex: none; }
body.pw-mobile .cv-pcard { width: auto; max-width: 200px; padding: 5px 9px 5px 5px; }
body.pw-mobile .cv-pcard .cv-card-th { width: 24px; height: 42px; }
body.pw-mobile .cv-pcard.is-end .cv-card-th { width: 32px; height: 32px; }
body.pw-mobile .cv-takes { flex-direction: row; align-items: center; max-height: none; overflow-x: auto; padding: 6px; }
body.pw-mobile .cv-takes-h { display: none; }
/* the latest takes, History, then (opened) the earlier runs side by side, each
   with its short name above its takes; they scroll sideways inside the row, so
   Send stays on screen at its end */
body.pw-mobile .cv-side { min-width: 0; }
body.pw-mobile .cv-takes { flex: 0 1 auto; min-width: 0; max-width: 100%; }
body.pw-mobile .cv-takes-list { flex: 0 1 auto; min-width: 0; flex-direction: row; align-items: flex-end; gap: 12px; margin-right: 0; overflow-x: auto; overflow-y: hidden; scrollbar-gutter: auto; }
body.pw-mobile .cv-hist { width: auto; min-width: 0; height: 40px; align-self: center; }
/* open, it sticks at the row's left edge as a narrow full-height icon button, so the
   takes scroll out of sight under it */
body.pw-mobile .cv-hist.is-open {
    position: sticky; z-index: 1; left: 0; height: auto; align-self: stretch; flex-direction: column; justify-content: center; gap: 4px; padding: 0 10px;
    box-shadow: 0 0 0 2px var(--sl-panel), 8px 0 0 2px var(--sl-panel);
}
body.pw-mobile .cv-hist.is-open .cv-ic:last-child { margin-left: 0; }
body.pw-mobile .cv-hist.is-open .cv-hist-t { display: none; }
body.pw-mobile .cv-run { flex: none; gap: 3px; }
body.pw-mobile .cv-run + .cv-run { padding-top: 0; border-top: 0; padding-left: 12px; border-left: 1px solid var(--sl-hairline); }
body.pw-mobile .cv-run-h span { display: none; }
body.pw-mobile .cv-takes-g { grid-auto-flow: column; grid-template-columns: none; grid-auto-columns: 40px; }
body.pw-mobile .cv-tk { width: 40px; }
body.pw-mobile .cv-send, body.pw-mobile .cv-sent { flex: none; }
body.pw-mobile .cv-wires { display: none; }

body.pw-mobile .cv-prompt-slot { width: 100%; }
body.pw-mobile .cv-prompt { gap: 6px; padding: 6px; }
body.pw-mobile .cv-set-btn { max-width: 38vw; padding: 0 8px; }
body.pw-mobile .cv-set-pop { left: -6px; width: min(304px, calc(100vw - 20px)); max-width: none; }
body.pw-mobile .cv-set-box { width: 100%; }
body.pw-mobile .cv-kbd { display: none; }
body.pw-mobile .cv-gen { padding: 0 12px; }
/* The settings chip, the prompt and a button such as "Generate image ref
   first" need about 420px in one row, so on a 360-430px phone the button ran
   off the right edge. There the button takes its own full-width row under the
   prompt, and the slot keeps room for the second row. */
@media (max-width: 560px) {
    body.pw-mobile .cv-prompt-slot { height: 86px; }
    body.pw-mobile .cv-prompt { flex-wrap: wrap; align-items: center; }
    body.pw-mobile .cv-prompt-in { min-width: 0; }
    body.pw-mobile .cv-gen { flex: 1 1 100%; justify-content: center; order: 3; }
}

body.pw-mobile .cv-bar { padding: 0 6px; gap: 2px; overflow-x: auto; }
body.pw-mobile .cv-clock-sep, body.pw-mobile .cv-clock-total,
body.pw-mobile .cv-zoom, body.pw-mobile .cv-keys,
body.pw-mobile .cv-bar .cv-tbtn-text, body.pw-mobile .cv-tbtn-label { display: none; }
body.pw-mobile .cv-tbtn-out { padding: 0 8px; }
/* A phone has no Video Editor (patchwork-editor-host.js editorMode 'phone'), and
   go to start / end stand for Home / End: that room goes to Export. */
body.pw-mobile .cv-tbtn-editor, body.pw-mobile .cv-bar-sep, body.pw-mobile .cv-tbtn-skip { display: none; }
body.pw-mobile .cv-clock { margin-left: 2px; }

body.pw-mobile .cv-timeline { height: 110px; }
body.pw-mobile .cv-tl-side { width: 92px; padding: 0 8px; }
body.pw-mobile .cv-runall { padding: 0 6px; font-size: 10.5px; }
body.pw-mobile .cv-tl-total { font-size: 13px; }
body.pw-mobile .cv-tl-sub { display: none; }
body.pw-mobile .cv-tl-scroll { padding: 0 10px; }
/* A phone on its side (UI revision phase 8): about 90px is left for the
   preview, so it ran under the prompt bar and its empty card spilled out.
   The column scrolls instead, the timeline is shorter, and an empty preview
   keeps only its icon. */
@media (max-height: 520px) {
    body.pw-mobile .cv-main { overflow-y: auto; }
    body.pw-mobile .cv-stage { min-height: 96px; }
    body.pw-mobile .cv-timeline { height: 80px; }
    body.pw-mobile .cv-frame-empty { padding: 6px; }
    body.pw-mobile .cv-frame-empty > :not(.cv-empty-ic) { display: none; }
}

/* the picker fills the phone */
body.pw-mobile .rp { padding: 0; }
body.pw-mobile .rp-card { width: 100%; height: 100%; border-radius: 0; border: 0; }
body.pw-mobile .rp-bar { flex-wrap: wrap; }
body.pw-mobile .rp-search { max-width: none; margin-left: 0; flex-basis: 100%; }
body.pw-mobile .rp-grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 8px; }
body.pw-mobile .rp-x { width: 40px; height: 40px; }

/* Light theme (css/slate.css §1b): the "inside a clip" violet, dark enough for text on white. */
:root[data-pw-theme="light"] .clips-view {
    --cv-inside: oklch(0.52 0.15 300);
    --cv-inside-tint: oklch(0.52 0.15 300 / 0.14);
}
