/* ─── Core tokens (preserving original brand) ─────────────────────────────── */
:root {
  --bg-darker: #080c14;
  --bg-dark: #0f1524;
  --bg-card: rgba(20, 27, 45, 0.65);
  --bg-card-solid: #141b2d;
  --bg-elev: rgba(255, 255, 255, 0.03);
  --bg-elev-hover: rgba(255, 255, 255, 0.06);

  --border-color: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(168, 85, 247, 0.4);
  --border-strong: rgba(255, 255, 255, 0.18);

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --text-inverse: #0f172a;

  --primary-gradient: linear-gradient(135deg, #a855f7 0%, #6366f1 100%);
  --secondary-gradient: linear-gradient(135deg, #06b6d4 0%, #3b82f6 100%);
  --gold-gradient: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
  --danger-gradient: linear-gradient(135deg, #ef4444 0%, #f43f5e 100%);

  --primary-color: #a855f7;
  --primary-color-2: #6366f1;
  --primary-glow: rgba(168, 85, 247, 0.5);
  --cyan-color: #06b6d4;
  --cyan-glow: rgba(6, 182, 212, 0.4);
  --gold-color: #fbbf24;
  --gold-glow: rgba(251, 191, 36, 0.4);
  --green-color: #10b981;
  --danger: #ef4444;

  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;

  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.5);

  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 20px;

  --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

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

html, body { height: 100%; }
body {
  font-family: var(--font-sans);
  background: var(--bg-darker);
  color: var(--text-main);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
  line-height: 1.5;
  font-feature-settings: "ss01", "cv11";
}

::selection { background: var(--primary-color); color: white; }

/* ─── Backdrop glows ──────────────────────────────────────────────────────── */
.glow-bg {
  position: fixed; inset: 0;
  z-index: -1; overflow: hidden;
  pointer-events: none;
}
.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.18;
  mix-blend-mode: screen;
  animation: float 22s infinite alternate ease-in-out;
}
.blob-purple { top: -10%; right: 5%;  width: 55vw; height: 55vw; background: #a855f7; }
.blob-cyan   { bottom: -15%; left: 0;  width: 50vw; height: 50vw; background: #06b6d4; animation-duration: 18s; }
@keyframes float {
  0%   { transform: translate(0, 0) scale(1); }
  100% { transform: translate(6%, 10%) scale(1.08); }
}

/* ─── Layout ─────────────────────────────────────────────────────────────── */
.container {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 2rem;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.logo {
  display: flex; align-items: center; gap: 0.65rem;
  font-size: 1.45rem; font-weight: 800; letter-spacing: -0.5px;
  color: var(--text-main); text-decoration: none;
}
.logo-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px;
  background: var(--primary-gradient);
  border-radius: 10px;
  box-shadow: 0 6px 18px var(--primary-glow);
  font-size: 1rem;
}
.logo-text .highlight {
  background: var(--secondary-gradient);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.header-actions { display: flex; gap: 0.5rem; }
.hide-sm { display: inline; }
@media (max-width: 640px) { .hide-sm { display: none; } }

/* ─── Cards ──────────────────────────────────────────────────────────────── */
.card {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04) 0%, rgba(255, 255, 255, 0) 30%),
    var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 1.5rem;
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  box-shadow:
    var(--shadow-md),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  position: relative;
}
.card::before {
  /* subtle inner glow on card top edge */
  content: '';
  position: absolute;
  inset: 0 0 auto 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(168, 85, 247, 0.4), rgba(6, 182, 212, 0.4), transparent);
  border-radius: var(--radius) var(--radius) 0 0;
  pointer-events: none;
}

.search-card {
  text-align: center;
  padding: 2.5rem 1.5rem;
  position: relative; overflow: hidden;
}
.search-card h1 {
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  font-weight: 800;
  letter-spacing: -1px;
  margin-bottom: 0.5rem;
  background: linear-gradient(180deg, #fff 0%, #cbd5e1 100%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.subtitle {
  color: var(--text-muted);
  font-size: 1rem;
  margin-bottom: 1.75rem;
  max-width: 580px; margin-left: auto; margin-right: auto;
}
.domain-hint { display: block; margin-top: 0.5rem; font-size: 0.85rem; color: var(--text-dim); }
.domain-hint code { background: var(--bg-elev); padding: 1px 6px; border-radius: 4px; color: var(--primary-color); font-family: var(--font-mono); }

/* ─── Forms ──────────────────────────────────────────────────────────────── */
.search-form { max-width: 720px; margin: 0 auto; }
.input-group {
  display: flex; align-items: center;
  background: var(--bg-elev);
  border: 1px solid var(--border-color);
  border-radius: 999px;
  padding: 0.35rem 0.35rem 0.35rem 1rem;
  transition: border-color var(--transition-normal), box-shadow var(--transition-normal);
}
.input-group:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 4px rgba(168, 85, 247, 0.12);
}
.input-group.valid-input { border-color: rgba(16, 185, 129, 0.5); }
.input-group.invalid-input { border-color: rgba(239, 68, 68, 0.5); }
.input-icon {
  display: inline-flex; align-items: center; justify-content: center;
  color: #ff0033; font-size: 1.25rem; width: 24px; margin-right: 0.5rem;
}
.input-icon .text-green { color: var(--green-color); }
.input-icon .text-red { color: var(--danger); }
.input-group input {
  flex: 1;
  background: transparent;
  border: 0; outline: 0;
  color: var(--text-main);
  font-family: inherit;
  font-size: 1rem;
  padding: 0.85rem 0.5rem;
  min-width: 0;
}
.input-group input::placeholder { color: var(--text-dim); }

/* ─── Buttons ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 0.5rem;
  border: 1px solid transparent;
  border-radius: 999px;
  font-family: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  padding: 0.7rem 1.25rem;
  cursor: pointer;
  transition: transform var(--transition-fast), background var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast), color var(--transition-fast);
  white-space: nowrap;
  user-select: none;
}
.btn:focus-visible { outline: 2px solid var(--primary-color); outline-offset: 2px; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none !important; }
.btn:not(:disabled):hover { transform: translateY(-1px); }
.btn:not(:disabled):active { transform: translateY(0); }

.btn-primary {
  background: var(--primary-gradient);
  color: white;
  font-weight: 700;
  letter-spacing: 0.3px;
  box-shadow:
    0 8px 22px rgba(168, 85, 247, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.25);
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.2);
  position: relative;
  overflow: hidden;
}
.btn-primary::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(120deg, transparent 30%, rgba(255, 255, 255, 0.18) 50%, transparent 70%);
  transform: translateX(-100%);
  transition: transform 0.6s ease;
  pointer-events: none;
}
.btn-primary:not(:disabled):hover {
  box-shadow:
    0 12px 36px rgba(168, 85, 247, 0.55),
    inset 0 1px 0 rgba(255, 255, 255, 0.35);
}
.btn-primary:not(:disabled):hover::after { transform: translateX(100%); }

.btn-secondary {
  background: var(--bg-elev);
  color: var(--text-main);
  border-color: var(--border-color);
}
.btn-secondary:not(:disabled):hover { background: var(--bg-elev-hover); border-color: var(--border-strong); }
.btn-secondary.is-premium { background: var(--gold-gradient); color: #0f172a; border-color: transparent; }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: transparent;
  padding: 0.6rem 0.9rem;
}
.btn-ghost:not(:disabled):hover { background: var(--bg-elev); color: var(--text-main); }

.btn-small { font-size: 0.8rem; padding: 0.45rem 0.75rem; }

.btn-glow { box-shadow: 0 0 0 0 var(--primary-glow); }
.btn-glow-purple { box-shadow: 0 8px 28px rgba(168, 85, 247, 0.38); }
.btn-glow-gold { box-shadow: 0 8px 28px var(--gold-glow); background: var(--gold-gradient); color: #1a1607; }
.btn-glow-gold:not(:disabled):hover { box-shadow: 0 10px 36px var(--gold-glow); }

.full-width { width: 100%; }

#load-btn { padding: 0.7rem 1.25rem; }
#load-btn .btn-loader { display: none; }
#load-btn.loading .btn-text { display: none; }
#load-btn.loading .btn-loader { display: inline-flex; }

/* ─── Workspace layout ───────────────────────────────────────────────────── */
.workspace { padding: 1.25rem; }
.workspace-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(280px, 1fr);
  gap: 1.5rem;
}
@media (max-width: 960px) {
  .workspace-layout { grid-template-columns: 1fr; }
}

.player-container { display: flex; flex-direction: column; gap: 0.75rem; min-width: 0; }
.iframe-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border-color);
}
.iframe-wrapper iframe { width: 100%; height: 100%; border: 0; display: block; }

