:root {
  color-scheme: dark;
  --bg: #0b0b12;
  --surface: #15151f;
  --surface-2: #1c1c2b;
  --border: #2a2a3d;
  --text: #f2f2f7;
  --text-dim: #9797ab;
  --accent: #7c6cff;
  --accent-2: #ff6cab;
  --gradient: linear-gradient(135deg, var(--accent), var(--accent-2));
  --danger: #f87171;
  --success: #4ade80;
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Inter", -apple-system, "Segoe UI", Roboto, sans-serif;
  background:
    radial-gradient(ellipse 900px 500px at 15% -10%, rgba(124, 108, 255, 0.16), transparent),
    radial-gradient(ellipse 900px 500px at 90% 0%, rgba(255, 108, 171, 0.12), transparent),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
  animation: fadeIn 0.35s ease;
}

h1, h2, .brand, .brand-title {
  font-family: "Space Grotesk", "Inter", sans-serif;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

@keyframes modalPop {
  from { opacity: 0; transform: scale(0.94) translateY(6px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

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

.topbar {
  border-bottom: 1px solid var(--border);
  background: rgba(11, 11, 18, 0.7);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 5;
}

.topbar-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 1040px;
  margin: 0 auto;
  padding: 16px 24px;
}

.brand {
  font-weight: 700;
  font-size: 18px;
  letter-spacing: 0.02em;
  text-decoration: none;
  color: var(--text);
}

.brand span {
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 18px;
}

.nav-links a { color: var(--text-dim); text-decoration: none; transition: color 0.15s ease; }
.nav-links a:hover { color: var(--text); }

.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 32px 24px;
  animation: fadeInUp 0.4s ease;
}

.container-wide {
  max-width: 1040px;
}

.home-hero {
  text-align: center;
  padding-top: 12vh;
}

.brand-title {
  font-size: 46px;
  font-weight: 700;
  margin-bottom: 8px;
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  letter-spacing: -0.02em;
}

.url-form {
  display: flex;
  gap: 10px;
  margin-top: 28px;
  max-width: 560px;
  margin-left: auto;
  margin-right: auto;
}

.url-form input {
  flex: 1;
  padding: 14px 18px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.url-form input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(124, 108, 255, 0.2);
}

.cached-section {
  margin-top: 56px;
  text-align: left;
}

.cached-section h2 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 14px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.video-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.video-card {
  display: block;
  width: 100%;
  border: none;
  padding: 0;
  font: inherit;
  text-align: left;
  text-decoration: none;
  color: var(--text);
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.video-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.45);
}

.video-card img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  display: block;
  background: var(--surface-2);
}

.video-card-title {
  padding: 10px 12px 0;
  font-size: 13px;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.video-card-meta {
  padding: 4px 12px 10px;
  font-size: 12px;
  color: var(--text-dim);
}

@media (max-width: 560px) {
  .video-grid { grid-template-columns: 1fr; }
}

.center-box {
  max-width: 420px;
  margin: 15vh auto 0;
  text-align: center;
  padding: 32px;
  animation: fadeInUp 0.4s ease;
}

.hidden { display: none !important; }

.btn {
  display: inline-block;
  padding: 11px 20px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
  font-family: inherit;
  text-decoration: none;
  transition: transform 0.12s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.btn:hover { border-color: var(--accent); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary, .btn-discord {
  background: var(--gradient);
  border-color: transparent;
  color: white;
  font-weight: 600;
  box-shadow: 0 4px 16px rgba(124, 108, 255, 0.25);
}

.btn-primary:hover, .btn-discord:hover {
  box-shadow: 0 6px 20px rgba(124, 108, 255, 0.4);
}

.link-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 14px;
  font-family: inherit;
  transition: color 0.15s ease;
}

.link-btn:hover { color: var(--text); }

.error-banner {
  background: rgba(248, 113, 113, 0.12);
  border: 1px solid var(--danger);
  color: var(--danger);
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  margin-top: 16px;
  animation: fadeInUp 0.25s ease;
}

.video-info img {
  width: 100%;
  max-width: 480px;
  border-radius: var(--radius);
  display: block;
  margin-bottom: 16px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
}

.hint { color: var(--text-dim); font-size: 13px; }

.format-picker {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.format-select {
  flex: 1;
  padding: 12px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.format-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(124, 108, 255, 0.2);
}

.progress-section { margin-top: 28px; animation: fadeInUp 0.3s ease; }

.progress-track {
  width: 100%;
  height: 10px;
  background: var(--surface);
  border-radius: 6px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--accent), var(--accent-2), var(--accent));
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
  transition: width 0.3s ease;
}

#progress-status { color: var(--text-dim); font-size: 13px; margin-top: 8px; }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(5, 5, 10, 0.65);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.15s ease;
}

.modal-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  max-width: 420px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  animation: modalPop 0.2s ease;
}

.modal-content img {
  width: 100%;
  border-radius: var(--radius);
  margin-bottom: 12px;
}

.modal-actions {
  display: flex;
  gap: 12px;
  margin-top: 16px;
}

.history-row {
  display: grid;
  grid-template-columns: 1fr repeat(4, auto);
  gap: 12px;
  padding: 12px 4px;
  border-bottom: 1px solid var(--border);
  align-items: center;
  transition: background 0.15s ease;
  border-radius: 8px;
}

.history-row:hover { background: rgba(255, 255, 255, 0.02); }

.history-status { font-size: 12px; padding: 3px 10px; border-radius: 999px; text-align: center; }
.status-done { color: var(--success); background: rgba(74, 222, 128, 0.1); }
.status-error, .status-rejected_size { color: var(--danger); background: rgba(248, 113, 113, 0.1); }
.status-queued, .status-processing { color: var(--text-dim); background: rgba(255, 255, 255, 0.05); }

section { margin-bottom: 32px; }
section h2 { font-size: 16px; color: var(--text-dim); font-weight: 600; }

.admin-form {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.admin-form input {
  flex: 1;
  padding: 10px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
}

.admin-form input:focus {
  outline: none;
  border-color: var(--accent);
}
