/* =========================================================
   Theme variables — light is default, dark via [data-theme="dark"]
   ========================================================= */
:root,
[data-theme="light"] {
  --bg: #ffffff;
  --card: #ffffff;
  --surface: #fafbfd;
  --ink: #0f1115;
  --ink-soft: #5a6072;
  --ink-mute: #8a92a3;
  --line: #e8e9ee;
  --line-soft: #f1f2f6;
  --field-bg: #ffffff;
  --accent: #2a5cff;
  --accent-soft: #e8efff;
  --accent-ink: #ffffff;
  --chip-bg: #f3f4f8;
  --chip-ink: #3a3f4d;
  --danger-bg: #ffe1e5;
  --danger-ink: #a01828;
  --feature-1: #e8f0ff;
  --feature-2: #ffe9f0;
  --feature-3: #e8fff3;
  --feature-4: #fff4e0;
  --shadow-card: 0 1px 2px rgba(15, 17, 21, 0.04), 0 12px 40px rgba(15, 17, 21, 0.06);
  --blob-1: #dbe7ff;
  --blob-2: #ffe0ef;
  --blob-3: #dfffe9;
  --dot:    #c8cdd9;
  --dot-2:  #d6cee0;
  --sq-tri:  #ffd3a3;
  --sq-ring: #7cd7c0;
  --sq-plus: #b388ff;
  --sq-sq:   #ffd1dc;
  --sq-star: #ffe28a;
  --squig:   #a4b3ff;
}

[data-theme="dark"] {
  --bg: #000000;
  --card: #000000;
  --surface: #0d1017;
  --ink: #e8ecf3;
  --ink-soft: #a3acc0;
  --ink-mute: #6b7388;
  --line: #232735;
  --line-soft: #1b1f2a;
  --field-bg: #0f1218;
  --accent: #6aa6ff;
  --accent-soft: rgba(106, 166, 255, 0.16);
  --accent-ink: #08111f;
  --chip-bg: #1c2030;
  --chip-ink: #c5cbdb;
  --danger-bg: #3a1a22;
  --danger-ink: #ffb3bf;
  --feature-1: #15203b;
  --feature-2: #321722;
  --feature-3: #11261f;
  --feature-4: #2c2110;
  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.4), 0 20px 60px rgba(0, 0, 0, 0.5);
  --blob-1: #1d3a78;
  --blob-2: #4a1f3a;
  --blob-3: #143728;
  --dot:    #2a3045;
  --dot-2:  #3a2e4a;
  --sq-tri:  #b07835;
  --sq-ring: #2c8068;
  --sq-plus: #5e3eb0;
  --sq-sq:   #6b3850;
  --sq-star: #b08a30;
  --squig:   #4664c3;
}

:root {
  --radius-card: 28px;
  --radius-input: 12px;
  --radius-pill: 999px;
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
  overflow-x: hidden;
  transition: background-color .35s ease, color .35s ease;
}

/* =========================================================
   Page + card
   ========================================================= */
.page { position: relative; z-index: 1; padding: 24px 22px 60px; display: flex; justify-content: center; }
.card {
  width: 100%;
  max-width: 1180px;
  background: var(--bg);
  border: none;
  border-radius: 0;
  box-shadow: none;
  padding: 22px 0 60px;
  overflow: hidden;
  transition: background-color .35s ease;
}

/* =========================================================
   Nav
   ========================================================= */
.nav {
  display: flex; align-items: center; justify-content: space-between; gap: 18px;
  padding: 10px 0 36px;
}
.brand {
  display: inline-flex; align-items: center; gap: 12px;
  color: var(--ink); text-decoration: none;
  font-weight: 700; font-size: 20px; letter-spacing: -0.01em;
}
.brand-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px;
}
.brand-mark img {
  max-width: 100%; max-height: 100%; object-fit: contain;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.12));
}
[data-theme="dark"] .brand-mark img { filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.4)); }
.brand-text { line-height: 1; }
.brand-accent { color: var(--accent); }
.nav-links { display: flex; gap: 36px; }
.nav-link {
  text-decoration: none; color: var(--ink-soft); font-weight: 500; font-size: 15px;
  padding: 6px 4px; transition: color .15s; position: relative;
}
.nav-link:hover { color: var(--ink); }
.nav-link.active { color: var(--accent); font-weight: 600; }
.nav-link.active::after {
  content: ""; position: absolute; left: 4px; right: 4px; bottom: -2px;
  height: 2px; border-radius: 2px; background: var(--accent);
}

