/* Social Video Downloader - warm paper, ink, one signal accent. */
:root {
  --paper: oklch(97% 0.010 80);
  --paper-2: oklch(94% 0.014 78);
  --paper-3: oklch(90.5% 0.016 76);
  --ink: oklch(21% 0.018 55);
  --ink-2: oklch(42% 0.020 55);
  --ink-3: oklch(58% 0.018 60);
  --line: oklch(86% 0.016 75);
  --line-2: oklch(78% 0.018 72);
  --signal: oklch(62% 0.210 30);
  --signal-2: oklch(55% 0.200 30);
  --signal-soft: oklch(94% 0.040 35);
  --ok: oklch(56% 0.140 150);
  --display: 'Bricolage Grotesque', 'Segoe UI Variable Display', 'Segoe UI', sans-serif;
  --ui: 'Instrument Sans', 'Segoe UI Variable Text', 'Segoe UI', sans-serif;
  --ease-out: cubic-bezier(.22, 1, .36, 1);
  --radius: 10px;
  --gutter: clamp(18px, 4vw, 48px);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { color-scheme: light; }
body {
  font-family: var(--ui);
  font-size: 15px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--paper);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}
::selection { background: var(--signal-soft); }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

/* ---------------------------------------------------------------- top bar */
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px var(--gutter);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; }
.mark { width: 26px; height: 26px; color: var(--signal); flex-shrink: 0; }
.mark-paper { fill: var(--paper); }
.wordmark {
  font-family: var(--display); font-weight: 750; font-size: 20px; letter-spacing: -0.02em;
  font-variation-settings: 'opsz' 96;
}
.brand-name { color: var(--ink-2); font-size: 14px; margin-left: 2px; }
.top-right { display: flex; align-items: center; gap: 10px; }
.engines { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--ink-2); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--line-2); }
.dot.ok { background: var(--ok); }
.dot.bad { background: var(--signal); }

/* ---------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid transparent; border-radius: var(--radius);
  padding: 10px 16px; font-weight: 600; font-size: 14px; line-height: 1;
  text-decoration: none; white-space: nowrap;
  transition: background-color .15s, border-color .15s, color .15s, transform .15s var(--ease-out);
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn-ink { background: var(--ink); color: var(--paper); }
.btn-ink:hover:not(:disabled) { background: oklch(30% 0.02 55); }
.btn-signal { background: var(--signal); color: var(--paper); padding: 12px 22px; font-size: 15px; }
.btn-signal:hover:not(:disabled) { background: var(--signal-2); }
.btn-quiet { background: transparent; color: var(--ink-2); border-color: var(--line-2); padding: 8px 12px; font-weight: 500; }
.btn-quiet:hover:not(:disabled) { color: var(--ink); border-color: var(--ink-3); background: var(--paper-2); }
.link { background: none; border: 0; color: var(--ink-2); font-size: 12.5px; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--line-2); padding: 0; }
.link:hover { color: var(--signal); text-decoration-color: currentColor; }
kbd { font: 600 11px var(--ui); background: oklch(100% 0 0 / .14); border-radius: 4px; padding: 2px 5px; }
:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; }

/* -------------------------------------------------------------------- page */
.page { flex: 1; width: 100%; max-width: 860px; margin: 0 auto; padding: 0 var(--gutter) 40px; }

.hero { padding: clamp(28px, 6vh, 56px) 0 22px; }
h1 {
  font-family: var(--display); font-weight: 600; letter-spacing: -0.035em; line-height: 1;
  font-size: clamp(32px, 5.2vw, 46px); margin-bottom: 18px;
  font-variation-settings: 'opsz' 96;
}
.linkbar {
  display: flex; align-items: stretch; gap: 0;
  border: 1px solid var(--line-2); border-radius: 14px; background: var(--paper-2);
  transition: border-color .15s, box-shadow .15s;
}
.linkbar:focus-within { border-color: var(--ink); box-shadow: 0 0 0 4px oklch(21% 0.018 55 / .08); }
.linkbar input {
  flex: 1; min-width: 0; background: transparent; border: 0; outline: 0;
  padding: 16px 18px; font-size: 17px; letter-spacing: -0.005em;
}
.linkbar input::placeholder { color: var(--ink-3); }
.linkbar .btn-ink { margin: 6px; border-radius: 9px; }
.linkbar .btn-ink .spin { margin: 0; }
.hint { margin-top: 12px; color: var(--ink-2); font-size: 13px; }
.sites { color: var(--ink); font-weight: 500; }
.hint-sep { margin: 0 6px; color: var(--line-2); }
.notice { margin-top: 12px; color: var(--signal-2); font-size: 14px; }

/* ------------------------------------------------------------ section label */
.label {
  display: flex; align-items: center; gap: 14px;
  font: 600 11.5px var(--ui); letter-spacing: .14em; text-transform: uppercase; color: var(--ink-2);
  margin: 34px 0 16px;
}
.label::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.label .link { order: 3; letter-spacing: 0; text-transform: none; font-weight: 500; }

