:root {
  --bg: #08090b;
  --text: #e7eaee;
  --muted: #878e99;
  --muted-2: #6b727d;
  --accent: #a6c8e0;
  --accent-ink: #08131c;
  --line: rgba(255, 255, 255, .08);
  --line-strong: rgba(255, 255, 255, .16);
  --glass: rgba(255, 255, 255, .04);
  --glass-hi: rgba(255, 255, 255, .07);
  --panel: rgba(16, 18, 22, .66);
  --danger: #f3787c;
  --ok: #8ad6a8;
  --radius: 18px;
  color-scheme: dark;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }

body {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  line-height: 1.6;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}

a { color: inherit; }

/* ── Starfield backdrop ───────────────────────────── */
.sky { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.stars { position: absolute; top: 0; left: 0; width: 1px; height: 1px; border-radius: 50%; background: transparent; }
.s2 { animation: twinkle 7s ease-in-out infinite alternate; }
@keyframes twinkle { from { opacity: .5; } to { opacity: 1; } }
.glow {
  position: absolute; top: -32vh; left: 50%; transform: translateX(-50%);
  width: 150vmax; height: 80vh;
  background: radial-gradient(48% 58% at 50% 42%, rgba(146, 178, 206, .10), transparent 70%);
}
.theme-spotify .glow {
  background: radial-gradient(48% 58% at 50% 42%, rgba(46, 196, 120, .10), transparent 70%);
}

/* ── Top bar ──────────────────────────────────────── */
.nav { position: relative; z-index: 2; }
.nav-in {
  max-width: 640px; margin: 0 auto; width: 100%;
  padding: 18px 24px; display: flex; align-items: center; gap: 16px;
}
.brand { display: inline-flex; align-items: center; gap: 9px; font-weight: 600; font-size: .98rem; text-decoration: none; letter-spacing: -.01em; }
.brand-mark {
  width: 24px; height: 24px; border-radius: 7px; display: block;
  background: url("/logo.png") center / cover no-repeat;
  border: 1px solid var(--line-strong);
}
.brand-by { color: var(--muted); font-weight: 500; }
.brand-by a { color: var(--accent); text-decoration: none; }
.nav-spacer { margin-left: auto; }
.nav-ver { font-family: "JetBrains Mono", ui-monospace, monospace; font-size: .76rem; color: var(--muted-2); }
.nav-links { display: flex; align-items: center; gap: 16px; }
.nav-links a { font-size: .86rem; color: var(--muted); text-decoration: none; transition: color .2s; }
.nav-links a:hover { color: var(--text); }
.nav-links a.active { color: var(--accent); }
.nav-links .pipe { color: var(--line-strong); user-select: none; }
@media (max-width: 600px) { .nav-links { display: none; } }

/* ── Floating accent chips ────────────────────────── */
.float { position: fixed; inset: 0; z-index: 0; pointer-events: none; }
.chip {
  position: absolute; display: inline-flex; align-items: center; gap: 9px;
  font-family: "JetBrains Mono", ui-monospace, monospace; font-size: .76rem; color: var(--muted);
  padding: 9px 14px; border-radius: 12px; white-space: nowrap;
  background: rgba(13, 15, 18, .6); border: 1px solid var(--line);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  animation: bob 9s ease-in-out infinite;
}
.chip-ic { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 7px; border: 1px solid var(--line); background: var(--glass); color: var(--text); }
.chip-ic svg { width: 13px; height: 13px; }
.chip.c1 { top: 21%; left: 9%; }
.chip.c2 { top: 33%; right: 8%; animation-delay: -2.5s; }
.chip.c3 { bottom: 26%; left: 13%; animation-delay: -5s; }
.chip.c4 { bottom: 32%; right: 11%; animation-delay: -7s; }
@keyframes bob { 0%, 100% { transform: translateY(-7px); } 50% { transform: translateY(7px); } }
@media (max-width: 1100px) { .float { display: none; } }

/* ── Hero brand badge ─────────────────────────────── */
.head-left { display: flex; align-items: center; gap: 15px; }
.brand-badge {
  width: 56px; height: 56px; flex: 0 0 auto; display: grid; place-items: center;
  border-radius: 16px; border: 1px solid var(--line-strong); background: var(--glass);
}
.brand-badge svg { width: 30px; height: 30px; }
.brand-badge-yt { color: #ff5f57; box-shadow: 0 0 30px -6px rgba(255, 95, 87, .55), inset 0 0 0 1px rgba(255, 95, 87, .12); }
.brand-badge-sp { color: #2ec478; box-shadow: 0 0 30px -6px rgba(46, 196, 120, .55), inset 0 0 0 1px rgba(46, 196, 120, .12); }
.brand-badge-zxc { color: var(--accent); box-shadow: 0 0 30px -6px color-mix(in srgb, var(--accent) 55%, transparent); }

/* ── Layout ───────────────────────────────────────── */
.page {
  position: relative; z-index: 1;
  flex: 1; width: 100%; max-width: 640px; margin: 0 auto;
  padding: 24px 24px 56px;
  display: flex; flex-direction: column; justify-content: center;
}

.back-link {
  display: inline-flex; align-items: center; gap: 7px;
  margin-bottom: 18px; color: var(--muted);
  font-size: .85rem; font-weight: 500; text-decoration: none;
  transition: color .2s;
}
.back-link:hover { color: var(--text); }

.panel {
  position: relative;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  -webkit-backdrop-filter: blur(16px) saturate(130%);
  backdrop-filter: blur(16px) saturate(130%);
  box-shadow: 0 30px 80px rgba(0, 0, 0, .5);
  padding: clamp(22px, 4vw, 34px);
  animation: rise .6s cubic-bezier(.2, .7, .2, 1) both;
}
@keyframes rise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }

.panel-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; margin-bottom: 26px;
}
.eyebrow {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: .76rem; color: var(--accent); opacity: .85; margin-bottom: 10px;
}
h1 {
  font-size: clamp(2rem, 5vw, 2.7rem); font-weight: 600;
  letter-spacing: -.03em; line-height: 1.05;
}
.subline { color: var(--muted); font-size: .95rem; margin-top: 10px; max-width: 46ch; }

.ready-pill {
  flex: 0 0 auto; display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 12px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--glass);
  font-size: .78rem; font-weight: 500; color: var(--muted);
  font-family: "JetBrains Mono", ui-monospace, monospace;
}
.ready-pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 8px var(--accent); }