/* Theme toggle — glass pill */
.theme-toggle {
  width: 42px; height: 42px; border-radius: 14px;
  color: var(--ink);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; padding: 0; isolation: isolate;
  background: linear-gradient(180deg, rgba(255,255,255,0.55), rgba(255,255,255,0.18));
  border: 1px solid rgba(255, 255, 255, 0.45);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.65),
    inset 0 -1px 0 rgba(0, 0, 0, 0.06),
    0 6px 18px rgba(15, 17, 21, 0.08);
  transition: transform .25s cubic-bezier(.34, 1.56, .64, 1), filter .2s;
}
[data-theme="dark"] .theme-toggle {
  background: linear-gradient(180deg, rgba(255,255,255,0.12), rgba(255,255,255,0.04));
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.18),
    inset 0 -1px 0 rgba(0, 0, 0, 0.4),
    0 8px 22px rgba(0, 0, 0, 0.55);
}
.theme-toggle:hover { filter: brightness(1.05); }
.theme-toggle:active { transform: scale(0.92); transition-duration: .08s; }
.theme-toggle .icon { transition: opacity .2s, transform .35s; position: absolute; }
.theme-toggle { position: relative; }
[data-theme="light"] .theme-toggle .icon-sun  { opacity: 1; transform: rotate(0); }
[data-theme="light"] .theme-toggle .icon-moon { opacity: 0; transform: rotate(60deg) scale(0.5); }
[data-theme="dark"]  .theme-toggle .icon-sun  { opacity: 0; transform: rotate(-60deg) scale(0.5); }
[data-theme="dark"]  .theme-toggle .icon-moon { opacity: 1; transform: rotate(0); }

/* =========================================================
   Views (SPA)
   ========================================================= */
.view { display: none; animation: viewIn .35s ease both; }
.view.is-active { display: block; }
@keyframes viewIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* =========================================================
   Hero
   ========================================================= */
.hero { max-width: 760px; padding: 24px 0 16px; }
.eyebrow {
  display: inline-flex; align-items: center; gap: 10px;
  font-size: 12px; letter-spacing: 0.16em; color: var(--ink-soft);
  font-weight: 600; margin: 0 0 20px; text-transform: uppercase;
}
.eyebrow-dash { display: inline-block; width: 22px; height: 2px; background: var(--accent); border-radius: 2px; }
h1 {
  margin: 0 0 22px;
  font-size: clamp(40px, 5.8vw, 68px);
  line-height: 1.02; letter-spacing: -0.025em; font-weight: 800;
  color: var(--ink);
}
.lede {
  color: var(--ink-soft); max-width: 580px;
  font-size: 17px; line-height: 1.55; margin: 0 0 32px;
}

/* =========================================================
   Input row
   ========================================================= */
.input-row { display: flex; gap: 10px; max-width: 680px; }
.input-wrap { position: relative; flex: 1; }
.input-icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); pointer-events: none; }
.input-wrap input {
  width: 100%;
  background: var(--field-bg);
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 14px 16px 14px 42px; border-radius: var(--radius-input);
  font-size: 15px; font-family: var(--font);
  outline: none; transition: border-color .15s, box-shadow .15s, background-color .35s;
}
.input-wrap input::placeholder { color: var(--ink-mute); }
.input-wrap input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

