/* ===== Reset ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ===== Theme Variables ===== */
:root {
  --bg: #f4f2ff;
  --bg-glass: rgba(255,255,255,0.65);
  --surface: #ffffff;
  --card: #ffffff;
  --card-shadow: 0 4px 32px rgba(99,102,241,0.10), 0 1px 4px rgba(0,0,0,0.04);
  --card-hover-shadow: 0 12px 48px rgba(99,102,241,0.18), 0 2px 8px rgba(0,0,0,0.06);
  --border: rgba(99,102,241,0.12);
  --border-strong: rgba(99,102,241,0.25);
  --text: #1e1b4b;
  --text-dim: #4338ca;
  --text-muted: #94a3b8;
  --input-bg: rgba(245,243,255,0.8);
  --accent-1: #6366f1;
  --accent-2: #a855f7;
  --accent-3: #ec4899;
  --gradient: linear-gradient(135deg, #6366f1 0%, #a855f7 50%, #ec4899 100%);
  --gradient-subtle: linear-gradient(135deg, rgba(99,102,241,0.08), rgba(168,85,247,0.08), rgba(236,72,153,0.08));
  --gradient-btn: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #a855f7 100%);
  --success: #10b981;
  --danger: #ef4444;
  --blob-1: rgba(99,102,241,0.18);
  --blob-2: rgba(236,72,153,0.14);
  --blob-3: rgba(168,85,247,0.12);
  --bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
  --spring: cubic-bezier(0.68, -0.3, 0.27, 1.3);
  --radius: 20px;
  --radius-sm: 14px;
  --radius-xs: 10px;
  color-scheme: light dark;
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c0a1d;
    --bg-glass: rgba(20,18,40,0.7);
    --surface: rgba(255,255,255,0.04);
    --card: rgba(255,255,255,0.06);
    --card-shadow: 0 4px 32px rgba(0,0,0,0.3), 0 0 0 1px rgba(255,255,255,0.04);
    --card-hover-shadow: 0 12px 48px rgba(99,102,241,0.15), 0 0 0 1px rgba(255,255,255,0.08);
    --border: rgba(255,255,255,0.08);
    --border-strong: rgba(255,255,255,0.15);
    --text: #eee8ff;
    --text-dim: #a5b4fc;
    --text-muted: #64748b;
    --input-bg: rgba(255,255,255,0.06);
    --blob-1: rgba(99,102,241,0.12);
    --blob-2: rgba(236,72,153,0.10);
    --blob-3: rgba(168,85,247,0.08);
  }
}
:root[data-theme="dark"] {
  --bg: #0c0a1d;
  --bg-glass: rgba(20,18,40,0.7);
  --surface: rgba(255,255,255,0.04);
  --card: rgba(255,255,255,0.06);
  --card-shadow: 0 4px 32px rgba(0,0,0,0.3), 0 0 0 1px rgba(255,255,255,0.04);
  --card-hover-shadow: 0 12px 48px rgba(99,102,241,0.15), 0 0 0 1px rgba(255,255,255,0.08);
  --border: rgba(255,255,255,0.08);
  --border-strong: rgba(255,255,255,0.15);
  --text: #eee8ff;
  --text-dim: #a5b4fc;
  --text-muted: #64748b;
  --input-bg: rgba(255,255,255,0.06);
  --blob-1: rgba(99,102,241,0.12);
  --blob-2: rgba(236,72,153,0.10);
  --blob-3: rgba(168,85,247,0.08);
}
:root[data-theme="light"] {
  --bg: #f4f2ff;
  --bg-glass: rgba(255,255,255,0.65);
  --surface: #ffffff;
  --card: #ffffff;
  --card-shadow: 0 4px 32px rgba(99,102,241,0.10), 0 1px 4px rgba(0,0,0,0.04);
  --card-hover-shadow: 0 12px 48px rgba(99,102,241,0.18), 0 2px 8px rgba(0,0,0,0.06);
  --border: rgba(99,102,241,0.12);
  --border-strong: rgba(99,102,241,0.25);
  --text: #1e1b4b;
  --text-dim: #4338ca;
  --text-muted: #94a3b8;
  --input-bg: rgba(245,243,255,0.8);
  --blob-1: rgba(99,102,241,0.18);
  --blob-2: rgba(236,72,153,0.14);
  --blob-3: rgba(168,85,247,0.12);
}

