/* ═══════════════════════════════════════════════
   SaveTube — Theme(v1)
   ═══════════════════════════════════════════════ */

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

:root {
  --bg: #0c0c0e;
  --card: #161619;
  --card-2: #1e1e22;
  --border: #2a2a30;
  --text: #ececf0;
  --text-2: #9898a6;
  --text-3: #5c5c6a;
  --accent: #6d5cff;
  --accent-2: #8577ff;
  --accent-soft: rgba(109, 92, 255, .12);
  --radius: 12px;
  --glow: 0 0 30px rgba(109, 92, 255, .25);
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  min-height: 100dvh;
}

.app {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 20px;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

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

.hero-inner {
  max-width: 520px;
  margin: 0 auto;
}

.hero-badge {
  display: inline-block;
  font-size: .68rem;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--accent-2);
  background: var(--accent-soft);
  padding: 6px 16px;
  border-radius: 20px;
  margin-bottom: 22px;
  border: 1px solid rgba(109, 92, 255, .15);
}

.hero-title {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.03em;
  margin-bottom: 16px;
}

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

.hero-desc {
  font-size: .9rem;
  color: var(--text-2);
  line-height: 1.65;
  margin-bottom: 32px;
}

/* ══════════════════════════════════════════════════
   SEARCH AREA
   ══════════════════════════════════════════════════ */
.search-area {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 480px;
  margin: 0 auto;
}

/* URL Input */
.url-input {
  width: 100%;
  padding: 16px 20px;
  font-size: .95rem;
  font-weight: 500;
  font-family: inherit;
  color: var(--text);
  background: #1c1c22;
  border: 2px solid #888;
  border-radius: var(--radius);
  outline: none;
  transition: border-color .2s, box-shadow .2s, background .2s;
  text-align: center;
  box-shadow: 0 0 16px rgba(109, 92, 255, .15), 0 2px 10px rgba(0, 0, 0, .3);
}

.url-input::placeholder {
  color: #aaa;
  font-weight: 400;
}

.url-input:hover {
  border-color: #aaa;
  background: #202028;
}

.url-input:focus {
  border-color: var(--accent);
  background: #1a1a24;
  box-shadow: 0 0 0 4px rgba(109, 92, 255, .2), 0 0 30px rgba(109, 92, 255, .3);
}

/* Download button */
.go-btn {
  width: 100%;
  padding: 14px 24px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: .92rem;
  font-family: inherit;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: opacity .15s, box-shadow .2s, transform .15s;
  box-shadow: 0 4px 16px rgba(109, 92, 255, .35);
}

.go-btn:hover:not(:disabled) {
  opacity: .9;
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(109, 92, 255, .45);
}

.go-btn:disabled {
  background: #4a3eb5;
  color: #fff;
  cursor: not-allowed;
}

.f-spin {
  display: inline-flex;
  align-items: center;
}

.f-spin[hidden] {
  display: none;
}

.f-spin svg {
  width: 16px;
  height: 16px;
  animation: spin .7s linear infinite;
}

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

.hero-features {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin-top: 28px;
}

.hf {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: .78rem;
  font-weight: 500;
  color: var(--text-3);
}

.hf svg {
  width: 16px;
  height: 16px;
}

/* How to Download */
.how-to {
  max-width: 540px;
  margin: 0 auto 32px;
}

.how-to[hidden] {
  display: none;
}

.stepper {
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

.step {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  width: 100px;
}

.step-circle {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--accent-soft);
  border: 2px solid rgba(109, 92, 255, .3);
  margin-bottom: 10px;
  transition: transform .2s, box-shadow .2s;
}

.step-circle svg {
  width: 20px;
  height: 20px;
  color: var(--accent-2);
}

.step:hover .step-circle {
  transform: scale(1.08);
  box-shadow: 0 0 20px rgba(109, 92, 255, .3);
}

.step-title {
  font-size: .78rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
}

.step-sub {
  font-size: .68rem;
  color: var(--text-3);
}