.player-fallback {
  position: relative;
  width: 100%; height: 100%;
  background: #000;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.player-fallback img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  opacity: 0.35;
  filter: blur(2px);
}
.player-fallback-overlay {
  position: relative; z-index: 1;
  text-align: center;
  padding: 1.5rem;
  display: flex; flex-direction: column; align-items: center; gap: 0.85rem;
}
.player-fallback-overlay i {
  font-size: 2.5rem;
  color: var(--gold-color);
}
.player-fallback-overlay p { color: var(--text-main); font-size: 1rem; line-height: 1.4; }
.player-fallback-overlay small { color: var(--text-muted); font-size: 0.82rem; }

/* Transport bar */
.transport {
  display: flex; align-items: center; flex-wrap: nowrap;
  gap: 0.6rem;
  padding: 0.7rem 0.9rem;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04) 0%, rgba(0, 0, 0, 0.15) 100%),
    var(--bg-elev);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 4px 14px rgba(0, 0, 0, 0.2);
  min-width: 0;
}
.transport-nav { display: inline-flex; align-items: center; gap: 0.3rem; flex-shrink: 0; }
.transport > .trim-seg { flex-shrink: 0; }
.transport > .time-display {
  margin-left: auto;
  flex-shrink: 0;
  white-space: nowrap;
}

/* Seek buttons with visible '5s' label */
.player-control-btn.with-label {
  width: auto; min-width: 52px;
  padding: 0 0.55rem;
  gap: 4px;
  font-family: var(--font-mono);
  font-size: 0.72rem; font-weight: 700;
  color: var(--text-main);
  letter-spacing: 0.3px;
}
.player-control-btn.with-label i { font-size: 0.8rem; opacity: 0.85; }
.player-control-btn.with-label .ctrl-label { color: var(--text-main); }

/* ─── Premium segmented TRIM pill ─────────────────────────────────────── */
.trim-seg {
  display: inline-flex; align-items: stretch;
  background:
    linear-gradient(135deg, rgba(168, 85, 247, 0.18), rgba(6, 182, 212, 0.10));
  border: 1px solid rgba(168, 85, 247, 0.4);
  border-radius: 14px;
  padding: 4px;
  box-shadow:
    0 6px 22px rgba(168, 85, 247, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.07);
  position: relative;
  overflow: hidden;
}
.trim-seg::before {
  /* iridescent edge highlight */
  content: '';
  position: absolute; inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(135deg, rgba(192, 132, 252, 0.6), rgba(6, 212, 212, 0.5));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0.6;
  pointer-events: none;
}
.trim-seg-tag {
  display: inline-flex; align-items: center; gap: 0.35rem;
  padding: 0 0.7rem 0 0.55rem;
  font-family: var(--font-mono);
  font-size: 0.64rem; font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--primary-color);
  text-shadow: 0 0 12px rgba(168, 85, 247, 0.5);
}
.trim-seg-tag i { font-size: 0.72rem; }
.trim-seg-sep {
  width: 1px;
  background: rgba(168, 85, 247, 0.3);
  margin: 4px 2px;
}
.trim-seg-btn {
  display: inline-flex; align-items: center; gap: 0.4rem;
  background: transparent;
  border: 0;
  border-radius: 10px;
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.78rem; font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  padding: 0.5rem 0.85rem;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}
.trim-seg-btn i { font-size: 0.78rem; color: var(--primary-color); }
.trim-seg-btn:hover {
  background: rgba(168, 85, 247, 0.18);
  color: white;
}
.trim-seg-btn.flash {
  background: var(--primary-gradient);
  color: white;
  animation: trim-pop 0.4s ease;
}
.trim-seg-btn.flash i { color: white; }
@keyframes trim-pop { 50% { transform: scale(1.06); } }
.transport .player-control-btn.active {
  background: linear-gradient(135deg, #06b6d4, #3b82f6);
  color: white;
  box-shadow: 0 4px 14px var(--cyan-glow);
}
.time-display {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 0.88rem;
  font-weight: 500;
  letter-spacing: 0.5px;
  color: var(--text-main);
  padding: 0 0.6rem;
  border-left: 1px solid var(--border-color);
  text-shadow: 0 0 12px rgba(255, 255, 255, 0.1);
}
.player-control-btn {
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-main);
  width: 36px; height: 36px;
  border-radius: 50%;
  cursor: pointer;
  transition: all var(--transition-fast);
  font-size: 0.85rem;
}
.player-control-btn:hover { background: var(--bg-elev-hover); border-color: var(--border-color); }
.player-control-btn.primary {
  background: var(--primary-gradient);
  color: white;
  width: 42px; height: 42px;
  box-shadow: 0 6px 18px var(--primary-glow);
}
.player-control-btn.active { background: var(--secondary-gradient); color: white; }
.time-display {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text-muted);
  padding-right: 0.25rem;
}

/* ─── Premium timeline ──────────────────────────────────────────────────── */
.timeline-shell {
  display: flex; flex-direction: column;
  gap: 6px;
  padding: 0;
}
.timeline-rulers {
  position: relative;
  height: 14px;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--text-dim);
}
.ruler-mark {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  padding: 0 2px;
  letter-spacing: 0.5px;
}
.ruler-mark::after {
  content: '';
  display: block;
  width: 1px; height: 4px;
  background: var(--border-strong);
  margin: 2px auto 0;
}