/* ── Form ─────────────────────────────────────────── */
.form-grid { display: grid; gap: 16px; }
.form-grid.is-busy .field-wrap,
.form-grid.is-busy .quality-picker,
.form-grid.is-busy input { pointer-events: none; opacity: .65; }

.field { display: grid; gap: 9px; }
.field-label {
  font-size: .82rem; font-weight: 500; color: var(--muted);
  font-family: "JetBrains Mono", ui-monospace, monospace; letter-spacing: .01em;
}

.field-wrap {
  position: relative; display: flex; align-items: center;
  min-height: 52px; border: 1px solid var(--line); border-radius: 13px;
  background: rgba(0, 0, 0, .25);
  transition: border-color .2s, background .2s;
}
.field-wrap:focus-within {
  border-color: color-mix(in srgb, var(--accent) 55%, transparent); background: rgba(0, 0, 0, .35);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent);
}

.field-icon { width: 44px; display: grid; place-items: center; color: var(--muted); flex: 0 0 auto; }
svg.ic { width: 18px; height: 18px; display: block; stroke: currentColor; stroke-width: 1.8; fill: none; stroke-linecap: round; stroke-linejoin: round; }

.field-input {
  width: 100%; min-height: 50px; border: 0; outline: none; background: transparent;
  color: var(--text); font: inherit; font-weight: 500; padding-right: 14px;
}
.field-input::placeholder { color: var(--muted-2); }

