/* Social Video Downloader — mobile-first UI. Uses Nova Saver theme tokens when present. */
.svd, .svd-sheet {
  --s-bg: var(--bg, #F2F4F7);
  --s-surface: var(--surface, #FFFFFF);
  --s-raised: var(--raised, #FAFBFC);
  --s-ink: var(--ink, #121826);
  --s-muted: var(--muted, #5B6472);
  --s-line: var(--line, #DDE2E8);
  --s-brand: var(--brand, #0A7C70);
  --s-ok: var(--ok, #0E9F6E);
  --s-bad: var(--bad, #C8283C);
  --s-display: var(--font-display, "Unbounded", system-ui, sans-serif);
  --s-text: var(--font-text, "Onest", system-ui, sans-serif);
  --lens: var(--accent, var(--s-brand));
  --on-lens: var(--on-accent, #FFFFFF);
  font-family: var(--s-text);
  color: var(--s-ink);
}
.svd *, .svd-sheet * { box-sizing: border-box; }
.svd-sr { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.svd { position: relative; margin: 0 0 2.5rem; }

/* ---------- Hero ---------- */
.svd-hero { padding: clamp(1.25rem, 5vw, 3rem) 0 1.25rem; }
.svd-h1 {
  font-family: var(--s-display);
  font-weight: 600;
  font-size: clamp(2.05rem, 8.6vw, 4.25rem);
  line-height: 1.02;
  letter-spacing: -0.035em;
  margin: 0;
  max-width: 13ch;
  text-wrap: balance;
}
.svd-sub { margin: .9rem 0 0; font-size: 1.0625rem; line-height: 1.5; color: var(--s-muted); max-width: 34ch; }

/* ---------- Tool chips ---------- */
.svd-tools {
  display: flex; gap: .5rem; overflow-x: auto; scrollbar-width: none;
  margin: 0 calc(-1 * var(--gutter, 16px)) 1.25rem; padding: 2px var(--gutter, 16px);
  scroll-snap-type: x proximity;
}
.svd-tools::-webkit-scrollbar { display: none; }
.svd .svd-tool {
  --c: var(--s-ink);
  flex: none; scroll-snap-align: start;
  display: inline-flex; align-items: center; gap: .5rem;
  min-height: 40px; padding: 0 1rem 0 .8rem;
  border: 1px solid var(--s-line); border-radius: 999px;
  background: var(--s-surface); color: var(--s-ink);
  font-size: .9375rem; font-weight: 500; text-decoration: none !important;
}
.svd .svd-tool::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.svd .svd-tool[aria-current="page"] { background: var(--s-ink); border-color: var(--s-ink); color: var(--s-bg); }
.svd .svd-tool:focus-visible { outline: 2px solid var(--s-brand); outline-offset: 2px; }
@media (min-width: 760px) {
  .svd-tools { flex-wrap: wrap; overflow: visible; margin: 0 0 1.25rem; padding: 0; }
}

/* ---------- Composer (the lens) ---------- */
.svd-composer { display: flex; gap: .5rem; align-items: stretch; }
.svd-lens {
  position: relative; flex: 1; min-width: 0;
  display: flex; align-items: center;
  height: 60px; padding: 0 .375rem 0 1.125rem;
  background: var(--s-surface);
  border-radius: 20px;
  isolation: isolate;
}
.svd-lens::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit; padding: 1.5px; z-index: -1;
  background: var(--s-line);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  transition: background .25s ease;
}
.svd-lens::after {
  content: ""; position: absolute; inset: -10px; border-radius: 28px; z-index: -2;
  background: var(--lens); opacity: 0; filter: blur(22px);
  transition: opacity .35s ease;
}
.svd[data-state="ready"] .svd-lens::before,
.svd[data-state="busy"] .svd-lens::before { background: var(--lens); }
.svd[data-state="ready"] .svd-lens::after { opacity: .22; }
.svd[data-state="busy"] .svd-lens::before {
  background: conic-gradient(from var(--sweep, 0deg), transparent 0 55%, var(--lens) 80%, transparent 100%), var(--s-line);
  animation: svd-sweep 1.1s linear infinite;
}
.svd[data-state="busy"] .svd-lens::after { opacity: .28; animation: svd-breathe 1.6s ease-in-out infinite; }
.svd[data-state="error"] .svd-lens::before { background: var(--s-bad); }
@property --sweep { syntax: "<angle>"; inherits: false; initial-value: 0deg; }
@keyframes svd-sweep { to { --sweep: 360deg; } }
@keyframes svd-breathe { 50% { opacity: .1; } }

.svd-detect {
  flex: none; max-width: 0; overflow: hidden; white-space: nowrap;
  font-size: .75rem; font-weight: 600; color: var(--lens);
  transition: max-width .3s ease, margin .3s ease;
}
.svd[data-state="ready"] .svd-detect:not(:empty),
.svd[data-state="busy"] .svd-detect:not(:empty) { max-width: 9rem; margin-right: .6rem; }
.svd-input {
  flex: 1; min-width: 0; height: 100%;
  border: 0; outline: 0; background: transparent; color: var(--s-ink);
  font: 400 16px/1.2 var(--s-text);
  text-overflow: ellipsis;
}
.svd-input::placeholder { color: var(--s-muted); opacity: 1; }
.svd-paste, .svd-clear {
  flex: none; height: 44px; border: 0; cursor: pointer; border-radius: 14px;
  background: var(--s-bg); color: var(--s-ink);
  font: 600 .875rem var(--s-text);
}
.svd-paste { padding: 0 .95rem; }
.svd .svd-paste[hidden], .svd .svd-clear[hidden] { display: none; }
.svd .svd-input:focus, .svd .svd-input:focus-visible { outline: none; }
.svd-lens:focus-within::before { background: var(--s-muted); }
.svd-clear { width: 44px; display: grid; place-items: center; color: var(--s-muted); background: transparent; }
.svd-paste:focus-visible, .svd-clear:focus-visible, .svd-go:focus-visible { outline: 2px solid var(--s-brand); outline-offset: 2px; }

.svd-go {
  flex: none; height: 60px; min-width: 60px; padding: 0 1.4rem;
  display: inline-flex; align-items: center; justify-content: center; gap: .55rem;
  border: 0; border-radius: 20px; cursor: pointer;
  background: var(--s-ink); color: var(--s-bg);
  font: 600 1rem var(--s-display); letter-spacing: -0.01em;
  transition: transform .15s ease, background .25s ease;
}
.svd[data-state="ready"] .svd-go { background: var(--lens); color: #fff; }
.svd[data-platform="x"][data-state="ready"] .svd-go,
.svd[data-platform="threads"][data-state="ready"] .svd-go { background: var(--s-ink); color: var(--s-bg); }
.svd[data-platform="snapchat"][data-state="ready"] .svd-go,
.svd[data-platform="tiktok"][data-state="ready"] .svd-go,
.svd[data-platform="vimeo"][data-state="ready"] .svd-go { color: #101018; }
.svd-go:active { transform: scale(.96); }
.svd-go[disabled] { cursor: progress; opacity: .85; }

.svd-status { min-height: 0; font-size: .9rem; line-height: 1.45; }
.svd-status:not(:empty) { margin-top: .75rem; }
.svd-status.is-error { color: var(--s-bad); }

.svd-recent { display: flex; align-items: center; gap: .6rem; margin-top: 1rem; overflow: hidden; }
.svd-recent[hidden] { display: none; }
.svd-recent-label { flex: none; font-size: .8125rem; color: var(--s-muted); }
.svd-recent-list { display: flex; gap: .4rem; overflow-x: auto; scrollbar-width: none; }
.svd-recent-list::-webkit-scrollbar { display: none; }
.svd-recent-list button {
  flex: none; max-width: 15rem; height: 34px; padding: 0 .8rem;
  border: 1px solid var(--s-line); border-radius: 999px; background: transparent; color: var(--s-ink);
  font: 500 .8125rem var(--s-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer;
}
.svd-note { margin: 1rem 0 0; font-size: .8125rem; color: var(--s-muted); }

/* ---------- Platform accent (tool pages) ---------- */
.svd-accent .svd-hero { position: relative; isolation: isolate; }
.svd-accent .svd-hero::before {
  content: ""; position: absolute; z-index: -1; pointer-events: none;
  left: calc(-1 * var(--gutter, 16px)); right: calc(-1 * var(--gutter, 16px)); top: -40px; height: 420px;
  background: radial-gradient(75% 55% at 22% 52%, color-mix(in srgb, var(--accent) 18%, transparent), transparent 72%);
}
.svd-accent .svd .svd-go { background: var(--accent); color: var(--on-accent); }
.svd-accent .svd[data-platform="x"][data-state="ready"] .svd-go,
.svd-accent .svd[data-platform="threads"][data-state="ready"] .svd-go { background: var(--s-ink); color: var(--s-bg); }
.svd-accent .svd .svd-lens::before { background: color-mix(in srgb, var(--accent) 30%, var(--s-line)); }
.svd-accent .svd[data-state="ready"] .svd-lens::before { background: var(--lens); }
.svd-accent .svd .svd-tool[aria-current="page"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.svd-accent .svd .svd-tool[aria-current="page"]::before { background: var(--on-accent); opacity: .7; }

/* ---------- Mobile: dock the composer in the thumb zone ---------- */
@media (max-width: 759px) {
  .svd.is-docked .svd-composer {
    position: fixed; left: 0; right: 0; z-index: 60;
    bottom: var(--kb, 0px);
    padding: .625rem var(--gutter, 16px) calc(.625rem + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--s-bg) 82%, transparent);
    -webkit-backdrop-filter: blur(18px) saturate(1.4); backdrop-filter: blur(18px) saturate(1.4);
    border-top: 1px solid var(--s-line);
  }
  .svd.is-docked .svd-go-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .svd.is-docked .svd-go { padding: 0; width: 60px; }
  .svd.is-docked .svd-status:not(:empty) {
    position: fixed; left: var(--gutter, 16px); right: var(--gutter, 16px); z-index: 61;
    bottom: calc(var(--kb, 0px) + 88px + env(safe-area-inset-bottom));
    margin: 0; padding: .75rem 1rem; border-radius: 14px;
    background: var(--s-surface); border: 1px solid var(--s-line);
    box-shadow: 0 10px 30px -12px rgba(10, 20, 30, .3);
  }
  body.svd-has-dock { padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
}

/* ---------- Result sheet ---------- */
.svd-sheet { position: fixed; inset: 0; z-index: 100; }
.svd-sheet[hidden] { display: none; }
.svd-sheet-backdrop { position: absolute; inset: 0; background: rgba(8, 14, 22, .55); opacity: 0; transition: opacity .25s ease; }
.svd-sheet-panel {
  position: absolute; left: 0; right: 0; bottom: 0;
  max-height: min(92vh, 900px); overflow-y: auto; overscroll-behavior: contain;
  background: var(--s-surface); border-radius: 28px 28px 0 0;
  padding: .5rem var(--gutter, 16px) calc(1.25rem + env(safe-area-inset-bottom));
  transform: translateY(100%); transition: transform .38s cubic-bezier(.2, .9, .25, 1);
  outline: none;
}
.svd-sheet.is-open .svd-sheet-backdrop { opacity: 1; }
.svd-sheet.is-open .svd-sheet-panel { transform: translateY(var(--drag, 0px)); }
.svd-grab { width: 44px; height: 5px; border-radius: 3px; background: var(--s-line); margin: .25rem auto .75rem; touch-action: none; }
.svd-sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.svd-sheet-title { margin: 0; font: 600 1.125rem/1.2 var(--s-display); letter-spacing: -0.02em; }
.svd-x { width: 44px; height: 44px; border: 0; border-radius: 50%; background: var(--s-bg); color: var(--s-ink); display: grid; place-items: center; cursor: pointer; }

@media (min-width: 760px) {
  .svd-sheet-panel { left: 50%; right: auto; bottom: 50%; width: min(560px, 92vw); border-radius: 28px; transform: translate(-50%, 60%); opacity: 0; transition: transform .3s ease, opacity .2s ease; }
  .svd-sheet.is-open .svd-sheet-panel { transform: translate(-50%, 50%); opacity: 1; }
  .svd-grab { display: none; }
}

.svd-results .svd-items { display: flex; gap: .75rem; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; margin: 0 calc(-1 * var(--gutter, 16px)); padding: 0 var(--gutter, 16px); }
.svd-items::-webkit-scrollbar { display: none; }
.svd-item { flex: 0 0 100%; scroll-snap-align: center; }
.svd-items.is-multi .svd-item { flex-basis: 84%; }

.svd-media { position: relative; border-radius: 20px; overflow: hidden; background: var(--s-bg); aspect-ratio: var(--ratio, .5625); max-height: 46vh; margin: 0 auto; }
.svd-media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.svd-dur, .svd-count {
  position: absolute; bottom: .6rem; padding: .2rem .55rem; border-radius: 8px;
  background: rgba(10, 8, 25, .66); color: #fff; font: 600 .75rem var(--s-text);
}
.svd-dur { right: .6rem; }
.svd-count { left: .6rem; }

.svd-meta { margin: .9rem 0 0; }
.svd-by { font-weight: 600; font-size: .9375rem; }
.svd-cap { margin: .25rem 0 0; color: var(--s-muted); font-size: .875rem; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.svd-copy { margin-top: .4rem; padding: .35rem 0; border: 0; background: none; color: var(--s-brand); font: 600 .875rem var(--s-text); cursor: pointer; }

.svd-save {
  --p: 0%;
  position: relative; overflow: hidden;
  width: 100%; height: 58px; margin-top: 1rem;
  display: flex; align-items: center; justify-content: center; gap: .6rem;
  border: 0; border-radius: 18px; cursor: pointer;
  background: var(--s-ink); color: var(--s-bg);
  font: 600 1rem var(--s-display); letter-spacing: -0.01em;
  text-decoration: none !important;
}
.svd-save::before { content: ""; position: absolute; inset: 0; width: var(--p); background: var(--lens); transition: width .2s linear; }
.svd-save > * { position: relative; }
.svd-save small { font: 500 .8125rem var(--s-text); opacity: .7; }
.svd-save.is-done { background: var(--s-ok); color: #fff; }
.svd-hint { margin: .6rem 0 0; font-size: .8125rem; color: var(--s-muted); text-align: center; }
.svd-hint[hidden] { display: none; }

.svd-more { margin-top: .9rem; }
.svd-more-label { font-size: .8125rem; color: var(--s-muted); margin-bottom: .45rem; }
.svd-opts { display: flex; flex-wrap: wrap; gap: .45rem; }
.svd-sheet .svd-opt {
  display: inline-flex; align-items: center; min-height: 40px; padding: 0 .9rem;
  border: 1px solid var(--s-line); border-radius: 12px; color: var(--s-ink); background: transparent;
  font: 500 .875rem var(--s-text); text-decoration: none !important; cursor: pointer;
}
.svd-opt:focus-visible, .svd-save:focus-visible, .svd-copy:focus-visible { outline: 2px solid var(--s-brand); outline-offset: 2px; }

.svd-skel { border-radius: 20px; background: linear-gradient(100deg, var(--s-bg) 30%, var(--s-line) 50%, var(--s-bg) 70%); background-size: 300% 100%; animation: svd-shimmer 1.2s linear infinite; }
@keyframes svd-shimmer { to { background-position: -150% 0; } }

/* ---------- Blog CTA ---------- */
.svd-cta { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem 1rem; margin: 2rem 0; padding: 1.1rem 1.25rem; border: 1px solid var(--s-line, #DEDCEC); border-radius: 20px; background: var(--surface, #fff); }
.svd-cta-t { margin: 0; font-weight: 600; }
.svd-cta-b { display: inline-flex; align-items: center; min-height: 44px; padding: 0 1.1rem; border-radius: 14px; background: var(--ink, #17162E); color: var(--bg, #fff) !important; font-weight: 600; text-decoration: none !important; }

@media (prefers-reduced-motion: reduce) {
  .svd *, .svd-sheet * { animation: none !important; transition: none !important; }
}

/* ---------- TapDL action icon (play turned down) ---------- */
.svd-e { flex: none; display: block; }
.svd-save .svd-e { color: var(--lens); }
.svd-save.is-done .svd-e { color: #fff; }
.svd-sheet .svd-opt { gap: .45rem; }
.svd-sheet .svd-opt .svd-e { color: inherit; opacity: .8; }
.svd-go .svd-go-ico { width: 26px; height: 26px; }
/* The save button stays dark in both themes so every platform colour reads on it */
.svd-sheet .svd-save { background: #121826; color: #FFFFFF; }
.svd-sheet[data-ink] .svd-save .svd-e { color: #2EE6C8; }
@media (prefers-color-scheme: dark) {
  .svd-sheet .svd-save { background: #0A1016; box-shadow: inset 0 0 0 1px var(--s-line); }
}
.svd-cta-b { gap: .5rem; }
.svd-cta-b .svd-e { color: var(--brand-bright, #2EE6C8); }

/* ---------- In-page preview (story viewer and every video) ---------- */
.svd-play {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 72px; height: 72px; border: 0; border-radius: 50%; cursor: pointer;
  display: grid; place-items: center; padding-left: 4px;
  background: rgba(10, 16, 24, .55); color: #fff;
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
}
.svd-play:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }
.svd-video { width: 100%; height: 100%; display: block; background: #000; object-fit: contain; }
.svd-byline { margin: -1.5rem 0 2rem; font-size: .875rem; color: var(--muted, #5B6472); }

/* ---------- Results inside the page (replaces the pop-up) ---------- */
.svd-results {
  margin-top: 1rem; padding: 1rem var(--gutter, 16px) 1.25rem;
  margin-left: calc(-1 * var(--gutter, 16px)); margin-right: calc(-1 * var(--gutter, 16px));
  background: var(--s-surface); border-top: 1px solid var(--s-line); border-bottom: 1px solid var(--s-line);
}
.svd-results[hidden] { display: none; }
.svd-results-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .9rem; }
.svd-results-title { margin: 0; font: 600 1.0625rem/1.2 var(--s-display); letter-spacing: -0.02em; color: var(--s-ink); }
.svd-results-x { width: 40px; height: 40px; border: 0; border-radius: 50%; background: var(--s-bg); color: var(--s-ink); display: grid; place-items: center; cursor: pointer; }
.svd-results-x:focus-visible { outline: 2px solid var(--s-brand); outline-offset: 2px; }
.svd-results .svd-items { margin: 0 calc(-1 * var(--gutter, 16px)); padding: 0 var(--gutter, 16px); gap: .75rem; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; }
.svd-results .svd-media { max-height: 56vh; }
.svd-results .svd-save { background: #121826; color: #fff; }
.svd-results[data-ink] .svd-save .svd-e { color: #2EE6C8; }
.svd-results .svd-opt { display: inline-flex; align-items: center; gap: .45rem; min-height: 40px; padding: 0 .9rem; border: 1px solid var(--s-line); border-radius: 12px; color: var(--s-ink); text-decoration: none !important; font: 500 .875rem var(--s-text); }
.svd-results .svd-opt .svd-e { opacity: .8; }
@media (prefers-color-scheme: dark) {
  .svd-results .svd-save { background: #0A1016; box-shadow: inset 0 0 0 1px var(--s-line); }
}
@media (min-width: 760px) {
  .svd-results { margin-left: 0; margin-right: 0; padding: 1.25rem; border: 1px solid var(--s-line); border-radius: 24px; }
  .svd-results .svd-items { margin: 0; padding: 0; }
  /* One video: preview on the left, details and buttons on the right */
  .svd-results .svd-items:not(.is-multi) .svd-item { display: grid; grid-template-columns: minmax(200px, 260px) 1fr; column-gap: 1.5rem; align-items: start; }
  .svd-results .svd-items:not(.is-multi) .svd-media { grid-row: 1 / span 6; width: 100%; max-height: 460px; }
  .svd-results .svd-items:not(.is-multi) .svd-item > :not(.svd-media) { grid-column: 2; }
  .svd-results .svd-items:not(.is-multi) .svd-meta { margin-top: 0; }
  .svd-results .svd-items.is-multi .svd-item { flex: 0 0 300px; }
  .svd-results .svd-save { max-width: 420px; }
}

/* Phones: one result = small preview beside the details, so Save stays above the docked box */
@media (max-width: 759px) {
  .svd-results .svd-items:not(.is-multi) .svd-item { display: grid; grid-template-columns: 128px 1fr; column-gap: 14px; align-items: start; }
  .svd-results .svd-items:not(.is-multi) .svd-media { grid-row: 1; grid-column: 1; width: 128px; max-height: 228px; border-radius: 16px; }
  .svd-results .svd-items:not(.is-multi) .svd-meta { grid-row: 1; grid-column: 2; margin-top: 0; }
  .svd-results .svd-items:not(.is-multi) .svd-cap { -webkit-line-clamp: 4; }
  .svd-results .svd-items:not(.is-multi) .svd-item > .svd-save,
  .svd-results .svd-items:not(.is-multi) .svd-item > .svd-hint,
  .svd-results .svd-items:not(.is-multi) .svd-item > .svd-more { grid-column: 1 / -1; }
  .svd-results .svd-items:not(.is-multi) .svd-play { width: 52px; height: 52px; }
  .svd-results .svd-items.is-multi .svd-media { max-height: 40vh; }
}
@media (min-width: 760px) {
  .svd-results .svd-items.is-multi .svd-item { flex-basis: 260px; }
  .svd-results .svd-items.is-multi .svd-media { max-height: 360px; }
}