.timeline {
  position: relative;
  height: 110px;            /* taller, room for inside chips */
  background: linear-gradient(180deg, rgba(15, 21, 36, 0.55) 0%, rgba(8, 12, 20, 0.85) 100%);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  overflow: visible;
  cursor: crosshair;
  user-select: none;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.04),
    0 6px 20px rgba(0, 0, 0, 0.35);
}
/* Real ffmpeg-extracted 30-frame strip (stretched horizontally) */
.timeline.has-sprite::before {
  content: '';
  position: absolute; inset: 0;
  background-image: var(--sprite-url);
  background-size: 100% 100%;
  background-repeat: no-repeat;
  border-radius: 10px;
  opacity: 0.5;
  filter: saturate(0.9) contrast(1.05) brightness(0.85);
  pointer-events: none;
  z-index: 0;
}
.timeline.has-sprite::after {
  /* Dark gradient overlay so the playhead/handles read clearly over thumbs */
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.2) 0%, rgba(0, 0, 0, 0.45) 100%);
  border-radius: 10px;
  pointer-events: none;
  z-index: 0;
}
.timeline.has-sprite .timeline-thumbs {
  opacity: 0.35;  /* fade bars to a subtle waveform overlay */
  mix-blend-mode: screen;
  position: relative; z-index: 1;
}
.timeline-selection, .timeline-playhead, .timeline-handle { z-index: 5; }
.timeline::before {
  /* subtle scanline texture for premium feel */
  content: '';
  position: absolute; inset: 0;
  background: repeating-linear-gradient(90deg, transparent 0 12px, rgba(255,255,255,0.012) 12px 13px);
  border-radius: 10px;
  pointer-events: none;
}

.timeline-thumbs {
  position: absolute; inset: 6px 6px 6px 6px;
  display: flex; align-items: flex-end;
  gap: 1px;
  border-radius: 8px;
  overflow: hidden;
}
.tick {
  flex: 1;
  height: var(--h, 60%);
  border-radius: 1px;
  background: linear-gradient(180deg,
    rgba(168, 85, 247, 0.45) 0%,
    rgba(99, 102, 241, 0.25) 50%,
    rgba(6, 182, 212, 0.15) 100%);
  transition: opacity 0.2s ease;
}
.tick:nth-child(7n)   { background: linear-gradient(180deg, rgba(6, 182, 212, 0.55) 0%, rgba(59, 130, 246, 0.25) 60%, rgba(168,85,247,0.15) 100%); }
.tick:nth-child(13n)  { background: linear-gradient(180deg, rgba(251, 191, 36, 0.4) 0%, rgba(168, 85, 247, 0.2) 100%); }

.timeline-selection {
  position: absolute; top: -2px; bottom: -2px;
  background:
    linear-gradient(180deg, rgba(168, 85, 247, 0.28) 0%, rgba(99, 102, 241, 0.18) 100%);
  border-top: 2px solid var(--primary-color);
  border-bottom: 2px solid var(--primary-color);
  border-radius: 4px;
  pointer-events: none;
  box-shadow:
    0 0 24px rgba(168, 85, 247, 0.35),
    inset 0 0 0 1px rgba(255, 255, 255, 0.08);
  transition: left 0.12s ease, width 0.12s ease;
}

.timeline-playhead {
  position: absolute; top: 4px; bottom: 4px;   /* INSIDE the timeline now */
  width: 2px;
  background: linear-gradient(180deg, var(--cyan-color), #fff, var(--cyan-color));
  box-shadow: 0 0 14px var(--cyan-glow), 0 0 28px rgba(6,182,212,0.4);
  pointer-events: none;
  border-radius: 2px;
  will-change: left;
  z-index: 6;
}
.timeline-playhead::before {
  content: '';
  position: absolute; left: 50%; top: 0;
  transform: translateX(-50%);
  width: 10px; height: 10px;
  background: var(--cyan-color);
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 10px var(--cyan-glow);
}
.timeline-playhead::after {
  content: '';
  position: absolute; left: 50%; bottom: 0;
  transform: translateX(-50%);
  width: 10px; height: 10px;
  background: var(--cyan-color);
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 10px var(--cyan-glow);
}
/* Playhead time tip — small, button-ish, sits just under the playhead's top dot */
.playhead-tip {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-mono);
  font-size: 0.58rem;
  font-weight: 800;
  letter-spacing: 0.4px;
  background: var(--cyan-color);
  color: var(--bg-darker);
  padding: 2px 6px;
  border-radius: 3px;
  border-bottom: 2px solid rgba(0, 0, 0, 0.3);
  white-space: nowrap;
  box-shadow: 0 2px 6px rgba(6, 182, 212, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.4);
  pointer-events: none;
}

.timeline-handle {
  position: absolute; top: 0; bottom: 0;     /* sits INSIDE the timeline */
  width: 14px;
  background: var(--primary-gradient);
  border: 2px solid rgba(255, 255, 255, 0.9);
  border-radius: 5px;
  cursor: ew-resize;
  transform: translateX(-50%);
  box-shadow:
    0 6px 20px rgba(168, 85, 247, 0.6),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  z-index: 10;
  padding: 0;
}
.timeline-handle:hover {
  transform: translateX(-50%) scaleY(1.06);
  box-shadow:
    0 8px 28px rgba(168, 85, 247, 0.75),
    inset 0 1px 0 rgba(255, 255, 255, 0.4);
}
.timeline-handle.dragging {
  transform: translateX(-50%) scaleY(1.12);
  box-shadow: 0 10px 32px rgba(168, 85, 247, 0.85);
}
.timeline-handle::before {
  content: '';
  position: absolute; left: 50%; top: 50%;
  width: 2px; height: 50%;
  background: rgba(255, 255, 255, 0.85);
  transform: translate(-50%, -50%);
  border-radius: 1px;
  box-shadow: 4px 0 0 rgba(255, 255, 255, 0.45), -4px 0 0 rgba(255, 255, 255, 0.45);
}
/* IN / OUT chip on each handle — small, button-shaped, always visible.
   Clicking focuses the corresponding time input in the right panel. */
