/* Video Orientation: same look as the irvinPH tool apps (Sound Mixer, Pixelate, QR Code). */
:root {
  --ink-950: #040b16;
  --ink-900: #07111f;
  --ink-850: #0a1728;
  --ink-800: #0e1e33;
  --ink-700: #16283f;
  --brand-200: #a8e6ff;
  --brand-300: #6fd4ff;
  --brand-400: #3fbef7;
  --brand-500: #1fa3e6;
  --white: #fff;
  --slate-200: #e2e8f0;
  --slate-300: #cbd5e1;
  --slate-400: #94a3b8;
  --slate-500: #64748b;
  --line: rgb(255 255 255 / .06);
  --line-2: rgb(255 255 255 / .1);
  --danger: #fda4af;
  font-family: "Nunito Sans", ui-sans-serif, system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { color: var(--slate-300); -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; }
::selection { background: rgb(63 190 247 / .3); }

.app-bg {
  background:
    radial-gradient(60rem 40rem at 72% -10%, rgb(30 110 190 / .22), transparent 65%),
    radial-gradient(50rem 35rem at 110% 110%, rgb(20 90 170 / .18), transparent 60%),
    radial-gradient(40rem 30rem at -10% 40%, rgb(20 70 140 / .12), transparent 60%),
    #050c18;
  background-attachment: fixed;
}
.preview-bg {
  background:
    radial-gradient(ellipse at 50% 35%, rgb(24 70 120 / .45), transparent 70%),
    #060f1c;
}

svg { width: 20px; height: 20px; flex: none; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
button:disabled { cursor: not-allowed; }
h1, h2, h3, p { margin: 0; }
[hidden] { display: none !important; }
:is(button, a, input):focus-visible { outline: 2px solid var(--brand-300); outline-offset: 2px; }

kbd {
  display: inline-flex; min-width: 24px; align-items: center; justify-content: center;
  padding: 1px 6px; border-radius: 6px; border: 1px solid rgb(255 255 255 / .15);
  background: rgb(255 255 255 / .06); font: 700 11px/1.6 inherit; color: var(--slate-200);
}

/* ---------- Type ---------- */
.eyebrow { font-size: 11px; font-weight: 800; letter-spacing: .18em; text-transform: uppercase; color: var(--brand-400); }
.step-title { margin-top: 6px; font-size: 1.5rem; line-height: 2rem; font-weight: 900; letter-spacing: -.02em; color: var(--white); }
.step-copy { margin-top: 6px; font-size: 15px; line-height: 1.6; color: var(--slate-300); }
.sub-title { font-size: 17px; font-weight: 900; color: var(--white); letter-spacing: -.01em; margin-bottom: 10px; }

/* ---------- Buttons ---------- */
.btn-primary, .primary-btn, .btn-outline, .outline-btn, .btn-ghost, .btn-icon, .chip-btn, .select-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  font-weight: 700; text-decoration: none; border: 0;
  transition: filter .15s, background-color .15s, border-color .15s, opacity .15s, color .15s;
}
.btn-primary, .primary-btn {
  height: 48px; padding: 0 20px; border-radius: .75rem; font-size: 15px; color: var(--ink-950);
  background-image: linear-gradient(to right, var(--brand-300), var(--brand-400));
  box-shadow: 0 10px 24px -8px rgb(63 190 247 / .45);
}
.btn-primary { width: 100%; margin-top: 12px; }
.btn-primary:hover:not(:disabled), .primary-btn:hover:not(:disabled) { filter: brightness(1.08); }
.btn-primary:disabled, .primary-btn:disabled {
  color: var(--slate-400); background-image: none; background-color: rgb(71 85 105 / .45); box-shadow: none;
}
.btn-outline, .outline-btn {
  height: 44px; padding: 0 18px; border-radius: .75rem; border: 1px solid var(--line-2);
  background: rgb(255 255 255 / .02); font-size: 15px; color: var(--slate-200);
}
.btn-outline:hover:not(:disabled), .outline-btn:hover:not(:disabled) { border-color: rgb(255 255 255 / .2); background: rgb(255 255 255 / .06); }
.btn-ghost {
  height: 44px; padding: 0 20px; border-radius: .75rem; font-size: 14px; color: var(--brand-200);
  border: 1px solid rgb(63 190 247 / .4); background: rgb(63 190 247 / .1);
}
.btn-ghost:hover:not(:disabled) { border-color: var(--brand-400); background: rgb(63 190 247 / .2); }
.btn-ghost svg { width: 16px; height: 16px; }
:is(.btn-outline, .outline-btn, .btn-ghost, .chip-btn):disabled { opacity: .45; }
.btn-icon { width: 36px; height: 36px; border-radius: .5rem; background: none; color: var(--white); }
.btn-icon:hover:not(:disabled) { background: rgb(255 255 255 / .1); }
.btn-icon:disabled { opacity: .4; }
.btn-icon.sm { width: 30px; height: 30px; }
.btn-icon.sm svg { width: 17px; height: 17px; }
.chip-btn {
  gap: 7px; height: 34px; padding: 0 12px; border-radius: .6rem; font-size: 13px; color: var(--slate-200);
  border: 1px solid var(--line-2); background: rgb(255 255 255 / .02);
}
.chip-btn:hover:not(:disabled) { border-color: rgb(255 255 255 / .2); background: rgb(255 255 255 / .06); }
.chip-btn svg { width: 16px; height: 16px; }
.block { width: 100%; }
.link {
  display: inline-flex; align-items: center; gap: 6px; padding: 0; border: 0; background: none;
  font-weight: 700; color: var(--brand-300); text-underline-offset: 4px;
}
.link:hover:not(:disabled) { color: var(--brand-200); text-decoration: underline; }
.link:disabled { opacity: .45; }
.link svg { width: 16px; height: 16px; }
.danger-btn { display: inline-flex; align-items: center; gap: 8px; padding: 6px 0; background: none; border: 0; color: #fb7185; font-size: 14px; font-weight: 700; }
.danger-btn:hover { color: var(--danger); }
.danger-btn svg { width: 18px; height: 18px; }

/* ---------- Shell ---------- */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  flex: none; width: 20rem; position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 24px; padding: 24px 28px;
  background: rgb(4 11 22 / .5); border-right: 1px solid var(--line);
  scrollbar-width: thin; scrollbar-color: rgb(255 255 255 / .1) transparent;
}
.brand { display: flex; align-items: center; gap: 12px; transition: opacity .2s; }
.brand:hover { opacity: .85; }
.brand-icon { width: 56px; height: 56px; object-fit: contain; }
.brand-logo { height: 60px; width: auto; }

.hero h1 { margin-top: 8px; font-size: 2rem; line-height: 1.12; font-weight: 900; letter-spacing: -.025em; color: var(--white); }
.hero h1 span { color: var(--brand-400); }
.hero-copy { margin-top: 12px; font-size: 14px; line-height: 1.6; color: var(--slate-400); }

.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.steps li { display: flex; align-items: center; gap: 16px; padding: 12px; border-radius: .75rem; transition: background .25s, box-shadow .25s; }
.steps b { display: block; font-size: 15px; font-weight: 800; color: var(--white); }
.steps small { display: block; font-size: 13px; color: var(--slate-400); }
.step-num {
  width: 32px; height: 32px; flex: none; display: grid; place-items: center; border-radius: 50%;
  border: 2px solid rgb(255 255 255 / .25); color: var(--white); font-size: 14px; font-weight: 800;
}
.step-num svg { display: none; width: 16px; height: 16px; }
.steps li.is-active { background-image: linear-gradient(to right, var(--brand-300), var(--brand-400)); box-shadow: 0 10px 15px -3px rgb(63 190 247 / .2); }
.steps li.is-active b { color: var(--ink-950); }
.steps li.is-active small { color: rgb(7 17 31 / .7); }
.steps li.is-active .step-num { border-color: transparent; background: var(--ink-900); }
.steps li.is-done .step-num { border-color: var(--brand-400); background: rgb(63 190 247 / .15); color: var(--brand-300); }
.steps li.is-done .step-num span { display: none; }
.steps li.is-done .step-num svg { display: block; }

.rule { border-top: 1px solid var(--line); }
.sidebar section .step-copy { margin-bottom: 20px; }

/* ---------- Dropzone ---------- */
.dropzone {
  display: flex; flex-direction: column; align-items: center; text-align: center; cursor: pointer;
  padding: 26px 14px; border-radius: 1rem; border: 2px dashed rgb(63 190 247 / .45); background: rgb(63 190 247 / .02);
  transition: border-color .2s, background .2s;
}
.dropzone:hover { border-color: rgb(63 190 247 / .8); background: rgb(63 190 247 / .05); }
.dropzone.is-over { border-color: var(--brand-300); background: rgb(63 190 247 / .1); }
.dropzone.has-video { border-style: solid; border-color: rgb(63 190 247 / .35); }
.drop-icon {
  width: 48px; height: 48px; display: grid; place-items: center; border-radius: .75rem; color: var(--ink-950);
  background-image: linear-gradient(to bottom, var(--brand-300), var(--brand-400)); box-shadow: 0 10px 15px -3px rgb(63 190 247 / .3);
}
.drop-icon svg { width: 24px; height: 24px; }
.drop-name { margin-top: 16px; font-weight: 700; color: var(--white); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drop-sub { margin-top: 4px; font-size: 14px; color: var(--slate-300); }
.drop-sub .link { font-weight: 600; color: var(--slate-300); text-decoration: underline; text-underline-offset: 3px; }
.drop-sub .link:hover { color: var(--white); }
.dropzone small { margin-top: 12px; font-size: 12px; font-weight: 600; color: var(--slate-400); }
.samples { margin-top: 16px; }
.sample-hint { font-size: 14px; color: var(--slate-400); }
.sample-grid { margin-top: 10px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.sample {
  --load: 0%;
  position: relative; display: flex; flex-direction: column; gap: 6px; padding: 0; border: 0; background: none; text-align: left; color: var(--slate-300);
}
.sample video {
  display: block; width: 100%; aspect-ratio: 16 / 10; object-fit: cover; border-radius: .6rem; background: var(--ink-800);
  border: 1px solid rgb(255 255 255 / .08); pointer-events: none; transition: border-color .15s, filter .15s;
}
.sample span { font-size: 12.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sample:hover video { border-color: var(--brand-400); filter: brightness(1.1); }
.sample:hover span { color: var(--white); }
.sample.is-current video { border-color: var(--brand-400); box-shadow: 0 0 0 1px var(--brand-400); }
.sample.is-current span { color: var(--brand-300); }
.sample.is-loading { cursor: progress; }
.sample.is-loading::after {
  content: ""; position: absolute; left: 6px; right: 6px; top: calc(100% - 30px); height: 4px; border-radius: 999px;
  background: linear-gradient(to right, var(--brand-400) var(--load), rgb(255 255 255 / .25) var(--load));
}
.sample-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.sample canvas, .sample video {
  display: block; width: 100%; aspect-ratio: 16 / 10; object-fit: contain; border-radius: .6rem; background: var(--ink-800);
  border: 1px solid rgb(255 255 255 / .08); pointer-events: none; transition: border-color .15s, filter .15s;
}
.sample:hover canvas { border-color: var(--brand-400); filter: brightness(1.1); }
.sample.is-current canvas { border-color: var(--brand-400); box-shadow: 0 0 0 1px var(--brand-400); }

/* ---------- Conversion modes ---------- */
.mode-list { display: grid; gap: 8px; }
.mode {
  display: flex; align-items: center; gap: 14px; padding: 12px 14px; text-align: left; border-radius: .75rem;
  border: 1px solid var(--line-2); background: rgb(255 255 255 / .02); transition: border-color .15s, background .15s, box-shadow .15s;
}
.mode:hover { border-color: rgb(255 255 255 / .2); background: rgb(255 255 255 / .05); }
.mode b { display: block; font-size: 15px; font-weight: 800; color: var(--white); }
.mode small { display: block; margin-top: 2px; font-size: 12.5px; line-height: 1.45; color: var(--slate-400); }
.mode-art { flex: none; display: inline-flex; align-items: center; gap: 2px; color: var(--slate-300); }
.mode-art svg { width: 18px; height: 18px; }
.mode-art i { font-style: normal; font-size: 12px; font-weight: 800; color: var(--slate-500); }
.mode[aria-checked="true"] { border-color: transparent; background-image: linear-gradient(to right, var(--brand-300), var(--brand-400)); box-shadow: 0 10px 15px -3px rgb(63 190 247 / .2); }
.mode[aria-checked="true"] b, .mode[aria-checked="true"] .mode-art { color: var(--ink-950); }
.mode[aria-checked="true"] small, .mode[aria-checked="true"] .mode-art i { color: rgb(7 17 31 / .7); }

/* Mode and framing switches */
body[data-mode="l2p"] .only-p2l, body[data-mode="p2l"] .only-l2p,
body[data-framing="fixed"] .only-follow, body[data-framing="follow"] .only-fixed { display: none !important; }

.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; border-radius: .75rem; background: rgb(255 255 255 / .03); border: 1px solid var(--line); }
.tabs button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; border: 0; border-radius: .5rem; background: none; color: var(--slate-400); font-size: 14px; font-weight: 700; }
.tabs button:hover { color: var(--white); }
.tabs button[aria-checked="true"] { background: rgb(63 190 247 / .15); color: var(--brand-300); box-shadow: inset 0 0 0 1px rgb(63 190 247 / .35); }
.tabs--sm button { height: 30px; padding: 0 12px; font-size: 13px; }

.badge {
  flex: none; display: inline-flex; align-items: center; height: 28px; padding: 0 10px; border-radius: .5rem;
  border: 1px solid rgb(63 190 247 / .45); background: rgb(63 190 247 / .08); color: var(--brand-200);
  font-size: 13px; font-weight: 800; font-variant-numeric: tabular-nums;
}

/* ---------- Workspace ---------- */
.workspace { flex: 1; min-width: 0; display: flex; flex-direction: column; padding: 20px 20px 16px; }
.workspace-top { display: flex; justify-content: flex-end; }
.howto-btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 10px 16px; border-radius: .75rem;
  border: 1px solid rgb(63 190 247 / .4); background: rgb(7 17 31 / .6); color: var(--white); font-size: 14px; font-weight: 700;
  transition: border-color .15s, background .15s;
}
.howto-btn:hover { border-color: var(--brand-400); background: rgb(63 190 247 / .1); }
.howto-btn svg { width: 18px; height: 18px; }

.card { border-radius: 1rem; border: 1px solid rgb(255 255 255 / .07); background-color: rgb(10 23 40 / .6); }
.workspace-card { flex: 1; margin-top: 12px; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 22rem); background-color: rgb(7 17 31 / .4); }

