:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #60a5fa;
  --secondary: #06b6d4;
  --green: #22c55e;
  --yellow: #fbbf24;
  --orange: #f97316;
  --red: #ef4444;
  --ink: #1e293b;
  --muted: #64748b;
  --line: #cbd5e1;
  --card: #fff;
  --bg: #f0f4ff;
  --shadow-sm: 0 2px 8px rgba(0,0,0,.06);
  --shadow: 0 4px 16px rgba(0,0,0,.08);
  --shadow-lg: 0 8px 24px rgba(0,0,0,.12);
  --radius: 20px;
  --radius-sm: 14px;
  --transition: all .3s ease;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
html,
body {
  overflow-x: hidden;
}
body {
  font-family: 'Prompt', sans-serif;
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 40%, #0ea5e9 100%);
  color: var(--ink);
  line-height: 1.7;
  min-height: 100vh;
}
a { text-decoration: none; color: inherit; }

/* ── Navbar ──────────────────────────────────────────────────────────── */
.navbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 32px;
  background: rgba(37,99,235,.95);
  backdrop-filter: blur(10px);
  position: sticky; top: 0; z-index: 1000;
  box-shadow: 0 4px 20px rgba(37,99,235,.35);
}
.logo { font-size: 1.2rem; font-weight: 800; color: #fff; }
.nav-links { display: flex; gap: 6px; flex-wrap: wrap; }
.nav-links a {
  display: inline-flex; align-items: center; justify-content: center;
  color: rgba(255,255,255,.9); font-weight: 600;
  padding: 8px 16px; border-radius: 50px; font-size: .9rem;
  transition: .3s; border: 1px solid rgba(255,255,255,.25);
  min-height: 40px;
  text-align: center;
}
.nav-links a:hover { background: rgba(255,255,255,.2); }

/* ── Page header ─────────────────────────────────────────────────────── */
.page-header {
  padding: 50px 32px 60px; text-align: center; color: #fff;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
}
.page-header h1 {
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  font-weight: 800; line-height: 1.25; margin: 0 auto 10px;
  max-width: min(900px, 92vw); overflow-wrap: anywhere;
}
.page-header p {
  opacity: .92; font-size: 1.05rem; max-width: 700px;
  margin: 0 auto; overflow-wrap: anywhere;
}

.wrap { width: min(960px, 94vw); margin: 0 auto; padding: 30px 0 50px; }

/* ── Pipeline diagram ────────────────────────────────────────────────── */
.pipeline {
  display: flex; align-items: stretch; gap: 8px; flex-wrap: wrap;
  justify-content: center; margin: 10px 0 25px; padding: 18px;
  background: rgba(255,255,255,.12); backdrop-filter: blur(10px);
  border-radius: var(--radius); border: 1px solid rgba(255,255,255,.2);
}
.pipe-step {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; background: #fff; border-radius: var(--radius-sm);
  font-size: .88rem; color: var(--ink); box-shadow: var(--shadow-sm);
}
.pipe-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: #fff; font-weight: 800; font-size: .9rem;
}
.pipe-step small { color: var(--muted); font-size: .76rem; }
.pipe-arrow { color: #fff; align-self: center; font-size: 1.5rem; font-weight: 700; }

/* ── Card ─────────────────────────────────────────────────────────────── */
.card {
  background: #fff; border-radius: var(--radius); padding: 28px;
  margin: 18px 0; box-shadow: var(--shadow); transition: .3s;
}
.card h2 {
  font-size: 1.3rem; font-weight: 700; color: var(--primary-dark);
  margin-bottom: 18px;
}

.section-head {
  display: flex; justify-content: space-between; gap: 14px; align-items: flex-start;
  margin-bottom: 18px;
}
.section-head h2 { margin-bottom: 4px; }
.section-subtitle { color: var(--muted); font-size: .9rem; }

/* ── Member auth ─────────────────────────────────────────────────────── */
.auth-card {
  border: 2px solid rgba(37,99,235,.18);
}
.auth-toggle {
  margin-top: 14px; text-align: center; color: var(--muted); font-size: .92rem;
}
.auth-toggle button,
.ghost-btn,
.member-bar button {
  font-family: inherit; font-weight: 700; cursor: pointer;
  border: 1px solid var(--line); background: #fff; color: var(--primary-dark);
  border-radius: 999px; padding: 9px 16px; transition: .25s;
}
.auth-toggle button {
  margin-left: 8px; border: none; padding: 4px 8px; text-decoration: underline;
}
.ghost-btn:hover,
.member-bar button:hover {
  border-color: var(--primary); background: var(--bg);
}
.member-bar {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  background: #fff; border: 1px solid rgba(255,255,255,.25);
  border-radius: var(--radius); padding: 16px 20px; margin: 10px 0 20px;
  box-shadow: var(--shadow-sm);
}
.member-bar strong { display: block; color: var(--primary-dark); }
.member-bar span { color: var(--muted); font-size: .9rem; }

/* ── Form ─────────────────────────────────────────────────────────────── */
.field { display: block; margin-bottom: 18px; }
.field .label {
  display: block; font-size: .92rem; font-weight: 600;
  color: var(--ink); margin-bottom: 8px;
}
.field .label em { color: var(--red); font-style: normal; }
.field .label em.muted { color: var(--muted); font-weight: 400; }
.field input[type="url"],
.field input[type="text"],
.field input[type="email"],
.field input[type="password"],
.field select {
  width: 100%; padding: 12px 14px;
  border: 2px solid var(--line); border-radius: var(--radius-sm);
  font-family: inherit; font-size: .95rem; background: #fff;
  color: var(--ink); transition: .25s;
}
.field input[type="url"]:focus,
.field input[type="text"]:focus,
.field input[type="email"]:focus,
.field input[type="password"]:focus,
.field select:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}
.field input[type="range"] {
  width: 100%; accent-color: var(--primary); height: 8px;
}
.form-row {
  display: grid; grid-template-columns: 1fr 1fr; gap: 18px;
}
@media (max-width: 640px) {
  .form-row { grid-template-columns: 1fr; }
}
.field-help {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: .78rem;
}
.class-export-panel {
  border: 1px solid rgba(37,99,235,.18);
  border-radius: var(--radius-sm);
  background: rgba(37,99,235,.05);
  padding: 16px;
  margin: 6px 0 20px;
}
.check-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  color: var(--ink);
}
.check-row input {
  width: 18px;
  height: 18px;
  margin-top: 3px;
  accent-color: var(--primary);
  flex: 0 0 auto;
}
.check-row strong {
  display: block;
  color: var(--primary-dark);
}
.check-row small {
  display: block;
  color: var(--muted);
  font-size: .82rem;
}
.check-row.compact {
  align-items: center;
  margin-top: -2px;
}
.class-export-fields {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid rgba(37,99,235,.16);
}
.class-export-fields .field {
  margin-bottom: 14px;
}