.handle-label {
  position: absolute;
  top: 4px; left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-mono);
  font-size: 0.55rem;
  font-weight: 800;
  letter-spacing: 0.8px;
  line-height: 1;
  color: white;
  background: linear-gradient(180deg, rgba(192, 132, 252, 1) 0%, rgba(168, 85, 247, 1) 100%);
  border: 0;
  border-bottom: 2px solid rgba(99, 102, 241, 0.85);   /* gives it "depressible" button look */
  padding: 3px 6px;
  border-radius: 4px;
  white-space: nowrap;
  pointer-events: auto;
  cursor: pointer;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.35);
  box-shadow:
    0 2px 6px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
  transition: all var(--transition-fast);
  user-select: none;
}
.handle-label:hover {
  background: linear-gradient(180deg, #d8b4fe 0%, #a855f7 100%);
  transform: translateX(-50%) translateY(-1px);
  box-shadow: 0 4px 10px rgba(168, 85, 247, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.4);
}
.handle-label:active {
  transform: translateX(-50%) translateY(0);
  border-bottom-width: 1px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}
/* Live time chip — sits below the handle INSIDE the timeline, shown on hover/drag */
.handle-time {
  position: absolute;
  bottom: 4px; left: 50%;
  transform: translateX(-50%) translateY(4px);
  font-family: var(--font-mono);
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.3px;
  color: white;
  background: rgba(20, 27, 45, 0.95);
  border: 1px solid var(--primary-color);
  padding: 1px 5px;
  border-radius: 3px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.18s ease, transform 0.18s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}
.timeline-handle:hover .handle-time,
.timeline-handle.dragging .handle-time,
.timeline-handle:focus .handle-time {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.handle-in  { left: 0%; }
.handle-out { left: 100%; }

.timeline-hover {
  position: absolute; bottom: calc(100% + 12px);
  transform: translateX(-50%);
  background: var(--bg-card-solid);
  border: 1px solid var(--border-strong);
  padding: 4px;
  border-radius: 8px;
  pointer-events: none;
  z-index: 20;
  box-shadow: var(--shadow-lg);
}
.timeline-hover img {
  display: block;
  width: 140px; height: 78px;
  object-fit: cover;
  border-radius: 4px;
}
.timeline-hover-time {
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-main);
  margin-top: 4px;
}

/* ─── Controls panel ─────────────────────────────────────────────────────── */
.controls-container { display: flex; flex-direction: column; gap: 1rem; min-width: 0; }
.video-title {
  font-size: 1.15rem; font-weight: 700; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.video-author { color: var(--text-muted); font-size: 0.85rem; margin-top: -0.25rem; }

.time-inputs-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}
.time-input-box label {
  display: flex; align-items: center; gap: 0.4rem;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--primary-color);
  margin-bottom: 0.4rem;
}
.time-input-box label::before {
  content: '';
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--primary-color);
  box-shadow: 0 0 10px rgba(168, 85, 247, 0.6);
}
.time-input-box.is-focused label { color: var(--cyan-color); }
.time-input-box.is-focused label::before { background: var(--cyan-color); box-shadow: 0 0 10px var(--cyan-glow); }
.time-input-wrapper {
  display: flex; gap: 0.4rem;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(0, 0, 0, 0.1)), var(--bg-elev);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 0.25rem 0.25rem 0.25rem 0.65rem;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.time-input-wrapper:hover { border-color: var(--border-strong); }
.time-input-wrapper:focus-within {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.18);
}
.time-input-wrapper input {
  flex: 1;
  background: transparent;
  border: 0; outline: 0;
  color: var(--text-main);
  font-family: var(--font-mono);
  font-size: 0.92rem;
  font-weight: 500;
  letter-spacing: 0.3px;
  padding: 0.45rem 0;
  min-width: 0;
}
.time-input-wrapper .btn-small {
  background: var(--primary-gradient);
  color: white;
  font-weight: 700;
  font-family: var(--font-mono);
  letter-spacing: 1px;
  padding: 0.45rem 0.65rem;
  box-shadow: 0 2px 8px rgba(168, 85, 247, 0.3);
  border: 0;
}
.time-input-wrapper .btn-small:hover { box-shadow: 0 4px 14px rgba(168, 85, 247, 0.5); }
.nudge-row {
  margin-top: 0.4rem;
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px;
}
.nudge-btn {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.01));
  border: 1px solid var(--border-color);
  border-bottom-width: 2px;     /* gives 3D button feel */
  color: var(--text-main);
  font-family: var(--font-mono); font-size: 0.72rem;
  font-weight: 600;
  padding: 0.4rem 0;
  border-radius: 7px;
  cursor: pointer;
  transition: all var(--transition-fast);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}
.nudge-btn:hover {
  background: linear-gradient(180deg, rgba(168, 85, 247, 0.15), rgba(168, 85, 247, 0.05));
  border-color: var(--primary-color);
  color: white;
  transform: translateY(-1px);
}
.nudge-btn:active {
  transform: translateY(0);
  border-bottom-width: 1px;
  margin-bottom: 1px;
}

.clip-duration-box {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.95rem 1.1rem;
  background:
    linear-gradient(135deg, rgba(168, 85, 247, 0.16) 0%, rgba(6, 182, 212, 0.10) 100%);
  border: 1px solid rgba(168, 85, 247, 0.3);
  border-radius: 12px;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1.2px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}
.clip-duration-box strong {
  font-family: var(--font-mono);
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: none;
  background: linear-gradient(135deg, var(--primary-color), var(--cyan-color));
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 0 24px rgba(168, 85, 247, 0.4);
}

.format-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem;
}
.format-box label {
  display: block;
  font-size: 0.7rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}
.form-select {
  width: 100%;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.04) 0%, rgba(255, 255, 255, 0.01) 100%), var(--bg-elev);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 500;
  padding: 0.78rem 2.5rem 0.78rem 0.95rem;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  /* color-scheme: dark forces Chromium/Firefox to use the dark-mode native dropdown
     menu so options inherit dark theme colors, not the system default white. */
  color-scheme: dark;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23a855f7' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 0.85rem center;
  background-size: 14px;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background-color var(--transition-fast);
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.3);
  letter-spacing: 0.2px;
}
.form-select:hover {
  border-color: var(--border-strong);
  background-color: var(--bg-elev-hover);
}
.form-select:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.18);
}
.form-select option,
.form-select optgroup {
  background: var(--bg-card-solid);
  color: var(--text-main);
  font-weight: 500;
  padding: 8px;
}
.form-select optgroup {
  color: var(--primary-color);
  font-weight: 700;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* ─── Premium source-mode tabs (Server / Direct) ────────────────────────── */
.source-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}
.source-tab {
  display: flex; flex-direction: column;
  align-items: flex-start;
  gap: 0.35rem;
  padding: 0.95rem 1rem;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(0, 0, 0, 0.12)), var(--bg-elev);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
  text-align: left;
  overflow: hidden;
}
.source-tab::before {
  content: '';
  position: absolute; left: 0; right: 0; top: 0;
  height: 2px;
  background: transparent;
  transition: background var(--transition-fast);
}
.source-tab > i:first-child {
  font-size: 1.2rem;
  color: var(--text-dim);
  transition: color var(--transition-fast);
}
.source-tab > span:first-of-type {
  font-size: 1rem;
  color: var(--text-main);
  letter-spacing: 0.2px;
}
.source-tab:hover {
  border-color: var(--border-strong);
  transform: translateY(-1px);
}
.source-tab.is-active {
  background: linear-gradient(180deg, rgba(168, 85, 247, 0.18) 0%, rgba(99, 102, 241, 0.08) 100%), var(--bg-elev);
  border-color: var(--primary-color);
  box-shadow:
    0 6px 24px rgba(168, 85, 247, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  color: var(--text-main);
}
.source-tab.is-active::before { background: linear-gradient(90deg, var(--primary-color), var(--cyan-color)); }
.source-tab.is-active > i:first-child { color: var(--primary-color); }
.tab-badge {
  font-size: 0.6rem; font-weight: 800;
  text-transform: uppercase; letter-spacing: 1px;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(168, 85, 247, 0.2);
  color: var(--primary-color);
  border: 1px solid rgba(168, 85, 247, 0.4);
  align-self: flex-start;
}
.tab-badge-alt {
  background: rgba(6, 182, 212, 0.15);
  color: var(--cyan-color);
  border-color: rgba(6, 182, 212, 0.4);
}
.source-tab-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.5;
  padding: 0.5rem 0.25rem 0;
  margin: 0;
}