.stage { min-width: 0; display: flex; flex-direction: column; padding: 24px 28px; border-right: 1px solid var(--line); }
.stage-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.stage-head .step-copy { max-width: 46rem; }
.step-copy em, .hint em { font-style: normal; font-weight: 700; color: var(--brand-300); }

/* ---------- Player ---------- */
.player { margin-top: 16px; }
.player:fullscreen { display: flex; flex-direction: column; padding: 12px; background: #000; }
.player:fullscreen .screen { flex: 1; aspect-ratio: auto; max-height: none; }
.screen {
  position: relative; width: 100%; aspect-ratio: 16 / 8; max-height: 58vh; min-height: 260px; overflow: hidden;
  display: grid; place-items: center; border-radius: 1rem; border: 1px solid rgb(255 255 255 / .07);
}
.screen.is-over::after { content: "Drop to load video"; position: absolute; inset: 0; display: grid; place-items: center; background: rgb(4 11 22 / .75); border: 2px dashed var(--brand-400); border-radius: 1rem; font-weight: 800; color: var(--white); z-index: 10; }
.frame { position: relative; overflow: hidden; border-radius: .5rem; box-shadow: 0 10px 40px rgb(0 0 0 / .45); }
.frame canvas { display: block; width: 100%; height: 100%; }
body[data-mode="p2l"] .frame { cursor: ew-resize; touch-action: none; }

/* Crop box: a huge outer shadow dims everything outside it */
.crop {
  position: absolute; top: 0; left: 0; cursor: grab; touch-action: none; outline: none;
  border: 2px solid var(--brand-300); box-shadow: 0 0 0 9999px rgb(4 11 22 / .55), 0 0 22px rgb(63 190 247 / .45);
}
.crop.is-dragging { cursor: grabbing; }
.crop:focus-visible { box-shadow: 0 0 0 9999px rgb(4 11 22 / .55), 0 0 0 3px rgb(63 190 247 / .5); }
.crop .h { position: absolute; width: 14px; height: 14px; border-radius: 50%; background: var(--white); border: 3px solid var(--brand-400); }
.h-tl { left: -8px; top: -8px; } .h-tr { right: -8px; top: -8px; } .h-bl { left: -8px; bottom: -8px; } .h-br { right: -8px; bottom: -8px; }
.crop .third { position: absolute; background: rgb(255 255 255 / .22); opacity: 0; transition: opacity .2s; pointer-events: none; }
.crop.is-dragging .third { opacity: 1; }
.third.v1, .third.v2 { top: 0; bottom: 0; width: 1px; } .third.v1 { left: 33.33%; } .third.v2 { left: 66.66%; }
.third.h1, .third.h2 { left: 0; right: 0; height: 1px; } .third.h1 { top: 33.33%; } .third.h2 { top: 66.66%; }
.crop-tip {
  position: absolute; left: 50%; top: 12px; transform: translateX(-50%); white-space: nowrap; pointer-events: none;
  padding: 5px 12px; border-radius: .5rem; background: rgb(4 11 22 / .85); border: 1px solid var(--line-2);
  font-size: 12.5px; font-weight: 700; color: var(--white); transition: opacity .3s;
}
.crop-tip.is-hidden { opacity: 0; }
.crop-move { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%; background: rgb(4 11 22 / .55); color: var(--white); pointer-events: none; opacity: .85; }
.crop-move svg { width: 22px; height: 22px; }

.screen-flash {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); pointer-events: none; z-index: 5;
  padding: 6px 14px; border-radius: 999px; background: rgb(4 11 22 / .85); border: 1px solid var(--line-2);
  font-size: 13px; font-weight: 700; color: var(--white); opacity: 0; transition: opacity .25s;
}
.screen-flash.show { opacity: 1; }

