/* Redigere. Values follow fixed scales: spacing 2/4/8/12/16/24/32/40/48/64/80/96,
   type 12/14/16/18/20/24/30/36/48, radius 4/6/8/12/16/full. */
@font-face {
  font-family: "Manrope";
  src: url("/static/fonts/manrope.woff2") format("woff2");
  font-weight: 200 800;
  font-display: swap;
}

:root {
  --bg: #000000;
  --surface: #181818;
  --raised: #1f1f1f;
  --line: #313131;
  --fg: #f4f4f5;
  --muted: #a1a1aa;
  --accent: #7c3aed;
  --accent-hover: #6d28d9;
  --accent-fg: #ffffff;
  --accent-text: #b79cff;
  --accent-soft: rgba(124, 58, 237, 0.16);
  --accent-line: rgba(167, 139, 250, 0.45);
  --ok: #4ade80;
  --err: #f87171;
  --err-soft: rgba(248, 113, 113, 0.12);
  --warn-soft: rgba(124, 58, 237, 0.12);
  --hero-from: #ffffff;
  --hero-to: #9b9b9b;
  --topbar: rgba(24, 24, 24, 0.72);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #fafafa;
    --surface: #ffffff;
    --raised: #f4f4f5;
    --line: #e4e4e7;
    --fg: #18181b;
    --muted: #52525b;
    --accent: #6d28d9;
    --accent-hover: #5b21b6;
    --accent-text: #6d28d9;
    --accent-soft: rgba(109, 40, 217, 0.08);
    --accent-line: rgba(109, 40, 217, 0.4);
    --ok: #15803d;
    --err: #b91c1c;
    --err-soft: rgba(185, 28, 28, 0.08);
    --warn-soft: rgba(109, 40, 217, 0.06);
    --hero-from: #000000;
    --hero-to: #666666;
    --topbar: rgba(255, 255, 255, 0.72);
    color-scheme: light;
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; } /* components set display; `hidden` must still win (also covers the SVG sprite) */
html { scroll-behavior: smooth; scroll-padding-top: 96px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 400 1rem/1.5rem "Manrope", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1, h2, p { margin: 0; }
h1, h2 { text-wrap: balance; }
p { text-wrap: pretty; }
img { display: block; max-width: 100%; }
code, .mono { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 0.875rem; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; line-height: 1.25rem; }
.grow { flex: 1 1 auto; min-width: 0; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 2px; }

.icon { width: 1.25rem; height: 1.25rem; fill: currentColor; flex: none; }
.icon.xl { width: 2.5rem; height: 2.5rem; }

.skip {
  position: absolute; left: 16px; top: 16px; z-index: 20;
  padding: 8px 12px; border-radius: 8px; background: var(--accent); color: var(--accent-fg);
  transform: translateY(-200%); transition: transform 300ms var(--ease);
}
.skip:focus { transform: none; }

/* --- top bar: compact, floating, translucent --- */
.topbar {
  position: sticky; top: 12px; z-index: 10;
  width: fit-content; max-width: calc(100% - 32px);
  margin: 12px auto 0; padding: 8px 8px 8px 12px;
  display: flex; align-items: center; gap: 24px;
  background: var(--topbar); border: 1px solid var(--line); border-radius: 16px;
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
}
.brand { display: flex; align-items: center; gap: 8px; color: var(--fg); text-decoration: none; font-weight: 700; font-size: 1.125rem; line-height: 1.75rem; }
.brand img { width: 32px; height: 32px; border-radius: 8px; }

main { max-width: 768px; margin: 0 auto; padding: 0 16px; }

/* --- hero --- */
.hero { padding: 64px 0 32px; text-align: center; }
.hero h1 {
  max-width: 680px; margin: 0 auto;
  font-size: 2.25rem; line-height: 2.5rem; font-weight: 700; letter-spacing: -0.02em;
  background: linear-gradient(90deg, var(--hero-from), var(--hero-to));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.lede { max-width: 680px; margin: 16px auto 0; color: var(--muted); font-size: 1.125rem; line-height: 1.75rem; }
.platforms { list-style: none; padding: 0; margin: 24px 0 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.platforms li { font-size: 0.875rem; line-height: 1.25rem; padding: 4px 12px; border: 1px solid var(--line); border-radius: 9999px; color: var(--muted); }
@media (max-width: 639px) {
  .hero h1 { font-size: 1.875rem; line-height: 2.25rem; }
  .hero h1 br { display: none; } /* let text-wrap: balance pick breaks on narrow screens */
}
@media (min-width: 640px) {
  .hero { padding: 80px 0 40px; }
  .hero h1 { font-size: 3rem; line-height: 1.1; }
}

/* --- surfaces --- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 24px; margin-bottom: 16px; }
.card h2 { font-size: 1.25rem; line-height: 1.75rem; font-weight: 700; }
.notice {
  display: flex; gap: 12px; align-items: flex-start;
  background: var(--warn-soft); border: 1px solid var(--accent-line); border-radius: 12px;
  padding: 12px 16px; margin-bottom: 16px; font-size: 0.875rem; line-height: 1.25rem;
}
.notice .icon { color: var(--accent-text); }
.label { display: block; font-weight: 600; font-size: 0.875rem; line-height: 1.25rem; margin-bottom: 8px; padding: 0; }
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 0.75rem; line-height: 1rem; font-weight: 600;
  padding: 2px 8px; border-radius: 9999px;
  background: var(--accent-soft); color: var(--accent-text);
}

/* --- controls --- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 8px 12px; border-radius: 8px; border: 1px solid transparent;
  font-family: inherit; font-weight: 600; font-size: 1rem; line-height: 1.5rem; cursor: pointer; text-decoration: none;
  transition: background-color 300ms var(--ease), border-color 300ms var(--ease), transform 300ms var(--ease), opacity 300ms var(--ease);
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn.sm { font-size: 0.875rem; line-height: 1.25rem; padding: 4px 12px; }
.btn.sm .icon { width: 1rem; height: 1rem; }
.btn.primary { background: var(--accent); color: var(--accent-fg); }
.btn.primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn.ghost { background: transparent; color: var(--fg); border-color: var(--line); }
.btn.ghost:hover:not(:disabled) { background: var(--raised); }
.btn.danger:hover:not(:disabled) { color: var(--err); border-color: var(--err); }

.field { display: flex; flex-wrap: wrap; gap: 8px; }
.input-wrap { position: relative; flex: 1 1 280px; min-width: 0; }
.input-wrap .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
input[type=url], select {
  width: 100%; font: inherit; color: var(--fg);
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 12px; transition: border-color 300ms var(--ease);
}
input[type=url] { padding-left: 40px; }
input[type=url]:hover, select:hover { border-color: var(--muted); }
input[type=url]:focus-visible, select:focus-visible { outline: none; border-color: var(--accent-text); box-shadow: 0 0 0 2px var(--accent-soft); }
input[aria-invalid=true] { border-color: var(--err); }
.error { color: var(--err); font-size: 0.875rem; line-height: 1.25rem; margin-top: 8px; }
.error:empty { display: none; }

/* --- preview --- */
.media { display: flex; gap: 16px; align-items: flex-start; }
.thumb { width: 192px; max-width: 40%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 8px; background: var(--raised); flex: none; }
.preview h2 { margin: 8px 0 4px; font-size: 1.125rem; line-height: 1.75rem; overflow-wrap: anywhere; }
.preview #meta { display: flex; gap: 8px; align-items: center; font-size: 0.875rem; line-height: 1.25rem; }
fieldset { border: 0; padding: 0; margin: 24px 0 0; min-width: 0; }
.choices { display: flex; flex-wrap: wrap; gap: 8px; }
.choice { position: relative; }
.choice input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.choice span {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 12px; border-radius: 8px; border: 1px solid var(--line);
  font-weight: 600; font-size: 0.875rem; line-height: 1.25rem; color: var(--muted);
  transition: background-color 300ms var(--ease), border-color 300ms var(--ease), color 300ms var(--ease);
}
.choice span .icon { width: 1rem; height: 1rem; }
.choice:hover span { color: var(--fg); border-color: var(--muted); }
.choice input:checked + span { background: var(--accent-soft); border-color: var(--accent-text); color: var(--fg); }
.choice input:focus-visible + span { outline: 2px solid var(--accent-text); outline-offset: 2px; }
.choice input:disabled + span { opacity: 0.45; cursor: not-allowed; }
.exact { margin-top: 16px; display: grid; gap: 4px; }
.actions { margin-top: 24px; display: flex; justify-content: flex-end; }
.playlist .row { margin-bottom: 8px; }
.entries { list-style: none; margin: 0; padding: 4px; max-height: 320px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
.entries label { display: flex; gap: 12px; align-items: center; padding: 8px; border-radius: 4px; cursor: pointer; overflow-wrap: anywhere; }
.entries label:hover { background: var(--raised); }
.entries input { accent-color: var(--accent); width: 16px; height: 16px; flex: none; }
.entries .dur { margin-left: auto; color: var(--muted); font-size: 0.875rem; font-variant-numeric: tabular-nums; }

/* skeleton */
.sk { background: var(--raised); border-radius: 4px; animation: pulse 1600ms var(--ease) infinite; }
.sk.thumb { border-radius: 8px; }
.sk.line { height: 12px; margin: 8px 0; }
.w30 { width: 30%; } .w50 { width: 50%; } .w70 { width: 70%; margin-top: 24px !important; } .w90 { width: 90%; }
@keyframes pulse { 50% { opacity: 0.45; } }

/* --- queue --- */
.section-head { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; }
.empty { display: grid; justify-items: center; text-align: center; gap: 4px; padding: 32px 16px; border: 1px dashed var(--line); border-radius: 12px; }
.empty .icon { color: var(--accent-text); margin-bottom: 8px; }
.empty-title { font-weight: 600; }
.empty[hidden] { display: none; }
.jobs { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.job { border: 1px solid var(--line); border-radius: 12px; padding: 16px; background: var(--bg); }
.job-head { display: flex; gap: 12px; align-items: flex-start; }
.job-title { font-weight: 600; overflow-wrap: anywhere; }
.status { display: inline-flex; align-items: center; gap: 4px; font-size: 0.875rem; line-height: 1.25rem; font-weight: 600; color: var(--muted); }
.status .icon { width: 1rem; height: 1rem; }
.job.done .status { color: var(--ok); }
.job.error .status { color: var(--err); }
.job.downloading .status, .job.processing .status { color: var(--accent-text); }
.job-meta { margin-top: 4px; display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; font-size: 0.875rem; line-height: 1.25rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.bar { height: 8px; margin-top: 12px; border-radius: 9999px; background: var(--raised); overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--accent); border-radius: inherit; transform-origin: left; transform: scaleX(0); transition: transform 500ms var(--ease); }
.job.processing .bar > span { animation: pulse 1600ms var(--ease) infinite; }
.job .error { background: var(--err-soft); border-radius: 8px; padding: 8px 12px; margin-top: 12px; }
.job .row { margin-top: 12px; }
.files { display: grid; gap: 8px; margin-top: 12px; }
.files .btn { justify-content: flex-start; overflow-wrap: anywhere; text-align: left; }

/* --- settings --- */
#settings h2 { margin-bottom: 8px; }
.setting { display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: center; padding: 16px 0; border-bottom: 1px solid var(--line); }
.setting:last-of-type { border-bottom: 0; }
.setting-title { display: flex; align-items: center; gap: 8px; font-weight: 600; margin-bottom: 4px; }
.setting-title .icon { color: var(--accent-text); }
#settings-msg:empty { display: none; }

.footer { max-width: 768px; margin: 0 auto; padding: 24px 16px 64px; text-align: center; font-size: 0.875rem; line-height: 1.25rem; display: grid; gap: 4px; }

/* --- motion --- */
.reveal:not([hidden]) { animation: rise 600ms var(--ease) both; }
.job.enter { animation: rise 500ms var(--ease) both; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

@media (max-width: 480px) {
  .card { padding: 16px; }
  .media { flex-direction: column; }
  .thumb { width: 100%; max-width: none; }
  .field .btn { width: 100%; }
  .actions .btn { width: 100%; }
}

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

/* --- login --- */
.login { max-width: 400px; padding: 80px 16px 48px; text-align: center; }
.login-logo { margin: 0 auto 24px; border-radius: 24px; }
.login h1 { font-size: 1.875rem; line-height: 2.25rem; font-weight: 700; margin-bottom: 8px; }
.login .card { margin: 32px 0 16px; text-align: left; display: grid; gap: 8px; }
.login input[type=password] {
  width: 100%; font: inherit; color: var(--fg); background: var(--bg);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px;
  transition: border-color 300ms var(--ease);
}
.login input[type=password]:focus-visible { outline: none; border-color: var(--accent-text); box-shadow: 0 0 0 2px var(--accent-soft); }
.btn.wide { width: 100%; margin-top: 8px; }