.submit-btn {
  display: block; width: 100%; padding: 16px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff; border: none; border-radius: var(--radius-sm);
  font-family: inherit; font-size: 1.05rem; font-weight: 700;
  cursor: pointer; transition: .3s;
  box-shadow: 0 4px 16px rgba(37,99,235,.35);
}
.submit-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(37,99,235,.45);
}
.submit-btn:disabled { opacity: .55; cursor: not-allowed; }

/* ── Status panel ────────────────────────────────────────────────────── */
.status-panel h2 { color: var(--primary); }
.progress-track {
  position: relative; height: 28px; background: #e2e8f0;
  border-radius: 50px; overflow: hidden; margin: 16px 0 10px;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--secondary), var(--green));
  transition: width .4s ease; border-radius: 50px;
}
.progress-pct {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  font-weight: 700; color: var(--ink); font-size: .88rem;
  text-shadow: 0 1px 2px rgba(255,255,255,.7);
}
.status-message {
  font-size: .96rem; color: var(--ink);
  padding: 10px 14px; background: rgba(37,99,235,.05);
  border-radius: var(--radius-sm); margin: 12px 0;
}
.status-stages {
  display: flex; gap: 6px; flex-wrap: wrap; margin: 12px 0;
}
.stage {
  display: inline-block; padding: 5px 12px; border-radius: 50px;
  background: #e2e8f0; color: var(--muted); font-size: .78rem; font-weight: 600;
  transition: var(--transition);
}
.stage.active {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: #fff;
}
.stage.done {
  background: var(--green); color: #fff;
}