/* ─── Set-In/Set-Out buttons in transport bar ───────────────────────────── */
.transport-divider {
  width: 1px; height: 22px;
  background: var(--border-color);
  margin: 0 0.35rem;
}
.mark-btn {
  display: inline-flex; align-items: center; gap: 0.4rem;
  background: linear-gradient(180deg, rgba(168, 85, 247, 0.10), rgba(168, 85, 247, 0.02)), var(--bg-elev);
  border: 1px solid rgba(168, 85, 247, 0.25);
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  padding: 0.45rem 0.8rem;
  border-radius: 8px;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(168, 85, 247, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}
.mark-btn i { color: var(--primary-color); font-size: 0.85rem; }
.mark-btn:hover {
  background: linear-gradient(180deg, rgba(168, 85, 247, 0.22), rgba(99, 102, 241, 0.10)), var(--bg-elev);
  border-color: var(--primary-color);
  box-shadow: 0 4px 14px rgba(168, 85, 247, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  transform: translateY(-1px);
}
.mark-btn:active { transform: translateY(0); }
.mark-btn.flash {
  background: var(--primary-gradient);
  color: white;
  border-color: transparent;
  box-shadow: 0 6px 20px rgba(168, 85, 247, 0.55);
  animation: mark-pop 0.35s ease;
}
.mark-btn.flash i { color: white; text-shadow: 0 0 8px rgba(255, 255, 255, 0.7); }
@keyframes mark-pop {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.08); }
  100% { transform: scale(1); }
}
@media (max-width: 640px) {
  .mark-btn span { display: none; }
  .mark-btn { padding: 0.45rem 0.6rem; }
}

/* ─── Hint line + link ──────────────────────────────────────────────────── */
.hint-line {
  font-size: 0.8rem;
  color: var(--text-dim);
  text-align: center;
  display: flex; flex-wrap: wrap;
  align-items: center; justify-content: center;
  gap: 0.5rem 1rem;
}
.hint-link {
  color: var(--cyan-color);
  text-decoration: none;
  font-weight: 500;
  display: inline-flex; align-items: center; gap: 0.35rem;
  padding: 2px 8px;
  border-radius: 6px;
  transition: background var(--transition-fast);
}
.hint-link:hover { background: rgba(6, 182, 212, 0.12); }
kbd {
  display: inline-block;
  font-family: var(--font-mono); font-size: 0.78rem;
  background: var(--bg-elev);
  border: 1px solid var(--border-color);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 1px 6px;
  color: var(--text-main);
}

/* ─── Animated scissors mascot for the progress card ───────────────────── */
/* Stack rhythm — give cards visible breathing room */
.app-main { display: flex; flex-direction: column; gap: 1.5rem; }
.progress-card { position: relative; padding: 1.5rem; margin-top: 0.5rem; }
/* Inline mascot — sits next to the title row, never overlaps any text */
.progress-mascot {
  position: static;
  width: 56px; height: 56px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--bg-card-solid);
  border: 1px solid var(--border-color);
  border-radius: 50%;
  box-shadow: 0 8px 22px rgba(168, 85, 247, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
  float: left;
  margin: 0 1rem 0.5rem 0;
}
.mascot-svg { width: 42px; height: 42px; display: block; margin: auto; }
/* Snip animation: blades open and close on a loop */
.blade { transform-origin: 22px 50px; transition: transform 0.3s ease; animation-duration: 1.6s; animation-iteration-count: infinite; animation-timing-function: ease-in-out; }
.blade-top { animation-name: snip-top; }
.blade-bot { animation-name: snip-bot; }
@keyframes snip-top {
  0%, 100% { transform: rotate(0deg); }
  50%      { transform: rotate(8deg); }
}
@keyframes snip-bot {
  0%, 100% { transform: rotate(0deg); }
  50%      { transform: rotate(-8deg); }
}
.sparks circle { animation: spark-twinkle 2s infinite ease-in-out; transform-origin: center; transform-box: fill-box; }
.sparks circle:nth-child(1) { animation-delay: 0s; }
.sparks circle:nth-child(2) { animation-delay: 0.3s; }
.sparks circle:nth-child(3) { animation-delay: 0.6s; }
.sparks circle:nth-child(4) { animation-delay: 0.9s; }
.sparks circle:nth-child(5) { animation-delay: 1.2s; }
@keyframes spark-twinkle {
  0%, 100% { opacity: 0.4; transform: scale(0.7); }
  50%      { opacity: 1;   transform: scale(1.3); }
}

/* Rotating fun message styling */
#fun-msg {
  transition: opacity 0.2s ease;
  display: inline-block;
  font-style: italic;
}
.speed-chip {
  display: inline-block;
  margin-left: 0.5rem;
  padding: 1px 8px;
  background: rgba(6, 182, 212, 0.15);
  border: 1px solid rgba(6, 182, 212, 0.35);
  color: var(--cyan-color);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
}

