/* VidPocket — mobile-first, no frameworks, system fonts (zero font downloads). */

:root {
  --bg: #f7f7f5;
  --surface: #ffffff;
  --surface-2: #f0f0ec;
  --text: #111318;
  --muted: #586070;
  --border: #e2e2dc;
  --accent: #2457f5;
  --accent-hover: #1a45d1;
  --accent-soft: #e8eeff;
  --on-accent: #ffffff;
  --ok: #0f7a55;
  --ok-soft: #e3f4ec;
  --err: #b8321c;
  --err-soft: #fdecea;
  --focus: #2457f5;
  --radius: 16px;
  --radius-sm: 12px;
  --shadow: 0 1px 2px rgba(16, 18, 24, .04), 0 8px 24px rgba(16, 18, 24, .06);
  --p-tiktok: #111318;
  --p-facebook: #1b6af2;
  --p-instagram: #c3368a;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c0e12;
    --surface: #151821;
    --surface-2: #1c202b;
    --text: #eef0f4;
    --muted: #a0a7b5;
    --border: #2a2f3b;
    --accent: #6e8cff;
    --accent-hover: #8aa2ff;
    --accent-soft: #1d2747;
    --on-accent: #0c0e12;
    --ok: #4cc795;
    --ok-soft: #12291f;
    --err: #ff8a75;
    --err-soft: #2e1714;
    --focus: #8aa2ff;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
    --p-tiktok: #eef0f4;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: 16px; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
main { flex: 1; }
img, svg { display: block; max-width: 100%; }
a { color: var(--accent); text-underline-offset: 3px; }
h1, h2, h3 { line-height: 1.15; margin: 0; letter-spacing: -0.02em; }
p { margin: 0; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 8px; }

.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip {
  position: absolute; left: 12px; top: -60px; z-index: 10;
  background: var(--surface); padding: 10px 14px; border-radius: 10px; box-shadow: var(--shadow);
}
.skip:focus { top: 12px; }

.wrap {
  width: 100%;
  max-width: 720px;
  margin-inline: auto;
  padding-inline: max(16px, env(safe-area-inset-left)) max(16px, env(safe-area-inset-right));
}

/* ── Header ─────────────────────────────────────────── */
.site-header { padding-top: env(safe-area-inset-top); }
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; height: 64px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 750; font-size: 1.125rem; letter-spacing: -0.02em; min-height: 44px; }
.brand-mark { width: 32px; height: 32px; color: var(--accent); flex: none; }
.brand-tld { color: var(--muted); font-weight: 600; }
.nav { display: flex; gap: 4px; }
.nav a { color: var(--muted); text-decoration: none; font-size: .9375rem; font-weight: 550; padding: 10px 10px; border-radius: 10px; }
.nav a:hover { color: var(--text); background: var(--surface-2); }
@media (max-width: 379px) { .nav a[href="#how"] { display: none; } .brand-tld { display: none; } }

/* ── Hero / form ────────────────────────────────────── */
.hero { padding-top: 28px; padding-bottom: 8px; }
.eyebrow { color: var(--accent); font-weight: 650; font-size: .875rem; letter-spacing: .02em; margin-bottom: 10px; }
h1 { font-size: clamp(2rem, 8vw, 3.25rem); font-weight: 780; }
.lede { color: var(--muted); font-size: 1.0625rem; margin-top: 12px; max-width: 34em; }

.dl-form { margin-top: 24px; display: grid; gap: 12px; }
.field {
  display: flex; align-items: center; gap: 6px;
  min-height: 60px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 6px 6px 14px;
  box-shadow: var(--shadow);
  transition: border-color .15s, box-shadow .15s;
  min-width: 0;
}
.field:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft), var(--shadow); }
.field.is-error { border-color: var(--err); }
.field input {
  flex: 1; min-width: 0; height: 46px;
  border: 0; outline: 0; background: transparent;
  font-size: 1rem; /* ≥16px prevents iOS zoom */
}
.field input::placeholder { color: var(--muted); opacity: .85; }
.field input:focus-visible { outline: none; }
.field-btn {
  flex: none; display: inline-flex; align-items: center; gap: 6px;
  height: 46px; min-width: 46px; padding: 0 14px;
  border: 0; border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--text); font-weight: 600; font-size: .9375rem;
}
.field-btn:hover { background: var(--border); }
.field-btn svg { width: 20px; height: 20px; }
.field-btn.icon-only { padding: 0; justify-content: center; }
@media (max-width: 359px) { #paste span { display: none; } #paste { padding: 0; justify-content: center; } }

.platform-badge {
  flex: none; display: inline-flex; align-items: center; gap: 6px;
  font-size: .8125rem; font-weight: 650; padding: 4px 10px 4px 8px; border-radius: 999px;
  background: var(--surface-2); color: var(--text); white-space: nowrap;
  animation: pop .18s ease-out;
}
.platform-badge::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--dot, var(--muted)); }
@media (max-width: 400px) { .platform-badge .pname { display: none; } .platform-badge { padding: 6px; } }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 48px; padding: 0 20px;
  border-radius: var(--radius); border: 1.5px solid transparent;
  font-weight: 680; font-size: 1rem; text-decoration: none; text-align: center;
  transition: background-color .15s, transform .05s, opacity .15s;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(.985); }