/* ── Custom dropdown ──────────────────────────────── */
.quality-picker { position: relative; }
.quality-trigger {
  width: 100%; min-height: 50px; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; border: 0; outline: none; background: transparent; color: var(--text);
  cursor: pointer; font: inherit; font-weight: 500; text-align: left; padding-right: 16px;
}
.quality-chevron {
  width: 9px; height: 9px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
  transform: rotate(45deg) translateY(-2px); transition: transform .18s; flex: 0 0 auto;
}
.quality-picker.is-open .quality-chevron { transform: rotate(225deg) translate(-2px, -1px); }

.quality-menu {
  position: absolute; left: 0; right: 0; top: calc(100% + 8px); z-index: 40;
  display: grid; gap: 2px; padding: 7px; list-style: none;
  border: 1px solid var(--line-strong); border-radius: 13px;
  background: rgba(18, 20, 24, .98);
  -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px);
  box-shadow: 0 20px 48px rgba(0, 0, 0, .5);
  opacity: 0; pointer-events: none; transform: translateY(-6px) scale(.99); transform-origin: top;
  transition: opacity .15s, transform .15s;
}
.quality-picker.is-open .quality-menu { opacity: 1; pointer-events: auto; transform: none; }
.quality-option {
  min-height: 36px; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 0 12px; border: 1px solid transparent; border-radius: 9px; color: var(--text);
  cursor: pointer; font-size: .9rem; font-weight: 500;
  transition: background .14s, border-color .14s, color .14s;
}
.quality-option:hover, .quality-option.is-active {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border-color: color-mix(in srgb, var(--accent) 25%, transparent);
}
.quality-option[aria-selected="true"] { color: var(--accent); }
.quality-option[aria-selected="true"]::after {
  content: ""; width: 6px; height: 11px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
  transform: rotate(45deg); flex: 0 0 auto;
}

/* ── Submit ───────────────────────────────────────── */
.submit {
  position: relative; overflow: hidden;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; min-height: 52px; margin-top: 4px;
  border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent); border-radius: 13px;
  cursor: pointer; color: var(--accent-ink);
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 92%, #fff), var(--accent));
  font: inherit; font-weight: 600; font-size: .98rem;
  box-shadow: 0 8px 24px -8px color-mix(in srgb, var(--accent) 60%, transparent);
  transition: transform .15s cubic-bezier(.2,.7,.2,1), filter .18s, box-shadow .2s, opacity .18s;
}
.submit > * { position: relative; z-index: 1; }
.submit::after {
  content: ""; position: absolute; inset: 0; z-index: 0;
  background: linear-gradient(120deg, transparent 32%, rgba(255, 255, 255, .35) 50%, transparent 68%);
  transform: translateX(-130%); transition: transform .6s ease;
}
.submit:hover:not(:disabled) { transform: translateY(-2px); filter: brightness(1.05); box-shadow: 0 14px 30px -10px color-mix(in srgb, var(--accent) 70%, transparent); }
.submit:hover:not(:disabled)::after { transform: translateX(130%); }
.submit:active:not(:disabled) { transform: translateY(0) scale(.985); }
.submit:disabled { cursor: wait; opacity: .7; box-shadow: none; }

/* ── Status + progress ────────────────────────────── */
.status {
  display: flex; align-items: center; gap: 11px; min-height: 40px;
  margin-top: 18px; color: var(--muted); font-size: .9rem; overflow-wrap: anywhere;
}
.status-icon {
  width: 30px; height: 30px; flex: 0 0 auto; display: grid; place-items: center;
  border: 1px solid var(--line); border-radius: 9px; background: var(--glass); color: var(--muted);
}
.status-main { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.status-time { font-family: "JetBrains Mono", ui-monospace, monospace; font-size: .74rem; color: var(--muted-2); }
.status.is-busy .status-icon { color: var(--accent); }
.status.is-busy .status-icon svg { animation: spin .85s linear infinite; }
.status.is-done { color: var(--ok); }
.status.is-done .status-icon { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 35%, transparent); }
.status.is-error { color: var(--danger); }
.status.is-error .status-icon { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }
@keyframes spin { to { transform: rotate(360deg); } }

