/* ==========================================================================
   Tube Downloader - dark theme
   One copy of every rule. Media queries are at the END so they can win.
   ========================================================================== */

:root {
  --ink: #080b14;
  --panel: #10151f;
  --panel-raised: #161c29;
  --line: #232b3d;
  --text: #edf1f7;
  --text-muted: #9099ad;

  --accent: #ef4444;
  --accent-ink: #ffffff;
  --accent-hover: #dc2626;
  --accent-soft: rgba(239, 68, 68, 0.14);

  --amber: #f59e0b;
  --danger: #f87171;
  --blue: #3b82f6;
  --ok: #34d399;

  --font-display: "Space Grotesk", "Segoe UI", sans-serif;
  --font-body: "Inter", "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;

  --wrap: 1120px;
  --radius-sm: 8px;
  --radius-md: 16px;
  --radius-lg: 28px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { color-scheme: dark; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--ink);
  color: var(--text);
  font-family: var(--font-body);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-wrap: break-word;
}
img, svg { max-width: 100%; display: block; }
a { color: inherit; }
button { font-family: inherit; }

.wrap {
  max-width: var(--wrap);
  margin-left: auto;
  margin-right: auto;
  padding-left: 20px;
  padding-right: 20px;
}
.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.skip-link {
  position: absolute; left: 12px; top: -56px; z-index: 300;
  background: var(--accent); color: var(--accent-ink);
  padding: 10px 16px; border-radius: var(--radius-sm); text-decoration: none;
}
.skip-link:focus { top: 12px; }

/* --- Header --- */
.site-header {
  border-bottom: 1px solid var(--line);
  padding-top: 18px;
  padding-bottom: 18px;
  background: rgba(8, 11, 20, 0.88);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
}
.brand {
  display: inline-flex; align-items: center; gap: 10px;
  text-decoration: none; font-family: var(--font-display);
  font-weight: 700; font-size: 1.15rem;
}
.brand-mark { color: var(--accent); display: flex; }
.primary-nav {
  display: flex; gap: 4px; font-size: 0.92rem;
  overflow-x: auto; padding-bottom: 4px; max-width: 100%;
}
.primary-nav::-webkit-scrollbar { display: none; }
.primary-nav a {
  text-decoration: none; color: var(--text-muted);
  padding: 8px 12px; border-radius: 999px;
  transition: background 0.2s, color 0.2s; white-space: nowrap;
}
.primary-nav a:hover:not(.is-active) { color: var(--text); background: var(--panel); }
.primary-nav a.is-active { color: var(--accent-ink); background: var(--accent); font-weight: 500; }

/* --- Hero --- */
.hero { padding-top: clamp(40px, 7vw, 88px); padding-bottom: clamp(40px, 7vw, 88px); }
.hero-grid {
  display: grid; grid-template-columns: 1.15fr 0.85fr;
  gap: clamp(32px, 5vw, 64px); align-items: center;
}
.hero-copy h1 {
  font-family: var(--font-display); font-weight: 700;
  font-size: clamp(2rem, 4.2vw, 3.2rem); line-height: 1.1;
  margin: 0 0 18px; letter-spacing: -0.02em;
}
.hero-subtitle { color: var(--text-muted); font-size: 1.08rem; max-width: 48ch; margin: 0 0 28px; }