/* ─── Premium Done card ─────────────────────────────────────────────────── */
.result-card {
  position: relative;
  padding: 2rem 1.75rem 1.75rem;
  background:
    radial-gradient(ellipse 70% 50% at 50% 0%, rgba(16, 185, 129, 0.22) 0%, transparent 60%),
    linear-gradient(180deg, rgba(20, 27, 45, 0.7), rgba(15, 21, 36, 0.92));
  border: 1px solid rgba(16, 185, 129, 0.4);
  border-radius: 18px;
  box-shadow:
    0 24px 80px rgba(0, 0, 0, 0.5),
    0 0 80px rgba(16, 185, 129, 0.15),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  animation: result-in 0.55s cubic-bezier(0.34, 1.56, 0.64, 1);
  overflow: hidden;
}
.result-card::before {
  content: '';
  position: absolute; inset: 0 0 auto 0; height: 2px;
  background: linear-gradient(90deg, transparent, var(--green-color) 30%, var(--primary-color) 70%, transparent);
  box-shadow: 0 0 18px rgba(16, 185, 129, 0.55);
}
@keyframes result-in {
  from { opacity: 0; transform: translateY(12px) scale(0.94); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.result-header {
  display: flex; flex-direction: column; align-items: center;
  text-align: center;
  gap: 0.7rem;
  margin-bottom: 1.5rem;
}
.result-icon {
  width: 78px; height: 78px;
  display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--green-color), #059669);
  border-radius: 24px;
  flex-shrink: 0;
  box-shadow:
    0 14px 36px rgba(16, 185, 129, 0.55),
    inset 0 2px 0 rgba(255, 255, 255, 0.3);
  animation: hero-bob 2.6s infinite ease-in-out;
}
@keyframes hero-bob {
  0%, 100% { transform: translateY(0) rotate(-2deg); }
  50%      { transform: translateY(-4px) rotate(2deg); }
}
.result-icon i { font-size: 2rem; color: white; }
.result-headline { width: 100%; }
.result-headline h3 {
  font-size: 1.6rem; font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #fff 0%, #cbd5e1 70%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.result-headline p {
  display: inline-block;
  font-family: var(--font-mono);
  color: var(--text-muted);
  font-size: 0.82rem;
  margin-top: 8px;
  padding: 3px 12px;
  background: rgba(168, 85, 247, 0.12);
  border: 1px solid rgba(168, 85, 247, 0.3);
  border-radius: 999px;
  max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.result-header .modal-close {
  position: absolute; top: 12px; right: 12px;
  margin-left: 0;
  width: 32px; height: 32px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: var(--bg-elev);
  color: var(--text-muted);
  font-size: 1.05rem;
}
.result-header .modal-close:hover { color: var(--text-main); border-color: var(--danger); }

.result-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.55rem;
  margin-bottom: 1.5rem;
  padding: 0;
  background: transparent;
  border: 0;
}
.result-stat {
  display: flex; flex-direction: column; align-items: center;
  gap: 0.3rem;
  padding: 0.9rem 0.65rem;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  transition: border-color var(--transition-fast), transform var(--transition-fast);
  text-align: center;
}
.result-stat:hover { border-color: rgba(168, 85, 247, 0.5); transform: translateY(-2px); }
.stat-label {
  font-family: var(--font-mono);
  font-size: 0.62rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1.5px;
  color: var(--text-dim);
}
.stat-value {
  font-family: var(--font-mono);
  font-size: 1.1rem; font-weight: 700;
  color: var(--text-main);
}
/* When the strategy wins, give it a special iridescent text */
#result-strategy {
  background: linear-gradient(135deg, var(--green-color), var(--cyan-color));
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}

.result-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}
.result-actions .btn { min-width: 0; }
/* Big primary download button spans full row */
.result-actions .btn-primary {
  grid-column: 1 / -1;
  padding: 1.05rem;
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0.4px;
}
/* PRO save button */
.btn-pro {
  grid-column: 1 / -1;
  display: inline-flex; align-items: center; justify-content: center; gap: 0.45rem;
  font-family: inherit;
  font-size: 0.88rem; font-weight: 700;
  padding: 0.85rem 1rem;
  border-radius: 12px;
  cursor: pointer;
  background: linear-gradient(135deg, rgba(251, 191, 36, 0.15), rgba(251, 191, 36, 0.05));
  border: 1px solid rgba(251, 191, 36, 0.5);
  color: var(--gold-color);
  transition: all var(--transition-fast);
}
.btn-pro:hover {
  background: rgba(251, 191, 36, 0.22);
  border-color: var(--gold-color);
  transform: translateY(-1px);
  box-shadow: 0 8px 22px rgba(251, 191, 36, 0.3);
}
.btn-pro .pro-tag {
  margin-left: 4px;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  background: var(--gold-color);
  color: #1a1607;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 800;
  letter-spacing: 1px;
}

/* ─── HTML5 preview fallback ────────────────────────────────────────────── */
.html5-preview {
  width: 100%; height: 100%;
  background: #000;
  display: block;
  object-fit: contain;
}
.preview-loading {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 0.85rem;
  background: rgba(8, 12, 20, 0.85);
  color: var(--text-muted);
  font-size: 0.95rem;
  pointer-events: none;
}
.preview-loading i { font-size: 2rem; color: var(--primary-color); }
.preview-loading .btn { pointer-events: auto; margin-top: 0.5rem; }

/* ─── Premium history items ─────────────────────────────────────────────── */
.history-empty {
  text-align: center; padding: 3rem 1rem;
  color: var(--text-dim);
}
.history-empty i {
  font-size: 2.5rem; color: var(--primary-color);
  margin-bottom: 1rem;
  opacity: 0.5;
}
.history-empty p { margin: 0.3rem 0; }

.history-item {
  display: flex; align-items: center; gap: 0.85rem;
  padding: 0.7rem;
  border-radius: 12px;
  border: 1px solid transparent;
  cursor: default;
  transition: all var(--transition-fast);
  margin-bottom: 0.5rem;
}
.history-item:hover {
  background: rgba(168, 85, 247, 0.06);
  border-color: rgba(168, 85, 247, 0.25);
  transform: translateX(-2px);
}
.history-item.is-complete { border-left: 3px solid var(--green-color); }
.history-item img {
  width: 92px; height: 52px;
  object-fit: cover;
  border-radius: 8px;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}
.history-meta { flex: 1; min-width: 0; }
.history-title {
  font-weight: 600; font-size: 0.92rem;
  color: var(--text-main);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-bottom: 4px;
}
.history-sub {
  display: flex; flex-wrap: wrap; gap: 0.5rem;
  font-size: 0.72rem; color: var(--text-muted);
}
.history-fmt {
  font-family: var(--font-mono);
  padding: 1px 6px;
  background: rgba(168, 85, 247, 0.18);
  color: var(--primary-color);
  border-radius: 4px;
  font-weight: 600;
}
.history-time { font-family: var(--font-mono); color: var(--text-dim); }
.history-when { margin-left: auto; color: var(--text-dim); font-style: italic; }
.history-actions {
  display: flex; gap: 4px;
  opacity: 0; transition: opacity var(--transition-fast);
}
.history-item:hover .history-actions { opacity: 1; }
.btn-icon {
  width: 32px; height: 32px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--bg-elev);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
  font-size: 0.85rem;
}
.btn-icon:hover { background: var(--primary-color); color: white; border-color: transparent; }
.btn-icon-danger:hover { background: var(--danger); }

/* ─── Progress card ──────────────────────────────────────────────────────── */
.progress-card .progress-header {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  margin-bottom: 0.85rem;
}
.progress-header h3 { font-size: 1rem; font-weight: 600; }
#progress-percent { font-family: var(--font-mono); font-size: 1.1rem; color: var(--primary-color); font-weight: 700; }
.progress-phases {
  display: flex; gap: 0.5rem; flex-wrap: wrap;
  font-size: 0.78rem;
  margin-bottom: 0.85rem;
}
.phase {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.3rem 0.7rem;
  background: var(--bg-elev);
  border: 1px solid var(--border-color);
  border-radius: 999px;
  color: var(--text-dim);
  transition: all var(--transition-fast);
}
.phase.done { color: var(--green-color); border-color: rgba(16, 185, 129, 0.4); }
.phase.active { color: var(--text-main); border-color: var(--primary-color); box-shadow: 0 0 0 2px rgba(168, 85, 247, 0.18); }
.progress-bar-container {
  width: 100%; height: 10px;
  background: var(--bg-elev);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 0.6rem;
}
.progress-bar-fill {
  height: 100%; width: 0%;
  background: var(--primary-gradient);
  border-radius: 999px;
  transition: width 0.3s ease;
  background-size: 200% 100%;
  animation: shimmer 2s infinite linear;
}
@keyframes shimmer { from { background-position: 0% 0; } to { background-position: -200% 0; } }
.progress-status-row {
  display: flex; justify-content: space-between; gap: 1rem;
  font-size: 0.85rem; color: var(--text-muted);
}