.progress {
  height: 3px; margin-top: 10px; overflow: hidden; border-radius: 999px;
  background: rgba(255, 255, 255, .07); opacity: 0; transition: opacity .2s;
}
.progress.is-active { opacity: 1; }
.progress span {
  display: block; width: 42%; height: 100%; border-radius: inherit; background: var(--accent);
  animation: slide 1.2s ease-in-out infinite;
}
.progress.is-determinate span { width: var(--pct, 0%); animation: none; transition: width .2s ease; }
@keyframes slide { 0% { transform: translateX(-110%); } 100% { transform: translateX(260%); } }

/* ── Slow-time hint ───────────────────────────────── */
.hint {
  display: flex; align-items: flex-start; gap: 9px;
  margin-top: 18px; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--glass);
  color: var(--muted); font-size: .82rem; line-height: 1.5;
}
.hint svg { flex: 0 0 auto; margin-top: 1px; color: var(--accent); }
.hint b { color: var(--text); font-weight: 600; }

/* ── Link preview ─────────────────────────────────── */
.preview-toggle {
  display: inline-flex; align-items: center; gap: 8px; align-self: flex-start;
  padding: 7px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--glass); color: var(--muted); cursor: pointer;
  font: inherit; font-size: .82rem; font-weight: 500;
  transition: color .2s, border-color .2s, background .2s;
}
.preview-toggle:hover { color: var(--text); border-color: var(--line-strong); background: var(--glass-hi); }
.preview-toggle .chev { width: 8px; height: 8px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg); transition: transform .2s; margin-left: 1px; }
.preview-toggle.open .chev { transform: rotate(-135deg); }

.preview { display: none; }
.preview.open { display: block; animation: preview-in .26s cubic-bezier(.2, .7, .2, 1) both; }
.preview-inner { padding-top: 12px; }
@keyframes preview-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
.preview-loading, .preview-error { padding: 14px 4px; color: var(--muted); font-size: .86rem; }
.preview-error { color: var(--danger); }

.yt-card { border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: rgba(0, 0, 0, .25); }
.yt-thumb { position: relative; aspect-ratio: 16 / 9; background: #000; display: grid; place-items: center; }
.yt-thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.yt-play {
  position: relative; z-index: 1; width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(8, 9, 11, .62); color: #fff; border: 1px solid rgba(255, 255, 255, .25);
  -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); transition: transform .2s, background .2s;
}
.yt-card:hover .yt-play { transform: scale(1.08); background: rgba(255, 0, 0, .82); border-color: transparent; }
.yt-play svg { width: 22px; height: 22px; margin-left: 3px; }
.yt-dur {
  position: absolute; z-index: 1; right: 8px; bottom: 8px; padding: 2px 6px; border-radius: 5px;
  background: rgba(0, 0, 0, .82); color: #fff; font-size: .72rem; font-family: "JetBrains Mono", ui-monospace, monospace;
}
.yt-meta { padding: 13px 14px; display: flex; flex-direction: column; gap: 6px; }
.yt-title { font-weight: 600; font-size: .95rem; line-height: 1.3; }
.yt-channel { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: .82rem; }
.yt-channel .av {
  width: 24px; height: 24px; border-radius: 50%; flex: 0 0 auto; display: grid; place-items: center;
  background: var(--glass-hi); border: 1px solid var(--line); color: var(--text); font-size: .74rem; font-weight: 600;
}

