/* DaVinci Tool — neon UI. No external assets; animations use transform/opacity only
   (the lone exceptions are the focus-ring gradient and details height, both cheap). */

:root {
  color-scheme: dark;
  --bg-0: #07070d;
  --bg-1: #0b0b16;
  --surface: rgba(255, 255, 255, .045);
  --surface-2: rgba(255, 255, 255, .075);
  --surface-solid: #11111f;
  --line: rgba(255, 255, 255, .09);
  --text: #f3f3fc;
  --muted: #a6a6c6;
  --magenta: #ff2bd6;
  --cyan: #00e5ff;
  --violet: #8b5cff;
  --green: #3dffa6;
  --amber: #ffc24a;
  --red: #ff5c7a;
  --grad: linear-gradient(120deg, var(--magenta), var(--violet) 55%, var(--cyan));
  --r: 14px;
  --ease: cubic-bezier(.22, .8, .24, 1);
  --t: 220ms;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scrollbar-color: #2a2a45 transparent; }
body {
  margin: 0; min-height: 100vh; background: var(--bg-0); color: var(--text);
  font: 15px/1.55 var(--font); overflow-x: hidden;
}
a { color: var(--cyan); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: var(--mono); font-size: .85em; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.grow { flex: 1 1 auto; min-width: 0; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
h1, h2, h3 { margin: 0; line-height: 1.2; letter-spacing: -.01em; }
h1 { font-size: clamp(1.7rem, 4vw, 2.3rem); font-weight: 750; }
h2 { font-size: 1.1rem; font-weight: 650; display: flex; align-items: center; gap: .55rem; margin-bottom: 1rem; }
h3 { font-size: 1.05rem; }
.i { width: 1.15em; height: 1.15em; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; vertical-align: -.2em; }
#i-play, #i-bolt { fill: currentColor; }

/* ── background: slow drifting glows + faint grid ─────────────────────────── */
.bg { position: fixed; inset: 0; z-index: -1; overflow: hidden; background: radial-gradient(120% 90% at 50% -10%, #12122a 0%, var(--bg-0) 60%); }
.glow { position: absolute; width: 60vmax; height: 60vmax; border-radius: 50%; filter: blur(90px); opacity: .22; will-change: transform; }
.g1 { background: var(--magenta); top: -25vmax; left: -15vmax; animation: drift1 38s ease-in-out infinite alternate; }
.g2 { background: var(--cyan); bottom: -30vmax; right: -20vmax; opacity: .16; animation: drift2 46s ease-in-out infinite alternate; }
.g3 { background: var(--violet); top: 30%; left: 40%; width: 40vmax; height: 40vmax; opacity: .12; animation: drift3 52s ease-in-out infinite alternate; }
.grid {
  position: absolute; inset: 0; opacity: .5;
  background-image: linear-gradient(rgba(255,255,255,.035) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.035) 1px, transparent 1px);
  background-size: 56px 56px;
  -webkit-mask-image: radial-gradient(70% 60% at 50% 30%, #000, transparent);
  mask-image: radial-gradient(70% 60% at 50% 30%, #000, transparent);
}
@keyframes drift1 { to { transform: translate3d(18vmax, 12vmax, 0) scale(1.15); } }
@keyframes drift2 { to { transform: translate3d(-16vmax, -10vmax, 0) scale(1.1); } }
@keyframes drift3 { to { transform: translate3d(-12vmax, 14vmax, 0) scale(.85); } }

/* ── shell ────────────────────────────────────────────────────────────────── */
.shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; padding: 20px 14px; view-transition-name: sidebar; }
.main { padding: 36px clamp(16px, 4vw, 48px) 120px; min-width: 0; }
.page { max-width: 1040px; margin: 0 auto; display: flex; flex-direction: column; gap: 20px; }

.nav {
  height: 100%; display: flex; flex-direction: column; gap: 22px; padding: 18px 12px;
  border-radius: 20px; background: rgba(12, 12, 24, .62); -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px);
  position: relative;
}
.nav::before, .card::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit; padding: 1px; pointer-events: none;
  background: linear-gradient(140deg, rgba(255,43,214,.5), rgba(139,92,255,.16) 40%, rgba(0,229,255,.34));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); padding: 0 6px; }
.brand:hover { text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 11px; background: var(--grad); color: #07070d; box-shadow: 0 0 22px rgba(255,43,214,.45); }
.brand-mark .i { stroke-width: 2; }
.brand-text { font-weight: 700; font-size: 1.05rem; letter-spacing: -.01em; }
.brand-text b { font-weight: 800; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; margin-left: 2px; }
.nav-links { display: flex; flex-direction: column; gap: 4px; }
.nav-link {
  display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 12px; color: var(--muted); font-weight: 550;
  position: relative; transition: color var(--t) var(--ease), background-color var(--t) var(--ease), transform var(--t) var(--ease);
}
.nav-link:hover { color: var(--text); background: var(--surface); text-decoration: none; transform: translateX(2px); }
.nav-link[aria-current="page"] { color: var(--text); background: linear-gradient(90deg, rgba(255,43,214,.16), rgba(0,229,255,.06)); }
.nav-link[aria-current="page"]::after {
  content: ""; position: absolute; left: -12px; top: 22%; bottom: 22%; width: 3px; border-radius: 3px; background: var(--grad); box-shadow: 0 0 12px var(--magenta);
}
.nav-link[aria-current="page"] .i { color: var(--cyan); filter: drop-shadow(0 0 6px rgba(0,229,255,.7)); }

.live { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; background: var(--surface); color: var(--muted); font-size: .85rem; }
.live:hover { text-decoration: none; color: var(--text); }
.live.busy { color: var(--text); background: rgba(0,229,255,.08); }
.dot-idle { width: 8px; height: 8px; border-radius: 50%; background: #4b4b6b; }
.pulse, .chip.processing .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 10px var(--cyan); position: relative; }
.pulse::after, .chip.processing .dot::after { content: ""; position: absolute; inset: 0; border-radius: 50%; background: var(--cyan); animation: ping 1.4s var(--ease) infinite; }
.pulse.idle { background: var(--amber); box-shadow: 0 0 10px var(--amber); }
.pulse.idle::after { background: var(--amber); }
@keyframes ping { 0% { transform: scale(1); opacity: .7; } 100% { transform: scale(3); opacity: 0; } }

@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { position: sticky; z-index: 20; height: auto; padding: 8px 8px 0; top: 0; }
  .nav { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 8px 10px; border-radius: 16px; }
  .brand-text { display: none; }
  .nav-links { flex-direction: row; order: 3; width: 100%; justify-content: space-between; }
  .nav-link { flex-direction: column; gap: 2px; padding: 6px 4px; font-size: .72rem; flex: 1; justify-content: center; text-align: center; }
  .nav-link[aria-current="page"]::after { left: 20%; right: 20%; top: auto; bottom: -2px; width: auto; height: 3px; }
  .live { margin: 0 0 0 auto; padding: 6px 10px; }
  .main { padding-top: 20px; }
}

/* ── page header, cards ───────────────────────────────────────────────────── */
.page-head { display: flex; flex-direction: column; gap: 6px; }
.page-head h1 { background: linear-gradient(100deg, #fff 30%, #c9b8ff 70%, var(--cyan)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.lead { margin: 0; color: var(--muted); }
.section-title { margin: 8px 0 -4px; font-size: .8rem; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); font-weight: 650; }
.card {
  position: relative; border-radius: var(--r); padding: 20px; background: var(--surface);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  transition: transform var(--t) var(--ease), background-color var(--t) var(--ease), box-shadow var(--t) var(--ease);
}
.card:hover { background: var(--surface-2); box-shadow: 0 10px 40px -18px rgba(255, 43, 214, .35); }
.stack { display: flex; flex-direction: column; gap: 14px; }
.stack-sm { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; gap: 10px; align-items: stretch; flex-wrap: wrap; }
.row > .ctl { flex: 1 1 200px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.settings-grid .wide { grid-column: 1 / -1; }
@media (max-width: 760px) { .grid-2, .grid-3, .settings-grid { grid-template-columns: minmax(0, 1fr); } }
.num-badge { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 8px; font-size: .8rem; background: var(--grad); color: #07070d; font-weight: 800; box-shadow: 0 0 14px rgba(255,43,214,.5); }

/* ── entrance animations ──────────────────────────────────────────────────── */
.enter { animation: rise .42s var(--ease) both; animation-delay: calc(var(--i, 0) * 45ms); }
@keyframes rise { from { opacity: 0; transform: translate3d(0, 14px, 0); } to { opacity: 1; transform: none; } }

/* ── forms ────────────────────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 8px; border: 0; padding: 0; margin: 14px 0 0; min-width: 0; }
.field:first-child, .step > .field:first-of-type { margin-top: 0; }
label, .label, legend { font-size: .84rem; font-weight: 600; color: #d6d6ee; padding: 0; }
.hint { margin: 0; font-size: .8rem; color: var(--muted); }
.err, .warn-note, .ok-note { display: flex; gap: 8px; align-items: flex-start; margin: 8px 0 0; font-size: .86rem; }
.err { color: var(--red); } .warn-note { color: var(--amber); } .ok-note { color: var(--green); }
.err .i, .warn-note .i { margin-top: 3px; }
.empty-note { color: var(--muted); font-size: .9rem; margin: 8px 0 0; }

.ctl { position: relative; border-radius: 12px; isolation: isolate; }
.ctl::before {
  content: ""; position: absolute; inset: -2px; z-index: -1; border-radius: 14px; opacity: 0;
  background: linear-gradient(120deg, var(--magenta), var(--cyan), var(--violet), var(--magenta)); background-size: 300% 100%;
  transition: opacity var(--t) var(--ease); box-shadow: 0 0 22px rgba(255, 43, 214, .35);
}
.ctl:focus-within::before { opacity: 1; animation: ring 3s linear infinite; }
@keyframes ring { to { background-position: 300% 0; } }
input[type=text], input[type=number], input[type=password], input:not([type]), select, textarea {
  width: 100%; min-height: 44px; padding: 10px 14px; color: var(--text); font: inherit; border-radius: 12px;
  background: #0d0d1b; border: 1px solid var(--line); outline: none; font-variant-numeric: tabular-nums;
  transition: border-color var(--t) var(--ease);
}
input::placeholder, textarea::placeholder { color: #7b7b9c; }
textarea { resize: vertical; min-height: 84px; }
select { appearance: none; -webkit-appearance: none; padding-right: 40px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--cyan) 50%), linear-gradient(135deg, var(--cyan) 50%, transparent 50%);
  background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%; background-size: 6px 6px; background-repeat: no-repeat; }
.ctl:focus-within input, .ctl:focus-within select, .ctl:focus-within textarea { border-color: transparent; }
:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
.ctl :focus-visible { outline: none; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 18px; cursor: pointer;
  border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); color: var(--text); font: inherit; font-weight: 600; text-decoration: none;
  position: relative; transition: transform var(--t) var(--ease), box-shadow var(--t) var(--ease), background-color var(--t) var(--ease), border-color var(--t) var(--ease);
}
.btn:hover { text-decoration: none; transform: translateY(-2px); border-color: rgba(0,229,255,.55); box-shadow: 0 8px 26px -10px rgba(0,229,255,.55); }
.btn:active { transform: translateY(0) scale(.97); transition-duration: 90ms; }
.btn:disabled, .btn[aria-disabled=true] { opacity: .45; pointer-events: none; }
.btn-sm { min-height: 36px; padding: 6px 12px; font-size: .86rem; border-radius: 10px; }
.btn-ghost { background: transparent; }
.btn-danger { border-color: rgba(255,92,122,.4); color: #ffb3c1; }
.btn-danger:hover, .danger:hover { border-color: var(--red); box-shadow: 0 8px 26px -10px rgba(255,92,122,.6); }
.btn-primary { background: var(--grad); color: #07070d; border: 0; box-shadow: 0 0 0 1px rgba(255,255,255,.12) inset, 0 10px 34px -8px rgba(255,43,214,.7), 0 0 28px -6px rgba(0,229,255,.5); }
.btn-primary:hover { box-shadow: 0 0 0 1px rgba(255,255,255,.2) inset, 0 14px 44px -8px rgba(255,43,214,.9), 0 0 40px -4px rgba(0,229,255,.7); }
.btn-xl { min-height: 56px; padding: 14px 40px; font-size: 1.1rem; border-radius: 16px; letter-spacing: .01em; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 12px; }
.card > .btn-row:first-child { margin-top: 0; }
.link { background: none; border: 0; color: var(--cyan); font: inherit; font-size: .84rem; cursor: pointer; padding: 4px 0; }
.link:hover { text-decoration: underline; }
.link.danger { color: var(--red); }
.inline { display: inline; margin: 0; }
.htmx-request.btn, .htmx-request .btn { pointer-events: none; }
.btn.htmx-request { opacity: .75; }
.btn.htmx-request::after { content: ""; width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.status-pill { padding: 3px 10px; border-radius: 999px; font-size: .78rem; font-weight: 650; border: 1px solid var(--line); }
.status-pill.on { color: var(--green); border-color: rgba(61,255,166,.4); }
.status-pill.off { color: var(--amber); border-color: rgba(255,194,74,.4); }

.seg-control { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.seg-control label { cursor: pointer; }
.seg-control input { position: absolute; opacity: 0; pointer-events: none; }
.seg-control span { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: #0d0d1b; font-weight: 650;
  transition: border-color var(--t) var(--ease), box-shadow var(--t) var(--ease), transform var(--t) var(--ease); }
.seg-control small { font-weight: 450; color: var(--muted); font-size: .78rem; }
.seg-control label:hover span { transform: translateY(-1px); }
.seg-control input:checked + span { border-color: var(--magenta); box-shadow: 0 0 0 1px var(--magenta), 0 0 24px -4px rgba(255,43,214,.55); }
.seg-control input:focus-visible + span { outline: 2px solid var(--cyan); outline-offset: 2px; }
.tc-field { display: none; flex-direction: column; gap: 8px; margin-top: 12px; }
.create:has(input[value=timecode]:checked) .tc-field { display: flex; animation: rise .3s var(--ease) both; }

.field-row { display: flex; justify-content: space-between; align-items: center; margin: 14px 0 8px; }
.ep-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr)); gap: 10px; }
.epcard { position: relative; display: grid; grid-template-columns: 22px minmax(0, 1fr); column-gap: 10px; padding: 12px; border-radius: 12px; border: 1px solid var(--line); background: #0d0d1b; cursor: pointer;
  transition: transform var(--t) var(--ease), border-color var(--t) var(--ease), box-shadow var(--t) var(--ease); animation: rise .35s var(--ease) both; animation-delay: calc(var(--i, 0) * 30ms); }
.epcard:hover { transform: translateY(-2px); border-color: rgba(0,229,255,.5); }
.epcard input { position: absolute; opacity: 0; pointer-events: none; }
.epcheck { grid-row: 1 / 3; width: 22px; height: 22px; border-radius: 7px; border: 1.5px solid #4a4a6e; display: grid; place-items: center; color: #07070d; transition: background-color var(--t), border-color var(--t); }
.epcheck .i { opacity: 0; transform: scale(.4); transition: opacity var(--t) var(--ease), transform var(--t) var(--ease); stroke-width: 2.6; }
.epcard:has(input:checked) { border-color: var(--cyan); box-shadow: 0 0 0 1px var(--cyan), 0 0 26px -6px rgba(0,229,255,.55); }
.epcard input:checked ~ .epcheck { background: var(--cyan); border-color: var(--cyan); }
.epcard input:checked ~ .epcheck .i { opacity: 1; transform: none; }
.epcard input:focus-visible ~ .epcheck { outline: 2px solid var(--cyan); outline-offset: 2px; }
.ep-name { font-weight: 600; overflow-wrap: anywhere; font-size: .9rem; }
.ep-meta { font-size: .78rem; color: var(--muted); }

.actionbar { position: sticky; bottom: 14px; z-index: 10; display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 14px 12px 20px; border-radius: 18px;
  background: rgba(10,10,22,.78); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); border: 1px solid var(--line); }
@media (max-width: 560px) { .actionbar .btn { flex: 1; padding-inline: 16px; } }

/* ── template preview ─────────────────────────────────────────────────────── */
.preview { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); position: relative; transition: opacity var(--t); }
.preview.htmx-request { opacity: .45; }
.preview.htmx-request::after, .skeleton i::after { content: ""; position: absolute; inset: 0; background: linear-gradient(100deg, transparent 20%, rgba(255,255,255,.12) 50%, transparent 80%); animation: shimmer 1.2s linear infinite; }
.preview.htmx-request::after { pointer-events: none; }
@keyframes shimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
.tpl-head { display: flex; flex-direction: column; gap: 4px; }
.tpl-head p { margin: 0; }
.tpl-chips, .tag-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 0; }
.tag { display: inline-flex; gap: 5px; align-items: center; padding: 3px 10px; border-radius: 999px; font-size: .78rem; background: var(--surface-2); border: 1px solid var(--line); color: #dcdcf4; }
.tag.soft { color: var(--muted); }
.seg-bar { display: flex; gap: 3px; height: 30px; margin-top: 14px; border-radius: 10px; overflow: hidden; }
.seg-bar i { flex-basis: 0; min-width: 0; display: grid; place-items: center; font-style: normal; font-size: .68rem; font-weight: 700; color: #07070d; overflow: hidden; text-transform: uppercase; letter-spacing: .04em;
  background: var(--violet); animation: grow .5s var(--ease) both; transform-origin: left; }
@keyframes grow { from { transform: scaleX(.2); opacity: 0; } to { transform: none; opacity: 1; } }
.seg-bar span { padding: 0 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.segs { list-style: none; margin: 14px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.segs li { display: grid; grid-template-columns: 132px minmax(0, 1fr) auto; gap: 12px; align-items: baseline; animation: rise .35s var(--ease) both; animation-delay: calc(var(--i, 0) * 40ms); }
.seg-goal { color: #cfcfe8; font-size: .88rem; }
.seg-secs { color: var(--muted); font-size: .82rem; }
@media (max-width: 560px) { .segs li { grid-template-columns: auto 1fr; } .seg-goal { grid-column: 1 / -1; order: 3; } }
.seg-badge { display: inline-block; padding: 2px 10px; border-radius: 8px; font-size: .74rem; font-weight: 750; text-transform: uppercase; letter-spacing: .05em; color: #07070d; background: var(--violet); white-space: nowrap; }
.seg-hook, .seg-bar .seg-hook { background: var(--magenta); }
.seg-cliffhanger { background: var(--cyan); }
.seg-peak, .seg-confrontation { background: var(--amber); }
.seg-conflict, .seg-escalation { background: #ff7a59; }
.seg-desire, .seg-development { background: #c28bff; }
.seg-context, .seg-opening { background: #5ee6c1; }

/* ── status chips, progress, stats, jobs ──────────────────────────────────── */
.chip { display: inline-flex; align-items: center; gap: 7px; padding: 3px 11px; border-radius: 999px; font-size: .76rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; border: 1px solid currentColor; }
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.chip.pending { color: var(--amber); } .chip.done { color: var(--green); } .chip.failed { color: var(--red); } .chip.processing { color: var(--cyan); }
.chip.processing .dot { background: var(--cyan); }
.chip.done, .chip.failed { box-shadow: 0 0 16px -6px currentColor; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.stats.compact { grid-template-columns: repeat(3, minmax(0, 1fr)); margin-bottom: 4px; }
.stat { padding: 14px 16px; border-radius: var(--r); background: var(--surface); border: 1px solid var(--line); display: flex; flex-direction: column; }
.stat-n { font-size: 1.7rem; font-weight: 750; line-height: 1.1; }
.stat-l { font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.stat.processing .stat-n { color: var(--cyan); text-shadow: 0 0 18px rgba(0,229,255,.55); }
.stat.done .stat-n { color: var(--green); } .stat.failed .stat-n { color: var(--red); }
@media (max-width: 560px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.progress { position: relative; height: 10px; border-radius: 999px; background: rgba(255,255,255,.07); overflow: hidden; margin-top: 14px; }
.progress i { position: absolute; inset: 0; border-radius: inherit; background: linear-gradient(90deg, var(--magenta), var(--cyan)); transform-origin: left; transform: scaleX(var(--p, 0)); transition: transform .6s var(--ease); box-shadow: 0 0 18px rgba(255,43,214,.7); overflow: hidden; }
.progress i::after { content: ""; position: absolute; inset: 0; background: linear-gradient(100deg, transparent 30%, rgba(255,255,255,.65) 50%, transparent 70%); animation: shimmer 1.4s linear infinite; }

.job { display: flex; flex-direction: column; gap: 10px; }
.job.processing { box-shadow: 0 0 0 1px rgba(0,229,255,.25), 0 14px 50px -20px rgba(0,229,255,.5); }
.job-head { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 10px; }
.job-kind { overflow-wrap: anywhere; }
.job-meta { margin: 0; display: flex; gap: 8px; font-size: .86rem; }
.job-actions { margin: 0; display: flex; justify-content: flex-end; }
.error-box { margin: 0; padding: 12px 14px; border-radius: 12px; background: rgba(255,92,122,.09); border: 1px solid rgba(255,92,122,.35); color: #ffc2cc; font: .82rem/1.5 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; max-height: 220px; overflow: auto; }
.result { display: flex; gap: 18px; align-items: flex-start; flex-wrap: wrap; }
.preview-video { width: min(100%, 240px); max-height: 430px; aspect-ratio: 9 / 16; border-radius: 14px; background: #000; border: 1px solid var(--line); object-fit: contain; box-shadow: 0 0 40px -10px rgba(255,43,214,.45); }
.result-side { flex: 1 1 280px; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.result-side .btn-row { margin-top: 0; }
.note { margin: 0; font-size: .88rem; }

/* ── folds (details) ──────────────────────────────────────────────────────── */
.fold > summary { display: flex; align-items: center; gap: 10px; cursor: pointer; list-style: none; padding: 6px 0; font-weight: 600; user-select: none; min-width: 0; }
.fold > summary::-webkit-details-marker { display: none; }
.fold > summary:hover { color: var(--cyan); }
.chev { transition: transform var(--t) var(--ease); }
.fold[open] > summary .chev { transform: rotate(90deg); }
.fold > summary .muted { font-weight: 450; font-size: .84rem; }
.ep > summary .ep-title { flex: 1 1 auto; }
.ep { padding-block: 12px; }
.card.fold + .card.fold { margin-top: 0; }
.fold::details-content { block-size: 0; overflow: hidden; opacity: 0; transition: block-size .3s var(--ease), opacity .25s var(--ease), content-visibility .3s allow-discrete; }
.fold[open]::details-content { block-size: auto; opacity: 1; }
@supports (interpolate-size: allow-keywords) { :root { interpolate-size: allow-keywords; } }
.fold[open] > .fold-body > * { animation: rise .3s var(--ease) both; }
.fold-body { padding-top: 10px; min-width: 0; }
.plan-head { margin: 4px 0 10px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.clips { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; counter-reset: c; }
.clips li { padding: 10px 12px; border-radius: 12px; background: rgba(255,255,255,.035); border: 1px solid var(--line); }
.clip-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: .86rem; }
.clip-top .ellipsis { flex: 1 1 120px; }
.quote { display: block; margin-top: 6px; font-style: italic; color: #e6e6fa; font-size: .9rem; }
.reason { margin: 4px 0 0; color: var(--muted); font-size: .82rem; }

.details-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 24px; }
.details-grid .wide { grid-column: 1 / -1; display: flex; flex-direction: column; gap: 6px; }
.kv { display: flex; justify-content: space-between; gap: 10px; border-bottom: 1px dashed var(--line); padding-bottom: 6px; }
@media (max-width: 560px) { .details-grid { grid-template-columns: minmax(0, 1fr); } }
.mix { display: flex; gap: 3px; height: 10px; border-radius: 6px; overflow: hidden; }
.mix i { flex-basis: 0; min-width: 0; } .mix .low { background: var(--green); } .mix .mid { background: var(--amber); } .mix .high { background: var(--red); }
.mix-legend { display: flex; gap: 14px; margin: 0; font-size: .8rem; }
.mix-legend .low { color: var(--green); } .mix-legend .mid { color: var(--amber); } .mix-legend .high { color: var(--red); }
.series-group { display: flex; flex-direction: column; gap: 12px; }
.ellipsis.ep-title { max-width: 100%; }
.skeleton { display: flex; flex-direction: column; gap: 10px; }
.skeleton i { position: relative; height: 14px; border-radius: 7px; background: rgba(255,255,255,.06); overflow: hidden; }
.skeleton i:nth-child(2) { width: 70%; } .skeleton i:nth-child(3) { width: 45%; }
.skeleton:not(:only-child) { display: none; }

.stale-list { margin: 8px 0 12px; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 4px; }
.confirm { margin-top: 14px; padding: 14px 16px; border-radius: 12px; border: 1px solid rgba(255,92,122,.45); background: rgba(255,92,122,.07); }
.confirm p { margin: 0 0 4px; display: flex; gap: 8px; align-items: flex-start; }
.confirm .btn-row { margin-top: 10px; }
.check-result { margin-top: 14px; display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; border: 1px solid; overflow-wrap: anywhere; }
.check-result.ok { color: var(--green); border-color: rgba(61,255,166,.4); background: rgba(61,255,166,.07); }
.check-result.bad { color: #ffb3c1; border-color: rgba(255,92,122,.45); background: rgba(255,92,122,.08); }
.empty-state { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 40px 20px; text-align: center; color: var(--muted); }
.empty-state .i { width: 40px; height: 40px; stroke: url(#neon-grad); }
.empty-state p { margin: 0; }
.alert { display: flex; gap: 12px; padding: 14px 16px; border-radius: 12px; border: 1px solid rgba(255,92,122,.45); background: rgba(255,92,122,.08); color: #ffc2cc; }
.alert ul { margin: 0; padding-left: 18px; }

/* ── toasts ───────────────────────────────────────────────────────────────── */
.toasts { position: fixed; top: 16px; right: 16px; z-index: 100; display: flex; flex-direction: column; gap: 10px; width: min(380px, calc(100vw - 32px)); pointer-events: none; }
.toast { display: flex; gap: 10px; align-items: flex-start; padding: 13px 16px; border-radius: 14px; background: rgba(14,14,28,.92); border: 1px solid var(--line); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  box-shadow: 0 14px 44px -12px rgba(0,0,0,.7), 0 0 28px -8px var(--tc, var(--cyan)); border-left: 3px solid var(--tc, var(--cyan)); animation: toast 6.2s var(--ease) both; pointer-events: auto; overflow-wrap: anywhere; }
.toast .i { color: var(--tc, var(--cyan)); margin-top: 2px; }
.toast.ok { --tc: var(--green); } .toast.error { --tc: var(--red); } .toast.warn { --tc: var(--amber); }
@keyframes toast { 0% { opacity: 0; transform: translate3d(24px, 0, 0); } 5%, 90% { opacity: 1; transform: none; } 100% { opacity: 0; transform: translate3d(24px, 0, 0); visibility: hidden; } }

/* ── page transitions (View Transitions API; falls back to plain swap) ───── */
@view-transition { navigation: auto; }
::view-transition-old(root) { animation: vt-out 160ms var(--ease) both; }
::view-transition-new(root) { animation: vt-in 280ms var(--ease) both; }
@keyframes vt-out { to { opacity: 0; transform: translate3d(0, -6px, 0); } }
@keyframes vt-in { from { opacity: 0; transform: translate3d(0, 10px, 0); } }
.htmx-added { opacity: 0; }
.htmx-settling .htmx-added { opacity: 1; transition: opacity 200ms var(--ease); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; animation-delay: 0ms !important; transition-duration: 1ms !important; scroll-behavior: auto !important; }
  .glow { animation: none !important; }
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
  .toast { animation: none !important; }
}

/* ── Add series (upload modal) ───────────────────────────────────────────── */
.page-head { position: relative; }
.btn-add { position: absolute; right: 0; top: 0; min-height: 44px; border-radius: 999px; padding-inline: 18px 22px; }
.btn-add .i { width: 1.3em; height: 1.3em; stroke-width: 2.4; transition: transform var(--t) var(--ease); }
.btn-add:hover .i { transform: rotate(90deg); }
@media (max-width: 560px) { .btn-add span { display: none; } .btn-add { width: 46px; padding: 0; } .page-head h1 { padding-right: 56px; } }
.modal { border: 0; padding: 0; background: transparent; color: var(--text); width: min(680px, calc(100vw - 24px)); max-height: calc(100vh - 24px); overflow: visible; margin: auto; }
.modal::backdrop { background: rgba(4, 4, 10, .72); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.modal[open] { animation: rise .3s var(--ease) both; }
.modal[open]::backdrop { animation: fade .3s var(--ease) both; }
@keyframes fade { from { opacity: 0; } }
.modal-card { position: relative; display: flex; flex-direction: column; gap: 16px; max-height: calc(100vh - 24px); overflow: auto; padding: 22px; border-radius: 20px; background: rgba(13, 13, 27, .96); box-shadow: 0 30px 90px -20px rgba(255, 43, 214, .35), 0 0 0 1px rgba(255,255,255,.08); }
.modal-head { display: flex; justify-content: space-between; align-items: center; }
.modal-head h2 { margin: 0; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.steps li { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line); color: var(--muted); font-size: .8rem; font-weight: 600; transition: color var(--t), border-color var(--t), box-shadow var(--t); }
.steps b { display: grid; place-items: center; flex: none; width: 22px; height: 22px; border-radius: 7px; background: var(--surface-2); font-size: .75rem; }
.steps li.on { color: var(--text); border-color: var(--cyan); box-shadow: 0 0 20px -6px rgba(0,229,255,.7); }
.steps li.on b { background: var(--cyan); color: #07070d; }
.steps li.done { color: var(--green); border-color: rgba(61,255,166,.4); }
.steps li.done b { background: var(--green); color: #07070d; }
@media (max-width: 560px) { .steps li span { font-size: .7rem; } .steps li { flex-direction: column; text-align: center; gap: 4px; } }
.dropzone { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 26px 16px; margin-top: 14px; text-align: center; border-radius: 16px; border: 1.5px dashed rgba(255,255,255,.2); background: rgba(255,255,255,.025); transition: border-color var(--t), background-color var(--t), transform var(--t) var(--ease); }
.dropzone .i { width: 34px; height: 34px; stroke: url(#neon-grad); }
.dropzone p { margin: 0; }
.dropzone .btn-row { margin-top: 6px; justify-content: center; }
.dropzone.over { border-color: var(--magenta); background: rgba(255,43,214,.08); transform: scale(1.01); box-shadow: 0 0 30px -8px var(--magenta); }
.up-overall .progress { margin-top: 8px; }
.up-line { margin: 0; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.vlist { position: relative; height: 240px; overflow-y: auto; margin-top: 12px; border-radius: 12px; border: 1px solid var(--line); background: #0a0a16; }
.vlist-pad { position: relative; width: 100%; }
.vrow { position: absolute; left: 0; right: 0; top: 0; height: 34px; display: flex; align-items: center; gap: 10px; padding: 0 12px; font-size: .84rem; overflow: hidden; }
.vname { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vsize { flex: none; color: var(--muted); font-size: .78rem; }
.vbar { position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: var(--grad); transform-origin: left; transform: scaleX(0); }
.vrow.skipped .vname { text-decoration: line-through; color: var(--muted); }
.vrow.skipped .vsize, .vrow.failed .vsize { color: var(--red); }
.vrow.done .vsize { color: var(--green); }
.vrow.sending .vsize { color: var(--cyan); }
.up-status { display: flex; flex-direction: column; gap: 12px; }
.err-inline { color: var(--red); }
.up-status .progress { margin-top: 0; }
@media (prefers-reduced-motion: reduce) { .modal[open], .modal[open]::backdrop { animation: none !important; } }
[hidden] { display: none !important; }
