:root {
  --bg: #0b0d12;
  --bg-soft: #12151c;
  --card: #161a23;
  --card-2: #1b202b;
  --border: #262c39;
  --text: #eef1f6;
  --muted: #98a2b3;
  --brand: #ff2f46;
  --brand-2: #ff6a3d;
  --accent: #6d5efc;
  --accent-2: #22d3ee;
  --ok: #22c55e;
  --radius: 16px;
  --shadow: 0 20px 60px -20px rgba(0, 0, 0, 0.7);
  --maxw: 1080px;
  --hero-glow: rgba(109, 94, 252, 0.35);
  --page-tint: #1a1030;
}

/* Light theme overrides */
:root[data-theme="light"] {
  --bg: #f4f6fb;
  --bg-soft: #ffffff;
  --card: #ffffff;
  --card-2: #f1f3f9;
  --border: #e2e6ef;
  --text: #131722;
  --muted: #5c6575;
  --shadow: 0 20px 50px -24px rgba(30, 40, 90, 0.35);
  --hero-glow: rgba(109, 94, 252, 0.22);
  --page-tint: #e9e4ff;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: "Plus Jakarta Sans", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: radial-gradient(1200px 700px at 50% -10%, var(--page-tint) 0%, transparent 55%), var(--bg);
  color: var(--text);
  transition: background-color 0.3s ease, color 0.3s ease;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }

/* ---------------- Header ---------------- */
.site-header {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 20px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 20px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 11px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  box-shadow: 0 8px 20px -6px rgba(255, 47, 70, 0.6);
}
.site-nav { display: flex; gap: 26px; align-items: center; font-weight: 600; color: var(--muted); }
.site-nav a:hover { color: var(--text); }
.theme-toggle {
  display: grid; place-items: center; width: 40px; height: 40px; border-radius: 11px;
  border: 1px solid var(--border); background: var(--card); color: var(--text); cursor: pointer;
  transition: border-color 0.2s ease, transform 0.1s ease;
}
.theme-toggle:hover { border-color: var(--accent); }
.theme-toggle:active { transform: scale(0.94); }
.theme-toggle .icon-moon { display: none; }
:root[data-theme="light"] .theme-toggle .icon-sun { display: none; }
:root[data-theme="light"] .theme-toggle .icon-moon { display: block; }

/* ---------------- Hero ---------------- */
.hero { max-width: 820px; margin: 40px auto 0; padding: 0 24px; text-align: center; position: relative; }
.hero-glow {
  position: absolute; inset: -60px 0 auto 0; height: 320px; z-index: -1;
  background: radial-gradient(500px 200px at 50% 0, var(--hero-glow), transparent 70%);
  filter: blur(10px);
}
.hero h1 { font-size: clamp(34px, 6vw, 58px); line-height: 1.05; font-weight: 800; margin: 8px 0 16px; letter-spacing: -0.02em; }
.grad {
  background: linear-gradient(100deg, var(--brand), var(--brand-2) 40%, var(--accent) 90%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.sub { font-size: clamp(15px, 2.4vw, 19px); color: var(--muted); max-width: 620px; margin: 0 auto 30px; line-height: 1.6; }

/* ---------------- Search box ---------------- */
.grab-box {
  display: flex; gap: 10px; padding: 10px;
  background: linear-gradient(var(--card), var(--card));
  border: 1px solid var(--border); border-radius: 18px;
  box-shadow: var(--shadow);
  position: relative;
}
.grab-box::before {
  content: ""; position: absolute; inset: -1px; border-radius: 19px; padding: 1px; pointer-events: none;
  background: linear-gradient(120deg, rgba(255, 47, 70, 0.5), rgba(109, 94, 252, 0.5));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude; opacity: 0.6;
}
.input-wrap { flex: 1; display: flex; align-items: center; gap: 10px; padding: 0 14px; }
.input-icon { color: var(--muted); flex: none; }
#url-input {
  flex: 1; background: transparent; border: none; outline: none;
  color: var(--text); font-size: 16px; font-family: inherit; padding: 16px 0;
}
#url-input::placeholder { color: #6b7280; }
#grab-btn {
  border: none; cursor: pointer; color: #fff; font-weight: 700; font-size: 15px; font-family: inherit;
  padding: 0 26px; border-radius: 12px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  box-shadow: 0 10px 24px -8px rgba(255, 47, 70, 0.7);
  transition: transform 0.12s ease, filter 0.2s ease;
  display: flex; align-items: center; gap: 10px;
}
#grab-btn:hover { filter: brightness(1.05); }
#grab-btn:active { transform: translateY(1px); }
#grab-btn:disabled { opacity: 0.7; cursor: default; }
.btn-spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.4); border-top-color: #fff;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.hint { margin-top: 12px; color: #6b7280; font-size: 13px; }