.fetch-form {
  display: flex; gap: 10px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; padding: 6px; max-width: 580px;
  box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.5);
}
.input-wrapper { position: relative; display: flex; align-items: center; flex: 1; min-width: 0; }
.fetch-form input {
  flex: 1; min-width: 0; width: 100%;
  background: transparent; border: none; color: var(--text);
  font-family: var(--font-mono); font-size: 0.95rem;
  padding: 13px 44px 13px 14px; outline: none;
}
.fetch-form input::placeholder { color: var(--text-muted); }
.fetch-form:focus-within { border-color: var(--accent); }
.paste-btn {
  position: absolute; right: 8px; width: 36px; height: 36px;
  background: transparent; border: none; color: var(--text-muted);
  border-radius: var(--radius-sm); cursor: pointer;
  display: grid; place-items: center; transition: background 0.2s, color 0.2s;
}
.paste-btn:hover { background: var(--panel-raised); color: var(--text); }
.fetch-form button[type="submit"] {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-width: 92px; background: var(--accent); color: var(--accent-ink);
  border: none; font-family: var(--font-display); font-weight: 600; font-size: 0.95rem;
  padding: 0 22px; border-radius: var(--radius-sm); cursor: pointer; transition: background 0.2s;
}
.fetch-form button[type="submit"]:hover { background: var(--accent-hover); }
.fetch-form button[type="submit"]:disabled { cursor: wait; opacity: 0.85; }
.fetch-form button.is-loading .btn-label { display: none; }
.btn-spinner {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.3); border-top-color: #fff;
  display: none; animation: spin 0.8s linear infinite;
}
.fetch-form button.is-loading .btn-spinner { display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

.trust-strip { margin: 16px 0 0; color: var(--text-muted); font-size: 0.9rem; }
.use-note { margin: 4px 0 0; color: var(--text-muted); font-size: 0.82rem; opacity: 0.8; }
.status { margin-top: 14px; font-size: 0.95rem; min-height: 1.4em; }
.status a { color: var(--accent); font-weight: 600; }
.status.is-error {
  color: var(--danger); padding: 12px 14px;
  background: rgba(239, 68, 68, 0.1); border: 1px solid rgba(239, 68, 68, 0.5);
  border-radius: var(--radius-sm); display: inline-block; max-width: 100%;
}

/* --- Preview phone --- */
.hero-device { display: flex; flex-direction: column; align-items: center; }
.device-frame {
  width: min(280px, 100%); aspect-ratio: 9 / 18;
  background: var(--panel-raised); border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: 12px; position: relative;
  box-shadow: 0 30px 60px -30px rgba(0, 0, 0, 0.8);
}
.device-notch { width: 70px; height: 6px; border-radius: 4px; background: var(--line); margin: 0 auto 10px; }
.device-screen {
  width: 100%; height: calc(100% - 24px); border-radius: 18px;
  background: var(--ink); overflow: hidden; display: grid; place-items: center;
  position: relative; border: 1px solid var(--line);
}
.device-screen iframe { width: 100%; height: 100%; border: none; }
.device-idle { text-align: center; color: var(--text-muted); font-size: 0.85rem; padding: 20px; }
.device-done { color: var(--text); font-weight: 600; margin: 0; }
.pulse-ring {
  width: 46px; height: 46px; margin: 0 auto 14px; border-radius: 50%;
  border: 2px solid var(--accent); opacity: 0.6; animation: pulse 2.4s ease-out infinite;
}
@keyframes pulse {
  0% { transform: scale(0.8); opacity: 0.7; }
  100% { transform: scale(1.5); opacity: 0; }
}
.device-play {
  position: relative; width: 100%; height: 100%; padding: 0; border: 0;
  background: #000; cursor: pointer; display: block;
}
.device-play img { width: 100%; height: 100%; object-fit: cover; opacity: 0.85; }
.play-mark {
  position: absolute; inset: 0; margin: auto; width: 56px; height: 56px;
  display: grid; place-items: center; border-radius: 50%;
  background: var(--accent); color: var(--accent-ink); font-size: 1.2rem; padding-left: 3px;
}

/* --- Results --- */
.result-section { padding-bottom: 60px; }
.result-card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius-md); padding: 24px;
  box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.4);
}
.result-header {
  display: flex; gap: 20px; margin-bottom: 24px; align-items: center;
  border-bottom: 1px solid var(--line); padding-bottom: 24px;
}
.result-thumb {
  width: 160px; height: auto; aspect-ratio: 16 / 9; object-fit: cover;
  border-radius: var(--radius-sm); border: 1px solid var(--line); flex: none;
}
.result-info { min-width: 0; }
.result-info h2 {
  margin: 0 0 8px; font-family: var(--font-display);
  font-size: 1.25rem; line-height: 1.3; color: var(--text);
}
.result-meta { margin: 0; color: var(--text-muted); font-size: 0.9rem; }
.result-meta span:empty { display: none; }
.result-meta span + span::before { content: "\2022"; margin: 0 8px; }

.notice {
  margin: 0 0 24px; padding: 12px 14px; border-radius: var(--radius-sm);
  background: rgba(245, 158, 11, 0.1); border: 1px solid rgba(245, 158, 11, 0.45); color: #fcd34d;
}