.error-box {
  background: #fee2e2; border-left: 5px solid var(--red);
  border-radius: var(--radius-sm); padding: 16px 20px; margin-top: 14px;
}
.error-box strong { color: var(--red); display: block; margin-bottom: 6px; }
.error-box p { color: var(--ink); font-size: .9rem; white-space: pre-wrap; }

.result-box {
  background: linear-gradient(135deg, rgba(34,197,94,.08), rgba(6,182,212,.08));
  border: 2px dashed var(--green);
  border-radius: var(--radius-sm); padding: 20px; margin-top: 14px;
}
.result-box h3 { color: var(--green); font-size: 1.05rem; margin-bottom: 12px; }
.result-box ul { list-style: none; margin-bottom: 16px; }
.result-box li {
  padding: 6px 0; border-bottom: 1px solid var(--line); font-size: .92rem;
}
.result-box li:last-child { border-bottom: none; }
.result-box li strong { color: var(--primary-dark); }

.result-actions {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
}
.view-btn,
.copy-btn,
.download-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 48px; padding: 12px 22px; border-radius: 50px;
  font-family: inherit; font-weight: 800; font-size: .94rem;
  cursor: pointer; transition: .3s; border: 0;
}
.view-btn {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: #fff; box-shadow: 0 4px 16px rgba(37,99,235,.35);
}
.copy-btn {
  background: #fff; color: var(--primary-dark);
  border: 2px solid rgba(37,99,235,.3);
}
.download-btn {
  background: linear-gradient(135deg, var(--green), #0ea5e9);
  color: #fff; box-shadow: 0 4px 16px rgba(34,197,94,.35);
}
.class-package-btn {
  background: linear-gradient(135deg, var(--orange), #dc2626);
}
.view-btn:hover,
.copy-btn:hover,
.download-btn:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(34,197,94,.45); }
.reset-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 48px; padding: 12px 20px;
  background: #fff; color: var(--ink); border: 2px solid var(--line);
  border-radius: 50px; font-family: inherit; font-weight: 600;
  font-size: .92rem; cursor: pointer; transition: .3s;
}
.reset-btn:hover { background: var(--bg); border-color: var(--primary); }