/* ------------------------------------------------------------------ result */
.result { animation: rise .42s var(--ease-out) both; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.result-grid { display: grid; grid-template-columns: minmax(200px, 300px) 1fr; gap: 26px; align-items: start; }
.thumb {
  position: relative; aspect-ratio: 16 / 9; border-radius: var(--radius); overflow: hidden;
  background: var(--paper-3); border: 1px solid var(--line);
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb img[src=""] { display: none; }
.badge {
  position: absolute; right: 8px; bottom: 8px;
  background: var(--ink); color: var(--paper); font-size: 11.5px; font-weight: 600;
  padding: 3px 7px; border-radius: 6px; font-variant-numeric: tabular-nums;
}
.badge:empty { display: none; }
.pv-title {
  font-family: var(--display); font-weight: 600; font-size: 21px; line-height: 1.2; letter-spacing: -0.015em;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  font-variation-settings: 'opsz' 40;
}
.pv-meta { margin-top: 6px; color: var(--ink-2); font-size: 13.5px; display: flex; gap: 12px; flex-wrap: wrap; }
.pv-meta span:empty { display: none; }
#pvSrc { color: var(--ink); font-weight: 600; }

.options { border: 0; margin-top: 18px; display: grid; }
.opt {
  display: grid; grid-template-columns: 18px 1fr auto; align-items: center; gap: 12px;
  padding: 10px 2px; border-top: 1px solid var(--line); cursor: pointer;
}
.opt:last-child { border-bottom: 1px solid var(--line); }
.opt input { appearance: none; width: 16px; height: 16px; border: 1.5px solid var(--line-2); border-radius: 50%; margin: 0; transition: border-color .15s, box-shadow .15s; }
.opt input:checked { border-color: var(--signal); box-shadow: inset 0 0 0 4px var(--signal); }
.opt:hover input:not(:checked) { border-color: var(--ink-3); }
.opt-name { font-weight: 600; }
.opt-name small { color: var(--ink-2); font-weight: 500; margin-left: 8px; }
.opt-size { color: var(--ink-2); font-size: 13px; font-variant-numeric: tabular-nums; }

.trim { margin-top: 14px; }
.disclosure {
  display: inline-flex; align-items: center; gap: 8px; background: none; border: 0;
  color: var(--ink-2); font-size: 13.5px; font-weight: 500; padding: 4px 0;
}
.disclosure:hover { color: var(--ink); }
.chev { width: 7px; height: 7px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(-45deg); transition: transform .2s var(--ease-out); }
.disclosure[aria-expanded="true"] .chev { transform: rotate(45deg); }
.trim-fields { display: grid; grid-template-columns: auto auto auto; align-items: end; gap: 10px; margin-top: 10px; }
.trim-fields label { display: grid; gap: 4px; font-size: 12px; color: var(--ink-2); }
.trim-fields input {
  width: 96px; padding: 9px 10px; border: 1px solid var(--line-2); border-radius: 8px; background: var(--paper-2);
  font-variant-numeric: tabular-nums;
}
.trim-fields input:focus { border-color: var(--ink); outline: 0; }
.trim-fields .arrow { color: var(--ink-3); padding-bottom: 10px; }
.trim-fields .check { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--ink); margin-top: 4px; }
.trim-fields .check input { width: 15px; height: 15px; padding: 0; margin: 0; accent-color: var(--signal); }
.trim-note { grid-column: 1 / -1; color: var(--ink-3); font-size: 12.5px; max-width: 52ch; }

.actions { display: flex; align-items: center; gap: 10px; margin-top: 22px; }
.spin {
  width: 14px; height: 14px; border: 2px solid oklch(100% 0 0 / .35); border-top-color: currentColor;
  border-radius: 50%; animation: spin .7s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --------------------------------------------------------------- downloads */
.jobs { list-style: none; }
.job {
  display: grid; grid-template-columns: 72px 1fr auto; gap: 14px; align-items: start;
  padding: 14px 0; border-top: 1px solid var(--line);
  animation: rise .36s var(--ease-out) both;
}
.job:last-child { border-bottom: 1px solid var(--line); }
.job-thumb { width: 72px; aspect-ratio: 16 / 9; border-radius: 6px; background: var(--paper-3); overflow: hidden; }
.job-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.job-thumb img[src=""] { display: none; }
.job-main { min-width: 0; }
.job-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.job-status { margin-top: 3px; font-size: 13px; color: var(--ink-2); font-variant-numeric: tabular-nums; display: flex; gap: 10px; flex-wrap: wrap; }
.job-status .err { color: var(--signal-2); }
.job-status .fin { color: var(--ink); }
.job-bar { position: relative; height: 3px; background: var(--paper-3); border-radius: 2px; margin-top: 9px; overflow: hidden; }
.job-bar i {
  position: absolute; inset: 0 auto 0 0; width: 0; background: var(--signal); border-radius: 2px;
  transition: width .3s linear;
}
.job.live .job-bar i {
  background-image: repeating-linear-gradient(-55deg, transparent 0 6px, oklch(100% 0 0 / .28) 6px 12px);
  background-size: 200% 100%;
  animation: tape 1.1s linear infinite;
}
.job.indeterminate .job-bar i { width: 30% !important; animation: slide 1.3s var(--ease-out) infinite; }
@keyframes tape { to { background-position: -34px 0; } }
@keyframes slide { 0% { left: -30%; } 100% { left: 100%; } }
.job-actions { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.job-actions .btn-quiet { padding: 6px 10px; font-size: 13px; }
.job-actions .x { border: 0; color: var(--ink-3); font-size: 18px; line-height: 1; padding: 4px 8px; background: none; border-radius: 6px; }
.job-actions .x:hover { color: var(--signal); background: var(--signal-soft); }
.empty { color: var(--ink-2); font-size: 14px; max-width: 52ch; }
.empty span:empty { display: none; }

/* ------------------------------------------------------------------ recent */
.recent-list { list-style: none; display: grid; gap: 2px; }
.recent-list button {
  width: 100%; text-align: left; background: none; border: 0; padding: 8px 2px;
  display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: baseline;
  border-top: 1px solid var(--line); color: var(--ink); font-size: 14px;
}
.recent-list li:last-child button { border-bottom: 1px solid var(--line); }
.recent-list button:hover { color: var(--signal); }
.recent-list .when { color: var(--ink-3); font-size: 12px; font-variant-numeric: tabular-nums; }
.recent-list .t { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* -------------------------------------------------------------------- foot */
.foot {
  display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 14px var(--gutter); border-top: 1px solid var(--line);
  color: var(--ink-3); font-size: 12px;
}

/* ---------------------------------------------------------------- settings */
.backdrop { position: fixed; inset: 0; background: oklch(21% 0.018 55 / .28); z-index: 20; }
.settings {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(440px, 100%); z-index: 21;
  background: var(--paper); border-left: 1px solid var(--line);
  transform: translateX(100%); transition: transform .34s var(--ease-out);
  display: flex; flex-direction: column;
}
.settings.open { transform: none; }
.settings-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 22px; border-bottom: 1px solid var(--line); }
.settings-head h2 { font-family: var(--display); font-size: 20px; font-weight: 650; letter-spacing: -0.02em; }
.settings-body { padding: 22px; overflow: auto; display: grid; gap: 22px; align-content: start; }
.field label { display: block; font-weight: 600; font-size: 13.5px; margin-bottom: 7px; }
.field-row { display: flex; gap: 8px; }
.field input, .field select {
  width: 100%; min-width: 0; padding: 10px 12px; border: 1px solid var(--line-2); border-radius: 8px; background: var(--paper-2);
}
.field input:focus, .field select:focus { border-color: var(--ink); outline: 0; }
.help { margin-top: 7px; color: var(--ink-2); font-size: 12.5px; line-height: 1.45; }
.saved { color: var(--ink-2); font-size: 13px; }
.saved.ok { color: var(--ok); }
.engines-list { border-top: 1px solid var(--line); padding-top: 16px; display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: 13px; color: var(--ink-2); }
.engines-list dt { font-weight: 600; color: var(--ink); }
.engines-list dd { font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------------- login */
.login-page { align-items: center; justify-content: center; padding: 24px; }
.login { width: 100%; max-width: 380px; }
.login .brand { margin-bottom: 26px; }
.login .mark { width: 40px; height: 40px; }
.login .wordmark { font-size: 28px; }
.login h1 { font-size: 30px; margin-bottom: 8px; }
.lede { color: var(--ink-2); margin-bottom: 20px; }
.login-form { display: flex; gap: 8px; }
.login-form input {
  flex: 1; min-width: 0; padding: 12px 14px; border: 1px solid var(--line-2); border-radius: var(--radius); background: var(--paper-2);
  letter-spacing: .1em;
}
.login-form input:focus { border-color: var(--ink); outline: 0; }

/* -------------------------------------------------------------- responsive */
@media (max-width: 640px) {
  .brand-name, .engines span:last-child { display: none; }
  .linkbar { flex-direction: column; }
  .linkbar .btn-ink { justify-content: center; }
  .result-grid { grid-template-columns: 1fr; gap: 16px; }
  .job { grid-template-columns: 56px 1fr; }
  .job-thumb { width: 56px; }
  .job-actions { grid-column: 2; justify-content: flex-start; }
  .trim-fields { grid-template-columns: 1fr auto 1fr; }
  .trim-fields input { width: 100%; }
  .foot { flex-direction: column; gap: 4px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
