/* RankVideo Studio — "leaderboard energy, editorial restraint."
   Bold display type carries the brand and the countdown numbers (the
   product's own voice); everything else stays quiet. Accent colors for
   UI chrome are pulled from the same five rank colors used in the
   rendered videos, rather than an arbitrary decorative palette. */

@import url('https://fonts.googleapis.com/css2?family=Archivo+Black&family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  --ink: #0A0912;
  --panel: #14111F;
  --panel-raised: #1C1830;
  --panel-elevated: #241E3A;
  --line: #2B2542;
  --line-bright: #3D3560;
  --text: #F5F3FB;
  --text-dim: #9A8FB8;
  --text-faint: #6B6289;

  --accent: #8B2FE0;
  --accent-bright: #B15CFF;
  --accent-soft: rgba(139, 47, 224, 0.16);

  --rank-1: #F1EDF7;
  --rank-2: #4ADE80;
  --rank-3: #FB923C;
  --rank-4: #FACC15;
  --rank-5: #60A5FA;

  --danger: #F87171;
  --danger-soft: rgba(248, 113, 113, 0.14);
  --success: #4ADE80;
  --warning: #FACC15;

  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;

  --font-display: 'Archivo Black', 'Inter', sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  font-family: var(--font-body);
  color-scheme: dark;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--ink);
  background-image:
    radial-gradient(ellipse 900px 500px at 15% -10%, rgba(139, 47, 224, 0.16), transparent 60%),
    radial-gradient(ellipse 700px 400px at 100% 0%, rgba(96, 165, 250, 0.08), transparent 55%);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

:focus-visible {
  outline: 2px solid var(--accent-bright);
  outline-offset: 2px;
  border-radius: 4px;
}

.muted { color: var(--text-dim); }
.small { font-size: 0.85rem; }

.brand {
  font-family: var(--font-display);
  font-size: 1.4rem;
  letter-spacing: -0.01em;
  margin: 0;
}
.brand span { color: var(--accent-bright); }

/* ---------- Auth ---------- */
.auth-body {
  display: grid;
  place-items: center;
  min-height: 100vh;
  position: relative;
  overflow: hidden;
}
.auth-glow {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle 380px at 20% 25%, rgba(139, 47, 224, 0.35), transparent 70%),
    radial-gradient(circle 320px at 82% 78%, rgba(96, 165, 250, 0.22), transparent 70%),
    radial-gradient(circle 260px at 85% 15%, rgba(250, 204, 21, 0.12), transparent 70%);
  pointer-events: none;
}
.auth-badges {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.4rem;
}
.mini-badge {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--c);
  color: #14111F;
  font-family: var(--font-display);
  font-size: 0.85rem;
  display: grid;
  place-items: center;
  box-shadow: 0 4px 14px -4px rgba(0, 0, 0, 0.5);
}
.auth-card {
  position: relative;
  width: 360px;
  background: linear-gradient(180deg, var(--panel-raised), var(--panel));
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 2.25rem;
  box-shadow: 0 20px 60px -20px rgba(0, 0, 0, 0.6);
}
.btn-block { width: 100%; text-align: center; }
.auth-sub { color: var(--text-dim); margin-top: 0.35rem; font-size: 0.95rem; }
.auth-form { display: flex; flex-direction: column; gap: 1.1rem; margin-top: 1.5rem; }
.auth-form label { display: flex; flex-direction: column; gap: 0.4rem; font-size: 0.85rem; font-weight: 600; color: var(--text-dim); }
.alert-error {
  color: var(--danger);
  background: var(--danger-soft);
  border: 1px solid rgba(248, 113, 113, 0.3);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.8rem;
  font-size: 0.88rem;
  margin-top: 1rem;
}