/* Download progress */
.job-panel {
  background: var(--panel-raised); border: 1px solid var(--line);
  border-radius: var(--radius-md); padding: 18px 20px; margin-bottom: 28px;
}
.job-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.job-row strong { font-family: var(--font-display); }
.progress { height: 8px; background: var(--ink); border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: var(--accent); border-radius: 999px; transition: width 0.5s ease; }
.progress.is-indeterminate .progress-fill { width: 35% !important; animation: slide 1.3s ease-in-out infinite; }
@keyframes slide { 0% { transform: translateX(-100%); } 100% { transform: translateX(300%); } }
.job-meta { margin: 10px 0 0; color: var(--text-muted); font-size: 0.88rem; min-height: 1.3em; }
.job-meta a { color: var(--accent); font-weight: 600; }

.btn-ghost, .btn-outline {
  background: transparent; color: var(--text); border: 1px solid var(--line);
  border-radius: var(--radius-sm); cursor: pointer;
  font-family: var(--font-display); font-weight: 600; transition: border-color 0.2s, color 0.2s;
}
.btn-ghost { padding: 6px 14px; font-size: 0.85rem; }
.btn-outline { padding: 10px 20px; font-size: 0.95rem; }
.btn-ghost:hover, .btn-outline:hover { border-color: var(--accent); color: var(--accent); }
.btn-outline.is-done { border-color: var(--ok); color: var(--ok); }
.button-row { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 14px; }

.format-group { margin-bottom: 30px; }
.format-group:last-child { margin-bottom: 0; }
.format-group h3 {
  font-family: var(--font-display); color: var(--text);
  font-size: 1.05rem; margin: 0 0 16px; display: flex; align-items: center; gap: 8px;
}
.format-group h3 .icon { color: var(--accent); }
.group-note { margin: 14px 0 0; color: var(--text-muted); font-size: 0.88rem; }
.group-note a { color: var(--accent); font-weight: 600; }

.result-items { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.result-item {
  background: var(--panel-raised); border: 1px solid var(--line);
  border-radius: var(--radius-sm); overflow: hidden;
  display: flex; flex-direction: column; transition: border-color 0.2s;
}
.result-item:hover, .result-item:focus-within { border-color: var(--accent); }
.thumb-preview { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; background: var(--ink); border-bottom: 1px solid var(--line); }
.result-item-data { padding: 12px 16px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.result-item-data .label { font-weight: 600; color: var(--text); font-size: 1.05rem; }
.result-item-data .meta { color: var(--text-muted); font-size: 0.8rem; font-family: var(--font-mono); }
.download-btn {
  display: block; width: 100%; appearance: none; border: 0; cursor: pointer;
  background: var(--line); color: var(--text); text-align: center; text-decoration: none;
  padding: 11px; font-family: var(--font-display); font-weight: 600; font-size: 0.9rem;
  transition: background 0.2s, color 0.2s;
}
.result-item:hover .download-btn:not(:disabled), .download-btn:focus-visible:not(:disabled) {
  background: var(--accent); color: var(--accent-ink);
}
.download-btn:disabled { opacity: 0.45; cursor: not-allowed; }

.tag-list { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  background: var(--panel-raised); border: 1px solid var(--line); color: var(--text);
  border-radius: 999px; padding: 5px 12px; font-size: 0.85rem; font-family: var(--font-mono);
}
.post-text {
  width: 100%; background: var(--panel-raised); border: 1px solid var(--line); color: var(--text);
  padding: 16px; border-radius: var(--radius-sm); font-family: var(--font-body);
  font-size: 0.95rem; resize: vertical; outline: none; margin-bottom: 4px;
}
.post-text + .button-row { margin: 0 0 18px; }

/* --- Content blocks --- */
.content-block { padding: 64px 0; border-top: 1px solid var(--line); }
.content-block.bg-alt { background: var(--panel); }
.block-header { text-align: center; margin: 0 auto 48px; max-width: 800px; }
.block-header h2 { font-family: var(--font-display); font-size: clamp(1.8rem, 3vw, 2.2rem); margin: 0 0 16px; }
.block-header p { color: var(--text-muted); font-size: 1.05rem; margin: 0; }

.steps-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; list-style: none; padding: 0; margin: 0; }
.step-card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius-md); overflow: hidden; text-align: center;
}
.step-graphic {
  height: 140px; background: linear-gradient(135deg, var(--panel-raised), var(--ink));
  border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: center; padding: 0 16px;
}
.mock-input {
  background: var(--ink); border: 1px solid var(--line); color: var(--text-muted);
  padding: 12px; border-radius: var(--radius-sm); font-family: var(--font-mono); font-size: 0.85rem;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.4); max-width: 100%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}