.step-n {
  font-size: .6rem;
  font-weight: 700;
  color: var(--accent-2);
  margin-bottom: 6px;
  letter-spacing: .03em;
}

.step-line {
  width: 28px;
  height: 2px;
  background: linear-gradient(90deg, rgba(109, 92, 255, .3), rgba(109, 92, 255, .1));
  margin-top: 22px;
  border-radius: 1px;
  flex-shrink: 0;
}

/* ── Error ── */
.error-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: rgba(239, 68, 68, .08);
  border: 1px solid rgba(239, 68, 68, .2);
  border-radius: var(--radius);
  color: #f87171;
  font-size: .84rem;
  margin-bottom: 16px;
  animation: fadeDown .25s ease;
}

.error-bar svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.error-bar[hidden] {
  display: none;
}

@keyframes fadeDown {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ── Video Card ── */
.results[hidden] {
  display: none;
}

.results {
  animation: fadeDown .3s ease;
}

.vid-card {
  display: flex;
  gap: 16px;
  padding: 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
}

.vid-thumb {
  position: relative;
  flex-shrink: 0;
  width: 180px;
  border-radius: 8px;
  overflow: hidden;
  background: #000;
}

.vid-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.vid-dur {
  position: absolute;
  bottom: 5px;
  right: 5px;
  background: rgba(0, 0, 0, .8);
  color: #fff;
  font-size: .68rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
}

.vid-info {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  min-width: 0;
}

.vid-info h2 {
  font-size: .95rem;
  font-weight: 600;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.vid-ch {
  font-size: .8rem;
  color: var(--text-2);
}

.vid-stats {
  font-size: .74rem;
  color: var(--text-3);
}

/* ── Tabs ── */
.tab-bar {
  display: flex;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px;
  margin-bottom: 14px;
}

.tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px;
  background: none;
  border: none;
  border-radius: 8px;
  color: var(--text-3);
  font-size: .82rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all .2s;
}

.tab svg {
  width: 16px;
  height: 16px;
}

.tab small {
  font-size: .62rem;
  font-weight: 700;
  background: rgba(255, 255, 255, .08);
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: .03em;
}

.tab:hover {
  color: var(--text-2);
}

.tab.active {
  background: var(--accent);
  color: #fff;
}

.tab.active small {
  background: rgba(255, 255, 255, .2);
}

/* ── Panes ── */
.pane {
  display: none;
}

.pane.active {
  display: block;
  animation: fadeDown .2s ease;
}

.pane-hint {
  font-size: .8rem;
  color: var(--text-3);
  margin-bottom: 12px;
}

.pane-hint strong {
  color: var(--text-2);
}

.q-grid {
  display: grid;
  gap: 6px;
}

.q-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  transition: border-color .15s;
}



.q-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.q-res {
  font-size: .92rem;
  font-weight: 700;
  min-width: 48px;
}

.q-label {
  font-size: .76rem;
  color: var(--text-3);
}

.q-tag {
  font-size: .62rem;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 3px 8px;
  border-radius: 4px;
  text-transform: uppercase;
}

.dl-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: .78rem;
  font-family: inherit;
  border: none;
  border-radius: 7px;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity .15s;
}

.dl-btn:hover {
  opacity: .88;
}

.dl-btn:disabled {
  opacity: .5;
  cursor: wait;
}

.dl-btn svg {
  width: 14px;
  height: 14px;
}

.mp3-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.mp3-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.mp3-icon {
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 1.3rem;
  font-weight: 700;
  border-radius: 10px;
  flex-shrink: 0;
}

.mp3-title {
  font-size: .88rem;
  font-weight: 600;
}

.mp3-sub {
  font-size: .74rem;
  color: var(--text-3);
  margin-top: 2px;
}

/* ── Footer ── */
.foot {
  margin-top: auto;
  padding: 40px 0 24px;
  text-align: center;
}

.foot p {
  font-size: .78rem;
  color: var(--text-2);
}