input[type="text"], input[type="password"], select, input[type="color"], input[type="number"] {
  background: var(--panel-raised);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.75rem;
  font-size: 0.95rem;
  font-family: var(--font-body);
  transition: border-color 0.15s ease, background 0.15s ease;
}
input[type="text"]:hover, input[type="password"]:hover, select:hover { border-color: var(--line-bright); }
input[type="text"]:focus, input[type="password"]:focus, select:focus, input[type="number"]:focus {
  border-color: var(--accent);
  background: var(--panel-elevated);
  outline: none;
}
input[type="color"] { padding: 0.2rem; height: 2.5rem; cursor: pointer; }

.btn-primary, .btn-ghost {
  border-radius: var(--radius-sm);
  padding: 0.6rem 1.1rem;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid transparent;
  font-family: var(--font-body);
  transition: transform 0.1s ease, box-shadow 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}
.btn-primary {
  background: var(--accent);
  background: linear-gradient(135deg, var(--accent), #6D1FC0);
  color: #fff;
  box-shadow: 0 4px 16px -4px rgba(139, 47, 224, 0.5);
}
.btn-primary:hover { background: linear-gradient(135deg, var(--accent-bright), var(--accent)); box-shadow: 0 6px 20px -4px rgba(139, 47, 224, 0.65); }
.btn-primary:active { transform: translateY(1px); }
.btn-primary:disabled { opacity: 0.55; cursor: not-allowed; box-shadow: none; }
.btn-ghost {
  background: var(--panel-raised);
  color: var(--text-dim);
  border-color: var(--line);
  text-decoration: none;
  display: inline-block;
}
.btn-ghost:hover { color: var(--text); border-color: var(--line-bright); background: var(--panel-elevated); }

/* ---------- Topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1.75rem;
  border-bottom: 1px solid var(--line);
  background: rgba(20, 17, 31, 0.7);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-nav { display: flex; align-items: center; gap: 1rem; }
.topbar-user { color: var(--text-dim); font-size: 0.88rem; }
.back-link { color: var(--text-dim); text-decoration: none; font-size: 0.88rem; font-weight: 600; transition: color 0.15s ease; }
.back-link:hover { color: var(--accent-bright); }
.editor-title { font-size: 1.05rem; margin: 0; font-weight: 700; }
.status-pill {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-dim);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.3rem 0.8rem;
  background: var(--panel-raised);
}

/* ---------- Dashboard ---------- */
.dashboard { padding: 2.5rem 1.75rem; max-width: 1150px; margin: 0 auto; }
.dashboard-head { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 2rem; }
.dashboard-head h2 { margin: 0 0 0.3rem; font-size: 1.6rem; letter-spacing: -0.01em; }
.dashboard-head p { margin: 0; }

.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 1.1rem;
}
.project-card {
  background: var(--panel-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 0;
  text-decoration: none;
  color: var(--text);
  display: block;
  overflow: hidden;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}
.project-card:hover {
  border-color: var(--line-bright);
  transform: translateY(-3px);
  box-shadow: 0 16px 40px -16px rgba(0, 0, 0, 0.5);
}
.project-card .card-accent { height: 5px; }
.project-card .card-body { padding: 1.2rem 1.3rem 1.35rem; }
.project-card h3 { margin: 0 0 0.4rem; font-size: 1.05rem; font-weight: 700; }
.project-card .meta { color: var(--text-dim); font-size: 0.82rem; }
.project-card .status {
  display: inline-block;
  margin-top: 0.7rem;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.22rem 0.6rem;
  border-radius: 999px;
  background: var(--panel-elevated);
  color: var(--text-dim);
}
.project-card .status.completed { color: var(--success); background: rgba(74, 222, 128, 0.14); }
.project-card .status.rendering, .project-card .status.processing, .project-card .status.queued { color: var(--warning); background: rgba(250, 204, 21, 0.14); }
.project-card .status.failed { color: var(--danger); background: var(--danger-soft); }

.empty-state {
  text-align: center;
  padding: 4rem 1.5rem;
  border: 1px dashed var(--line);
  border-radius: var(--radius-lg);
  color: var(--text-dim);
}
.empty-state svg { margin-bottom: 1rem; opacity: 0.8; }
.empty-state p { margin: 0.25rem 0; }

.dialog {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, var(--panel-raised), var(--panel));
  color: var(--text);
  padding: 0;
  width: 380px;
  box-shadow: 0 24px 70px -20px rgba(0, 0, 0, 0.7);
}
.dialog::backdrop { background: rgba(5, 4, 10, 0.7); backdrop-filter: blur(2px); }
.dialog-form { padding: 1.75rem; display: flex; flex-direction: column; gap: 1.1rem; }
.dialog-form h3 { margin: 0; font-size: 1.15rem; }
.dialog-form label { display: flex; flex-direction: column; gap: 0.4rem; font-size: 0.85rem; font-weight: 600; color: var(--text-dim); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 0.6rem; margin-top: 0.4rem; }