.mock-chip { background: var(--accent); color: var(--accent-ink); padding: 3px 8px; border-radius: 4px; font-size: 0.75rem; margin-left: 6px; }
.mock-accent { background: var(--accent); color: var(--accent-ink); border-color: transparent; font-weight: 600; }
.step-content { padding: 24px; }
.step-content h3 { color: var(--text); margin: 0 0 10px; font-size: 1.2rem; font-family: var(--font-display); }
.step-content p { color: var(--text-muted); margin: 0; font-size: 0.95rem; }

.features-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 48px 32px; }
.feature-item { text-align: center; padding: 0 20px; }
.feature-item > .icon { margin: 0 auto 16px; color: var(--accent); }
.feature-item h3 { margin: 0 0 12px; font-size: 1.25rem; font-family: var(--font-display); }
.feature-item p { margin: 0; color: var(--text-muted); font-size: 0.95rem; }

/* Other tools */
.tool-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.tool-card {
  display: flex; gap: 16px; align-items: flex-start; text-decoration: none;
  background: var(--panel-raised); border: 1px solid var(--line);
  border-radius: var(--radius-md); padding: 20px; transition: border-color 0.2s;
}
.tool-card:hover { border-color: var(--accent); }
.tool-icon { width: 44px; height: 44px; flex: none; display: grid; place-items: center; border-radius: 12px; color: #fff; }
.tool-title { display: block; font-family: var(--font-display); font-weight: 600; font-size: 1.05rem; margin-bottom: 2px; }
.tool-text { display: block; color: var(--text-muted); font-size: 0.9rem; }
.t-video, .bg-video { background: linear-gradient(135deg, #ef4444, #b91c1c); }
.t-shorts, .bg-shorts { background: linear-gradient(135deg, #f59e0b, #d97706); }
.t-mp3, .bg-audio { background: linear-gradient(135deg, #3b82f6, #1d4ed8); }
.t-thumbnail, .bg-thumbnail { background: linear-gradient(135deg, #10b981, #047857); }
.t-tags, .bg-tags { background: linear-gradient(135deg, #8b5cf6, #6d28d9); }
.t-post, .bg-profile { background: linear-gradient(135deg, #ec4899, #be185d); }

/* FAQ / table */
.faq-list { display: flex; flex-direction: column; gap: 12px; max-width: 800px; margin: 0 auto; }
.faq-item { border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--panel-raised); }
.faq-item summary {
  cursor: pointer; padding: 18px 48px 18px 18px; font-weight: 500;
  font-family: var(--font-display); font-size: 1.05rem; list-style: none; position: relative;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after {
  content: "+"; position: absolute; right: 18px; top: 16px;
  color: var(--accent); font-family: var(--font-mono); font-size: 1.2rem;
}
.faq-item[open] summary::after { content: "\2212"; }
.faq-item p { color: var(--text-muted); margin: 0; padding: 0 18px 18px; font-size: 0.95rem; }

.table-scroll { max-width: 800px; margin: 0 auto; overflow-x: auto; }
.troubleshoot-table {
  width: 100%; border-collapse: collapse; text-align: left;
  background: var(--panel-raised); border: 1px solid var(--line);
}
.troubleshoot-table th, .troubleshoot-table td { padding: 16px; border-bottom: 1px solid var(--line); vertical-align: top; }
.troubleshoot-table thead th { background: var(--panel); font-family: var(--font-display); color: var(--accent); }
.troubleshoot-table tbody th { font-weight: 600; width: 32%; }
.troubleshoot-table td { color: var(--text-muted); }
.troubleshoot-table tr:last-child th, .troubleshoot-table tr:last-child td { border-bottom: none; }

/* --- Footer --- */
.site-footer { border-top: 1px solid var(--line); padding: 40px 0 20px; background: var(--ink); }
.footer-row { display: flex; justify-content: space-between; gap: 24px; flex-wrap: wrap; }
.footer-brand { font-family: var(--font-display); font-weight: 700; margin: 0 0 8px; font-size: 1.2rem; color: var(--text); }
.footer-disclaimer { color: var(--text-muted); font-size: 0.85rem; max-width: 56ch; margin: 0; }
.footer-links { display: flex; gap: 20px; font-size: 0.9rem; flex-wrap: wrap; align-content: flex-start; }
.footer-links a { text-decoration: none; color: var(--text-muted); transition: color 0.2s; }
.footer-links a:hover { color: var(--accent); }
.footer-copy {
  text-align: center; color: var(--text-muted); font-size: 0.85rem;
  margin: 40px 0 0; padding-top: 20px; border-top: 1px solid var(--line);
}

/* --- Text pages (About, Terms, Privacy, DMCA, Contact, 404) --- */
.page-content { padding-top: 60px; padding-bottom: 80px; max-width: 800px; margin: 0 auto; }
.page-content h1 { font-family: var(--font-display); font-size: 2.5rem; color: var(--text); margin-bottom: 32px; }
.page-content h2 { font-family: var(--font-display); font-size: 1.6rem; margin: 40px 0 16px; color: var(--text); }
.page-content h3 { font-family: var(--font-display); font-size: 1.3rem; margin: 32px 0 16px; color: var(--accent); }
.page-content p, .page-content ul, .page-content ol { color: var(--text-muted); font-size: 1.05rem; line-height: 1.7; margin-bottom: 16px; }
.page-content a { color: var(--accent); }
.page-content .updated { font-size: 0.9rem; margin-top: -16px; }

/* Centered pages (404, Contact) */
.page-center { text-align: center; min-height: 50vh; display: flex; flex-direction: column; justify-content: center; align-items: center; }
.page-center > .icon { margin-bottom: 24px; color: var(--accent); }
.error-code { font-family: var(--font-display); font-size: 4rem; line-height: 1; margin: 0 0 10px; color: var(--text); }
.page-lead { font-size: 1.1rem; margin: 0 0 30px; color: var(--text-muted); }
.page-content a.btn-primary {
  display: inline-block; background: var(--accent); color: var(--accent-ink);
  padding: 12px 28px; border-radius: var(--radius-sm); font-weight: 600;
  text-decoration: none; font-family: var(--font-display); transition: background 0.2s;
}
.page-content a.btn-primary:hover { background: var(--accent-hover); }
.link-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 18px; margin-top: 28px; font-size: 0.95rem; }
.contact-card {
  background: var(--panel); border: 1px solid var(--line); padding: 36px 40px;
  border-radius: var(--radius-md); max-width: 100%;
}
.contact-label { color: var(--text-muted); font-size: 0.95rem; margin: 0 0 8px; }
.page-content a.contact-mail {
  font-family: var(--font-display); font-size: clamp(1.1rem, 5vw, 1.5rem);
  font-weight: 600; text-decoration: none; overflow-wrap: anywhere;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

/* --- Responsive (keep last) --- */
@media (max-width: 860px) {
  /* Mobile nav: wrap onto two lines under the logo instead of scrolling sideways */
  .site-header { position: static; padding-top: 14px; padding-bottom: 12px; }
  .header-row { gap: 10px; }
  .primary-nav {
    flex-basis: 100%; flex-wrap: wrap; overflow-x: visible;
    gap: 6px; padding-bottom: 0; font-size: 0.88rem;
  }
  .primary-nav a { padding: 7px 11px; background: var(--panel); }
  .primary-nav a.is-active { background: var(--accent); }

  .hero-grid { grid-template-columns: 1fr; text-align: center; }
  .hero-subtitle { margin: 0 auto 28px; }
  .fetch-form { margin: 0 auto; }
  .device-frame { width: min(220px, 60vw); }
  .steps-list, .features-grid { grid-template-columns: 1fr; }
  .status.is-error { text-align: left; }
  .footer-row { flex-direction: column; }
}
@media (max-width: 560px) {
  .result-card { padding: 16px; }
  .result-header { flex-direction: column; align-items: flex-start; }
  .result-thumb { width: 100%; }
  .result-items { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
  .troubleshoot-table tbody th { width: auto; }
  .troubleshoot-table th, .troubleshoot-table td { padding: 12px; }
  .page-content h1 { font-size: 2rem; }
}