/* Theme toggle icon visibility */
.icon-moon { display: none; }
.icon-sun { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon-moon { display: block; }
  :root:not([data-theme="light"]) .icon-sun { display: none; }
}
[data-theme="dark"] .icon-moon { display: block; }
[data-theme="dark"] .icon-sun { display: none; }
[data-theme="light"] .icon-moon { display: none; }
[data-theme="light"] .icon-sun { display: block; }

/* ===== Base ===== */
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  transition: background 0.4s ease, color 0.3s ease;
}

.hidden { display: none !important; }

/* ===== Background Blobs ===== */
.bg-blobs {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}
.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(100px);
}
.blob-1 {
  width: 500px; height: 500px;
  background: var(--blob-1);
  top: -150px; right: -100px;
  animation: blobDrift 22s ease-in-out infinite;
}
.blob-2 {
  width: 400px; height: 400px;
  background: var(--blob-2);
  bottom: -100px; left: -80px;
  animation: blobDrift 26s ease-in-out infinite reverse;
}
.blob-3 {
  width: 350px; height: 350px;
  background: var(--blob-3);
  top: 40%; left: 50%;
  animation: blobDrift 20s ease-in-out infinite 5s;
}

/* ===== Bubbles ===== */
.bubbles {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}
.bubble {
  position: absolute;
  width: var(--s);
  height: var(--s);
  border-radius: 50%;
  background: var(--gradient);
  opacity: 0.12;
  left: var(--x);
  bottom: -30px;
  animation: bubbleFloat var(--dur) ease-in-out infinite;
  animation-delay: var(--d);
}

/* ===== Gradient Text ===== */
.gradient-text {
  background: var(--gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ===== Login ===== */
#login-screen {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card {
  background: var(--bg-glass);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--border);
  border-radius: 28px;
  padding: 56px 44px 48px;
  width: 100%;
  max-width: 400px;
  text-align: center;
  box-shadow: var(--card-shadow);
  animation: cardEnter 0.7s var(--bounce);
}

.login-logo {
  margin-bottom: 28px;
  display: flex;
  justify-content: center;
}
.logo-orb {
  width: 80px;
  height: 80px;
  border-radius: 24px;
  background: var(--gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  box-shadow: 0 8px 32px rgba(99,102,241,0.35);
  animation: logoFloat 3s ease-in-out infinite, logoPulse 3s ease-in-out infinite;
}

.login-card h1 {
  font-size: 32px;
  font-weight: 800;
  margin-bottom: 8px;
  letter-spacing: -0.5px;
}

.login-subtitle {
  color: var(--text-muted);
  font-size: 15px;
  margin-bottom: 36px;
}

#login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ===== Input Wrappers ===== */
.input-wrapper {
  position: relative;
}
.input-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  transition: color 0.2s;
}
.input-wrapper input {
  padding-left: 46px;
}
.input-wrapper:focus-within .input-icon {
  color: var(--accent-1);
}

input[type="password"],
input[type="url"] {
  background: var(--input-bg);
  backdrop-filter: blur(8px);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  outline: none;
  width: 100%;
  transition: border-color 0.3s, box-shadow 0.3s, transform 0.2s;
}
input:focus {
  border-color: var(--accent-1);
  box-shadow: 0 0 0 4px rgba(99,102,241,0.12), 0 0 24px rgba(99,102,241,0.08);
  transform: translateY(-1px);
}
input::placeholder { color: var(--text-muted); }

/* ===== Buttons ===== */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--gradient-btn);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 14px 28px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: transform 0.2s var(--bounce), box-shadow 0.3s;
}
.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 8px 24px rgba(99,102,241,0.3);
}
.btn-primary:active:not(:disabled) {
  transform: translateY(0) scale(0.98);
}
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-glow::after {
  content: '';
  position: absolute;
  top: -50%;
  left: -60%;
  width: 40%;
  height: 200%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
  transform: skewX(-20deg);
  animation: btnShine 4s ease-in-out infinite;
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: none;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  border-radius: var(--radius-xs);
  transition: all 0.2s;
}
.btn-ghost:hover { color: var(--text); background: var(--gradient-subtle); }

.btn-icon-round {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--bg-glass);
  backdrop-filter: blur(8px);
  color: var(--text-dim);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.25s var(--bounce);
}
.btn-icon-round:hover {
  transform: scale(1.1) rotate(15deg);
  border-color: var(--accent-1);
  box-shadow: 0 0 16px rgba(99,102,241,0.2);
}