/* ---------- Editor ---------- */
.editor-grid {
  display: grid;
  grid-template-columns: 310px 1fr 300px;
  gap: 1px;
  background: var(--line);
  min-height: calc(100vh - 69px);
}
.panel { background: var(--ink); padding: 1.5rem; overflow-y: auto; }
.panel-title { margin: 0 0 0.8rem; font-size: 0.82rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-dim); }

.dropzone {
  border: 1.5px dashed var(--line-bright);
  border-radius: var(--radius-md);
  text-align: center;
  padding: 1.75rem 1rem;
  margin-bottom: 1.2rem;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.dropzone.dragover { border-color: var(--accent-bright); background: var(--accent-soft); }
.dropzone p { margin: 0.3rem 0; }
.file-btn { margin: 0.7rem 0; }

.upload-progress { margin-bottom: 1.2rem; }
.progress-bar { background: var(--panel-raised); border-radius: 999px; height: 7px; overflow: hidden; }
.progress-fill { background: linear-gradient(90deg, var(--accent), var(--accent-bright)); height: 100%; width: 0%; transition: width 0.2s ease; }

.video-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.6rem; }
.video-card {
  background: var(--panel-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.65rem;
  display: flex;
  gap: 0.65rem;
  align-items: center;
  transition: border-color 0.15s ease;
}
.video-card:hover { border-color: var(--line-bright); }
.video-card img { width: 64px; height: 36px; object-fit: cover; border-radius: 6px; background: var(--panel-elevated); flex-shrink: 0; }
.video-card .name { font-size: 0.85rem; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 130px; }
.video-card .meta { font-size: 0.72rem; color: var(--text-dim); }
.video-card .del { margin-left: auto; background: none; border: none; color: var(--text-faint); cursor: pointer; font-size: 1rem; padding: 0.2rem 0.4rem; border-radius: 6px; transition: color 0.15s ease, background 0.15s ease; }
.video-card .del:hover { color: var(--danger); background: var(--danger-soft); }
.video-card.failed { border-color: rgba(248, 113, 113, 0.4); }
.video-card.failed .meta { color: var(--danger); }

.rank-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.65rem; max-width: 520px; }
.rank-card {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  background: var(--panel-raised);
  border: 1px solid var(--line);
  border-left: 3px solid var(--line);
  border-radius: var(--radius-md);
  padding: 0.8rem 1rem;
  cursor: grab;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.rank-card:hover { box-shadow: 0 8px 24px -12px rgba(0, 0, 0, 0.5); }
.rank-card.dragging { opacity: 0.4; cursor: grabbing; }
.rank-number {
  font-family: var(--font-display);
  font-size: 1.5rem;
  width: 2.3rem;
  text-align: center;
  flex-shrink: 0;
}
.rank-card[data-rank="1"] { border-left-color: var(--rank-1); }
.rank-card[data-rank="2"] { border-left-color: var(--rank-2); }
.rank-card[data-rank="3"] { border-left-color: var(--rank-3); }
.rank-card[data-rank="4"] { border-left-color: var(--rank-4); }
.rank-card[data-rank="5"] { border-left-color: var(--rank-5); }
.rank-card[data-rank="1"] .rank-number { color: var(--rank-1); }
.rank-card[data-rank="2"] .rank-number { color: var(--rank-2); }
.rank-card[data-rank="3"] .rank-number { color: var(--rank-3); }
.rank-card[data-rank="4"] .rank-number { color: var(--rank-4); }
.rank-card[data-rank="5"] .rank-number { color: var(--rank-5); }
.rank-card img { width: 72px; height: 40px; object-fit: cover; border-radius: 6px; flex-shrink: 0; }
.rank-fields { display: flex; flex-direction: column; gap: 0.4rem; flex: 1; min-width: 0; }
.caption-input {
  background: var(--panel-elevated);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.65rem;
  font-size: 0.85rem;
  width: 100%;
  font-family: var(--font-body);
}
.caption-input:focus { border-color: var(--accent); outline: none; }
.duration-row { display: flex; align-items: center; gap: 0.5rem; }
.duration-input {
  background: var(--panel-elevated);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 0.3rem 0.5rem;
  font-size: 0.8rem;
  width: 72px;
  font-family: var(--font-body);
}

.render-box {
  margin-top: 1.4rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.65rem;
  max-width: 520px;
}
.render-box .btn-primary { display: inline-flex; align-items: center; gap: 0.5rem; }
.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

.props-form { display: flex; flex-direction: column; gap: 1rem; }
.props-form label { display: flex; flex-direction: column; gap: 0.4rem; font-size: 0.84rem; font-weight: 600; color: var(--text-dim); }
.props-form .checkbox-label { flex-direction: row; align-items: flex-start; gap: 0.6rem; font-weight: 500; line-height: 1.4; cursor: pointer; }
.props-form .checkbox-label input[type="checkbox"] { margin-top: 0.15rem; width: 16px; height: 16px; flex-shrink: 0; accent-color: var(--accent); }

.preview-swatch {
  margin-top: 1.6rem;
  border-radius: var(--radius-lg);
  padding: 2.2rem 1rem;
  text-align: center;
  background: var(--accent);
  font-family: var(--font-display);
  font-size: 1.15rem;
  color: #fff;
  text-transform: uppercase;
  box-shadow: 0 16px 40px -16px rgba(139, 47, 224, 0.5);
}
.preview-swatch em { color: #1A1424; font-style: normal; }

/* ==================================================================
   Responsive — tablet and phone. The editor's fixed 3-column grid is
   the main thing that breaks on a narrow screen; everything else here
   is spacing/sizing so it doesn't feel like a shrunk desktop page.
   ================================================================== */

@media (max-width: 980px) {
  .editor-grid {
    grid-template-columns: 1fr;
    min-height: auto;
  }
  .panel { overflow-y: visible; }
}

@media (max-width: 720px) {
  .topbar { padding: 0.9rem 1.1rem; flex-wrap: wrap; gap: 0.6rem; }
  .brand { font-size: 1.15rem; }
  .editor-title { font-size: 0.95rem; }
  .topbar-user { display: none; } /* redundant with being logged in; reclaim space */

  .dashboard { padding: 1.5rem 1.1rem; }
  .dashboard-head { flex-direction: column; align-items: flex-start; gap: 1rem; }
  .dashboard-head .btn-primary { width: 100%; text-align: center; }
  .project-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 0.8rem; }

  .panel { padding: 1.1rem; }
  .rank-card { flex-wrap: wrap; padding: 0.7rem 0.85rem; }
  .rank-card img { width: 56px; height: 32px; }
  .rank-number { font-size: 1.25rem; width: 1.9rem; }
  .rank-fields { min-width: 160px; }

  .video-card .name { max-width: 100px; }

  .dialog, .auth-card { width: min(92vw, 380px); }
  .dialog-form, .auth-card { padding: 1.4rem; }

  .render-box, .rank-list { max-width: 100%; }
}

@media (max-width: 420px) {
  .brand { font-size: 1.05rem; }
  .dashboard-head h2 { font-size: 1.35rem; }
  .project-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .rank-number { display: none; } /* the color-coded left border already conveys rank; reclaim width for text */
  .badge-x-placeholder { display: none; }
}