.transport {
  margin-top: 16px; display: flex; align-items: center; gap: 16px; padding: 6px 16px 6px 6px;
  border-radius: 1rem; border: 1px solid rgb(255 255 255 / .07); background: rgb(7 17 31 / .7);
}
.transport-left { display: flex; align-items: center; gap: 8px; padding: 6px 16px 6px 6px; border-radius: .75rem; border: 1px solid var(--line); background: var(--ink-850); }
.transport-left .btn-icon { width: 40px; height: 40px; }
.time { font-size: 13px; font-weight: 700; color: var(--white); font-variant-numeric: tabular-nums; white-space: nowrap; }
.transport .seek { flex: 1; min-width: 60px; }

.range {
  --p: 0%;
  -webkit-appearance: none; appearance: none; height: 4px; margin: 0; border-radius: 999px; cursor: pointer; outline: none;
  background: linear-gradient(to right, var(--brand-400) var(--p), rgb(255 255 255 / .14) var(--p));
}
.range::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%; background: #fff; border: 3px solid var(--brand-400); box-shadow: 0 0 0 4px rgb(63 190 247 / .2); }
.range::-moz-range-thumb { width: 10px; height: 10px; border-radius: 50%; background: #fff; border: 3px solid var(--brand-400); box-shadow: 0 0 0 4px rgb(63 190 247 / .2); }
.range:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 6px rgb(63 190 247 / .35); }
.range:disabled { cursor: default; opacity: .5; }