.btn-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--gradient-subtle);
  color: var(--text-dim);
  border: 1.5px solid var(--border);
  border-radius: 24px;
  padding: 8px 16px;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.25s var(--bounce);
  white-space: nowrap;
}
.btn-pill:hover:not(:disabled) {
  transform: translateY(-2px) scale(1.05);
  border-color: var(--border-strong);
  box-shadow: 0 4px 16px rgba(99,102,241,0.12);
}
.btn-pill:active:not(:disabled) { transform: scale(0.95); }
.btn-pill:disabled { opacity: 0.3; cursor: not-allowed; }
.btn-pill.success {
  background: rgba(16,185,129,0.12);
  border-color: var(--success);
  color: var(--success);
}

.btn-pill.btn-copy { --c: #6366f1; }
.btn-pill.btn-txt { --c: #10b981; }
.btn-pill.btn-thumb { --c: #a855f7; }
.btn-pill.btn-toggle { --c: #f59e0b; }
.btn-pill.btn-copy:hover, .btn-pill.btn-txt:hover, .btn-pill.btn-thumb:hover, .btn-pill.btn-toggle:hover {
  border-color: var(--c);
  background: color-mix(in srgb, var(--c) 10%, transparent);
  color: var(--c);
}

.btn-remove {
  background: transparent;
  border: 1.5px solid transparent;
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.25s var(--bounce);
  flex-shrink: 0;
}
.btn-remove:hover {
  color: var(--danger);
  background: rgba(239,68,68,0.1);
  border-color: rgba(239,68,68,0.2);
  transform: scale(1.15) rotate(90deg);
}

.btn-batch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-glass);
  backdrop-filter: blur(8px);
  color: var(--text);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 22px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.25s var(--bounce);
}
.btn-batch:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(99,102,241,0.12);
  border-color: var(--border-strong);
}

/* ===== App Layout ===== */
#app-screen { position: relative; z-index: 1; padding: 0 24px; }

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 0;
  max-width: 860px;
  margin: 0 auto;
  animation: fadeInDown 0.5s var(--bounce);
}
.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}
.header-logo {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  box-shadow: 0 4px 16px rgba(99,102,241,0.25);
  animation: logoFloat 3s ease-in-out infinite;
}
.app-header h1 { font-size: 22px; font-weight: 800; letter-spacing: -0.3px; }
.header-right { display: flex; align-items: center; gap: 8px; }

.app-main {
  max-width: 860px;
  margin: 0 auto;
  padding-bottom: 120px;
}

/* ===== Input Section ===== */
.input-section {
  display: flex;
  gap: 14px;
  margin-bottom: 36px;
  animation: fadeInUp 0.5s var(--bounce) 0.15s both;
}
.input-wrapper-url { flex: 1; }

/* ===== Empty State ===== */
.empty-state {
  text-align: center;
  padding: 80px 20px;
  animation: fadeInUp 0.6s var(--bounce) 0.3s both;
}
.empty-icon {
  width: 96px;
  height: 96px;
  border-radius: 28px;
  background: var(--gradient-subtle);
  border: 2px dashed var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 24px;
  color: var(--text-muted);
  animation: emptyBounce 4s ease-in-out infinite;
}
.empty-state h2 {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}
.empty-state p {
  color: var(--text-muted);
  font-size: 15px;
}

/* ===== Video Cards ===== */
.video-list {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.video-card {
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--card-shadow);
  animation: cardEnter 0.5s var(--bounce);
  transition: box-shadow 0.3s, border-color 0.3s, transform 0.3s;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.video-card:hover {
  box-shadow: var(--card-hover-shadow);
  border-color: var(--border-strong);
  transform: translateY(-2px);
}

.card-header {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 18px 20px;
}

.card-thumb {
  width: 170px;
  height: 96px;
  border-radius: var(--radius-xs);
  overflow: hidden;
  flex-shrink: 0;
  background: var(--input-bg);
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
}
.card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.4s ease;
}
.video-card:hover .card-thumb img { transform: scale(1.06); }

.card-info { flex: 1; min-width: 0; }

.card-title {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-height: 1.4;
}

.card-status { font-size: 12px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
.card-status::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
}
.status-loading { color: var(--text-muted); }
.status-loading::before { background: var(--text-muted); animation: statusPulse 1.2s ease-in-out infinite; }
.status-ready { color: var(--success); }
.status-ready::before { background: var(--success); }
.status-error { color: var(--danger); }
.status-error::before { background: var(--danger); }