/* ─── Toasts ─────────────────────────────────────────────────────────────── */
.toast-host {
  position: fixed; top: 16px; right: 16px;
  display: flex; flex-direction: column; gap: 0.5rem;
  z-index: 9000;
  max-width: 360px;
}
.toast {
  display: flex; align-items: center; gap: 0.65rem;
  padding: 0.75rem 0.85rem;
  background: var(--bg-card-solid);
  border: 1px solid var(--border-color);
  border-left: 4px solid var(--primary-color);
  border-radius: 10px;
  color: var(--text-main);
  font-size: 0.9rem;
  box-shadow: var(--shadow-lg);
  animation: toast-in 0.22s ease;
}
.toast-info    { border-left-color: var(--cyan-color); }
.toast-success { border-left-color: var(--green-color); }
.toast-warning { border-left-color: var(--gold-color); }
.toast-error   { border-left-color: var(--danger); }
.toast.leaving { animation: toast-out 0.22s ease forwards; }
.toast i { font-size: 1.05rem; }
.toast-info i { color: var(--cyan-color); }
.toast-success i { color: var(--green-color); }
.toast-warning i { color: var(--gold-color); }
.toast-error i { color: var(--danger); }
.toast-close {
  margin-left: auto;
  background: transparent; border: 0;
  color: var(--text-dim); cursor: pointer;
  font-size: 1.15rem; line-height: 1;
}
.toast-close:hover { color: var(--text-main); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-12px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toast-out { from { opacity: 1; transform: translateY(0); } to { opacity: 0; transform: translateY(-12px); } }

/* ─── Modal & drawer ─────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(8, 12, 20, 0.78);
  backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  padding: 1rem; z-index: 8000;
  animation: fade-in 0.2s ease;
}
.modal {
  position: relative;
  max-width: 460px; width: 100%;
  max-height: calc(100vh - 2rem); /* fit any viewport — scroll if taller */
  overflow-y: auto;
  text-align: center;
  padding: 2rem 1.75rem;
  animation: pop-in 0.25s ease;
}
.modal-wide { max-width: 720px; text-align: left; }
.modal::-webkit-scrollbar { width: 8px; }
.modal::-webkit-scrollbar-track { background: transparent; }
.modal::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 4px; }
.modal::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

