/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --success: #16a34a;
    --success-hover: #15803d;
    --error: #dc2626;
    --error-bg: #fef2f2;
    --bg: #f8fafc;
    --surface: #ffffff;
    --text: #1e293b;
    --text-light: #64748b;
    --border: #e2e8f0;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    overflow-x: hidden;
    min-width: 320px;
}

.container { max-width: 860px; margin: 0 auto; padding: 0 16px; }

/* ── Header (mobile-first: compact) ── */
.site-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 10px 0;
    position: sticky; top: 0; z-index: 100;
}
.site-header .container {
    display: flex; align-items: center; justify-content: space-between;
    gap: 8px; flex-wrap: nowrap;
}
.logo { font-size: 1rem; font-weight: 700; color: var(--primary); text-decoration: none; white-space: nowrap; }
nav { display: flex; gap: 2px; flex-shrink: 0; }
nav a {
    text-decoration: none; color: var(--text-light); font-size: 0.8rem;
    padding: 8px 10px; border-radius: 8px; transition: all 0.15s;
    white-space: nowrap; min-height: 36px; display: flex; align-items: center;
}
nav a:hover, nav a.active { background: #eff6ff; color: var(--primary); }

/* ── Hero (mobile-first: compact padding, smaller headings) ── */
.hero { background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%); padding: 32px 0 28px; text-align: center; }
.hero h1 { font-size: 1.4rem; font-weight: 800; margin-bottom: 8px; line-height: 1.3; padding: 0 4px; }
.hero .highlight { color: var(--primary); }
.hero .subtitle { color: var(--text-light); font-size: 0.9rem; max-width: 560px; margin: 0 auto 20px; padding: 0 8px; }
.hero .subtitle strong { color: var(--text); }

/* ── Download Form (mobile-first: stacked, large touch targets) ── */
.download-form { max-width: 560px; margin: 0 auto; padding: 0 4px; }
.input-group { display: flex; flex-direction: column; gap: 8px; }
.input-group input {
    width: 100%; padding: 14px 16px; font-size: 16px; /* 16px prevents iOS zoom */
    border: 2px solid var(--border); border-radius: var(--radius); outline: none;
    transition: border-color 0.15s; -webkit-appearance: none;
}
.input-group input:focus { border-color: var(--primary); }
.input-group input::placeholder { color: #94a3b8; }
.input-group button {
    width: 100%; padding: 14px 24px; font-size: 16px; font-weight: 600; border: none;
    background: var(--success); color: white; cursor: pointer; border-radius: var(--radius);
    transition: background 0.15s; min-height: 48px;
    -webkit-appearance: none; -webkit-tap-highlight-color: transparent;
}
.input-group button:hover { background: var(--success-hover); }
.input-group button:active { transform: scale(0.98); }
.input-group button:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }
.input-hint { color: var(--text-light); font-size: 0.8rem; margin-top: 8px; text-align: center; }

/* ── Result ── */
.result {
    max-width: 560px; margin: 20px auto 0; padding: 16px;
    background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
    text-align: left; word-wrap: break-word; overflow-wrap: break-word;
}
.result-preview { margin-bottom: 12px; }
.preview-image { width: 100%; max-height: 300px; object-fit: contain; border-radius: 8px; background: #f1f5f9; }
.result-info { margin-top: 8px; }
.result-type {
    display: inline-block; background: #dbeafe; color: var(--primary);
    padding: 3px 10px; border-radius: 20px; font-size: 0.75rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.5px;
}
.result-author { font-weight: 600; margin-top: 6px; font-size: 0.95rem; }
.result-caption { color: var(--text-light); font-size: 0.85rem; margin-top: 4px; word-break: break-word; }
.result-actions { margin-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.btn-download {
    display: block; width: 100%; padding: 13px 20px; background: var(--success); color: white;
    text-decoration: none; border-radius: 10px; font-weight: 600; font-size: 15px;
    text-align: center; transition: background 0.15s; min-height: 48px;
    -webkit-tap-highlight-color: transparent;
}
.btn-download:hover { background: var(--success-hover); }
.btn-download:active { transform: scale(0.98); }
.carousel-count { color: var(--text-light); font-size: 0.85rem; }
.remaining { color: var(--text-light); font-size: 0.75rem; text-align: center; margin-top: 4px; }

/* ── Error ── */
.error {
    max-width: 560px; margin: 12px auto 0; padding: 12px 16px;
    background: var(--error-bg); color: var(--error); border-radius: 10px;
    font-size: 0.9rem; border: 1px solid #fecaca; word-wrap: break-word;
}

/* ── Loading ── */
.loading { max-width: 560px; margin: 20px auto 0; text-align: center; color: var(--text-light); }
.spinner {
    width: 32px; height: 32px; margin: 0 auto 10px;
    border: 3px solid var(--border); border-top-color: var(--primary);
    border-radius: 50%; animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Features (mobile: single column) ── */
.features { padding: 36px 0; }
.features h2, .how-it-works h2, .faq h2, .seo-content h2 {
    text-align: center; font-size: 1.3rem; margin-bottom: 20px;
}
.features-grid {
    display: grid; grid-template-columns: 1fr; gap: 12px;
}
.feature-card {
    background: var(--surface); padding: 20px 16px; border-radius: var(--radius);
    box-shadow: var(--shadow); text-align: center;
}
.feature-icon { font-size: 1.6rem; display: block; margin-bottom: 8px; }
.feature-card h3 { font-size: 1rem; margin-bottom: 4px; }
.feature-card p { color: var(--text-light); font-size: 0.85rem; }

/* ── How It Works / Platform Guides ── */
.how-it-works { padding: 0 0 32px; }
.platform-tabs { display: flex; flex-direction: column; gap: 12px; }
.platform-guide {
    background: var(--surface); padding: 16px; border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.platform-guide h3 { font-size: 0.95rem; margin-bottom: 8px; }
.steps { padding-left: 20px; margin: 0; }
.steps li { margin-bottom: 8px; color: var(--text-light); font-size: 0.85rem; line-height: 1.5; }
.steps li strong { color: var(--text); }
.steps a { color: var(--primary); }

/* ── FAQ ── */
.faq { padding: 0 0 36px; }
.faq details { margin: 0 auto 8px; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); }
.faq summary { padding: 14px 16px; font-weight: 600; cursor: pointer; font-size: 0.9rem; line-height: 1.4; }
.faq details p { padding: 0 16px 14px; color: var(--text-light); font-size: 0.85rem; line-height: 1.6; }

/* ── SEO Content ── */
.seo-content { padding: 28px 0 40px; border-top: 1px solid var(--border); }
.seo-content p {
    max-width: 700px; margin: 0 auto 14px; text-align: left;
    color: var(--text-light); line-height: 1.7; font-size: 0.9rem;
}
.seo-content p strong { color: var(--text); }
.seo-content a { color: var(--primary); text-decoration: underline; }

/* ── Footer ── */
.site-footer { background: var(--surface); border-top: 1px solid var(--border); padding: 20px 0; text-align: center; }
.footer-nav { display: flex; justify-content: center; flex-wrap: wrap; gap: 6px 12px; margin-bottom: 10px; }
.footer-nav a { color: var(--text-light); text-decoration: none; font-size: 0.8rem; }
.footer-nav a:hover { color: var(--primary); }
.footer-sep { color: var(--border); font-size: 0.8rem; user-select: none; }
.disclaimer { color: var(--text-light); font-size: 0.75rem; max-width: 500px; margin: 0 auto; }

/* ── Legal / Info Pages ── */
.legal-page { padding: 40px 0 48px; }
.legal-page h1 { font-size: 1.6rem; font-weight: 800; margin-bottom: 4px; }
.legal-page .legal-date { color: var(--text-light); font-size: 0.8rem; margin-bottom: 28px; }
.legal-page h2 { font-size: 1.15rem; font-weight: 700; margin-top: 28px; margin-bottom: 10px; color: var(--text); }
.legal-page p { color: var(--text-light); font-size: 0.92rem; line-height: 1.7; margin-bottom: 12px; }
.legal-page ul, .legal-page ol { margin: 0 0 16px 20px; color: var(--text-light); font-size: 0.92rem; line-height: 1.7; }
.legal-page li { margin-bottom: 6px; }
.legal-page a { color: var(--primary); text-decoration: underline; }
.legal-page strong { color: var(--text); }

/* Contact cards */
.contact-methods { display: flex; flex-direction: column; gap: 12px; margin: 16px 0 24px; }
.contact-card {
    display: flex; gap: 14px; align-items: flex-start;
    background: var(--surface); padding: 16px; border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.contact-icon { font-size: 1.5rem; flex-shrink: 0; }
.contact-card strong { display: block; font-size: 0.92rem; margin-bottom: 4px; color: var(--text); }
.contact-card p { font-size: 0.85rem; margin-bottom: 4px; }
.contact-card a { color: var(--primary); text-decoration: none; font-weight: 600; }

@media (min-width: 640px) {
    .legal-page h1 { font-size: 1.9rem; }
    .contact-methods { flex-direction: row; flex-wrap: wrap; }
    .contact-card { flex: 1; min-width: 280px; }
}

/* ── Stats Dashboard ── */
.stats-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px; margin: 16px 0 24px;
}
.stat-card {
    background: var(--surface); padding: 20px 16px; border-radius: var(--radius);
    box-shadow: var(--shadow); text-align: center;
    border-left: 4px solid var(--primary);
}
.stat-card.stat-story { border-left-color: #f59e0b; }
.stat-card.stat-reel { border-left-color: #8b5cf6; }
.stat-card.stat-post { border-left-color: #10b981; }
.stat-card.stat-total { border-left-color: var(--primary); }
.stat-card.stat-users { border-left-color: #06b6d4; }
.stat-card.stat-limit { border-left-color: #ef4444; }
.stat-number {
    display: block; font-size: 2rem; font-weight: 800; color: var(--text);
    line-height: 1.2;
}
.stat-label {
    display: block; font-size: 0.8rem; color: var(--text-light);
    margin-top: 4px;
}
.stats-note {
    text-align: center; font-size: 0.75rem; color: var(--text-light);
    margin-top: 16px; font-style: italic;
}

/* ── Story Feed ── */
.story-feed {
    display: flex; flex-direction: column; gap: 16px;
}
.story-feed-header {
    text-align: center; margin-bottom: 8px;
}
.story-feed-title {
    font-weight: 700; font-size: 1.05rem; color: var(--text);
}
.story-feed-author {
    font-size: 0.85rem; color: var(--primary); font-weight: 600;
    display: inline-block; margin-top: 2px;
}
.story-feed-count {
    font-size: 0.75rem; color: var(--text-light);
    display: inline-block; margin-left: 8px;
}
.story-feed-caption {
    font-size: 0.82rem; color: var(--text-light);
    margin-top: 6px; line-height: 1.5; word-break: break-word;
    max-width: 600px; margin-left: auto; margin-right: auto;
}

/* Individual story card in the feed */
.story-item {
    background: var(--surface); border-radius: var(--radius);
    box-shadow: var(--shadow); overflow: hidden;
    border: 2px solid transparent; transition: all 0.25s;
    position: relative;
}
.story-item:target, .story-item-matched {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.25), 0 4px 16px rgba(37,99,235,0.12);
}
.story-item:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,0.1);
}

/* Media area — dark background like Instagram */
.story-media {
    background: #0f0f0f; position: relative;
    min-height: 280px; display: flex; align-items: center; justify-content: center;
    overflow: hidden;
    /* Instagram story aspect ratio on mobile */
    aspect-ratio: 9/16; max-height: 75vh;
}
.story-media img {
    width: 100%; height: 100%; object-fit: contain; display: block;
}
.story-media video {
    width: 100%; height: 100%; object-fit: contain; display: block;
    background: #0f0f0f;
}

/* Photo placeholder when no preview_url (fallback) */
.story-media-placeholder {
    color: #64748b; font-size: 0.85rem; text-align: center;
    padding: 24px;
}
.story-media-placeholder .icon {
    font-size: 3rem; display: block; margin-bottom: 8px; opacity: 0.4;
}

/* Play button overlay for video stories */
.story-play-overlay {
    position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
    background: rgba(0,0,0,0.25); cursor: pointer; transition: background 0.2s;
    z-index: 2;
}
.story-play-overlay:hover { background: rgba(0,0,0,0.15); }
.story-play-btn {
    width: 64px; height: 64px; background: rgba(255,255,255,0.92);
    border-radius: 50%; display: flex; align-items: center; justify-content: center;
    box-shadow: 0 2px 12px rgba(0,0,0,0.3); transition: transform 0.15s;
}
.story-play-btn::after {
    content: ''; display: block;
    width: 0; height: 0;
    border-left: 18px solid #1e293b;
    border-top: 11px solid transparent;
    border-bottom: 11px solid transparent;
    margin-left: 4px; /* optical center */
}
.story-play-overlay:hover .story-play-btn { transform: scale(1.08); }

/* Type badge on the media */
.story-type-badge {
    position: absolute; top: 10px; left: 10px; z-index: 3;
    background: rgba(0,0,0,0.65); color: white;
    padding: 4px 10px; border-radius: 20px;
    font-size: 0.7rem; font-weight: 600;
    letter-spacing: 0.3px; backdrop-filter: blur(4px);
}

/* Matched story indicator */
.story-matched-badge {
    position: absolute; top: 10px; right: 10px; z-index: 3;
    background: var(--primary); color: white;
    padding: 4px 10px; border-radius: 20px;
    font-size: 0.65rem; font-weight: 700;
    letter-spacing: 0.3px;
}

/* Info bar below media */
.story-item-bar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 14px; gap: 10px; flex-wrap: wrap;
}
.story-item-label {
    font-weight: 600; font-size: 0.85rem; color: var(--text);
}
.story-item-label .num { color: var(--primary); }
.story-item-meta {
    font-size: 0.7rem; color: var(--text-light);
}

/* Download button inside card */
.story-dl-btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 9px 18px; background: var(--success); color: white;
    text-decoration: none; border-radius: 8px;
    font-weight: 600; font-size: 0.85rem;
    transition: background 0.15s; white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
}
.story-dl-btn:hover { background: var(--success-hover); }
.story-dl-btn:active { transform: scale(0.97); }
.story-dl-btn .arrow { font-size: 0.9rem; }

/* Navigation between stories (sticky bottom bar?) — inline pager */
.story-pager {
    display: flex; align-items: center; justify-content: center; gap: 12px;
    margin-top: 8px; padding: 8px 0;
}
.story-pager-btn {
    padding: 8px 16px; background: var(--surface); border: 1px solid var(--border);
    border-radius: 8px; cursor: pointer; font-size: 0.85rem; font-weight: 600;
    color: var(--text); transition: all 0.15s;
    -webkit-tap-highlight-color: transparent;
}
.story-pager-btn:hover { background: #eff6ff; border-color: var(--primary); color: var(--primary); }
.story-pager-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.story-pager-info { font-size: 0.8rem; color: var(--text-light); min-width: 60px; text-align: center; }

/* ── Responsive: desktop story items ── */
@media (min-width: 640px) {
    .story-media { aspect-ratio: auto; min-height: 360px; max-height: 65vh; }
    .story-item-bar { padding: 12px 20px; }
    .story-feed-title { font-size: 1.2rem; }
    .story-type-badge { top: 14px; left: 14px; font-size: 0.75rem; padding: 5px 12px; }
    .story-matched-badge { top: 14px; right: 14px; font-size: 0.7rem; padding: 5px 12px; }
}

@media (min-width: 768px) {
    .story-media { min-height: 420px; max-height: 60vh; }
}

/* ── Desktop (2-col features, side-by-side input) ── */
@media (min-width: 640px) {
    .site-header { padding: 12px 0; }
    .container { padding: 0 20px; }
    .logo { font-size: 1.15rem; }
    nav a { font-size: 0.88rem; padding: 7px 14px; }

    .hero { padding: 56px 0 44px; }
    .hero h1 { font-size: 2rem; }
    .hero .subtitle { font-size: 1.05rem; margin-bottom: 28px; }

    .input-group { flex-direction: row; gap: 0; }
    .input-group input {
        border-radius: var(--radius) 0 0 var(--radius); border-right: none;
        font-size: 1rem;
    }
    .input-group button {
        width: auto; padding: 16px 32px; border-radius: 0 var(--radius) var(--radius) 0;
    }

    .features-grid { grid-template-columns: repeat(2, 1fr); gap: 16px; }
    .feature-card { padding: 24px 20px; }

    .platform-tabs {
        flex-direction: row; gap: 16px;
    }
    .platform-guide { flex: 1; }

    .steps li { font-size: 0.9rem; }
    .faq summary { font-size: 0.95rem; }
    .seo-content p { font-size: 0.95rem; text-align: center; }
}

@media (min-width: 768px) {
    .features-grid { grid-template-columns: repeat(4, 1fr); }
    .features h2, .how-it-works h2, .faq h2, .seo-content h2 { font-size: 1.6rem; }
    .hero h1 { font-size: 2.2rem; }
}