/* ---------- Timeline: thumbnails + keyframes ---------- */
.timeline-head { margin-top: 20px; margin-bottom: 10px; display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.timeline-head h3 { font-size: 16px; font-weight: 800; color: var(--white); }
.timeline-tools { display: flex; align-items: center; gap: 8px; }

.timeline { position: relative; padding: 0 14px 10px; border: 1px solid rgb(255 255 255 / .07); border-radius: 1rem; background: rgb(6 15 28 / .7); user-select: none; cursor: pointer; touch-action: none; }
.tl-ruler { position: relative; height: 30px; }
.tick { position: absolute; bottom: 0; width: 1px; height: 6px; background: rgb(255 255 255 / .15); }
.tick.major { height: 11px; background: var(--slate-500); }
.tick span { position: absolute; bottom: 13px; left: 0; transform: translateX(-50%); font-size: 11.5px; font-weight: 600; color: var(--slate-400); white-space: nowrap; font-variant-numeric: tabular-nums; }
.tl-strip { display: flex; height: 52px; border-radius: .5rem; overflow: hidden; background: var(--ink-800); }
.tl-strip .thumb { flex: 1; min-width: 0; height: 100%; background: var(--ink-800) center / cover no-repeat; border-right: 1px solid rgb(4 11 22 / .6); }
.tl-strip .thumb:last-child { border-right: 0; }
.tl-keys { position: relative; height: 26px; margin-top: 6px; border-radius: .4rem; background: rgb(255 255 255 / .02); }
.tl-keys::before { content: ""; position: absolute; left: 0; right: 0; top: 50%; height: 1px; background: var(--line-2); }
.tl-keys .seg { position: absolute; top: 50%; height: 2px; transform: translateY(-50%); background: rgb(63 190 247 / .5); }
.kf {
  position: absolute; top: 50%; width: 14px; height: 14px; padding: 0; border: 2px solid var(--brand-300); background: var(--ink-900);
  transform: translate(-50%, -50%) rotate(45deg); border-radius: 2px; transition: background .15s, box-shadow .15s;
}
.kf:hover { background: rgb(63 190 247 / .4); }
.kf.is-selected { background: var(--brand-300); box-shadow: 0 0 0 4px rgb(63 190 247 / .25), 0 0 12px rgb(63 190 247 / .7); }
body[data-framing="fixed"] .tl-keys { opacity: .35; pointer-events: none; }

.playhead { position: absolute; top: 0; bottom: 0; left: 14px; width: 0; pointer-events: none; z-index: 8; }
.playhead::before { content: ""; position: absolute; top: 18px; bottom: 4px; left: -1px; width: 2px; border-radius: 2px; background: var(--brand-400); box-shadow: 0 0 8px rgb(63 190 247 / .8); }
.playhead i { position: absolute; top: 16px; left: -7px; width: 14px; height: 14px; background: var(--brand-400); clip-path: polygon(0 0, 100% 0, 100% 45%, 50% 100%, 0 45%); }

.stage-foot { padding-top: 12px; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.status { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--slate-400); }
.status i { width: 8px; height: 8px; border-radius: 50%; background: var(--brand-400); }
.kf-count { font-size: 13px; font-weight: 700; color: var(--slate-400); font-variant-numeric: tabular-nums; }

/* ---------- Settings column ---------- */
/* Right column stays in view and scrolls on its own, like the left sidebar */
.panel {
  display: flex; flex-direction: column; gap: 24px; padding: 24px 28px; min-width: 0;
  position: sticky; top: 0; align-self: start; max-height: 100vh; overflow-y: auto; overscroll-behavior: contain;
  scrollbar-width: thin; scrollbar-color: rgb(255 255 255 / .1) transparent;
}
.panel > section + section { padding-top: 24px; border-top: 1px solid var(--line); }
.panel section { display: grid; gap: 12px; align-content: start; min-width: 0; }
.panel .sub-title { margin-bottom: 0; }
.panel .step-title { margin-top: -6px; }
.panel .step-copy { margin-top: -8px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.tall { height: 360px; display: grid; place-items: center; border-radius: 1rem; border: 1px solid rgb(255 255 255 / .07); overflow: hidden; }
.tall canvas { display: block; max-width: 100%; max-height: 100%; border-radius: .4rem; box-shadow: 0 10px 30px rgb(0 0 0 / .45); }
.dims { text-align: center; font-size: 13px; font-weight: 700; color: var(--slate-400); font-variant-numeric: tabular-nums; }
.hint { font-size: 13px; line-height: 1.6; color: var(--slate-400); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button { height: 34px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line-2); background: rgb(255 255 255 / .02); color: var(--slate-300); font-size: 13px; font-weight: 700; }
.chips button small { margin-left: 4px; font-size: 11.5px; font-weight: 600; color: var(--slate-500); }
.chips button:hover { border-color: rgb(255 255 255 / .2); color: var(--white); }
.chips button[aria-checked="true"] { border-color: rgb(63 190 247 / .5); background: rgb(63 190 247 / .15); color: var(--brand-300); }
.chips button[aria-checked="true"] small { color: var(--brand-200); }

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field { display: grid; gap: 6px; min-width: 0; }
.field-label { font-size: 14px; font-weight: 600; color: var(--slate-300); }
.field-line { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.select-wrap { position: relative; display: flex; align-items: center; height: 44px; border: 1px solid var(--line-2); border-radius: .75rem; background: rgb(7 17 31 / .7); transition: border-color .15s; }
.select-wrap:focus-within { border-color: var(--brand-400); }
.select-wrap select { -webkit-appearance: none; appearance: none; width: 100%; height: 100%; padding: 0 36px 0 12px; border: 0; background: none; outline: none; font: inherit; font-size: 15px; font-weight: 600; color: var(--white); cursor: pointer; }
.select-wrap select option { background: var(--ink-850); }
.select-wrap svg { position: absolute; right: 12px; width: 16px; height: 16px; color: var(--slate-300); pointer-events: none; }
.color-wrap { display: inline-flex; align-items: center; gap: 10px; height: 38px; padding: 0 12px 0 5px; border: 1px solid var(--line-2); border-radius: .6rem; background: rgb(7 17 31 / .7); cursor: pointer; font-size: 13px; font-weight: 700; color: var(--white); font-variant-numeric: tabular-nums; }
.color-wrap input { width: 28px; height: 28px; padding: 0; border: 0; border-radius: .4rem; background: none; cursor: pointer; }
.color-wrap input::-webkit-color-swatch-wrapper { padding: 0; }
.color-wrap input::-webkit-color-swatch { border: 1px solid rgb(255 255 255 / .2); border-radius: .4rem; }

.slider-field { display: grid; gap: 10px; }
.slider-top { display: flex; justify-content: space-between; align-items: baseline; }
.slider-top output { font-size: 14px; font-weight: 700; color: var(--white); font-variant-numeric: tabular-nums; }
.slider-field .range { width: 100%; }
.bg-video-opts { display: grid; gap: 14px; transition: opacity .2s; }
.bg-video-opts.is-off { opacity: .4; pointer-events: none; }

.toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 4px 0; font-size: 15px; font-weight: 600; color: var(--slate-200); cursor: pointer; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle i { position: relative; width: 38px; height: 22px; flex: none; border-radius: 999px; background: rgb(255 255 255 / .14); transition: background .2s; }
.toggle i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #cbd5e1; transition: transform .2s; }
.toggle input:checked + i { background: var(--brand-400); }
.toggle input:checked + i::after { transform: translateX(16px); background: #fff; }
.toggle input:focus-visible + i { outline: 2px solid var(--brand-300); outline-offset: 2px; }

/* Export confirmation, same as the Pixelate and Sound Mixer apps */
.confirm {
  display: flex; align-items: flex-start; gap: 12px; padding: 12px; cursor: pointer;
  border-radius: .75rem; border: 1px solid rgb(255 255 255 / .07); background: rgb(255 255 255 / .02);
  font-size: 13px; line-height: 1.6; color: var(--slate-300); transition: border-color .15s, background .15s;
}
.confirm:hover { border-color: rgb(255 255 255 / .15); }
.confirm:has(:checked) { border-color: rgb(63 190 247 / .4); background: rgb(63 190 247 / .06); }
.confirm input { flex: none; width: 16px; height: 16px; margin: 3px 0 0; cursor: pointer; accent-color: var(--brand-400); }
.confirm .link { display: inline; font-weight: 700; text-decoration: underline; }
.panel .btn-primary { margin-top: 0; }
.export-hint { text-align: center; font-size: 13px; color: rgb(252 211 77 / .9); }

.panel-bottom { margin-top: auto; display: grid; gap: 12px; }
.info-card { display: flex; gap: 12px; padding: 16px; }
.info-card > svg { width: 28px; height: 28px; color: var(--brand-400); }
.info-title { font-size: 15px; font-weight: 800; color: var(--brand-400); }
.info-card p + p { margin-top: 4px; font-size: 13px; line-height: 1.6; color: var(--slate-400); }
.keys-card { padding: 14px 16px; }
.keys-title { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; font-size: 13px; font-weight: 800; color: var(--white); }
.keys-title svg { color: var(--brand-400); }
.key-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.key-list li { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 13px; color: var(--slate-300); }
.key-list li > span:last-child:not(:first-child) { display: inline-flex; gap: 4px; }

.credit { padding-top: 16px; text-align: center; font-size: 13px; color: var(--slate-500); display: grid; gap: 6px; }
.credit a { font-weight: 700; color: var(--brand-400); text-decoration: none; text-underline-offset: 4px; }
.credit a:hover { color: var(--brand-300); text-decoration: underline; }
.credit .link { display: inline; font-weight: 600; color: var(--slate-400); text-decoration: underline; }
.credit .link:hover { color: var(--white); }

/* ---------- Dialogs ---------- */
.modal {
  width: min(32rem, calc(100vw - 32px)); max-height: 90vh; overflow-y: auto; padding: 28px; border-radius: 1rem; border: 1px solid rgb(255 255 255 / .07);
  background: var(--ink-900); color: var(--slate-300); box-shadow: 0 25px 50px -12px rgb(0 0 0 / .5);
}
.modal::backdrop { background: rgb(4 11 22 / .8); backdrop-filter: blur(4px); }
.modal h2 { font-size: 1.5rem; font-weight: 900; letter-spacing: -.02em; color: var(--white); }
.modal .sub { margin-top: 6px; font-size: 15px; line-height: 1.6; color: var(--slate-300); }
.modal .icon-btn { display: grid; place-items: center; width: 36px; height: 36px; padding: 0; border: 0; border-radius: .5rem; background: none; color: var(--slate-300); }
.modal .icon-btn:hover { background: rgb(255 255 255 / .1); }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.modal h3 { margin: 20px 0 8px; font-size: 15px; font-weight: 800; color: var(--white); }
.modal-copy { display: grid; gap: 12px; font-size: 14px; line-height: 1.6; color: var(--slate-300); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.modal-actions.split { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 24px; }
.howto-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.howto-steps li { display: flex; gap: 12px; font-size: 15px; line-height: 1.6; color: var(--slate-300); }
.howto-steps li > span { width: 24px; height: 24px; flex: none; margin-top: 2px; display: grid; place-items: center; border-radius: 50%; background: rgb(63 190 247 / .15); color: var(--brand-300); font-size: 12px; font-weight: 800; }
.howto-steps b { display: block; color: var(--white); }
.howto em, .howto-notes em { font-style: normal; font-weight: 700; color: var(--brand-300); }
.howto-notes { margin: 0; padding: 12px 12px 12px 30px; border-radius: .75rem; border: 1px solid rgb(63 190 247 / .2); background: rgb(63 190 247 / .06); font-size: 13px; line-height: 1.6; color: var(--slate-300); }
.howto-ok { width: 100%; margin-top: 20px; }
.progress { height: 8px; margin-top: 20px; border-radius: 999px; background: rgb(255 255 255 / .1); overflow: hidden; }
.progress i { display: block; height: 100%; width: 0; border-radius: inherit; background-image: linear-gradient(to right, var(--brand-300), var(--brand-400)); transition: width .2s linear; }
.export-stats { display: flex; justify-content: space-between; margin-top: 8px; font-size: 12px; font-weight: 700; color: var(--slate-300); font-variant-numeric: tabular-nums; }

.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 50; transform: translate(-50%, 20px);
  max-width: calc(100vw - 32px); padding: 12px 18px; border-radius: .75rem;
  background: var(--ink-850); border: 1px solid var(--line-2); box-shadow: 0 12px 40px rgb(0 0 0 / .5);
  font-size: 14px; font-weight: 600; color: var(--white); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.is-error { border-color: rgb(251 113 133 / .6); }

/* ---------- Responsive ---------- */
@media (min-width: 1536px) {
  .workspace-card { grid-template-columns: minmax(0, 1fr) minmax(0, 24rem); }
  .tall { height: 420px; }
}

@media (max-width: 1279px) {
  .workspace-card { grid-template-columns: minmax(0, 1fr); }
  .stage { border-right: 0; }
  .panel { position: static; max-height: none; overflow: visible; border-top: 1px solid var(--line); display: grid; grid-template-columns: 1fr 1fr; column-gap: 32px; }
  .panel > section + section { padding-top: 0; border-top: 0; }

  .panel-bottom { grid-column: 1 / -1; grid-template-columns: 1fr 1fr; }
}

@media (max-width: 1023px) {
  .shell { flex-direction: column; }
  .sidebar { position: static; width: auto; height: auto; overflow: visible; padding: 24px; border-right: 0; border-bottom: 1px solid var(--line); }
  .hero h1 br { display: none; }
  .steps-nav, .rule { display: none; }
  .workspace { padding: 16px; }
  .workspace-top { position: absolute; top: 24px; right: 24px; }
}

@media (max-width: 720px) {
  .panel { display: flex; }
  .panel > section + section { padding-top: 24px; border-top: 1px solid var(--line); }
  .panel-bottom { grid-template-columns: 1fr; }
  .keys-card { display: none; }
  .stage, .panel { padding: 20px 16px; }
  .screen { aspect-ratio: 4 / 3; min-height: 0; }
  .transport { gap: 8px; padding-right: 10px; }
  #mute-btn { display: none; }
  .crop-tip { display: none; }
}

@media (max-width: 480px) {
  .workspace-top { position: static; }
  .brand-icon { width: 44px; height: 44px; }
  .brand-logo { height: 48px; }
  .hero h1 { font-size: 1.7rem; }
}

/* ---------- Empty state (before a video is loaded) ---------- */
.screen-empty {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 24px; text-align: center; cursor: pointer; border: 2px dashed transparent; border-radius: 1rem; transition: border-color .2s;
}
.play-ring { width: 64px; height: 64px; display: grid; place-items: center; border-radius: 50%; border: 2px solid rgb(255 255 255 / .9); color: var(--white); transition: transform .2s; }
.play-ring svg { width: 28px; height: 28px; transform: translateX(2px); }
.screen-empty:hover .play-ring { transform: scale(1.05); }
.screen-empty b { margin-top: 20px; font-size: 18px; font-weight: 800; color: var(--white); }
.screen-empty small { margin-top: 4px; font-size: 15px; color: var(--slate-300); }
.screen-empty .btn-ghost { margin-top: 24px; }
.screen-empty .btn-ghost.is-loading { cursor: progress; opacity: .7; }
body.has-video .screen-empty, body:not(.has-video) .frame { display: none; }
.tall { position: relative; }
.tall-empty { display: grid; justify-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--slate-500); }
.tall-empty svg { width: 28px; height: 28px; }
body.has-video .tall-empty, body:not(.has-video) .tall canvas { display: none; }
.tl-empty { position: absolute; inset: 30px 0 0; display: grid; place-items: center; border-radius: 0 0 1rem 1rem; background: rgb(6 15 28 / .82); color: var(--slate-400); font-size: 14px; z-index: 9; cursor: default; }
body.has-video .tl-empty, body:not(.has-video) .playhead { display: none; }
body:not(.has-video) .timeline { min-height: 120px; }
body:not(.has-video) .status i { background: var(--slate-500); }
body:not(.has-video) .timeline-tools .chip-btn { opacity: .45; pointer-events: none; }

/* ---------- Trim handles on the timeline ---------- */
.trim { position: absolute; top: 30px; left: 14px; right: 14px; height: 52px; pointer-events: none; z-index: 7; --a: 0%; --b: 100%; }
.trim-shade { position: absolute; top: 0; bottom: 0; background: rgb(4 11 22 / .72); }
.trim-shade--l { left: 0; width: var(--a); border-radius: .5rem 0 0 .5rem; }
.trim-shade--r { left: var(--b); right: 0; border-radius: 0 .5rem .5rem 0; }
.trim-range { position: absolute; top: 0; bottom: 0; left: var(--a); width: calc(var(--b) - var(--a)); border-top: 2px solid var(--brand-400); border-bottom: 2px solid var(--brand-400); opacity: 0; transition: opacity .15s; }
.trim.is-trimmed .trim-range { opacity: 1; }
.trim-h {
  position: absolute; top: 0; bottom: 0; width: 12px; padding: 0; border: 0; pointer-events: auto; cursor: ew-resize; touch-action: none;
  background: var(--brand-400); box-shadow: 0 0 10px rgb(63 190 247 / .5);
}
.trim-h::after { content: ""; position: absolute; top: 50%; left: 50%; width: 2px; height: 16px; transform: translate(-50%, -50%); border-radius: 2px; background: var(--ink-950); }
.trim-h:hover, .trim-h.is-dragging { background: var(--brand-300); }
.trim-h--in { left: var(--a); transform: translateX(-100%); border-radius: .4rem 0 0 .4rem; }
.trim-h--out { left: var(--b); border-radius: 0 .4rem .4rem 0; }
body:not(.has-video) .trim { display: none; }
.foot-right { display: inline-flex; align-items: center; gap: 14px; }
.trim-info { font-size: 13px; font-weight: 700; color: var(--slate-400); font-variant-numeric: tabular-nums; }
.trim-info b { color: var(--brand-300); }
.foot-right .link { font-size: 13px; }

/* ---------- Safe zones ---------- */
.safe { display: grid; gap: 10px; margin-top: 4px; }
.tabs--3 { grid-template-columns: repeat(3, 1fr); }
.safe:not(.is-on) .tabs { opacity: .45; pointer-events: none; }
.safe:not(.is-on) .hint { display: none; }

/* ---------- Remove video ---------- */
.stage-actions { display: flex; align-items: center; gap: 10px; flex: none; }
.remove-btn:hover { border-color: rgb(251 113 133 / .5); color: var(--danger); background: rgb(251 113 133 / .08); }
.remove-link { margin-top: 8px; font-size: 13px; }
body:not(.has-video) .remove-btn, body:not(.has-video) .remove-link { display: none; }
@media (max-width: 480px) { .remove-btn { padding: 0 9px; font-size: 0; gap: 0; } }

.steps li.is-active.is-done .step-num { border-color: transparent; background: var(--ink-900); color: var(--brand-300); }