/* ── Member jobs ─────────────────────────────────────────────────────── */
.job-table-wrap {
  width: 100%; overflow-x: auto; border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
.job-table {
  width: 100%; border-collapse: collapse; min-width: 720px; background: #fff;
}
.job-table th,
.job-table td {
  padding: 12px 14px; border-bottom: 1px solid #e2e8f0;
  text-align: left; vertical-align: top; font-size: .9rem;
}
.job-table th {
  color: var(--muted); background: #f8fafc; font-size: .82rem;
}
.job-table td small {
  display: block; color: var(--muted); margin-top: 4px;
  max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.status-pill {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 90px; padding: 6px 10px; border-radius: 999px;
  font-size: .78rem; font-weight: 800; background: #dbeafe; color: var(--primary-dark);
}
.status-pill.completed { background: #dcfce7; color: #15803d; }
.status-pill.failed { background: #fee2e2; color: #b91c1c; }
.status-pill.packaging,
.status-pill.generating_html,
.status-pill.parsing_vtt,
.status-pill.fetching_subtitle,
.status-pill.fetching_metadata {
  background: #e0f2fe; color: #0369a1;
}
.table-actions {
  display: flex; flex-wrap: wrap; gap: 6px; min-width: 220px;
}
.table-action {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 34px; padding: 7px 11px; border-radius: 999px;
  background: #fff; color: var(--primary-dark); border: 1px solid var(--line);
  font-family: inherit; font-size: .78rem; font-weight: 800;
  cursor: pointer;
}
.table-action.primary {
  background: var(--primary); color: #fff; border-color: var(--primary);
}
.muted-text,
.empty-jobs {
  color: var(--muted); font-size: .88rem;
}
.empty-jobs { padding-top: 14px; }

/* ── Feature list ─────────────────────────────────────────────────────── */
.feature-list {
  list-style: none;
}
.feature-list li {
  padding: 10px 0; padding-left: 28px; position: relative;
  border-bottom: 1px solid var(--line); font-size: .94rem;
}
.feature-list li::before {
  content: '✅'; position: absolute; left: 0; top: 10px;
}
.feature-list li:last-child { border-bottom: none; }
.feature-list strong { color: var(--primary-dark); }

/* ── Footer ───────────────────────────────────────────────────────────── */
footer {
  color: rgba(255,255,255,.7); padding: 30px 32px;
  text-align: center; margin-top: 40px; font-size: .9rem;
}
footer a { color: #fbbf24; font-weight: 600; }
footer p { margin: 4px 0; }

/* ── Utilities ────────────────────────────────────────────────────────── */
.hidden { display: none !important; }
.fade-up { opacity: 0; transform: translateY(20px); animation: fadeUp .6s ease forwards; }
.fade-up:nth-child(1) { animation-delay: 0s; }
.fade-up:nth-child(2) { animation-delay: .1s; }
.fade-up:nth-child(3) { animation-delay: .2s; }
.fade-up:nth-child(4) { animation-delay: .3s; }
@keyframes fadeUp {
  to { opacity: 1; transform: translateY(0); }
}

/* ── Responsive ──────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .navbar { flex-direction: column; align-items: stretch; gap: 12px; padding: 14px 18px; }
  .logo { text-align: left; line-height: 1.25; }
  .nav-links { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .nav-links a { width: 100%; padding: 9px 10px; font-size: .86rem; }
  .page-header {
    padding: 34px 20px 42px;
    text-align: left;
    background: linear-gradient(150deg, #2563eb 0%, #1d4ed8 58%, #0891b2 100%);
  }
  .page-header h1 {
    font-size: clamp(1.8rem, 9vw, 2.35rem);
    max-width: 100%;
    word-break: break-word;
  }
  .page-header p {
    font-size: 1rem; max-width: 100%;
    word-break: break-word;
  }
  .wrap { width: min(100vw - 24px, 720px); padding: 20px 0 38px; }
  .pipeline {
    display: grid; grid-template-columns: 1fr;
    padding: 12px; gap: 8px; border-radius: 18px;
  }
  .pipe-step { padding: 6px 10px; font-size: .8rem; }
  .pipe-arrow { display: none; }
  .card { padding: 20px; margin: 14px 0; border-radius: 18px; }
  .section-head,
  .member-bar { flex-direction: column; align-items: stretch; }
  .ghost-btn,
  .member-bar button { width: 100%; }
  .result-actions > * {
    width: 100%;
  }
  .job-table-wrap {
    border: 0;
    overflow: visible;
  }
  .job-table {
    min-width: 0;
  }
  .job-table thead {
    display: none;
  }
  .job-table,
  .job-table tbody,
  .job-table tr,
  .job-table td {
    display: block;
    width: 100%;
  }
  .job-table tr {
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 12px;
    margin-bottom: 12px;
    background: #fff;
    box-shadow: var(--shadow-sm);
  }
  .job-table td {
    border: 0;
    padding: 6px 0;
  }
  .job-table td small {
    max-width: 100%;
    white-space: normal;
  }
  .table-actions {
    min-width: 0;
  }
}

@media (max-width: 520px) {
  .navbar { padding: 12px 14px; }
  .logo { font-size: 1.05rem; }
  .nav-links a { min-height: 42px; font-size: .82rem; }
  .page-header { padding: 30px 18px 40px; }
  .page-header h1 { font-size: clamp(1.72rem, 10vw, 2.1rem); }
  .page-header p { font-size: .98rem; }
  .wrap {
    width: calc(100vw - 24px);
    max-width: 420px;
    margin-left: auto;
    margin-right: auto;
  }
  .card { padding: 18px; }
  .public-stats-preview.card { padding: 18px; }
  .public-stats-preview .public-stats-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px;
  }
  .public-stats-preview .public-stat-card {
    min-height: 100px;
    padding: 12px;
  }
  .public-stats-preview .public-stat-card strong {
    font-size: 1.55rem;
  }
  .public-stats-preview .public-stats-panel {
    padding: 12px;
  }
  .public-stats-preview .public-stats-chart,
  .public-stats-preview .public-stats-donut-wrap {
    min-height: 190px;
  }
}
