*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #0f0f13; --card: #1a1a24; --border: #2a2a3a;
  --text: #e2e8f0; --muted: #c4cdd6;
}
html.light {
  --bg: #f5f5f7; --card: #ffffff; --border: #e0e0e8;
  --text: #1a1a2e; --muted: #4b5563;
}
/* Theme toggle button */
html.light {
  --bg: #f5f5f7; --card: #ffffff; --border: #e0e0e8;
  --text: #1a1a2e; --muted: #4b5563;
}
body { background: var(--bg); color: var(--text); font-family: 'Segoe UI', 'Noto Sans Devanagari', system-ui, sans-serif; min-height: 100vh; display: flex; flex-direction: column; }

header { background: rgba(26,26,36,0.95); border-bottom: 1px solid var(--border); backdrop-filter: blur(10px); position: sticky; top: 0; z-index: 100; }
html.light header { background: rgba(255,255,255,0.95); }
.nav-top { padding: 0.6rem 1rem; display: flex; align-items: center; gap: 0.4rem; max-width: 1100px; margin: 0 auto; width: 100%; }
.nav-actions { margin-left: auto; display: flex; align-items: center; gap: 0.3rem; flex-shrink: 0; }
.nav-top-right { display: flex; align-items: center; gap: 0.3rem; }
.logo { font-size: 1.1rem; font-weight: 800; background: linear-gradient(135deg,#7c3aed,#06b6d4); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; text-decoration: none; white-space: nowrap; }
.nav-platforms { display: flex; gap: 0; border-top: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; -ms-overflow-style: none; justify-content: center; min-width: 0; }
.nav-platforms::-webkit-scrollbar { display: none; }
@media (max-width: 600px) { .nav-platforms { justify-content: flex-start; } }
.nav-link { display: flex; align-items: center; gap: 0.4rem; padding: 0.7rem 1.3rem; font-size: 0.85rem; font-weight: 600; color: #b0bec5; text-decoration: none; white-space: nowrap; border-bottom: 2px solid transparent; transition: opacity 0.2s; }
.nav-link:hover { opacity: 0.8; background: rgba(255,255,255,0.04); }
/* Active nav: use white text in dark mode for sufficient contrast */
.nav-link.active { color: #fff; border-bottom-color: var(--p-color); font-weight: 700; }

main { flex: 1; max-width: 1100px; width: 100%; margin: 0 auto; padding: 2rem 1rem; contain: layout style; }

.dl-header { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.5rem; }
.dl-header .p-icon { display: none; }
.dl-header h1 { font-size: 1.5rem; font-weight: 700; line-height: 1.3; }
.dl-header p { font-size: 0.85rem; color: var(--muted); margin-top: 0.2rem; }

/* ── Mobile h1/h2 ── */
@media (max-width: 480px) {
  .dl-header h1 { font-size: 1.2rem; }
  .dl-header { gap: 0.5rem; margin-bottom: 1rem; }
  .seo-section h2 { font-size: 0.95rem; }
  main { padding: 1rem 0.75rem; }
}
@media (max-width: 360px) {
  .dl-header h1 { font-size: 1.05rem; }
}
.p-badge { padding: 0.2rem 0.75rem; border-radius: 999px; font-size: 0.72rem; font-weight: 700; background: color-mix(in srgb, var(--p-color) 18%, transparent); color: var(--p-color); border: 1px solid color-mix(in srgb, var(--p-color) 35%, transparent); }

.nav-link .nav-icon { width: 20px; height: 20px; object-fit: contain; }

/* URL input */
.input-card { background: transparent; border: none; border-radius: 0; padding: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.input-card input {
  width: 100%;
  background: var(--bg);
  border: 2px solid color-mix(in srgb, var(--p-color) 40%, transparent);
  border-radius: 12px;
  padding: 1.1rem 1.2rem;
  color: var(--text);
  font-size: 1.05rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  -webkit-appearance: none;
  appearance: none;
}
.input-card input:focus {
  border-color: var(--p-color);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--p-color) 22%, transparent);
}
.url-input-focus {
  border-color: var(--p-color) !important;
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--p-color) 22%, transparent) !important;
}
.input-card input::placeholder { color: var(--muted); font-size: 0.9rem; }
@media (max-width: 480px) {
  .input-card { padding: 0.9rem; border-radius: 14px; }
  .input-card input { font-size: 0.95rem; padding: 0.85rem 0.9rem; }
}
.input-card .btn-primary { width: 100%; }
.btn-row { display: flex; gap: 0.5rem; align-items: stretch; }
.btn-row .btn-primary { flex: 1; width: auto; }
.btn { padding: 0.75rem 1.4rem; border-radius: 10px; border: none; cursor: pointer; font-weight: 600; font-size: 0.9rem; transition: opacity 0.2s, transform 0.2s; white-space: nowrap; }
.btn-primary { background: linear-gradient(135deg, var(--p-color), var(--p-dark, #5b1fa8)); color: #fff; }
.btn-primary:hover { opacity: 0.88; transform: translateY(-1px); }
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.error-msg { background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.3); color: #fca5a5; border-radius: 10px; padding: 0.75rem 1rem; font-size: 0.88rem; display: none; margin-top: 0.75rem; }

/* Preview card */
#preview { display: none; margin-top: 1.2rem; background: var(--card); border: 1px solid var(--border); border-radius: 16px; overflow: hidden; }

.thumb-wrap { position: relative; width: 100%; aspect-ratio: 16/9; background: #111; }
.thumb-wrap img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb-wrap .duration-badge { position: absolute; bottom: 8px; right: 8px; background: rgba(0,0,0,0.8); color: #fff; font-size: 0.78rem; font-weight: 600; padding: 0.2rem 0.5rem; border-radius: 6px; }

.video-info { padding: 1rem 1.2rem; }
.video-title { font-size: 1rem; font-weight: 700; line-height: 1.4; margin-bottom: 0.3rem; }
.video-meta { font-size: 0.8rem; color: var(--muted); }

.download-btns { display: flex; gap: 0.75rem; padding: 0 1.2rem 1.2rem; flex-wrap: wrap; }
.btn-dl { flex: 1; min-width: 140px; padding: 0.85rem 1rem; border-radius: 12px; border: none; cursor: pointer; font-weight: 700; font-size: 0.9rem; transition: opacity 0.2s, transform 0.2s; display: flex; align-items: center; justify-content: center; gap: 0.5rem; }
.btn-dl-video { background: linear-gradient(135deg, var(--p-color), var(--p-dark, #5b1fa8)); color: #fff; }
.btn-dl-video:hover { opacity: 0.88; transform: translateY(-1px); }
.btn-dl-mp3 { background: var(--bg); border: 1px solid var(--border); color: var(--text); }
.btn-dl-mp3:hover { opacity: 0.75; }
.btn-dl:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

/* Progress */
#progress-section { display: none; padding: 0 1.2rem 1.2rem; }
.progress-bar-wrap { background: var(--bg); border-radius: 999px; height: 8px; overflow: hidden; margin: 0.5rem 0; }
.progress-bar { height: 100%; background: linear-gradient(90deg, var(--p-color), #06b6d4); border-radius: 999px; transition: width 0.3s; width: 0%; }
.progress-label { display: flex; justify-content: space-between; font-size: 0.82rem; color: var(--muted); }

.tips-box { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 1rem 1.2rem; margin-top: 1rem; font-size: 0.83rem; color: var(--muted); line-height: 1.7; }
.tips-box strong { color: var(--text); }

@media (max-width: 480px) {
  .download-btns { flex-direction: column; }
  .btn-dl { min-width: unset; }
  .nav-top { padding: 0.9rem 1rem; }
  .btn { padding: 0.85rem 1rem; font-size: 0.88rem; }
  .btn-primary { border-radius: 12px; }
}

/* FOOTER */
footer { margin-top: auto; padding: 2rem 1rem; text-align: center; border-top: 1px solid var(--border); }
.footer-links { display: flex; gap: 1.5rem; justify-content: center; flex-wrap: wrap; margin-bottom: 0.75rem; }
.footer-links a { color: var(--muted); text-decoration: none; font-size: 0.82rem; transition: opacity 0.2s; }
.footer-links a:hover { opacity: 0.7; }
.footer-copy { color: var(--muted); font-size: 0.78rem; }

/* LEGAL PAGES */
.legal-content { max-width: 720px; margin: 0 auto; padding: 2rem 1rem; contain: layout; }
.legal-content h1 { font-size: 1.8rem; font-weight: 800; margin-bottom: 0.4rem; }
.legal-content .last-updated { color: var(--muted); font-size: 0.85rem; margin-bottom: 2rem; }
.legal-content h2 { font-size: 1.1rem; font-weight: 700; margin: 1.8rem 0 0.6rem; color: var(--text); }
.legal-content p, .legal-content li { color: var(--muted); font-size: 0.9rem; line-height: 1.8; }
.legal-content ul { padding-left: 1.4rem; margin-top: 0.4rem; }
.legal-content a { color: #93c5fd; text-decoration: underline; }
html.light .legal-content a { color: #1d4ed8; }
.legal-content .highlight-box { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 1rem 1.2rem; margin: 1rem 0; }

/* PWA Install Button */
#install-btn { display: inline-flex; align-items: center; gap: 0.2rem; background: linear-gradient(135deg,#7c3aed,#06b6d4); color: #fff; border: none; padding: 0.32rem 0.55rem; border-radius: 7px; font-size: 0.72rem; font-weight: 600; cursor: pointer; transition: opacity 0.2s; white-space: nowrap; flex-shrink: 0; }
#install-btn:hover { opacity: 0.88; }

/* Theme toggle */
#theme-btn { display: inline-flex !important; align-items: center; background: var(--card); border: 1px solid var(--border); color: var(--text); padding: 0.32rem 0.4rem; border-radius: 7px; cursor: pointer; font-size: 0.75rem; transition: opacity 0.2s; white-space: nowrap; flex-shrink: 0; min-width: 58px; justify-content: center; }
#theme-btn:hover { opacity: 0.75; }
@media (max-width: 480px) { .nav-top { padding: 0.5rem 0.6rem; } }

/* Light theme fixes */
html.light header { background: rgba(245,245,247,0.95); }
html.light .nav-link:hover { background: rgba(0,0,0,0.04); }
html.light .input-card input { background: #f0f0f5; }
html.light .progress-bar-wrap { background: #e0e0e8; }
html.light .seo-keywords .kw { background: color-mix(in srgb, var(--p-color) 10%, #fff); }
html.light .error-msg { background: rgba(239,68,68,0.08); }
html.light #ios-install-banner { background: #fff; }

/* Keywords / SEO section */
.seo-keywords { padding: 0.5rem 0; margin-top: 0.5rem; display: flex; flex-wrap: wrap; gap: 0.4rem; }
.seo-keywords .kw {
  display: inline-block; padding: 0.3rem 0.75rem;
  background: color-mix(in srgb, var(--p-color) 12%, transparent);
  color: color-mix(in srgb, var(--p-color) 80%, var(--text));
  border: 1px solid color-mix(in srgb, var(--p-color) 25%, transparent);
  border-radius: 999px; font-size: 0.75rem; font-weight: 500;
  cursor: default; transition: opacity 0.15s;
}
.seo-keywords .kw:hover {
  opacity: 0.75;
}

/* Stable layout — no layout shift */
.video-title { font-size: 1rem; font-weight: 700; line-height: 1.4; margin-bottom: 0.3rem; word-break: break-word; overflow-wrap: anywhere; }
.video-meta { font-size: 0.78rem; color: var(--muted); line-height: 1.8; min-height: 1.2em; flex-wrap: wrap; }
.thumb-wrap img { min-height: 60px; background: #1a1a24; }

/* Error toast — fixed bottom, doesn't break layout */
.error-msg {
  position: fixed !important; bottom: 1.5rem; left: 50%; transform: translateX(-50%);
  background: rgba(220,38,38,0.97) !important; color: #fff !important;
  border: none !important; border-radius: 10px; padding: 0.75rem 1.4rem;
  font-size: 0.88rem; display: none; z-index: 9999;
  max-width: 90vw; text-align: center;
  box-shadow: 0 4px 24px rgba(0,0,0,0.5);
  animation: slideup 0.2s ease;
  margin: 0 !important;
}
@keyframes slideup {
  from { opacity:0; transform: translateX(-50%) translateY(10px); }
  to   { opacity:1; transform: translateX(-50%) translateY(0); }
}

/* Progress section always same height */
#progress-section { min-height: 52px; }
.download-btns { min-height: 56px; }

/* Copy title button */
.copy-btn {
  display: inline-flex; align-items: center; gap: 0.3rem;
  background: none; border: 1px solid var(--border);
  color: var(--muted); border-radius: 6px;
  padding: 0.2rem 0.6rem; font-size: 0.75rem;
  cursor: pointer; transition: opacity 0.2s; margin-left: 0.5rem;
  vertical-align: middle;
}
.copy-btn:hover { opacity: 0.7; }
.copy-btn.copied { border-color: #10b981; color: #10b981; }

/* iOS install banner */
#ios-install-banner {
  display: none;
  position: fixed; bottom: 1.5rem; left: 50%; transform: translateX(-50%);
  background: var(--card); border: 1px solid var(--border);
  border-radius: 14px; padding: 0.9rem 1.2rem;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  z-index: 9998; width: 90vw; max-width: 360px;
  text-align: center; font-size: 0.85rem; color: var(--text);
}
#ios-install-banner .ios-close {
  position: absolute; top: 0.5rem; right: 0.75rem;
  background: none; border: none; color: var(--muted);
  font-size: 1.1rem; cursor: pointer;
}
#ios-install-banner .ios-icon { font-size: 1.5rem; margin-bottom: 0.3rem; }
#ios-install-banner p { color: var(--muted); font-size: 0.8rem; margin-top: 0.3rem; line-height: 1.5; }

#vid-desc { display: none; font-size: 0.78rem; color: var(--muted); margin-top: 0.4rem; line-height: 1.6; word-break: break-word; }

/* ── SEO Content Sections ── */
.features-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  margin: 1.5rem 0 0.75rem;
  text-align: center;
}
.features-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-top: 1.5rem;
}
@media (max-width: 640px) {
  .features-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 360px) {
  .features-grid { grid-template-columns: 1fr 1fr; gap: 0.6rem; }
}
.feature-item {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 14px; padding: 1.2rem 0.8rem; text-align: center;
  transition: border-color 0.2s, transform 0.15s;
}
.feature-item:hover { border-color: var(--p-color); transform: translateY(-2px); }
.feature-item .f-icon { font-size: 2rem; margin-bottom: 0.5rem; display: block; }
.feature-item .f-title { font-size: 0.88rem; font-weight: 700; color: var(--text); margin-bottom: 0.3rem; }
.feature-item .f-desc { font-size: 0.75rem; color: var(--muted); line-height: 1.5; }

.how-steps { display: flex; gap: 1rem; margin-top: 1rem; flex-wrap: wrap; }
.step {
  flex: 1; min-width: 160px; display: flex; gap: 0.75rem;
  align-items: flex-start; background: var(--card);
  border: 1px solid var(--border); border-radius: 12px; padding: 1rem;
}
.step-num {
  width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
  background: var(--p-color); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.8rem; font-weight: 800;
}
.step-text .st { font-size: 0.82rem; font-weight: 700; color: var(--text); }
.step-text .sd { font-size: 0.75rem; color: var(--muted); margin-top: 0.2rem; }

.seo-section { margin-top: 2rem; }
.seo-section h2 { font-size: 1.1rem; font-weight: 800; margin-bottom: 0.6rem; color: var(--text); }
.seo-section p { font-size: 0.85rem; color: var(--muted); line-height: 1.8; }
.seo-section p a { color: #93c5fd; text-decoration: underline; }
html.light .seo-section p a { color: #1d4ed8; }

.faq-list { margin-top: 0.75rem; display: flex; flex-direction: column; gap: 0.5rem; }
.faq-item {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 10px; overflow: hidden;
}
.faq-q {
  width: 100%; text-align: left; background: none; border: none;
  color: var(--text); font-size: 0.88rem; font-weight: 600;
  padding: 0.9rem 1rem; cursor: pointer; display: flex;
  justify-content: space-between; align-items: center;
  transition: opacity 0.2s;
}
.faq-q:hover { opacity: 0.75; }
.faq-q .arrow { transition: transform 0.2s; font-size: 0.75rem; color: var(--muted); }
.faq-q.open .arrow { transform: rotate(180deg); }
.faq-a { display: none; padding: 0 1rem 0.9rem; font-size: 0.82rem; color: var(--muted); line-height: 1.7; }
.faq-a.open { display: block; }

/* Remove old keyword badges */
.seo-keywords { display: none !important; }
/* Light theme fixes */
html.light .faq-item { background: var(--card); }
html.light .step { background: var(--card); }
html.light .feature-item { background: var(--card); }
html.light .input-card { background: var(--card); }
html.light #preview { background: var(--card); }
html.light .tips-box { background: var(--card); }
html.light .ios-install-banner { background: var(--card); }
html.light .error-msg { background: rgba(239,68,68,0.08); }

/* ── Language Selector ── */
.lang-selector { position: relative; margin-left: 0.2rem; }
.lang-btn {
  display: inline-flex; align-items: center; gap: 0.2rem;
  background: var(--card); border: 1px solid var(--border);
  color: var(--text); padding: 0.32rem 0.55rem; border-radius: 7px;
  font-size: 0.85rem; font-weight: 600; cursor: pointer;
  transition: opacity 0.2s; white-space: nowrap;
  min-width: unset;
}
.lang-btn:hover { opacity: 0.75; }
.lang-dropdown {
  display: none; position: absolute; top: calc(100% + 6px); right: 0;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 12px; min-width: 200px; z-index: 999;
  box-shadow: 0 8px 32px rgba(0,0,0,0.3); overflow: hidden;
  max-height: 320px; overflow-y: auto;
}
.lang-dropdown.open { display: block; }
.lang-option {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.6rem 1rem; cursor: pointer; font-size: 0.85rem;
  color: var(--text); transition: opacity 0.15s;
  text-decoration: none;
}
.lang-option:hover { opacity: 0.7; }
.lang-option.active { color: var(--p-color, #7c3aed); font-weight: 700; }
.lang-option .flag { font-size: 1.1rem; line-height: 1; }
.flag-img { width: 20px; height: 15px; object-fit: cover; border-radius: 2px; flex-shrink: 0; }
/* Country code badge - no external image request */
.lang-cc {
  display: inline-block; font-size: 0.65rem; font-weight: 800; letter-spacing: 0.02em;
  background: rgba(255,255,255,0.15); color: inherit;
  border-radius: 3px; padding: 1px 4px; margin-right: 2px;
  vertical-align: middle; line-height: 1.4;
}
html.light .lang-cc { background: rgba(0,0,0,0.1); }

/* ── RTL Support (Arabic, Urdu) ── */
[dir="rtl"] .nav-top { flex-direction: row-reverse; }
[dir="rtl"] .nav-top > *:first-child { margin-left: auto; margin-right: 0; }
[dir="rtl"] .nav-link { flex-direction: row-reverse; }
[dir="rtl"] .dl-header { flex-direction: row-reverse; }
[dir="rtl"] .input-card input { text-align: right; }
[dir="rtl"] .video-info { text-align: right; }
[dir="rtl"] .video-meta { text-align: right; }
[dir="rtl"] .progress-label { flex-direction: row-reverse; }
[dir="rtl"] .download-btns { flex-direction: row-reverse; }
[dir="rtl"] .features-grid { direction: rtl; }
[dir="rtl"] .feature-item { text-align: right; }
[dir="rtl"] .how-steps { flex-direction: row-reverse; }
[dir="rtl"] .step { flex-direction: row-reverse; text-align: right; }
[dir="rtl"] .step-text { text-align: right; }
[dir="rtl"] .seo-section { text-align: right; }
[dir="rtl"] .seo-section h2 { text-align: right; }
[dir="rtl"] .faq-q { flex-direction: row-reverse; text-align: right; }
[dir="rtl"] .faq-a { text-align: right; }
[dir="rtl"] .footer-links { flex-direction: row-reverse; }
[dir="rtl"] .lang-dropdown { right: auto; left: 0; }
[dir="rtl"] .lang-option { flex-direction: row-reverse; }
[dir="rtl"] .copy-btn { margin-left: 0; margin-right: 0.5rem; }
[dir="rtl"] .legal-content ul { padding-left: 0; padding-right: 1.4rem; }
[dir="rtl"] .nav-platforms { flex-direction: row-reverse; }

/* ── URL Button Row ── */
.url-btn-row {
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
  margin-top: 0.5rem;
  flex-wrap: nowrap;
  width: 100%;
}
.url-btn-row .btn-primary {
  flex: 1;
  min-width: 0;
  padding: 0.85rem 1rem;
  font-size: 0.95rem;
  border-radius: 12px;
  white-space: nowrap;
}
@media (max-width: 480px) {
  .url-btn-row { gap: 0.4rem; }
  .url-btn-row .btn-primary { font-size: 0.88rem; padding: 0.8rem 0.75rem; }
}
.btn-paste, .btn-clear {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.3rem;
  background: var(--border);
  border: 1px solid var(--border);
  color: var(--text); padding: 0.85rem 0; border-radius: 12px;
  font-size: 0.88rem; font-weight: 600; cursor: pointer;
  transition: opacity 0.2s; white-space: nowrap; flex-shrink: 0;
  min-width: 80px;
}
.btn-paste:hover { opacity: 0.75; }
.btn-clear {
  color: #ef4444; border-color: rgba(239,68,68,0.4);
  background: rgba(239,68,68,0.08);
  min-width: 80px;
}
.btn-clear:hover { opacity: 0.75; }
.btn-row { display: flex; gap: 0.5rem; align-items: stretch; flex-wrap: nowrap; }
.btn-row .btn-primary { flex: 1; width: auto; min-width: 0; }
@media (max-width: 480px) {
  .btn-paste { font-size: 0.78rem; padding: 0.8rem 0.65rem; }
  .btn-clear { padding: 0.8rem 0.65rem; }
}

/* ── Internal Tools Links ── */
.other-tools { margin-top: 2rem; background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 1.2rem; }
.other-tools h3 { font-size: 0.95rem; font-weight: 700; margin-bottom: 0.75rem; color: var(--text); }
.other-tools p { font-size: 0.82rem; color: var(--muted); margin-bottom: 0.75rem; line-height: 1.6; }
.tools-links { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.tool-link { display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.4rem 0.8rem; border-radius: 8px; border: 1px solid var(--border); background: var(--bg); color: var(--text); text-decoration: none; font-size: 0.8rem; font-weight: 600; transition: all 0.2s; }
.tool-link:hover { border-color: var(--p-color); color: var(--p-color); }
.tool-link img { width: 16px; height: 16px; }

/* ── Tool Links (about page cross-links) ── */
.tool-link {
  display: inline-flex; align-items: center; gap: 0.5rem;
  padding: 0.5rem 1rem; border-radius: 8px;
  border: 1px solid var(--border); color: var(--text);
  text-decoration: none; font-size: 0.85rem; font-weight: 600;
  background: var(--card);
  transition: opacity 0.2s, transform 0.2s;
}
.tool-link:hover { opacity: 0.8; transform: translateY(-1px); }
.tools-links { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.75rem; }

/* ── Fix CLS: reserve header height ── */
header { min-height: 100px; }

/* ── Fix active nav contrast in light mode ── */
html.light .nav-link.active { color: #1a1a2e; border-bottom-color: var(--p-color); font-weight: 700; }
html.light .nav-link { color: #374151; }
html.light .nav-link:hover { color: #1a1a2e; }
html.light .footer-links a { color: #374151; }
html.light .footer-copy { color: #374151; }
html.light .last-updated { color: #374151; }

/* ── Sub-Tools Bar ── */
.sub-tools-bar { display: flex; gap: 0.5rem; margin-bottom: 1.2rem; flex-wrap: wrap; }
.sub-tool-btn {
  display: inline-flex; align-items: center; gap: 0.3rem;
  padding: 0.45rem 1rem; border-radius: 8px; font-size: 0.82rem; font-weight: 600;
  text-decoration: none; border: 1px solid var(--border);
  color: #b0bec5; background: var(--card); transition: opacity 0.2s;
}
.sub-tool-btn:hover { opacity: 0.75; }
/* Active sub-tool: use a neutral high-contrast style instead of brand color */
.sub-tool-btn.active { background: var(--text); color: var(--bg); border-color: var(--text); }
/* MP3 button: purple is dark enough for white text */
.sub-tool-btn.active[href*="mp3"] { background: #7c3aed; border-color: #7c3aed; color: #fff; }

/* ── Internal Link Tip ── */
.internal-link-tip {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px; padding: 0.5rem 1rem; font-size: 0.82rem;
  color: var(--text); margin-bottom: 1rem;
}
/* Use white/bright link in dark mode for contrast, dark in light mode */
.internal-link-tip a { color: #e2e8f0; font-weight: 700; text-decoration: underline; text-decoration-color: var(--p-color); }
.internal-link-tip a:hover { opacity: 0.85; }

/* ── CLS Fix: Reserve space for dynamically injected elements ── */
.sub-tools-bar { min-height: 38px; }
.features-grid { min-height: 160px; }
.internal-link-tip { min-height: 36px; }
/* Header: fixed height + isolation so JS updates don't shift <main> */
header { min-height: 100px; contain: layout; isolation: isolate; }
/* Reserve space for paste/clear btn row to prevent CLS */
.input-card { min-height: 130px; }
/* Prevent nav-platforms from wrapping and changing header height */
.nav-platforms { height: auto; overflow-x: auto; overflow-y: hidden; }

/* ── Accessibility: Fix contrast for sub-tool-btn active in light mode ── */
html.light .sub-tool-btn.active { color: #fff; background: #1a1a2e; border-color: #1a1a2e; }
html.light .sub-tool-btn.active[href*="mp3"] { background: #7c3aed; border-color: #7c3aed; color: #fff; }
html.light .sub-tool-btn { color: #1a1a2e; border-color: #9ca3af; background: #fff; }
html.light .sub-tool-btn:hover { color: #1a1a2e; border-color: var(--p-color); background: #f9fafb; }

/* ── Accessibility: Fix internal-link-tip contrast in light mode ── */
html.light .internal-link-tip { color: #1a1a2e; background: #f0f0f5; border-color: #d1d5db; }
html.light .internal-link-tip a { color: #5b21b6; font-weight: 700; text-decoration: underline; }

/* ── Performance: defer rendering of below-fold content ── */
.seo-section { content-visibility: auto; contain-intrinsic-size: 0 300px; }
.faq-list    { content-visibility: auto; contain-intrinsic-size: 0 200px; }
.seo-illus-wrap { contain: layout style; }

/* ── SEO Section Illustrations ── */
.seo-illus-wrap {
  margin: 1rem 0 0.5rem;
  max-width: 320px;
}
.seo-illus-wrap.seo-illus-right { margin-left: auto; margin-right: 0; }
.seo-illus-wrap.seo-illus-left  { margin-left: 0; margin-right: auto; }
.seo-illus-img svg { width: 100%; height: auto; display: block; }

/* Desktop side-by-side layout */
@media (min-width: 900px) {
  .seo-section h2 { text-align: center; margin-bottom: 1.2rem; }
  .seo-section-row {
    display: flex;
    align-items: center;
    gap: 2.5rem;
  }
  .seo-section-row.img-right { flex-direction: row; }
  .seo-section-row.img-left  { flex-direction: row-reverse; }
  .seo-section-text { flex: 1; min-width: 0; }
  .seo-illus-wrap {
    flex: 0 0 300px;
    max-width: 300px;
    margin: 0;
  }
}

/* ── Hero Downloader Section ── */
.downloader-hero {
  background: var(--card);
  border: none;
  border-radius: 20px;
  padding: 2rem 1.5rem 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: none;
  position: relative;
  overflow: hidden;
}
.downloader-hero::before { display: none; }
.downloader-hero-title {
  text-align: center;
  font-size: 1rem;
  font-weight: 700;
  color: var(--p-color, #7c3aed);
  margin-bottom: 1.2rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  font-size: 0.78rem;
  opacity: 0.85;
}
.downloader-hero .input-card {
  background: transparent;
  border: none;
  max-width: 860px;
  margin: 0 auto;
  box-shadow: none;
}
html.light .downloader-hero {
  box-shadow: none;
}
html.light .downloader-hero .input-card {
  background: #f8f8fc;
}