/* =========================================================
   Buttons — iOS 26 "Liquid Glass" style
   Multi-layer: translucent base, backdrop blur+saturate,
   inner highlight, specular sheen, soft outer shadow,
   spring press animation.
   ========================================================= */
.btn {
  position: relative;
  border: 1px solid var(--line);
  background: var(--field-bg);
  color: var(--ink);
  padding: 12px 20px; border-radius: 14px;
  font-size: 14px; font-family: var(--font); font-weight: 600;
  cursor: pointer; isolation: isolate;
  display: inline-flex; align-items: center; gap: 8px;
  transition: transform .25s cubic-bezier(.34, 1.56, .64, 1),
              background .2s, border-color .2s, filter .2s, box-shadow .25s;
}
.btn:hover { background: var(--chip-bg); }
.btn:active { transform: scale(0.96); transition-duration: .08s; }
.btn[disabled] { opacity: 0.75; cursor: progress; }

/* Primary = Liquid Glass tinted */
.btn.primary {
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.35);
  padding: 13px 28px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.18) 0%, rgba(255,255,255,0) 60%),
    linear-gradient(135deg, #4a7eff 0%, #2a5cff 55%, #1e44d4 100%);
  background-blend-mode: overlay, normal;
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.45),
    inset 0 -1px 0 rgba(0, 0, 0, 0.18),
    0 1px 2px rgba(0, 0, 0, 0.06),
    0 10px 26px rgba(42, 92, 255, 0.35),
    0 22px 50px rgba(42, 92, 255, 0.18);
}
.btn.primary::before {
  content: ""; position: absolute; inset: 1px;
  border-radius: 13px; pointer-events: none; z-index: -1;
  background: radial-gradient(120% 80% at 50% -10%, rgba(255,255,255,0.55), rgba(255,255,255,0) 55%);
  opacity: 0.9;
}
.btn.primary::after {
  content: ""; position: absolute; left: 8%; right: 8%; top: 2px; height: 6px;
  border-radius: 999px; pointer-events: none;
  background: linear-gradient(90deg, rgba(255,255,255,0) 0%, rgba(255,255,255,0.55) 50%, rgba(255,255,255,0) 100%);
  filter: blur(2px); opacity: 0.85;
}
.btn.primary:hover { filter: brightness(1.06) saturate(1.05); }
.btn.primary:active {
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.3),
    inset 0 -1px 0 rgba(0, 0, 0, 0.22),
    0 1px 2px rgba(0, 0, 0, 0.08),
    0 4px 12px rgba(42, 92, 255, 0.3);
}

/* Secondary glass (neutral, used for theme toggle / fmt download chips) */
.btn-glass {
  background: linear-gradient(180deg, rgba(255,255,255,0.55), rgba(255,255,255,0.18));
  border: 1px solid rgba(255, 255, 255, 0.45);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.65),
    inset 0 -1px 0 rgba(0, 0, 0, 0.06),
    0 6px 18px rgba(15, 17, 21, 0.08);
}
[data-theme="dark"] .btn-glass {
  background: linear-gradient(180deg, rgba(255,255,255,0.12), rgba(255,255,255,0.04));
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.18),
    inset 0 -1px 0 rgba(0, 0, 0, 0.4),
    0 8px 22px rgba(0, 0, 0, 0.55);
}

.spinner {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.45); border-top-color: transparent;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* =========================================================
   Platform chips
   ========================================================= */
.platforms { display: flex; flex-wrap: wrap; gap: 8px; margin: 18px 0 0; }
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12.5px; color: var(--chip-ink); font-weight: 500;
  padding: 7px 12px; border-radius: var(--radius-pill);
  background: var(--chip-bg);
}
.chip svg { flex-shrink: 0; }
/* Lift white-fill icons (TikTok, X) in dark theme so they don't disappear */
[data-theme="dark"] .chip svg path[fill="#000"],
[data-theme="dark"] .chip svg path[fill="#000000"] { fill: #e8ecf3; }

/* =========================================================
   Result
   ========================================================= */
.error {
  margin-top: 22px; padding: 12px 14px; border-radius: var(--radius-input);
  background: var(--danger-bg); border: 1px solid transparent;
  color: var(--danger-ink); font-size: 14px; max-width: 680px;
}

/* Server stamps data-ffmpeg on <html>; hide banner when ffmpeg is present. */
html[data-ffmpeg="true"] #ffmpeg-banner { display: none !important; }

.ffmpeg-banner {
  display: flex; gap: 12px; align-items: flex-start;
  margin: 14px 0 22px; padding: 12px 14px;
  border-radius: 12px; border: 1px solid var(--line);
  background: var(--feature-4); color: var(--ink);
  font-size: 13.5px; line-height: 1.5;
  max-width: 720px;
}
.ffmpeg-banner svg { flex-shrink: 0; margin-top: 2px; color: #cc7a00; }
.ffmpeg-banner code {
  background: var(--line-soft); padding: 1px 6px; border-radius: 6px;
  font-size: 12.5px; font-family: ui-monospace, "SF Mono", Consolas, monospace;
}

.login-panel {
  margin-top: 18px; padding: 22px;
  border-radius: 18px; border: 1px solid var(--line);
  background: var(--surface);
  max-width: 680px;
}
.login-panel-head { display: flex; gap: 14px; align-items: flex-start; color: var(--accent); }
.login-panel-head h3 { margin: 0 0 4px; font-size: 16px; font-weight: 700; color: var(--ink); }
.login-panel-head p { margin: 0; }
.login-steps { margin: 16px 0 14px 20px; padding: 0; color: var(--ink-soft); font-size: 14px; line-height: 1.55; }
.login-steps li { margin-bottom: 4px; }
.login-steps code, .login-steps em {
  font-style: normal; background: var(--line-soft); padding: 1px 6px; border-radius: 6px;
  font-size: 13px; color: var(--ink); font-family: ui-monospace, "SF Mono", Consolas, monospace;
}
.login-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.file-btn { cursor: pointer; }
.file-btn input { display: none; }
#cookies-status:empty { display: none; }

.result { margin-top: 30px; display: flex; flex-direction: column; gap: 18px; max-width: 880px; }
.result-head { display: flex; gap: 18px; align-items: flex-start; }
.thumb-wrap {
  width: 200px; height: 112px; border-radius: 14px; overflow: hidden;
  background: var(--line-soft); border: 1px solid var(--line); flex-shrink: 0;
}
.thumb-wrap img { width: 100%; height: 100%; object-fit: cover; display: block; }
.meta { flex: 1; min-width: 0; }
.meta h2 { margin: 0 0 6px; font-size: 19px; line-height: 1.35; font-weight: 700;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.muted { color: var(--ink-soft); margin: 2px 0; font-size: 13px; }
.small { font-size: 12px; }

.formats {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 10px;
}
.fmt {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: var(--radius-input);
  background: var(--field-bg);
  transition: border-color .15s, transform .05s ease, box-shadow .15s, background-color .35s;
}
.fmt:hover { border-color: var(--accent); box-shadow: 0 4px 12px rgba(42, 92, 255, 0.08); }
.fmt .lbl { font-size: 14px; font-weight: 500; }
.fmt .sz { color: var(--ink-soft); font-size: 12px; margin-top: 2px; }
.fmt a {
  position: relative; isolation: isolate;
  text-decoration: none; color: #ffffff; font-weight: 600; font-size: 13px;
  padding: 7px 14px; border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.22) 0%, rgba(255,255,255,0) 60%),
    linear-gradient(135deg, #4a7eff 0%, #2a5cff 100%);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.45),
    inset 0 -1px 0 rgba(0, 0, 0, 0.18),
    0 4px 14px rgba(42, 92, 255, 0.3);
  transition: transform .25s cubic-bezier(.34, 1.56, .64, 1), filter .2s, box-shadow .2s;
}
.fmt a:hover { filter: brightness(1.06); }
.fmt a:active { transform: scale(0.94); transition-duration: .08s; }

/* =========================================================
   Features (home bottom)
   ========================================================= */
.features {
  margin-top: 80px;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px;
}
.feature {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 22px;
  transition: background-color .35s, border-color .35s, transform .2s;
}
.feature:hover { transform: translateY(-3px); }
.feature-icon {
  width: 44px; height: 44px; border-radius: 12px;
  display: inline-flex; align-items: center; justify-content: center;
  margin-bottom: 14px;
}
.feature h3 { margin: 0 0 6px; font-size: 16px; font-weight: 700; }
.feature p { margin: 0; color: var(--ink-soft); font-size: 14px; line-height: 1.5; }

/* =========================================================
   About
   ========================================================= */
.about-hero { max-width: 720px; padding: 24px 0 8px; }
.about-grid {
  margin-top: 38px;
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px;
}
.about-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 26px;
  transition: background-color .35s, border-color .35s, transform .2s;
}
.about-card:hover { transform: translateY(-3px); }
.about-card-icon {
  width: 48px; height: 48px; border-radius: 14px;
  display: inline-flex; align-items: center; justify-content: center;
  margin-bottom: 16px;
}
.about-card h3 { margin: 0 0 8px; font-size: 18px; font-weight: 700; }
.about-card p { margin: 0; color: var(--ink-soft); font-size: 15px; line-height: 1.55; }
.about-card code {
  background: var(--line-soft); padding: 1px 6px; border-radius: 6px;
  font-size: 13px; color: var(--ink);
}
.about-link {
  display: inline-block; margin-top: 14px;
  color: var(--accent); text-decoration: none; font-weight: 600; font-size: 14px;
}
.about-link:hover { text-decoration: underline; }

/* =========================================================
   NProgress — top loading bar
   ========================================================= */
#nprogress .bar {
  background: linear-gradient(90deg, var(--accent) 0%, #5fa8ff 50%, var(--accent) 100%) !important;
  height: 3px !important;
  box-shadow: 0 0 12px rgba(42, 92, 255, 0.6), 0 0 6px rgba(42, 92, 255, 0.4);
}
#nprogress .peg {
  box-shadow: 0 0 14px var(--accent), 0 0 6px var(--accent) !important;
}
#nprogress .spinner-icon {
  border-top-color: var(--accent) !important;
  border-left-color: var(--accent) !important;
}

