:root {
  --bg: #0a0a0a;
  --surface: #141414;
  --surface2: #1f1f1f;
  --border: #2a2a2a;
  --text: #f5f5f5;
  --text-muted: #999;
  --red: #ff0033;
  --red-dim: #cc0029;
  --green: #22c55e;
  --radius: 12px;
}

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

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }

/* ─── Nav ─── */
.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 2rem;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: rgba(10, 10, 10, 0.9);
  backdrop-filter: blur(8px);
  z-index: 50;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 1.1rem;
}

.nav-logo {
  background: var(--red);
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
}

.nav-links { display: flex; gap: 1.5rem; align-items: center; }
.nav-links a { color: var(--text-muted); font-size: 0.9rem; }
.nav-links a:hover { color: var(--text); }

.badge-free {
  background: rgba(34, 197, 94, 0.15);
  color: var(--green);
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
}

/* ─── Hero ─── */
.hero {
  text-align: center;
  padding: 4rem 1.5rem 3rem;
  max-width: 720px;
  margin: 0 auto;
}

.hero-badge {
  display: inline-block;
  background: rgba(255, 0, 51, 0.1);
  color: var(--red);
  padding: 0.4rem 1rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 1.5rem;
}

.hero h1 {
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 800;
  line-height: 1.15;
  margin-bottom: 1rem;
}

.hero h1 span { color: var(--red); }

.hero p {
  color: var(--text-muted);
  font-size: 1.1rem;
  max-width: 540px;
  margin: 0 auto 2rem;
}

/* ─── Tool grid ─── */
.section {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

.section h2 {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
}

.section-sub {
  color: var(--text-muted);
  margin-bottom: 2rem;
}

.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
}

.tool-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  transition: border-color 0.2s, transform 0.2s;
  display: block;
}

.tool-card:hover {
  border-color: #444;
  transform: translateY(-2px);
}

.tool-icon {
  width: 44px;
  height: 44px;
  background: var(--surface2);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  margin-bottom: 1rem;
}

.tool-card h3 { font-size: 1rem; margin-bottom: 0.5rem; }
.tool-card p { color: var(--text-muted); font-size: 0.875rem; line-height: 1.5; }

.tool-badge {
  display: inline-block;
  margin-top: 0.75rem;
  font-size: 0.75rem;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-weight: 600;
}

.tool-badge.free { background: rgba(34,197,94,0.15); color: var(--green); }
.tool-badge.api { background: rgba(255,0,51,0.1); color: var(--red); }

/* ─── Features row ─── */
.features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.5rem;
  max-width: 900px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
  text-align: center;
}

.feature h3 { font-size: 0.95rem; margin-bottom: 0.4rem; }
.feature p { color: var(--text-muted); font-size: 0.85rem; }

/* ─── Tool page ─── */
.tool-page {
  max-width: 800px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

.tool-page-header { margin-bottom: 2rem; }

.tool-page-header a.back {
  color: var(--text-muted);
  font-size: 0.9rem;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin-bottom: 1rem;
}

.tool-page-header a.back:hover { color: var(--text); }
.tool-page-header h1 { font-size: 1.6rem; margin-bottom: 0.5rem; }
.tool-page-header p { color: var(--text-muted); }

.search-box {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

input[type="text"], textarea, select {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  font-size: 0.95rem;
  font-family: inherit;
  width: 100%;
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: #555;
}

textarea { resize: vertical; }

.btn {
  padding: 0.75rem 1.25rem;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
  transition: background 0.15s;
}

.btn-primary { background: var(--red); color: #fff; }
.btn-primary:hover { background: var(--red-dim); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 0.5rem 0.9rem;
  font-size: 0.85rem;
}

.btn-secondary:hover { background: #2a2a2a; }

.btn-copy {
  background: transparent;
  color: var(--green);
  border: 1px solid var(--green);
  padding: 0.3rem 0.7rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.8rem;
}

.field-group { margin-top: 1.25rem; }
.field-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.4rem;
}
.field-header label {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.thumb-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.thumb-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.thumb-card img { width: 100%; display: block; aspect-ratio: 16/9; object-fit: cover; }
.thumb-card .thumb-info { padding: 0.6rem; }
.thumb-card .quality { font-size: 0.75rem; color: var(--text-muted); margin-bottom: 0.4rem; }

.video-list { display: flex; flex-direction: column; gap: 0.75rem; }

.video-card {
  display: flex;
  gap: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem;
  cursor: pointer;
  transition: border-color 0.15s;
}

.video-card:hover { border-color: #444; }
.video-card img { width: 120px; height: 68px; object-fit: cover; border-radius: 6px; flex-shrink: 0; }
.video-card .title { font-size: 0.9rem; font-weight: 600; }
.video-card .channel, .video-card .stats { font-size: 0.8rem; color: var(--text-muted); }

.shorts-grid .video-card img { width: 72px; height: 108px; }

.toolbar { display: flex; gap: 1rem; align-items: flex-end; flex-wrap: wrap; margin-bottom: 1rem; }
.toolbar label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.85rem; color: var(--text-muted); }
.toolbar select { width: auto; min-width: 150px; }

.error {
  background: rgba(255, 0, 51, 0.1);
  border: 1px solid var(--red);
  color: #ff6b6b;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin-top: 1rem;
  font-size: 0.9rem;
}

.loading { color: var(--text-muted); margin-top: 1rem; font-size: 0.9rem; }
.hidden { display: none !important; }

footer {
  text-align: center;
  padding: 2rem;
  color: var(--text-muted);
  font-size: 0.8rem;
  border-top: 1px solid var(--border);
}

.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--green);
  color: #000;
  padding: 0.6rem 1.5rem;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.9rem;
  z-index: 300;
}

/* ─── API Key Modal ─── */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 1rem;
}

.overlay-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  max-width: 420px;
  width: 100%;
}

.overlay-card h2 { font-size: 1.15rem; margin-bottom: 0.5rem; }
.overlay-card .feature-name { color: var(--red); font-weight: 600; }
.overlay-card p { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 1rem; }
.overlay-card input { margin-bottom: 0.75rem; }
.overlay-card .hint { font-size: 0.8rem; margin-top: 1rem; }
.overlay-card .hint a { color: var(--red); }
.full-width { width: 100%; }

.modal-actions { display: flex; gap: 0.5rem; margin-top: 0.5rem; }
.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  cursor: pointer;
  flex: 1;
}

@media (max-width: 600px) {
  .nav { padding: 1rem; }
  .nav-links { display: none; }
  .search-box { flex-direction: column; }
  .video-card img { width: 90px; height: 50px; }
}