.btn-lg { min-height: 58px; font-size: 1.0625rem; width: 100%; }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--surface-2); }
.btn-link { background: none; border: 0; color: var(--accent); font-weight: 600; padding: 0 8px; min-height: 44px; }
.btn[disabled], .btn[aria-busy="true"] { opacity: .7; cursor: progress; }

.spinner {
  width: 18px; height: 18px; border-radius: 50%; flex: none;
  border: 2.5px solid currentColor; border-right-color: transparent;
  animation: spin .7s linear infinite;
}

.hint { margin-top: 14px; color: var(--muted); font-size: .875rem; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font-weight: 550; font-size: .8125rem;
  transition: background-color .15s, border-color .15s;
}
.chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--dot); }
.chip.is-on { border-color: var(--dot); background: var(--surface-2); }
[data-p="tiktok"] { --dot: var(--p-tiktok); }
[data-p="facebook"] { --dot: var(--p-facebook); }
[data-p="instagram"] { --dot: var(--p-instagram); }

.status { min-height: 28px; margin-top: 14px; display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: .9375rem; font-weight: 550; }
.status .spinner { color: var(--accent); }
.status.is-ok { color: var(--ok); }
.alert {
  margin-top: 4px; padding: 12px 14px; border-radius: var(--radius-sm);
  background: var(--err-soft); color: var(--err); font-weight: 600; font-size: .9375rem;
  display: flex; gap: 10px; align-items: flex-start;
}
.alert svg { width: 20px; height: 20px; flex: none; margin-top: 1px; }

/* ── Result card ────────────────────────────────────── */
.result { padding-top: 8px; padding-bottom: 8px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 20px;
  box-shadow: var(--shadow); overflow: hidden; animation: rise .22s ease-out;
}
.media { display: grid; }
.thumb {
  position: relative; aspect-ratio: 16 / 9; background: var(--surface-2); overflow: hidden;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb.is-portrait img { object-fit: contain; }
.thumb .ph { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); }
.thumb .ph svg { width: 44px; height: 44px; opacity: .6; }
.duration {
  position: absolute; right: 10px; bottom: 10px; padding: 2px 8px; border-radius: 8px;
  background: rgba(0, 0, 0, .72); color: #fff; font-size: .8125rem; font-weight: 650; font-variant-numeric: tabular-nums;
}
.meta { padding: 16px 16px 4px; display: grid; gap: 8px; min-width: 0; }
.pill {
  justify-self: start; display: inline-flex; align-items: center; gap: 6px;
  font-size: .8125rem; font-weight: 650; padding: 3px 10px; border-radius: 999px; background: var(--surface-2);
}
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--dot); }
.title { font-size: 1.1875rem; font-weight: 700; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.title:focus { outline: none; }
.uploader { color: var(--muted); font-size: .9375rem; overflow-wrap: anywhere; }

.picker { padding: 12px 16px 0; border: 0; margin: 0; min-width: 0; }
.picker legend { padding: 0; font-size: .8125rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-bottom: 10px; }
.qualities { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 132px), 1fr)); gap: 8px; }
.q { position: relative; }
.q input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.q label {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  min-height: 52px; padding: 8px 12px; border-radius: var(--radius-sm);
  border: 1.5px solid var(--border); background: var(--surface); cursor: pointer;
  transition: border-color .12s, background-color .12s;
}
.q label:hover { border-color: var(--muted); }
.q input:checked + label { border-color: var(--accent); background: var(--accent-soft); }
.q input:focus-visible + label { outline: 3px solid var(--focus); outline-offset: 2px; }
.q-main { display: grid; line-height: 1.2; }
.q-res { font-weight: 750; font-size: 1.0625rem; font-variant-numeric: tabular-nums; }
.q-size { color: var(--muted); font-size: .75rem; font-weight: 550; white-space: nowrap; }
.q label { position: relative; padding-right: 10px; }
.q .tag { position: absolute; top: 6px; right: 6px; }
.tag { font-size: .6875rem; font-weight: 800; letter-spacing: .04em; padding: 2px 6px; border-radius: 6px; background: var(--surface-2); color: var(--muted); }
.tag.best { background: var(--accent); color: var(--on-accent); }