/* ─── Activity log modal ────────────────────────────────────────────────── */
.logs-list {
  max-height: 60vh; overflow-y: auto;
  margin-top: 1rem;
  padding-right: 0.25rem;
  display: flex; flex-direction: column; gap: 0.55rem;
}
.logs-empty { color: var(--text-dim); text-align: center; padding: 2rem 0; }
.log-row {
  padding: 0.75rem 0.9rem;
  background: var(--bg-elev);
  border: 1px solid var(--border-color);
  border-left: 3px solid var(--green-color);
  border-radius: 10px;
}
.log-row.log-err { border-left-color: var(--danger); }
.log-head {
  display: flex; align-items: center; gap: 0.65rem;
  font-size: 0.92rem;
}
.log-row.log-ok .log-head i { color: var(--green-color); }
.log-row.log-err .log-head i { color: var(--danger); }
.log-vid {
  flex: 1;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.log-meta { font-family: var(--font-mono); font-size: 0.78rem; color: var(--text-muted); }
.log-time { font-family: var(--font-mono); font-size: 0.78rem; color: var(--text-dim); }
.log-won { font-size: 0.85rem; color: var(--text-muted); margin-top: 4px; padding-left: 1.5rem; }
.log-won strong { color: var(--green-color); font-family: var(--font-mono); }
.log-error { font-size: 0.8rem; color: var(--danger); margin-top: 4px; padding-left: 1.5rem; line-height: 1.4; }
.log-attempts { margin-top: 0.5rem; padding-left: 1.5rem; }
.log-attempts summary {
  cursor: pointer;
  font-size: 0.78rem; color: var(--text-dim);
  padding: 2px 0;
}
.log-attempts summary:hover { color: var(--text-main); }
.log-attempts table {
  width: 100%; border-collapse: collapse;
  margin-top: 6px;
  font-size: 0.78rem;
}
.log-attempts td {
  padding: 4px 8px;
  border-top: 1px solid var(--border-color);
  vertical-align: top;
}
.log-attempts td:first-child { width: 16px; }
.log-attempts td:nth-child(2) { width: 130px; font-family: var(--font-mono); }
.log-attempts td:nth-child(3) { width: 60px; font-family: var(--font-mono); color: var(--text-dim); text-align: right; }
.log-attempts td:nth-child(4) { color: var(--text-muted); }
.attempt-ok td:first-child i { color: var(--green-color); }
.attempt-err td:first-child i { color: var(--danger); }
.attempt-err td:nth-child(2) code { color: var(--text-muted); }
.modal h2 { font-size: 1.4rem; margin-bottom: 0.65rem; }
.modal-desc { color: var(--text-muted); margin-bottom: 1.25rem; }
.modal-close {
  position: absolute; top: 0.5rem; right: 0.65rem;
  background: transparent; border: 0; color: var(--text-muted);
  font-size: 1.6rem; cursor: pointer; line-height: 1;
}
.modal-close:hover { color: var(--text-main); }
.modal-header-icon { font-size: 2.5rem; margin-bottom: 0.6rem; color: var(--gold-color); }
.text-gold { color: var(--gold-color); }
.text-purple { color: var(--primary-color); }
.text-green { color: var(--green-color); }
.text-red { color: var(--danger); }
.premium-benefits { display: flex; flex-direction: column; gap: 0.55rem; text-align: left; margin: 1.25rem 0; }
.benefit-item { display: flex; align-items: center; gap: 0.65rem; color: var(--text-muted); font-size: 0.92rem; }
.benefit-item strong { color: var(--text-main); font-weight: 600; }
.price-tier {
  display: flex; align-items: baseline; justify-content: center; gap: 0.3rem;
  margin: 1rem 0 1.25rem;
}
.price-value { font-size: 2.25rem; font-weight: 800; color: var(--gold-color); }
.price-period { color: var(--text-muted); }
.modal-footer-note { color: var(--text-dim); font-size: 0.78rem; margin-top: 0.85rem; }

.shortcuts {
  width: 100%; text-align: left;
  border-collapse: collapse;
}
.shortcuts th {
  padding: 0.85rem 0.5rem 0.4rem;
  color: var(--primary-color);
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 1px;
  border-bottom: 1px solid var(--border-color);
}
.shortcuts td { padding: 0.4rem 0.5rem; color: var(--text-muted); font-size: 0.92rem; }
.shortcuts td:first-child { white-space: nowrap; color: var(--text-main); font-family: var(--font-mono); }

.drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: min(420px, 100vw);
  background: var(--bg-card-solid);
  border-left: 1px solid var(--border-color);
  box-shadow: -20px 0 60px rgba(0,0,0,0.5);
  z-index: 7000;
  display: flex; flex-direction: column;
  animation: slide-in 0.25s ease;
}
.drawer-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 1rem 1.25rem; border-bottom: 1px solid var(--border-color);
}
.drawer-header h2 { font-size: 1.05rem; font-weight: 700; display: flex; align-items: center; gap: 0.55rem; }
.history-list { padding: 1rem 1.25rem; overflow-y: auto; flex: 1; }
.history-empty { color: var(--text-dim); font-size: 0.9rem; text-align: center; padding: 2rem 0; }
.history-item {
  display: flex; align-items: center; gap: 0.85rem;
  padding: 0.65rem;
  border-radius: 10px;
  transition: background var(--transition-fast);
}
.history-item:hover { background: var(--bg-elev); }
.history-item img { width: 80px; height: 45px; object-fit: cover; border-radius: 6px; flex-shrink: 0; }
.history-meta { flex: 1; min-width: 0; }
.history-title {
  font-weight: 600; font-size: 0.9rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.history-sub { font-family: var(--font-mono); font-size: 0.75rem; color: var(--text-muted); }

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop-in { from { opacity: 0; transform: scale(0.96); } to { opacity: 1; transform: scale(1); } }
@keyframes slide-in { from { transform: translateX(20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

.animate-bounce { animation: bounce 1.4s infinite; }
.animate-pulse { animation: pulse 1.5s infinite; }
@keyframes bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.6; } }

/* ─── Footer ─────────────────────────────────────────────────────────────── */
.app-footer { text-align: center; color: var(--text-dim); font-size: 0.8rem; margin-top: auto; padding-top: 1rem; }

/* ─── Utility ────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ═══ MOBILE & RESPONSIVE OVERRIDES ═══════════════════════════════════════ */

/* Tablet & smaller — single-column workspace */
@media (max-width: 960px) {
  .workspace-layout { grid-template-columns: 1fr; }
  .container { padding: 1rem 1rem 1.5rem; }
  .app-header { margin-bottom: 1rem; }
}

/* Phones */
@media (max-width: 640px) {
  .hide-sm { display: none; }
  .logo { font-size: 1.2rem; }
  .logo-icon { width: 32px; height: 32px; }
  .search-card { padding: 1.75rem 1.1rem; }
  .search-card h1 { font-size: 1.5rem; letter-spacing: -0.5px; }
  .subtitle { font-size: 0.92rem; }
  .domain-hint { font-size: 0.78rem; }
  .input-group { flex-wrap: wrap; padding: 0.4rem 0.4rem 0.4rem 0.75rem; }
  .input-group input { font-size: 0.92rem; padding: 0.7rem 0.3rem; min-width: 0; flex: 1 1 100%; }
  #load-btn { width: 100%; margin-top: 0.4rem; }
  .workspace { padding: 1rem; }
  .iframe-wrapper { border-radius: 10px; }

  /* Transport bar — wrap to multiple rows, hide some labels */
  .transport {
    flex-direction: column; align-items: stretch;
    gap: 0.5rem; padding: 0.6rem;
  }
  .transport-nav {
    justify-content: center;
    width: 100%;
  }
  .trim-group {
    width: 100%; justify-content: space-between;
    padding: 0.45rem;
  }
  .trim-group .mark-btn { flex: 1; justify-content: center; }
  .trim-group-label {
    border-right: 0;
    padding-right: 0.4rem;
  }
  .time-display {
    width: 100%; margin-left: 0;
    border-left: 0; border-top: 1px solid var(--border-color);
    padding: 0.5rem 0 0; text-align: center;
  }

  /* Timeline — slightly shorter on mobile */
  .timeline { height: 56px; }
  .ruler-mark { font-size: 0.6rem; }
  .timeline-rulers { height: 12px; }

  /* IN/OUT handle time chips: smaller + tighter */
  .handle-label { font-size: 0.55rem; padding: 0 5px; top: -19px; }
  .handle-time { font-size: 0.65rem; padding: 1px 5px; top: -38px; }

  /* Hover preview — narrower on phones */
  .timeline-hover img { width: 110px; height: 62px; }

  /* Time/format inputs */
  .time-inputs-grid { gap: 0.5rem; }
  .time-input-box label { font-size: 0.65rem; }
  .time-input-wrapper input { font-size: 0.88rem; }
  .nudge-row .nudge-btn { font-size: 0.65rem; padding: 0.32rem 0; }
  .format-grid { gap: 0.5rem; }

  /* Source mode tabs stack vertically on tiny screens */
  .source-tabs { grid-template-columns: 1fr; }
  .source-tab-desc { font-size: 0.78rem; padding: 0.4rem 0.2rem; }

  /* Cards: less padding */
  .card { padding: 1.1rem; }

  /* Progress card mascot smaller */
  .progress-mascot { width: 56px; height: 56px; top: -22px; right: 1rem; }
  .mascot-svg { width: 44px; height: 44px; }

  /* Result/completion */
  .result-stats { grid-template-columns: 1fr 1fr; }
  .result-actions { flex-direction: column; }
  .result-actions .btn { width: 100%; min-width: 0; }

  /* Drawers go full-width */
  .drawer { width: 100vw; }
  .history-item img { width: 70px; height: 40px; }

  /* Modals — fill viewport */
  .modal-overlay { padding: 0.5rem; align-items: flex-end; }
  .modal { max-width: 100%; max-height: 92vh; padding: 1.5rem 1.2rem; border-radius: 18px 18px 0 0; }
  .modal-wide { max-height: 92vh; }
  .shortcuts td { padding: 0.32rem 0.4rem; font-size: 0.85rem; }
  .shortcuts kbd { font-size: 0.72rem; padding: 1px 5px; }

  /* Toast container — fill bottom on phone */
  .toast-host {
    top: auto; bottom: 12px;
    left: 12px; right: 12px;
    max-width: none;
  }
}

/* Very small phones */
@media (max-width: 380px) {
  .header-actions .btn-text, .header-actions span { display: none; }
  .header-actions .btn { padding: 0.5rem 0.7rem; }
  .transport-nav { gap: 0.2rem; }
  .player-control-btn { width: 32px; height: 32px; font-size: 0.78rem; }
  .player-control-btn.primary { width: 38px; height: 38px; }
}

/* Landscape phones — keep things tight */
@media (max-height: 480px) and (orientation: landscape) {
  .modal { max-height: calc(100vh - 1rem); }
}