.card-actions {
  display: flex;
  gap: 8px;
  padding: 0 20px 16px;
  flex-wrap: wrap;
}

/* ===== Transcript Area ===== */
.card-transcript-wrapper {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.45s ease;
}
.card-transcript-wrapper.expanded { grid-template-rows: 1fr; }
.card-transcript { overflow: hidden; }

.card-transcript pre {
  padding: 20px;
  margin: 0;
  font-size: 13.5px;
  line-height: 1.8;
  color: var(--text-dim);
  white-space: pre-wrap;
  word-wrap: break-word;
  border-top: 1.5px solid var(--border);
  max-height: 420px;
  overflow-y: auto;
  font-family: inherit;
  background: var(--gradient-subtle);
}

.card-transcript .error-text {
  padding: 18px 20px;
  color: var(--danger);
  font-size: 13px;
  font-weight: 500;
  border-top: 1.5px solid var(--border);
  background: rgba(239,68,68,0.04);
}

/* ===== Skeleton ===== */
.skeleton {
  height: 64px;
  background: linear-gradient(90deg, var(--input-bg) 25%, var(--surface) 50%, var(--input-bg) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.6s ease-in-out infinite;
  border-radius: 8px;
  margin: 18px 20px;
}

/* ===== Batch Bar ===== */
.batch-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1.5px solid var(--border);
  padding: 18px 24px;
  display: flex;
  gap: 12px;
  justify-content: center;
  animation: slideUp 0.4s var(--bounce);
  z-index: 100;
}

/* ===== Toast ===== */
.toast-container {
  position: fixed;
  top: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 300;
  pointer-events: none;
}
.toast {
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 24px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  box-shadow: 0 8px 32px rgba(0,0,0,0.12);
  transform: translateX(130%) scale(0.8);
  transition: transform 0.4s var(--bounce);
  pointer-events: auto;
}
.toast.show { transform: translateX(0) scale(1); }
.toast-error { border-color: rgba(239,68,68,0.3); color: var(--danger); }
.toast-info { border-color: rgba(99,102,241,0.3); color: var(--accent-1); }

/* ===== Animations ===== */
@keyframes blobDrift {
  0%, 100% { transform: translate(0, 0) scale(1); }
  25% { transform: translate(40px, -30px) scale(1.05); }
  50% { transform: translate(-20px, 20px) scale(0.95); }
  75% { transform: translate(30px, 40px) scale(1.02); }
}

@keyframes bubbleFloat {
  0% { transform: translateY(0) scale(1) rotate(0deg); opacity: 0; }
  10% { opacity: 0.15; }
  90% { opacity: 0.08; }
  100% { transform: translateY(-100vh) scale(0.4) rotate(360deg); opacity: 0; }
}

@keyframes cardEnter {
  0% { opacity: 0; transform: translateY(30px) scale(0.95); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-16px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

@keyframes logoFloat {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-6px) rotate(2deg); }
}

@keyframes logoPulse {
  0%, 100% { box-shadow: 0 8px 32px rgba(99,102,241,0.35); }
  50% { box-shadow: 0 8px 48px rgba(99,102,241,0.55), 0 0 0 8px rgba(99,102,241,0.08); }
}

@keyframes emptyBounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

@keyframes statusPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.7); }
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

@keyframes btnShine {
  0%, 100% { left: -60%; }
  50% { left: 120%; }
}

.removing {
  animation: cardExit 0.35s ease forwards;
}
@keyframes cardExit {
  to { opacity: 0; transform: translateX(-40px) scale(0.95); }
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }

/* ===== Responsive ===== */
@media (max-width: 640px) {
  .card-header { flex-direction: column; align-items: stretch; }
  .card-thumb { width: 100%; height: auto; aspect-ratio: 16/9; }
  .input-section { flex-direction: column; }
  .batch-bar { flex-wrap: wrap; padding: 14px 16px; }
  .batch-bar .btn-primary, .batch-bar .btn-batch { flex: 1; min-width: 140px; }
  .login-card { padding: 40px 28px; }
  .blob-1 { width: 300px; height: 300px; }
  .blob-2 { width: 250px; height: 250px; }
  .blob-3 { width: 200px; height: 200px; }
}
