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

:root {
  --accent:            #78d028;
  --accent-glow:       rgba(120, 208, 40, 0.28);
  --accent-hover:      #8fe040;
  --body-bg:           #0d0d14;
  --surface:           #13131f;
  --surface-alt:       #1a1a2a;
  --body-color:        #e8e8f0;
  --header-bg:         rgba(13, 13, 20, 0.85);
  --header-border:     rgba(255, 255, 255, 0.08);
  --card-bg:           #16162a;
  --card-border:       rgba(255, 255, 255, 0.08);
  --card-hover-shadow: 0 12px 32px rgba(0, 0, 0, 0.50);
  --input-bg:          rgba(255, 255, 255, 0.06);
  --input-border:      rgba(255, 255, 255, 0.14);
  --input-focus-bg:    rgba(255, 255, 255, 0.10);
  --btn-ghost-bg:      rgba(255, 255, 255, 0.07);
  --btn-primary-bg:    rgba(255, 255, 255, 0.10);
  --btn-primary-color: #fff;
  --text-muted:        rgba(255, 255, 255, 0.45);
  --error-bg:          rgba(255, 70, 70, 0.12);
  --error-border:      rgba(255, 70, 70, 0.40);
  --radius:            14px;
  --radius-sm:         8px;
  --radius-xs:         6px;
  --font:              -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

/* ── Base ──────────────────────────────────────────────────────────────────── */
html { min-height: 100%; }

body {
  background: var(--body-bg);
  color: var(--body-color);
  font-family: var(--font);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ── Navbar ────────────────────────────────────────────────────────────────── */
.navbar {
  width: 100%;
  background: var(--header-bg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--header-border);
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.navbar-mascot {
  width: 34px;
  height: 34px;
  object-fit: contain;
}

.navbar-title {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.2px;
}

.navbar-title .green { color: var(--accent); }
.navbar-title .white { color: #fff; }

.navbar-sub {
  margin-left: auto;
  font-size: 0.75rem;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

/* ── Main layout ───────────────────────────────────────────────────────────── */
.page {
  width: 100%;
  max-width: 620px;
  padding: 44px 16px 80px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

/* ── Hero ──────────────────────────────────────────────────────────────────── */
.hero {
  text-align: center;
  padding: 8px 0;
}

.hero-mascot-wrap {
  display: inline-block;
  margin-bottom: 14px;
}

.hero-mascot {
  width: 120px;
  filter: drop-shadow(0 0 20px var(--accent-glow));
  transition: filter 0.35s;
}

.hero-mascot:hover {
  filter: drop-shadow(0 0 38px rgba(120, 208, 40, 0.50));
}

.hero h1 {
  font-size: 1.85rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  margin-bottom: 8px;
  line-height: 1.2;
  color: #fff;
}

.hero h1 .green { color: var(--accent); }

.hero p {
  color: var(--text-muted);
  font-size: 0.88rem;
}

/* ── Dark card ─────────────────────────────────────────────────────────────── */
.card {
  width: 100%;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 20px;
  transition: box-shadow 0.2s;
}

.card:hover {
  box-shadow: var(--card-hover-shadow);
}

/* ── URL Input ─────────────────────────────────────────────────────────────── */
.input-row {
  display: flex;
  gap: 10px;
}

#url-input {
  flex: 1;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: var(--radius-xs);
  color: #fff;
  font-family: var(--font);
  font-size: 0.92rem;
  padding: 11px 14px;
  outline: none;
  transition: background 0.2s, border-color 0.2s;
}

#url-input:focus {
  background: var(--input-focus-bg);
  border-color: var(--accent);
}

#url-input::placeholder { color: rgba(255,255,255,0.28); }

/* ── Buttons ───────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: none;
  border-radius: var(--radius-xs);
  cursor: pointer;
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 11px 18px;
  transition: background 0.18s, opacity 0.18s, box-shadow 0.18s;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.40;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--btn-primary-bg);
  color: var(--btn-primary-color);
  border: 1px solid rgba(255,255,255,0.14);
}

.btn-primary:hover:not(:disabled) {
  background: rgba(255,255,255,0.15);
  box-shadow: 0 4px 14px rgba(0,0,0,0.3);
}

.btn-download {
  background: var(--accent);
  color: #0d0d14;
  width: 100%;
  padding: 13px;
  font-size: 0.95rem;
  font-weight: 700;
  margin-top: 18px;
  border-radius: var(--radius-sm);
  box-shadow: 0 4px 16px var(--accent-glow);
}

.btn-download:hover:not(:disabled) {
  background: var(--accent-hover);
  box-shadow: 0 6px 24px rgba(120, 208, 40, 0.42);
}

/* ── Error ─────────────────────────────────────────────────────────────────── */
.error {
  margin-top: 10px;
  padding: 9px 13px;
  background: var(--error-bg);
  border: 1px solid var(--error-border);
  border-radius: var(--radius-xs);
  color: #ff9999;
  font-size: 0.85rem;
}

/* ── Video info ────────────────────────────────────────────────────────────── */
.video-info {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 18px;
}

#thumbnail {
  width: 116px;
  height: 66px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  background: var(--surface-alt);
}

.video-meta { min-width: 0; }

.video-title {
  font-weight: 600;
  font-size: 0.93rem;
  line-height: 1.4;
  color: #fff;
  margin-bottom: 5px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.video-uploader,
.video-duration {
  color: var(--text-muted);
  font-size: 0.80rem;
  margin-top: 2px;
}

/* ── Options row ───────────────────────────────────────────────────────────── */
.options-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.format-toggle {
  display: flex;
  gap: 6px;
}

.toggle-label {
  display: flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  font-size: 0.86rem;
  color: var(--text-muted);
  background: var(--btn-ghost-bg);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius-xs);
  padding: 6px 12px;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  user-select: none;
}

.toggle-label:has(input:checked) {
  color: var(--accent);
  background: rgba(120, 208, 40, 0.10);
  border-color: rgba(120, 208, 40, 0.40);
}

.toggle-label input[type="radio"] {
  accent-color: var(--accent);
  cursor: pointer;
}

.quality-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.quality-wrapper label {
  font-size: 0.82rem;
  color: var(--text-muted);
}

#quality-select {
  background: var(--surface-alt);
  border: 1px solid var(--input-border);
  border-radius: var(--radius-xs);
  color: #fff;
  font-family: var(--font);
  font-size: 0.85rem;
  padding: 6px 10px;
  outline: none;
  cursor: pointer;
}

#quality-select:focus { border-color: var(--accent); }
#quality-select option { background: #1a1a2a; }

/* ── Spinner ───────────────────────────────────────────────────────────────── */
.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,0.2);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
  flex-shrink: 0;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Utility ───────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }
