/* ==========================================================================
   Videoz — modern dark downloader theme
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }

:root {
    color-scheme: dark;
    --radius: 14px;
    --radius-sm: 10px;
    --max-w: 1180px;
    --shadow-lg: 0 24px 60px -10px rgba(0,0,0,.55);
    --shadow-md: 0 10px 30px -8px rgba(0,0,0,.45);
    --shadow-glow: 0 0 0 1px rgba(245,158,11,.18), 0 18px 60px -12px rgba(220,38,38,.45);
    --line: rgba(255,255,255,.06);
    --muted: #94a3b8;
    --soft: #cbd5e1;
}

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial,
                 "Apple Color Emoji", "Segoe UI Emoji", sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

img { max-width: 100%; height: auto; display: block; }
a { color: inherit; text-decoration: none; transition: color .15s ease; }
a:hover { color: var(--accent); }

.container { max-width: var(--max-w); margin: 0 auto; padding: 0 20px; }

/* ===== Header ============================================================ */
.site-header {
    position: sticky; top: 0; z-index: 50;
    background: rgba(15,23,42,.78);
    backdrop-filter: saturate(180%) blur(12px);
    -webkit-backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--line);
}
.header-row {
    display: flex; align-items: center; justify-content: space-between;
    gap: 16px; padding: 14px 20px;
}
.brand {
    display: inline-flex; align-items: center; gap: 10px; font-weight: 800;
    color: var(--text); font-size: 19px; letter-spacing: -.01em;
}
.brand-mark {
    display: inline-grid; place-items: center; width: 36px; height: 36px;
    background: linear-gradient(135deg, var(--primary), #7c2222);
    color: white; border-radius: 10px;
    box-shadow: 0 6px 16px -6px rgba(220,38,38,.7);
}
.brand-name { background: linear-gradient(180deg, #fff, #cbd5e1); -webkit-background-clip: text; background-clip: text; color: transparent; }
.primary-nav { display: flex; gap: 28px; }
.primary-nav a { font-size: 14px; font-weight: 500; color: var(--soft); }
.install-btn {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 10px 16px; border-radius: 999px; font-weight: 700; font-size: 14px;
    background: linear-gradient(180deg, var(--primary), #991b1b);
    color: #fff !important; box-shadow: 0 8px 22px -10px rgba(220,38,38,.85);
}
.install-btn:hover { filter: brightness(1.08); }

.menu-toggle { display: none; background: none; border: 0; padding: 8px; cursor: pointer; }
.menu-toggle span { display: block; width: 22px; height: 2px; background: var(--text); margin: 5px 0; border-radius: 2px; transition: transform .2s; }

@media (max-width: 860px) {
    .primary-nav { display: none; }
    .menu-toggle { display: block; }
    .install-btn span { display: none; }
    .install-btn { padding: 10px; }
    body.menu-open .primary-nav {
        display: flex; position: absolute; top: 100%; left: 0; right: 0;
        flex-direction: column; gap: 0;
        background: rgba(17,24,39,.96);
        border-bottom: 1px solid var(--line);
        padding: 8px 20px 16px;
    }
    body.menu-open .primary-nav a { padding: 12px 4px; border-bottom: 1px solid var(--line); }
    body.menu-open .primary-nav a:last-child { border-bottom: 0; }
}

/* ===== Hero ============================================================== */
.hero { position: relative; padding: 64px 0 88px; overflow: hidden; }
.hero-bg {
    position: absolute; inset: 0; z-index: 0;
    background:
        radial-gradient(closest-side at 18% 22%, rgba(220,38,38,.18), transparent 60%),
        radial-gradient(closest-side at 82% 12%, rgba(245,158,11,.15), transparent 65%),
        radial-gradient(closest-side at 50% 110%, rgba(124,58,237,.10), transparent 60%);
    pointer-events: none;
}
.hero-inner { position: relative; z-index: 1; text-align: center; }
.hero-title {
    font-size: clamp(30px, 5.4vw, 56px);
    line-height: 1.06; margin: 6px auto 14px; max-width: 920px;
    letter-spacing: -.02em; font-weight: 800;
    background: linear-gradient(180deg, #fff 0%, #f1f5f9 55%, #94a3b8 110%);
    -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero-sub {
    max-width: 720px; margin: 0 auto 32px; color: var(--soft); font-size: clamp(15px, 1.6vw, 18px);
}
.hero-note { margin: 22px auto 0; color: var(--muted); font-size: 13px; display: inline-flex; align-items: center; gap: 8px; }
.hero-note .dot {
    width: 8px; height: 8px; border-radius: 50%; background: #22c55e; display: inline-block;
    box-shadow: 0 0 0 4px rgba(34,197,94,.18);
}

/* ===== Downloader form =================================================== */
.downloader-form {
    display: flex; gap: 10px; align-items: stretch;
    background: linear-gradient(180deg, rgba(255,255,255,.04), rgba(255,255,255,.02));
    padding: 10px; border-radius: 18px;
    border: 1px solid rgba(255,255,255,.07);
    box-shadow: var(--shadow-glow);
    max-width: 760px; margin: 0 auto;
}
.input-wrap {
    flex: 1; position: relative; display: flex; align-items: center;
    background: #0b1220; border-radius: 12px; padding: 0 12px;
    border: 1px solid #1f2937;
}
.input-wrap:focus-within { border-color: var(--primary); }
.input-icon { color: var(--muted); flex-shrink: 0; }
#tiktok-url {
    flex: 1; min-width: 0;
    background: transparent; border: 0; outline: none;
    color: var(--text); font-size: 15px; padding: 14px 8px;
    font-family: inherit;
}
#tiktok-url::placeholder { color: var(--muted); }
.paste-btn {
    display: inline-flex; align-items: center; gap: 6px;
    background: rgba(255,255,255,.05); color: var(--soft);
    border: 1px solid rgba(255,255,255,.08); border-radius: 9px;
    padding: 8px 12px; font-size: 13px; cursor: pointer; flex-shrink: 0;
    font-weight: 600;
}
.paste-btn:hover { background: rgba(255,255,255,.1); color: var(--text); }
.download-btn {
    position: relative;
    padding: 0 28px; min-height: 56px;
    border: 0; cursor: pointer;
    border-radius: 12px; color: white; font-weight: 700; font-size: 15px;
    background: linear-gradient(180deg, var(--primary), #991b1b);
    transition: transform .15s ease, filter .15s ease;
    box-shadow: 0 10px 24px -8px rgba(220,38,38,.7);
    flex-shrink: 0;
    font-family: inherit;
}
.download-btn:hover:not(:disabled) { filter: brightness(1.08); }
.download-btn:active:not(:disabled) { transform: translateY(1px); }
.download-btn:disabled { opacity: .9; cursor: progress; }
/* State backgrounds — label text itself is controlled by JS (no ::before). */
.download-btn[data-state="loading"] { background: linear-gradient(180deg, var(--accent), #b45309); color: #1f2937; }
.download-btn[data-state="loading"] .dl-label { color: #1f2937; font-weight: 700; }
.download-btn[data-state="success"] { background: linear-gradient(180deg, #16a34a, #14532d); }
.download-btn[data-state="error"]   { background: linear-gradient(180deg, #ef4444, #7f1d1d); }
.dl-spinner {
    position: absolute; top: 50%; right: 14px; width: 18px; height: 18px;
    border: 2px solid rgba(255,255,255,.35); border-top-color: white;
    border-radius: 50%; transform: translateY(-50%) rotate(0deg);
    animation: spin .8s linear infinite;
    opacity: 0; transition: opacity .15s ease;
}
.download-btn[data-state="loading"] .dl-spinner { opacity: 1; border-color: rgba(31,41,55,.35); border-top-color: #1f2937; }
@keyframes spin { to { transform: translateY(-50%) rotate(360deg); } }

@media (max-width: 640px) {
    .downloader-form { flex-direction: column; }
    .download-btn { width: 100%; padding: 16px; }
    .paste-btn span { display: none; }
}

/* ===== Result ============================================================ */
.result, .result-error {
    margin: 32px auto 0; max-width: 760px; text-align: left;
}
.result-card {
    display: grid; grid-template-columns: 220px 1fr;
    gap: 18px; align-items: stretch;
    background: var(--surface); border: 1px solid var(--line);
    padding: 16px; border-radius: 16px;
    box-shadow: var(--shadow-md);
}
.result-thumb {
    aspect-ratio: 9/16; max-height: 240px;
    background: #0b1220; border-radius: 10px; overflow: hidden;
    display: grid; place-items: center; color: var(--muted);
}
.result-thumb img { width: 100%; height: 100%; object-fit: cover; }
.result-meta { display: flex; flex-direction: column; gap: 10px; }
.result-title { font-size: 16px; font-weight: 700; line-height: 1.35; margin: 0; }
.result-author { color: var(--accent); font-size: 13px; font-weight: 600; margin: 0; }
.result-buttons { display: flex; flex-direction: column; gap: 10px; margin-top: auto; }
.btn-primary, .btn-secondary {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 14px 18px; border-radius: 11px; font-weight: 700; font-size: 15px;
    text-align: center; cursor: pointer; border: 0; font-family: inherit;
}
.btn-primary {
    background: linear-gradient(180deg, var(--primary), #991b1b);
    color: white !important;
    box-shadow: 0 10px 22px -8px rgba(220,38,38,.7);
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-secondary {
    background: rgba(255,255,255,.05); color: var(--text) !important;
    border: 1px solid rgba(255,255,255,.1);
}
.btn-secondary:hover { background: rgba(255,255,255,.08); }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-row > * { flex: 1; min-width: 140px; }

.result-error {
    background: rgba(220,38,38,.12); border: 1px solid rgba(220,38,38,.35);
    padding: 14px 16px; border-radius: 12px; color: #fecaca;
    font-size: 14px;
}

@media (max-width: 640px) {
    .result-card { grid-template-columns: 1fr; }
    .result-thumb { aspect-ratio: 16/9; max-height: 200px; }
}

/* ===== Sections common =================================================== */
.section-title {
    font-size: clamp(24px, 3.4vw, 36px); font-weight: 800; text-align: center;
    margin: 0 0 10px; letter-spacing: -.02em;
}
.section-sub { text-align: center; color: var(--muted); max-width: 640px; margin: 0 auto 40px; font-size: 16px; }

/* ===== Features ========================================================== */
.features { padding: 80px 0; }
.feature-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.feature {
    padding: 28px; border-radius: var(--radius);
    background: linear-gradient(180deg, rgba(255,255,255,.03), rgba(255,255,255,.01));
    border: 1px solid var(--line);
    transition: transform .2s ease, border-color .2s ease;
}
.feature:hover { transform: translateY(-3px); border-color: rgba(245,158,11,.3); }
.feature-icon {
    width: 56px; height: 56px; border-radius: 12px;
    display: grid; place-items: center; margin-bottom: 16px;
    background: linear-gradient(135deg, rgba(220,38,38,.18), rgba(245,158,11,.15));
    color: var(--accent);
}
.feature h3 { margin: 0 0 8px; font-size: 18px; font-weight: 700; }
.feature p { margin: 0; color: var(--soft); font-size: 14.5px; }

@media (max-width: 900px) { .feature-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .feature-grid { grid-template-columns: 1fr; } }

/* ===== How it works ====================================================== */
.how-it-works { padding: 24px 0 80px; }
.steps-list {
    list-style: none; padding: 0; margin: 24px auto 0;
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px;
    counter-reset: step;
}
.steps-list li {
    padding: 28px; border-radius: var(--radius);
    background: var(--surface); border: 1px solid var(--line);
    position: relative;
}
.step-num {
    display: inline-block; font-size: 13px; font-weight: 800;
    color: var(--primary); letter-spacing: .08em; margin-bottom: 10px;
}
.steps-list h3 { margin: 0 0 8px; font-size: 18px; font-weight: 700; }
.steps-list p { margin: 0; color: var(--soft); font-size: 14.5px; }
@media (max-width: 900px) { .steps-list { grid-template-columns: 1fr; } }

/* ===== SEO Article ======================================================= */
.seo-article { padding: 60px 0; background: linear-gradient(180deg, transparent, rgba(255,255,255,.015)); }
.article-inner { max-width: 800px; }
.article-inner h2 { font-size: clamp(24px, 3.2vw, 32px); margin: 0 0 18px; letter-spacing: -.02em; line-height: 1.2; }
.article-inner h3 { font-size: clamp(19px, 2.4vw, 22px); margin: 36px 0 12px; color: var(--text); }
.article-inner p { color: var(--soft); font-size: 16px; line-height: 1.75; margin: 0 0 16px; }
.article-inner ol, .article-inner ul { color: var(--soft); padding-left: 22px; line-height: 1.75; }
.article-inner li { margin-bottom: 8px; }
.article-inner strong { color: var(--text); }
.article-inner code {
    background: rgba(245,158,11,.12); color: var(--accent);
    padding: 2px 6px; border-radius: 4px; font-size: .92em;
}

/* ===== FAQ =============================================================== */
.faqs { padding: 60px 0 100px; }
.faq-list { max-width: 820px; margin: 24px auto 0; display: flex; flex-direction: column; gap: 12px; }
.faq-item {
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius); overflow: hidden;
    transition: border-color .2s ease;
}
.faq-item[open] { border-color: rgba(245,158,11,.4); }
.faq-item summary {
    list-style: none; cursor: pointer; padding: 18px 20px;
    display: flex; align-items: center; justify-content: space-between;
    font-weight: 600; gap: 16px;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item .chev { color: var(--muted); transition: transform .2s ease; flex-shrink: 0; }
.faq-item[open] .chev { transform: rotate(180deg); color: var(--accent); }
.faq-body { padding: 0 20px 20px; color: var(--soft); font-size: 15px; line-height: 1.7; }

/* ===== Footer ============================================================ */
.site-footer {
    background: #0a1124;
    border-top: 1px solid var(--line);
    padding: 56px 0 24px; margin-top: 40px;
}
.footer-inner {
    display: grid; grid-template-columns: 1.4fr 2fr; gap: 40px;
    align-items: start;
}
.footer-brand p { color: var(--muted); margin: 12px 0 0; font-size: 14px; }
.footer-name { font-size: 20px; font-weight: 800; }
.footer-cols { display: grid; grid-template-columns: repeat(3, 1fr); gap: 30px; }
.footer-col h4 { margin: 0 0 14px; font-size: 13px; text-transform: uppercase; letter-spacing: .09em; color: var(--accent); font-weight: 700; }
.footer-col a { display: block; padding: 4px 0; font-size: 14px; color: var(--soft); }
.footer-bottom {
    display: flex; justify-content: space-between; align-items: center;
    margin-top: 40px; padding-top: 20px; border-top: 1px solid var(--line);
    flex-wrap: wrap; gap: 10px;
}
.footer-bottom p { margin: 0; font-size: 13px; color: var(--muted); }
.disclaimer { opacity: .8; }

@media (max-width: 760px) {
    .footer-inner { grid-template-columns: 1fr; gap: 24px; }
    .footer-cols { grid-template-columns: repeat(3, 1fr); gap: 16px; }
}
@media (max-width: 480px) {
    .footer-cols { grid-template-columns: 1fr 1fr; }
}

/* ===== Blog ============================================================== */
.blog-hero { padding: 64px 0 32px; text-align: center; }
.blog-hero .eyebrow {
    color: var(--accent);
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin: 0 0 10px;
}
.blog-hero h1 { font-size: clamp(28px, 4vw, 44px); margin: 0 0 10px; letter-spacing: -.02em; }
.blog-hero p { color: var(--muted); max-width: 600px; margin: 0 auto; }

.blog-cats {
    border-bottom: 1px solid var(--line);
    padding: 14px 0;
    overflow-x: auto;
}
.blog-cats .container { display: flex; gap: 8px; flex-wrap: wrap; }
.blog-cats a {
    padding: 6px 14px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--soft);
    font-size: 13.5px;
    font-weight: 600;
    transition: all 0.15s ease;
    white-space: nowrap;
}
.blog-cats a:hover { color: var(--text); border-color: rgba(245,158,11,0.35); }
.blog-cats a.active { background: linear-gradient(135deg, rgba(220,38,38,0.25), rgba(245,158,11,0.18)); color: var(--text); border-color: transparent; }

.empty-state { text-align: center; padding: 60px 0; }
.empty-state h1, .empty-state h2 { font-size: 28px; margin: 0 0 10px; }
.empty-state p { color: var(--muted); }

.blog-thumb-placeholder {
    background: linear-gradient(135deg, rgba(220,38,38,0.12), rgba(245,158,11,0.08));
}

.pagination {
    display: flex;
    gap: 6px;
    justify-content: center;
    padding: 8px 0 40px;
    flex-wrap: wrap;
}
.pagination a {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: var(--surface);
    border: 1px solid var(--line);
    color: var(--soft);
    display: inline-grid;
    place-items: center;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.15s ease;
}
.pagination a:hover { border-color: var(--accent); color: var(--text); }
.pagination a.active { background: linear-gradient(135deg, var(--primary), var(--accent)); color: white; border-color: transparent; }

.blog-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; padding: 30px 0 80px; }
.blog-card {
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius); overflow: hidden;
    transition: transform .2s ease, border-color .2s ease;
}
.blog-card:hover { transform: translateY(-3px); border-color: rgba(245,158,11,.3); }
.blog-card a { display: block; height: 100%; }
.blog-thumb { aspect-ratio: 16/9; background: #0b1220; }
.blog-thumb img { width: 100%; height: 100%; object-fit: cover; }
.blog-body { padding: 18px 20px 22px; }
.blog-body h3 { margin: 0 0 8px; font-size: 17px; line-height: 1.35; }
.blog-body p { margin: 0; color: var(--soft); font-size: 14px; }
.blog-meta { display: block; color: var(--muted); font-size: 12px; margin-top: 10px; }

@media (max-width: 900px) { .blog-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .blog-grid { grid-template-columns: 1fr; } }

.post-wrap { padding: 50px 0 80px; max-width: 800px; margin: 0 auto; }
.post-hero img { width: 100%; border-radius: 16px; margin: 18px 0 28px; max-height: 420px; object-fit: cover; }
.post-wrap h1 { font-size: clamp(28px, 4vw, 42px); margin: 0 0 6px; line-height: 1.15; letter-spacing: -.02em; }
.post-meta { color: var(--muted); font-size: 14px; }
.post-body { font-size: 17px; line-height: 1.8; color: var(--soft); margin-top: 22px; }
.post-body h2 { color: var(--text); margin: 36px 0 12px; font-size: 26px; letter-spacing: -.01em; }
.post-body h3 { color: var(--text); margin: 28px 0 10px; font-size: 21px; }
.post-body p { margin: 0 0 16px; }
.post-body img { border-radius: 12px; margin: 18px 0; }
.post-body a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.post-body table { width: 100%; border-collapse: collapse; margin: 20px 0; font-size: 15px; }
.post-body table th, .post-body table td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; }
.post-body table th { color: var(--text); }
.post-body blockquote {
    border-left: 4px solid var(--accent); padding: 6px 16px;
    color: var(--text); margin: 16px 0; background: rgba(245,158,11,.06); border-radius: 6px;
}

/* ===== Light mode ======================================================== */
[data-theme="light"] {
    --bg: #f8fafc;
    --surface: #ffffff;
    --text: #0f172a;
    --line: rgba(15,23,42,.08);
    --muted: #64748b;
    --soft: #334155;
    color-scheme: light;
}
[data-theme="light"] body { background: var(--bg); color: var(--text); }
[data-theme="light"] .site-header { background: rgba(255,255,255,.85); border-bottom: 1px solid var(--line); }
[data-theme="light"] .brand-name { background: linear-gradient(180deg, #0f172a, #334155); -webkit-background-clip: text; background-clip: text; color: transparent; }
[data-theme="light"] .input-wrap { background: #f1f5f9; border-color: #cbd5e1; }
[data-theme="light"] .paste-btn { background: #fff; color: #334155; border-color: #cbd5e1; }
[data-theme="light"] .feature, [data-theme="light"] .steps-list li, [data-theme="light"] .faq-item, [data-theme="light"] .blog-card { background: #fff; border-color: var(--line); }
[data-theme="light"] .site-footer { background: #f1f5f9; }
[data-theme="light"] .hero-title { background: linear-gradient(180deg, #0f172a, #475569); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* ===== Reduced motion ==================================================== */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .001ms !important;
        transition-duration: .001ms !important;
    }
}

/* ===== Print  ============================================================ */
@media print {
    .site-header, .site-footer, .download-btn, .install-btn { display: none !important; }
}

/* ===== Post page extras ================================================== */
.breadcrumbs { color: var(--muted); font-size: 14px; margin-bottom: 14px; }
.breadcrumbs a { color: var(--soft); }
.breadcrumbs a:hover { color: var(--accent); }
.breadcrumbs span { margin: 0 6px; opacity: 0.7; }

.post-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
    padding: 32px 0 0;
    margin-top: 32px;
    border-top: 1px solid var(--line);
    flex-wrap: wrap;
}
.post-footer .btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    font-weight: 700;
    font-size: 14px;
    text-decoration: none;
    transition: transform 0.1s ease;
}
.post-footer .btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: white;
}
.post-footer .btn-secondary {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--line);
}
.post-footer .btn:hover { transform: translateY(-1px); }

/* ===== Focus / preview mode =============================================
   When the user has a successful fetch, hide the marketing sections so the
   page reads like a focused download view (input + preview card + footer).
   Toggled by JS adding .has-preview on the <body>. */
body.has-preview .hero-title,
body.has-preview .hero-sub,
body.has-preview .hero-note,
body.has-preview .features,
body.has-preview .how-it-works,
body.has-preview .seo-article,
body.has-preview .faqs {
    display: none !important;
}
body.has-preview .hero {
    min-height: auto;
    padding-top: 24px;
    padding-bottom: 32px;
}
body.has-preview main { padding-bottom: 24px; }

/* "Download New" reset button in the result card — same shape as a secondary
   download but with a refresh accent so it reads as the new-session action. */
.btn-reset {
    border: 1px dashed var(--line) !important;
    background: transparent !important;
    color: var(--text) !important;
}
.btn-reset:hover { background: var(--surface) !important; }