.note { margin: 12px 16px 0; font-size: .875rem; color: var(--muted); display: flex; gap: 8px; align-items: flex-start; }
.note svg { width: 18px; height: 18px; flex: none; margin-top: 2px; }

.facts { display: flex; flex-wrap: wrap; gap: 8px 16px; padding: 14px 16px 0; font-size: .9375rem; }
.fact { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.fact svg { width: 18px; height: 18px; }
.fact.ok { color: var(--ok); }
.fact.warn { color: var(--muted); }

.actions { padding: 16px; display: grid; gap: 10px; }
.progress { display: grid; gap: 8px; }
.bar { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.bar > span { display: block; height: 100%; width: 0; background: var(--accent); border-radius: inherit; transition: width .3s ease; }
.bar.is-indeterminate > span { width: 35%; animation: slide 1.1s ease-in-out infinite; }
.progress-text { display: flex; justify-content: space-between; gap: 8px; color: var(--muted); font-size: .875rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.again { justify-self: center; }

/* ── Info sections ──────────────────────────────────── */
.info { padding-top: 40px; }
.info h2 { font-size: 1.375rem; font-weight: 750; margin-bottom: 16px; }
.steps { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.steps li { display: flex; gap: 14px; padding: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.steps h3 { font-size: 1rem; margin-bottom: 4px; }
.steps p { color: var(--muted); font-size: .9375rem; }
.step-n { flex: none; width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); font-weight: 800; }

details { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 10px; }
summary { cursor: pointer; padding: 14px 16px; font-weight: 650; min-height: 48px; display: flex; align-items: center; justify-content: space-between; gap: 12px; list-style: none; }
summary::-webkit-details-marker { display: none; }
summary::after { content: "+"; font-size: 1.375rem; line-height: 1; color: var(--muted); flex: none; }
details[open] summary::after { content: "–"; }
details p { padding: 0 16px 16px; color: var(--muted); font-size: .9375rem; }

/* ── Footer ─────────────────────────────────────────── */
.site-footer { margin-top: 56px; border-top: 1px solid var(--border); padding-bottom: max(24px, env(safe-area-inset-bottom)); }
.footer-inner { padding-top: 24px; display: grid; gap: 14px; font-size: .875rem; color: var(--muted); }
.footer-links { display: flex; flex-wrap: wrap; gap: 4px 18px; }
.footer-links a { color: var(--text); text-decoration: none; font-weight: 600; padding: 8px 0; }
.footer-links a:hover { color: var(--accent); }
.noscript { padding-block: 16px; color: var(--err); }

/* ── Larger screens ─────────────────────────────────── */
@media (min-width: 640px) {
  .hero { padding-top: 56px; }
  .dl-form { grid-template-columns: 1fr auto; align-items: stretch; }
  .btn-lg { width: auto; min-width: 168px; padding-inline: 28px; }
  .steps { grid-template-columns: repeat(3, 1fr); }
  .steps li { flex-direction: column; }
}
@media (min-width: 768px) {
  .media { grid-template-columns: 300px 1fr; align-items: start; }
  .thumb { margin: 16px 0 0 16px; border-radius: 14px; }
  .meta { padding: 16px 16px 4px 18px; }
  .picker { padding-top: 20px; }
  .footer-inner { grid-template-columns: 1fr auto; align-items: center; }
  .footer-note { grid-column: 1 / -1; }
}
@media (min-width: 1280px) {
  .wrap { max-width: 760px; }
}

/* ── Motion ─────────────────────────────────────────── */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pop { from { transform: scale(.9); opacity: 0; } }
@keyframes rise { from { transform: translateY(6px); opacity: 0; } }
@keyframes slide { 0% { transform: translateX(-100%); } 100% { transform: translateX(290%); } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
  .spinner { animation: spin 1.5s linear infinite !important; }
}

/* Legal pages */
.legal { padding-top: 24px; }
.legal h1 { font-size: clamp(1.75rem, 6vw, 2.5rem); margin-bottom: 8px; }
.legal h2 { font-size: 1.1875rem; margin: 28px 0 8px; }
.legal p, .legal li { color: var(--muted); }
.legal p + p { margin-top: 10px; }
.legal ul { padding-left: 1.2em; }
.legal .updated { font-size: .875rem; }
.legal .cta { margin-top: 20px; }