.error {
  margin: 20px auto 0; max-width: 620px; padding: 14px 18px;
  background: rgba(255, 47, 70, 0.1); border: 1px solid rgba(255, 47, 70, 0.35);
  border-radius: 12px; color: #ffb4bd; font-size: 14px;
}

/* ---------------- Results ---------------- */
.results-wrap { max-width: var(--maxw); margin: 50px auto 0; padding: 0 24px; }
.results-head { display: flex; align-items: baseline; gap: 14px; margin-bottom: 22px; }
.results-head h2 { font-size: 24px; margin: 0; }
.video-id {
  font-size: 12px; color: var(--muted); font-family: ui-monospace, monospace;
  background: var(--card); border: 1px solid var(--border); padding: 4px 10px; border-radius: 8px;
}
/* Vertical stack — one thumbnail per row, so ad slots can sit between them */
.stack { display: flex; flex-direction: column; gap: 18px; }

.thumb-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; display: flex; flex-direction: row; align-items: stretch;
  transition: transform 0.18s ease, border-color 0.18s ease;
  animation: rise 0.4s ease both;
}
.thumb-card:hover { transform: translateY(-3px); border-color: var(--accent); }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }
.thumb-img { position: relative; width: 360px; flex: none; aspect-ratio: 16 / 9; background: #000; overflow: hidden; }
.thumb-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.res-badge {
  position: absolute; top: 10px; left: 10px;
  background: rgba(0, 0, 0, 0.65); backdrop-filter: blur(6px);
  color: #fff; font-size: 12px; font-weight: 700; padding: 5px 10px; border-radius: 8px;
}
.thumb-body { flex: 1; padding: 20px 24px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.thumb-meta .q-label { font-weight: 700; font-size: 18px; }
.thumb-meta .q-dims { color: var(--muted); font-size: 14px; margin-top: 4px; }

/* Ad slot rendered between stacked thumbnails */
.ad-between { margin: 0; padding: 0; }
.ad-between:not(:empty) {
  border: 1px dashed var(--border); border-radius: 12px; padding: 14px; background: var(--bg-soft);
}
.dl-btn {
  border: none; cursor: pointer; font-family: inherit; font-weight: 700; font-size: 14px; color: #fff;
  padding: 10px 16px; border-radius: 10px; white-space: nowrap;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  display: flex; align-items: center; gap: 8px;
  transition: filter 0.2s ease, transform 0.1s ease;
}
.dl-btn:hover { filter: brightness(1.08); }
.dl-btn:active { transform: translateY(1px); }
.dl-btn svg { width: 16px; height: 16px; }

/* ---------------- Info sections ---------------- */
.info { max-width: var(--maxw); margin: 80px auto 0; padding: 0 24px; }
.info > h2 { font-size: 28px; text-align: center; margin-bottom: 34px; }
.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 20px; }
.step {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 26px 22px;
}
.step-n {
  display: grid; place-items: center; width: 40px; height: 40px; border-radius: 11px; font-weight: 800;
  background: linear-gradient(135deg, rgba(109, 94, 252, 0.25), rgba(34, 211, 238, 0.2));
  color: var(--accent-2); margin-bottom: 14px;
}
.step h3 { margin: 0 0 8px; font-size: 18px; }
.step p { margin: 0; color: var(--muted); line-height: 1.6; font-size: 14px; }

.faq { max-width: 760px; }
.faq details {
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  padding: 16px 20px; margin-bottom: 12px; cursor: pointer;
}
.faq summary { font-weight: 700; list-style: none; display: flex; justify-content: space-between; align-items: center; }
.faq summary::after { content: "+"; color: var(--muted); font-size: 20px; }
.faq details[open] summary::after { content: "–"; }
.faq p { color: var(--muted); margin: 12px 0 0; line-height: 1.6; }

/* ---------------- Footer ---------------- */
.site-footer { max-width: var(--maxw); margin: 90px auto 0; padding: 30px 24px 50px; text-align: center; border-top: 1px solid var(--border); }
.site-footer p { color: var(--muted); font-size: 14px; }
.legal-nav { display: flex; flex-wrap: wrap; gap: 8px 22px; justify-content: center; margin-bottom: 14px; }
.legal-nav a { color: var(--muted); font-size: 14px; font-weight: 600; }
.legal-nav a:hover { color: var(--text); }

/* ---------------- Contact form ---------------- */
.contact-form { display: flex; flex-direction: column; gap: 16px; max-width: 560px; margin-top: 24px; }
.contact-form label { display: flex; flex-direction: column; gap: 8px; }
.contact-form label span { font-weight: 600; font-size: 14px; }
.contact-form input, .contact-form textarea {
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  color: var(--text); padding: 13px 15px; font-family: inherit; font-size: 15px; outline: none; resize: vertical;
}
.contact-form input:focus, .contact-form textarea:focus { border-color: var(--accent); }
.contact-form .save-btn {
  align-self: flex-start; border: none; cursor: pointer; color: #fff; font-weight: 700; font-size: 15px; font-family: inherit;
  padding: 13px 26px; border-radius: 12px; background: linear-gradient(135deg, var(--brand), var(--brand-2));
}
.contact-form .save-btn:disabled { opacity: 0.7; cursor: default; }
.contact-status { padding: 13px 16px; border-radius: 12px; font-size: 14px; }
.contact-status.ok { background: rgba(34,197,94,0.12); border: 1px solid rgba(34,197,94,0.35); color: #86efac; }
.contact-status.err { background: rgba(255,47,70,0.1); border: 1px solid rgba(255,47,70,0.35); color: #ffb4bd; }

/* ---------------- Ads ---------------- */
.ad-slot:empty { display: none; }
.ad-slot { max-width: var(--maxw); margin: 22px auto 0; padding: 0 24px; text-align: center; }
.ad-mid { margin: 60px auto 0; }
#ad-header { margin-top: 0; padding-top: 14px; }

/* ---------------- Blog index ---------------- */
.blog-wrap { max-width: var(--maxw); margin: 40px auto 0; padding: 0 24px; }
.blog-head { text-align: center; margin-bottom: 40px; }
.blog-head h1 { font-size: clamp(30px, 5vw, 46px); margin: 0 0 12px; letter-spacing: -0.02em; }
.blog-head p { color: var(--muted); font-size: 17px; max-width: 560px; margin: 0 auto; }
.blog-empty { color: var(--muted); text-align: center; padding: 60px 0; font-size: 16px; }
.post-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 22px; }
.post-card {
  display: flex; flex-direction: column; background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; transition: transform 0.18s ease, border-color 0.18s ease;
}
.post-card:hover { transform: translateY(-4px); border-color: var(--accent); }
.post-cover { aspect-ratio: 16 / 9; background: var(--card-2); overflow: hidden; }
.post-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.post-cover--ph { display: grid; place-items: center; font-size: 40px; opacity: 0.5; }
.post-card-body { padding: 18px 20px 20px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.post-card-body h2 { font-size: 19px; margin: 0; line-height: 1.3; }
.post-card-body p { color: var(--muted); font-size: 14px; margin: 0; line-height: 1.55; flex: 1; }
.post-date { color: #6b7280; font-size: 13px; margin-top: 4px; }

/* ---------------- Article ---------------- */
.article-wrap { max-width: 760px; margin: 30px auto 0; padding: 0 24px; }
.crumbs { color: var(--muted); font-size: 13px; margin-bottom: 20px; }
.crumbs a { color: var(--accent-2); }
.crumbs span { color: var(--text); }
.article h1 { font-size: clamp(28px, 5vw, 42px); line-height: 1.15; letter-spacing: -0.02em; margin: 0 0 12px; }
.article-meta { color: var(--muted); font-size: 14px; margin-bottom: 24px; }
.article-cover { width: 100%; border-radius: var(--radius); margin-bottom: 30px; border: 1px solid var(--border); }
.article-body { font-size: 17px; line-height: 1.75; color: #d7dce6; }
:root[data-theme="light"] .article-body { color: #2b303b; }
.article-body h2 { font-size: 26px; margin: 40px 0 14px; letter-spacing: -0.01em; color: var(--text); }
.article-body h3 { font-size: 21px; margin: 30px 0 10px; color: var(--text); }
.article-body p { margin: 0 0 18px; }
.article-body ul, .article-body ol { margin: 0 0 18px; padding-left: 24px; }
.article-body li { margin: 8px 0; }
.article-body a { color: var(--accent); text-decoration: underline; }
.article-body img { max-width: 100%; height: auto; border-radius: 12px; margin: 10px 0; }
.article-body blockquote { margin: 18px 0; padding: 12px 20px; border-left: 3px solid var(--accent); background: var(--card); border-radius: 0 10px 10px 0; color: var(--muted); }
.article-body pre { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 16px; overflow-x: auto; }
.article-body code { background: var(--card-2); padding: 2px 6px; border-radius: 5px; font-size: 15px; }
.article-body pre code { background: none; padding: 0; }
.article-body hr { border: none; border-top: 1px solid var(--border); margin: 30px 0; }
.article-cta {
  margin: 50px 0; padding: 30px; text-align: center; border-radius: var(--radius);
  background: linear-gradient(135deg, rgba(109,94,252,0.14), rgba(34,211,238,0.1)); border: 1px solid var(--border);
}
.article-cta h3 { margin: 0 0 6px; font-size: 22px; }
.article-cta p { color: var(--muted); margin: 0 0 18px; }

/* ---------------- Responsive ---------------- */
@media (max-width: 720px) {
  .thumb-card { flex-direction: column; }
  .thumb-img { width: 100%; }
}
@media (max-width: 620px) {
  .site-nav a { display: none; }
  .grab-box { flex-direction: column; }
  #grab-btn { padding: 15px; justify-content: center; }
  .thumb-body { flex-direction: column; align-items: stretch; }
  .dl-btn { justify-content: center; }
}