.foot a {
  color: var(--accent-2);
  text-decoration: none;
  font-weight: 600;
}

.foot a:hover {
  text-decoration: underline;
}

.foot-sub {
  font-size: .7rem !important;
  color: var(--text-3) !important;
  margin-top: 4px;
}

/* ── Toast ── */
/* ── Download Progress Overlay ────────────────── */
.dl-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  backdrop-filter: blur(4px);
}
.dl-overlay[hidden] { display: none; }

.dl-progress-card {
  background: var(--card-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 32px;
  min-width: 320px;
  max-width: 400px;
  text-align: center;
}
.dl-status {
  font-size: .88rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 16px;
}
.dl-status.preparing {
  animation: pulse 1.5s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .5; }
}
.dl-bar-track {
  width: 100%;
  height: 8px;
  background: var(--bg-2);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 10px;
}
.dl-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: 4px;
  transition: width .3s ease;
}
.dl-bar-fill.indeterminate {
  width: 30% !important;
  animation: indeterminate 1.5s ease-in-out infinite;
}
@keyframes indeterminate {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(400%); }
}
.dl-meta {
  display: flex;
  justify-content: space-between;
  font-size: .74rem;
  color: var(--text-3);
}

.toasts {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 100;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--card-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: .82rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .4);
  animation: tIn .25s ease;
}

.toast.ok {
  border-left: 3px solid #22c55e;
}

.toast.err {
  border-left: 3px solid #ef4444;
}

.toast.out {
  animation: tOut .2s ease forwards;
}

@keyframes tIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translate(0);
  }
}

@keyframes tOut {
  to {
    opacity: 0;
    transform: translateY(10px);
  }
}

/* ── Mobile ── */
@media(max-width:600px) {
  .app {
    padding: 0 16px;
  }

  .hero {
    padding: 44px 0 28px;
  }

  .hero-title {
    font-size: 1.5rem;
  }

  .hero-desc {
    font-size: .84rem;
  }

  .search-area {
    gap: 8px;
  }

  .url-input {
    padding: 14px 16px;
    font-size: .88rem;
  }

  .go-btn {
    padding: 13px 20px;
    font-size: .88rem;
  }

  .hero-features {
    gap: 16px;
    flex-wrap: wrap;
  }

  .hf {
    font-size: .72rem;
  }

  .how-to {
    margin: 0 auto 24px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
  }

  .stepper {
    flex-direction: column;
    align-items: stretch;
    gap: 0;
  }

  .step {
    flex-direction: row;
    text-align: left;
    width: auto;
    gap: 14px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
  }

  .step:last-child {
    border-bottom: none;
    padding-bottom: 0;
  }

  .step:first-child {
    padding-top: 0;
  }

  .step-circle {
    width: 36px;
    height: 36px;
    margin-bottom: 0;
    flex-shrink: 0;
  }

  .step-circle svg {
    width: 16px;
    height: 16px;
  }

  .step-title {
    font-size: .82rem;
  }

  .step-sub {
    font-size: .7rem;
  }

  .step-line {
    display: none;
  }

  .vid-card {
    flex-direction: column;
  }

  .vid-thumb {
    width: 100%;
    aspect-ratio: 16/9;
  }

  .q-row {
    padding: 10px 12px;
  }

  .q-res {
    font-size: .84rem;
    min-width: 42px;
  }

  .mp3-card {
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
  }

  .mp3-card .dl-btn {
    width: 100%;
    justify-content: center;
    padding: 12px;
  }

  .tab-bar {
    margin-bottom: 12px;
  }

  .tab {
    padding: 8px;
    font-size: .78rem;
  }

  .toasts {
    bottom: 12px;
    right: 12px;
    left: 12px;
  }

  .toast {
    font-size: .78rem;
  }
}

::-webkit-scrollbar {
  width: 4px;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, .06);
  border-radius: 2px;
}

::selection {
  background: var(--accent);
  color: #fff;
}