/* =========================================================
   Toastify overrides
   ========================================================= */
.toastify {
  border-radius: 12px !important;
  font-family: var(--font) !important;
  font-weight: 500 !important;
  font-size: 14px !important;
  padding: 12px 18px !important;
  box-shadow: 0 12px 32px rgba(15, 17, 21, 0.18) !important;
}
.toastify.toast-success { background: linear-gradient(135deg, #1aa872, #15c98a) !important; }
.toastify.toast-error   { background: linear-gradient(135deg, #d33a4f, #ff5e7a) !important; }
.toastify.toast-info    { background: linear-gradient(135deg, #2a5cff, #5fa8ff) !important; }

/* =========================================================
   Tippy
   ========================================================= */
.tippy-box[data-theme~="chill"] {
  background: var(--ink); color: var(--bg);
  border-radius: 8px; font-family: var(--font); font-weight: 500; font-size: 12.5px;
  padding: 2px 4px;
}
.tippy-box[data-theme~="chill"] .tippy-arrow { color: var(--ink); }

/* =========================================================
   Responsive
   ========================================================= */
@media (max-width: 860px) {
  .features { grid-template-columns: 1fr; }
  .about-grid { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .card { padding: 18px 22px 40px; border-radius: 22px; }
  .nav { padding-bottom: 24px; gap: 8px; }
  .nav-links { gap: 22px; }
  .input-row { flex-direction: column; }
  .result-head { flex-direction: column; }
  .thumb-wrap { width: 100%; height: auto; aspect-ratio: 16/9; }
  .decor-shape { display: none; }
  .brand-text { display: none; }
}