.sp-card { display: flex; gap: 14px; align-items: center; border: 1px solid var(--line); border-radius: 14px; padding: 12px; background: rgba(0, 0, 0, .25); }
.sp-cover { width: 86px; height: 86px; border-radius: 9px; overflow: hidden; flex: 0 0 auto; background: #000; }
.sp-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.sp-meta { display: flex; flex-direction: column; gap: 6px; min-width: 0; }

/* ── Landing chooser ──────────────────────────────── */
.choose { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.choice {
  position: relative; display: flex; flex-direction: column; gap: 13px; padding: 24px;
  border: 1px solid var(--line); border-radius: 16px; background: var(--glass);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  color: var(--text); text-decoration: none;
  transition: background .25s, border-color .25s, transform .25s;
}
.choice:hover { background: var(--glass-hi); border-color: var(--line-strong); transform: translateY(-3px); }
.choice-arrow { position: absolute; top: 18px; right: 20px; color: var(--muted); opacity: .35; transition: opacity .25s, transform .25s; }
.choice:hover .choice-arrow { opacity: 1; transform: translate(2px, -2px); }
.choice-mark { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 13px; border: 1px solid var(--line-strong); background: var(--glass); }
.choice-yt .choice-mark { color: #ff5f57; }
.choice-sp .choice-mark { color: #2ec478; }
.choice-name { font-size: 1.1rem; font-weight: 600; letter-spacing: -.01em; }
.choice-desc { color: var(--muted); font-size: .86rem; flex: 1; }
.choice-go { font-family: "JetBrains Mono", ui-monospace, monospace; font-size: .76rem; color: var(--accent); }

/* ── Footer ───────────────────────────────────────── */
.foot { position: relative; z-index: 1; border-top: 1px solid var(--line); }
.foot-in {
  max-width: 640px; margin: 0 auto; width: 100%;
  padding: 18px 24px; display: flex; align-items: center; justify-content: space-between; gap: 14px;
  color: var(--muted-2); font-size: .8rem;
}
.foot-in a { color: var(--accent); text-decoration: none; }

/* ── Modal (warnings) ─────────────────────────────── */
dialog {
  width: min(420px, calc(100vw - 32px)); margin: auto; border: 1px solid var(--line-strong); border-radius: 18px;
  padding: 0; background: #16181c; color: var(--text); box-shadow: 0 24px 64px rgba(0, 0, 0, .6);
}
dialog::backdrop { background: rgba(0, 0, 0, .65); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
.modal-body { padding: 26px; }
.modal-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.modal-icon { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 11px; border: 1px solid var(--line-strong); background: var(--glass); color: var(--accent); flex: 0 0 auto; }
.modal-title { font-size: 1.15rem; font-weight: 600; letter-spacing: -.015em; }
.modal-copy { color: var(--muted); margin: 0 0 22px; line-height: 1.55; font-size: .92rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }
.dialog-button {
  min-height: 42px; padding: 0 18px; border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
  border-radius: 11px; cursor: pointer; color: var(--accent-ink); background: var(--accent);
  font: inherit; font-weight: 600;
}
.dialog-button.secondary { border: 1px solid var(--line); color: var(--text); background: var(--glass); }

/* ── Micro-interactions ───────────────────────────── */
.choice { will-change: transform; }
.choice:active { transform: scale(.99); }
.choice-mark { transition: transform .25s, box-shadow .25s; }
.choice:hover .choice-mark { transform: translateY(-2px); }
.choice-yt:hover .choice-mark { box-shadow: 0 0 24px -6px rgba(255, 95, 87, .6); }
.choice-sp:hover .choice-mark { box-shadow: 0 0 24px -6px rgba(46, 196, 120, .6); }
.quality-trigger { transition: color .15s; }
.quality-option { transition: background .14s, border-color .14s, color .14s, transform .1s; }
.quality-option:active { transform: scale(.985); }
.back-link { transition: color .2s, transform .2s; }
.back-link:hover { transform: translateX(-3px); }
.dialog-button { transition: transform .12s, filter .18s; }
.dialog-button:hover { filter: brightness(1.06); }
.dialog-button:active { transform: scale(.97); }
.brand-mark { transition: transform .25s; }
.brand:hover .brand-mark { transform: rotate(-6deg) scale(1.06); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 8px; }
/* The field wrapper shows focus via :focus-within — don't draw a second ring on the control inside it. */
.field-input:focus, .field-input:focus-visible,
.quality-trigger:focus, .quality-trigger:focus-visible { outline: none; }

/* ── Spotify theme override ───────────────────────── */
.theme-spotify { --accent: #2ec478; --accent-ink: #03190d; }

@media (max-width: 540px) {
  .choose { grid-template-columns: 1fr; }
  .panel-head { flex-direction: column; }
  .nav-ver { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .s2, .panel { animation: none !important; }
  * { transition: none !important; }
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .panel { background: rgba(16, 18, 22, .96); }
  .choice { background: rgba(15, 17, 20, .92); }
}
