/* Layout concept: a single centred column on near-black. A huge tight headline sits
   over one dark card; everything else is stripped away. Monochrome: white is the only
   accent, with green and red reserved for success and error. A faint grid and a
   cursor spotlight give depth. One committed dark look, so every colour is explicit. */

@property --angle { syntax: "<angle>"; inherits: false; initial-value: 0deg; }

:root {
  --bg: #07080a;
  --surface: #0e0f12;
  --surface-2: #14161a;
  --text: #f4f5f7;
  --muted: #8a8f9a;
  --line: rgba(255, 255, 255, 0.08);
  --line-2: rgba(255, 255, 255, 0.16);
  --ok: #5fd39a;
  --err: #ff8c7a;

  --font-sans: "Geist", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 0;
  overflow-x: hidden;
}
/* faint grid + top glow */
body::before {
  content: ""; position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(70% 45% at 50% 0%, rgba(255, 255, 255, 0.07), transparent 70%),
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px) 0 0 / 56px 56px,
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px) 0 0 / 56px 56px;
  -webkit-mask-image: radial-gradient(75% 65% at 50% 28%, #000 25%, transparent 78%);
  mask-image: radial-gradient(75% 65% at 50% 28%, #000 25%, transparent 78%);
}

button, input { font: inherit; color: inherit; }
p, h1, dl, dd, dt { margin: 0; }
:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- layout ---------- */
.shell {
  position: relative; z-index: 1;
  display: flex; flex-direction: column;
  max-width: 1040px; margin-inline: auto;
  min-height: calc(100svh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
}
.main {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: clamp(28px, 5vw, 48px); padding-block: 56px 32px; text-align: center;
  transition: gap 0.6s var(--ease);
}
.intro { display: grid; gap: 18px; justify-items: center; }
.intro h1 {
  font-weight: 600; font-size: clamp(2.7rem, 10.5vw, 5.6rem); line-height: 0.98; letter-spacing: -0.045em;
  text-wrap: balance; max-width: 11ch;
  background: linear-gradient(180deg, #fff 30%, #9ea3ad);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
  transition: font-size 0.7s var(--ease);
}
.intro h1 em { font-style: normal; -webkit-text-fill-color: transparent; background: linear-gradient(180deg, #7d828c, #4d515a); -webkit-background-clip: text; background-clip: text; }
.intro p { color: var(--muted); font-size: clamp(1rem, 2.6vw, 1.15rem); max-width: 32ch; text-wrap: balance; }

.main[data-state="selected"] .intro h1,
.main[data-state="uploading"] .intro h1,
.main[data-state="done"] .intro h1,
.main[data-state="error"] .intro h1 { font-size: clamp(2rem, 7vw, 3.2rem); max-width: 20ch; }
.main[data-state="selected"], .main[data-state="uploading"], .main[data-state="done"], .main[data-state="error"] { gap: clamp(20px, 3vw, 30px); }

.foot { padding-block: 12px 28px; text-align: center; font-family: var(--font-mono); font-size: 12px; color: #5d626c; }

/* ---------- entrance ---------- */
.intro, .stage { animation: rise 0.9s var(--ease) backwards; }
.stage { animation-delay: 160ms; }
@keyframes rise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }

/* ---------- card ---------- */
.stage {
  position: relative; width: min(100%, 640px); padding: 8px; text-align: left; border-radius: 28px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.015));
  box-shadow: 0 0 0 1px var(--line), 0 50px 100px -40px rgba(0, 0, 0, 0.95);
}
.stage-body {
  position: relative; overflow: hidden; border-radius: 21px;
  background:
    radial-gradient(420px circle at var(--mx, 50%) var(--my, 0%), rgba(255, 255, 255, 0.06), transparent 60%),
    var(--surface);
  box-shadow: inset 0 0 0 1px var(--line);
}
/* rim light that follows the cursor */
.stage::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; padding: 1px; pointer-events: none;
  background: radial-gradient(240px circle at var(--sx, 50%) var(--sy, 0%), rgba(255, 255, 255, 0.55), transparent 70%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  opacity: 0; transition: opacity 0.5s var(--ease);
}
.stage:hover::after { opacity: 1; }
/* travelling light while dragging or uploading */
.stage::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit; padding: 1px; pointer-events: none;
  background: conic-gradient(from var(--angle), transparent 0 60%, rgba(255, 255, 255, 0.85) 80%, transparent 95%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  opacity: 0; transition: opacity 0.5s var(--ease);
}
.stage[data-state="dragging"]::before, .stage[data-state="uploading"]::before { opacity: 1; animation: spin 6s linear infinite; }
@keyframes spin { to { --angle: 360deg; } }

.panel { animation: panel-in 0.5s var(--ease) both; }
@keyframes panel-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- buttons ---------- */
.btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  height: 52px; padding: 0 26px; border: 1px solid transparent; border-radius: 999px; cursor: pointer;
  font-size: 15px; font-weight: 550; letter-spacing: -0.005em; white-space: nowrap;
  transition: transform 0.3s var(--ease), translate 0.3s var(--ease), background-color 0.25s, border-color 0.25s, box-shadow 0.3s;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: #fff; color: #08090b; box-shadow: 0 0 0 0 rgba(255, 255, 255, 0); }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 10px 34px -8px rgba(255, 255, 255, 0.45); }
.btn-ghost { background: rgba(255, 255, 255, 0.04); color: var(--text); border-color: var(--line-2); }
.btn-ghost:hover { background: rgba(255, 255, 255, 0.09); }
.icon-btn {
  flex: none; width: 44px; height: 44px; display: grid; place-items: center; cursor: pointer;
  border: 1px solid var(--line); border-radius: 50%; color: var(--muted); background: rgba(255, 255, 255, 0.03);
  transition: color 0.25s, background-color 0.25s, transform 0.35s var(--ease);
}
.icon-btn:hover { color: var(--text); background: rgba(255, 255, 255, 0.09); transform: rotate(90deg); }

/* ---------- 1 + 2 · dropzone ---------- */
.dz {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px;
  margin: 10px; min-height: clamp(300px, 44vw, 340px); padding: 40px 20px; text-align: center; cursor: pointer;
  border: 1.5px dashed var(--line-2); border-radius: 16px;
  transition: border-color 0.3s, background-color 0.3s;
}
.dz:hover { border-color: rgba(255, 255, 255, 0.4); background: rgba(255, 255, 255, 0.025); }
.dz-icon {
  width: 60px; height: 60px; display: grid; place-items: center; border-radius: 18px; color: #fff;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.03));
  box-shadow: inset 0 0 0 1px var(--line-2), 0 16px 30px -12px rgba(0, 0, 0, 0.8);
  transition: transform 0.5s var(--ease);
}
.dz-icon svg { transition: transform 0.5s var(--ease); }
.dz:hover .dz-icon { transform: translateY(-3px); }
.dz:hover .dz-icon svg { transform: translateY(-2px); }

.formats {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 8px;
  font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted);
}
.formats span { padding: 4px 10px; border-radius: 999px; box-shadow: inset 0 0 0 1px var(--line); }
.formats .sep { box-shadow: none; text-transform: none; letter-spacing: 0; padding-inline: 2px; }

.dz-drag { cursor: copy; border-style: solid; border-color: #fff; background: rgba(255, 255, 255, 0.05); }
.dz-drag:hover { border-color: #fff; background: rgba(255, 255, 255, 0.05); }
.dz-drag .dz-icon { position: relative; background: #fff; color: #08090b; animation: bob 1.5s ease-in-out infinite; }
.dz-drag .dz-icon::after {
  content: ""; position: absolute; inset: -10px; border-radius: 26px; border: 1px solid rgba(255, 255, 255, 0.6);
  animation: ping 1.6s ease-out infinite;
}
.drag-label { font-size: clamp(1.3rem, 5vw, 1.6rem); font-weight: 600; letter-spacing: -0.02em; }
@keyframes bob { 50% { transform: translateY(-5px); } }
@keyframes ping { from { opacity: 0.8; transform: scale(0.9); } to { opacity: 0; transform: scale(1.35); } }

/* ---------- 3 · selected ---------- */
.sel { display: flex; flex-direction: column; gap: 16px; padding: 8px 8px 0; }
.preview { position: relative; width: 100%; aspect-ratio: 16 / 9; overflow: hidden; border-radius: 14px; background: #000; box-shadow: inset 0 0 0 1px var(--line); }
.preview video { display: block; width: 100%; height: 100%; object-fit: contain; background: #000; cursor: pointer; }
.preview-fallback {
  position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 12px;
  padding: 24px; text-align: center; color: var(--muted); font-size: 14px; background: linear-gradient(135deg, #15171b, #0b0c0e);
}
.ready {
  position: absolute; top: 12px; left: 12px; display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px 6px 10px; border-radius: 999px; font-size: 12px; font-weight: 500;
  background: rgba(10, 11, 13, 0.6); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.14);
}
.ready i { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 10px var(--ok); }
.play {
  position: absolute; inset: 0; margin: auto; width: 64px; height: 64px; display: grid; place-items: center; padding-left: 3px;
  border: 0; border-radius: 50%; cursor: pointer; color: #08090b; background: #fff;
  box-shadow: 0 14px 40px -8px rgba(0, 0, 0, 0.7);
  transition: transform 0.35s var(--ease), opacity 0.25s;
}
.play:hover { transform: scale(1.06); }
.is-playing .play, .is-failed .play { opacity: 0; pointer-events: none; }
.is-failed .ready { display: none; }
.bar { position: absolute; left: 0; right: 0; bottom: 0; display: flex; align-items: center; gap: 6px; padding: 28px 10px 8px; background: linear-gradient(transparent, rgba(0, 0, 0, 0.75)); }
.is-failed .bar { display: none; }
.ctl { flex: none; width: 40px; height: 40px; display: grid; place-items: center; border: 0; border-radius: 50%; background: transparent; color: #fff; cursor: pointer; transition: background-color 0.25s; }
.ctl:hover { background: rgba(255, 255, 255, 0.16); }
.time { flex: 1; font-family: var(--font-mono); font-size: 12px; color: rgba(255, 255, 255, 0.9); font-variant-numeric: tabular-nums; }
.bar .ctl:last-child { margin-left: auto; }
.i-pause, .i-sound { display: none; }
.is-playing .i-play { display: none; }
.is-playing .i-pause { display: block; }
.is-unmuted .i-muted { display: none; }
.is-unmuted .i-sound { display: block; }

.strip {
  --p: 0%; position: relative; height: 46px; overflow: hidden; border-radius: 12px; cursor: ew-resize;
  touch-action: pan-y; user-select: none; -webkit-user-select: none;
  background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line);
}
.frames { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(var(--n, 8), 1fr); }
.frames i { background: center / cover no-repeat; opacity: 0; transition: opacity 0.5s var(--ease); }
.frames i.on { opacity: 1; }
.strip.plain .frames { display: none; }
.strip-rest { position: absolute; top: 0; bottom: 0; right: 0; left: var(--p); background: rgba(7, 8, 10, 0.62); pointer-events: none; }
.strip-head { position: absolute; top: 0; bottom: 0; left: var(--p); width: 2px; margin-left: -1px; background: #fff; box-shadow: 0 0 12px rgba(255, 255, 255, 0.8); pointer-events: none; }
.strip-head::before { content: ""; position: absolute; top: 3px; left: 50%; width: 8px; height: 8px; margin-left: -4px; border-radius: 50%; background: #fff; }

.file-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 4px 6px 0; }
.file-main { min-width: 0; flex: 1; }
.file-name { font-size: 18px; font-weight: 600; letter-spacing: -0.015em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meta { display: grid; grid-template-columns: repeat(4, auto); justify-content: start; gap: 10px 32px; margin-top: 12px; }
.meta dt { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.meta dd { margin-top: 2px; font-size: 14px; font-variant-numeric: tabular-nums; }
.actions { display: flex; justify-content: flex-end; gap: 10px; padding: 4px 6px 10px; }

/* ---------- 4 · uploading ---------- */
.up { padding: 28px 26px 22px; }
.up-head, .done-file { display: flex; align-items: center; gap: 14px; min-width: 0; }
.thumb { flex: none; width: 64px; aspect-ratio: 16 / 10; border-radius: 10px; background: linear-gradient(135deg, #1b1d22, #0e0f12) center / cover no-repeat; box-shadow: inset 0 0 0 1px var(--line-2); }
.up-id, .done-id { min-width: 0; }
.up-name, .done-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.up-state { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.up-state::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: #fff; animation: blink 1.3s ease-in-out infinite; }
@keyframes blink { 50% { opacity: 0.25; } }
.pct { display: flex; align-items: baseline; gap: 4px; margin-top: 30px; font-size: clamp(4rem, 17vw, 5.6rem); font-weight: 300; line-height: 1; letter-spacing: -0.05em; font-variant-numeric: tabular-nums; }
.pct small { font-size: 0.3em; letter-spacing: 0; color: var(--muted); }
.track { position: relative; height: 4px; margin-top: 22px; overflow: hidden; border-radius: 4px; background: rgba(255, 255, 255, 0.1); }
.fill { position: absolute; inset: 0; border-radius: inherit; background: #fff; box-shadow: 0 0 16px rgba(255, 255, 255, 0.7); transform-origin: left center; transform: scaleX(0); will-change: transform; }
.up-stats { display: flex; justify-content: space-between; gap: 16px; margin-top: 14px; font-family: var(--font-mono); font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.actions-end { padding: 22px 0 0; }

/* ---------- 5 · done ---------- */
.done { position: relative; display: flex; flex-direction: column; align-items: center; gap: 22px; padding: 40px 24px 30px; text-align: center; }
.burst { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.check { filter: drop-shadow(0 0 22px rgba(95, 211, 154, 0.35)); }
.check circle { stroke: var(--ok); stroke-width: 1.5; stroke-dasharray: 151; stroke-dashoffset: 151; animation: draw 0.9s var(--ease) 0.1s forwards; }
.check path { stroke: var(--ok); stroke-width: 2.4; stroke-dasharray: 42; stroke-dashoffset: 42; animation: draw 0.6s var(--ease) 0.55s forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
.done-file { width: 100%; max-width: 380px; padding: 10px 16px 10px 10px; border-radius: 16px; text-align: left; background: rgba(255, 255, 255, 0.04); box-shadow: inset 0 0 0 1px var(--line); }
.done-meta { font-family: var(--font-mono); font-size: 12px; color: var(--muted); }
.done .btn { width: 100%; max-width: 380px; }

/* ---------- 6 · error ---------- */
.err { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 44px 24px 34px; text-align: center; }
.err-mark { margin-bottom: 4px; animation: nudge 0.5s var(--ease); }
.err-mark circle { stroke: var(--err); stroke-width: 1.5; opacity: 0.6; }
.err-mark path { stroke: var(--err); stroke-width: 2.4; }
.err-title { font-size: clamp(1.4rem, 5vw, 1.7rem); font-weight: 600; letter-spacing: -0.02em; }
.err-detail { max-width: 38ch; margin-bottom: 10px; color: var(--muted); text-wrap: balance; overflow-wrap: anywhere; }
@keyframes nudge { 20% { transform: translateX(-5px); } 45% { transform: translateX(4px); } 70% { transform: translateX(-2px); } }

/* ---------- headline word reveal (JS) ---------- */
.w { display: inline-block; animation: word 0.9s var(--ease) backwards; animation-delay: calc(var(--i, 0) * 70ms + 40ms); }
@keyframes word { from { opacity: 0; transform: translateY(0.4em); filter: blur(10px); } to { opacity: 1; transform: none; filter: blur(0); } }

/* ---------- phone ---------- */
@media (max-width: 600px) {
  .main { padding-block: 32px 20px; }
  .stage { padding: 6px; border-radius: 24px; }
  .stage-body { border-radius: 18px; }
  .dz { margin: 8px; padding: 36px 16px; min-height: 280px; }
  .dz .btn { width: 100%; max-width: 300px; }
  .sel { padding: 6px 6px 0; }
  .meta { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 24px; }
  .up { padding: 22px 18px 18px; }
  .done { padding: 32px 18px 22px; }
  .err { padding: 36px 18px 26px; }
  .ctl { width: 44px; height: 44px; }
  .time { font-size: 11px; }
  .play { width: 56px; height: 56px; }
  .err .btn { width: 100%; max-width: 320px; }
  .actions-end .btn { width: 100%; }

  /* the main action stays reachable while a video is selected */
  .stage, .stage-body { overflow: visible; }
  .stage[data-state="selected"] .actions {
    position: sticky; bottom: env(safe-area-inset-bottom, 0px); z-index: 3;
    margin: 0 -6px; padding: 14px 12px calc(14px + env(safe-area-inset-bottom, 0px));
    border-radius: 0 0 18px 18px; background: var(--surface); border-top: 1px solid var(--line);
  }
  .stage[data-state="selected"] .actions .btn { flex: 1 1 0; min-width: 0; padding-inline: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}
