/* ─── Design tokens ──────────────────────────────────────────────────────── */
:root {
    --brand:        #5B4CF5;
    --brand-dark:   #3D2FD9;
    --brand-light:  #EEF0FF;
    --ink:          #0F0E17;
    --ink-2:        #3A3750;
    --ink-3:        #7A7896;
    --rule:         #E8E8F0;
    --surface:      #FFFFFF;
    --bg:           #F7F7FA;
    --success:      #0D9488;
    --error-bg:     #FEF2F2;
    --error-border: #FECACA;
    --error-text:   #991B1B;

    --radius-sm:  6px;
    --radius-md:  12px;
    --radius-lg:  20px;
    --radius-xl:  28px;

    --shadow-card: 0 1px 3px rgba(0,0,0,.06), 0 8px 32px rgba(0,0,0,.08);
    --shadow-lift: 0 4px 20px rgba(91,76,245,.22);
}

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

/* ─── Base ───────────────────────────────────────────────────────────────── */
html { scroll-behavior: smooth; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background-color: var(--bg);
    color: var(--ink);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* ─── Hero ───────────────────────────────────────────────────────────────── */
.hero {
    background: linear-gradient(160deg, #0F0E17 0%, #1A1740 60%, #2B1F6B 100%);
    padding: 64px 24px 80px;
    text-align: center;
    position: relative;
    overflow: hidden;
}

/* subtle radial glow */
.hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse 70% 60% at 50% 110%, rgba(91,76,245,.35) 0%, transparent 70%);
    pointer-events: none;
}

.hero-inner {
    position: relative;
    max-width: 680px;
    margin: 0 auto;
}

/* Logo */
.logo {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 40px;
}

.logo-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: var(--brand);
    color: #fff;
    font-family: 'DM Serif Display', Georgia, serif;
    font-size: 1.25rem;
    border-radius: 9px;
    box-shadow: 0 0 0 2px rgba(255,255,255,.12);
}

.logo-text {
    font-size: 1.15rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: -0.3px;
}

/* Headline */
.hero-headline {
    font-family: 'DM Serif Display', Georgia, serif;
    font-size: clamp(2.4rem, 6vw, 3.6rem);
    font-weight: 400;
    line-height: 1.15;
    color: #fff;
    margin-bottom: 20px;
    letter-spacing: -0.5px;
}

.hero-headline em {
    font-style: italic;
    color: #A99FFB;
}

.hero-sub {
    font-size: 1.1rem;
    color: rgba(255,255,255,.65);
    max-width: 520px;
    margin: 0 auto 40px;
    line-height: 1.65;
}

/* Search bar */
.search-bar {
    display: flex;
    gap: 10px;
    background: rgba(255,255,255,.08);
    border: 1px solid rgba(255,255,255,.15);
    border-radius: var(--radius-xl);
    padding: 8px 8px 8px 20px;
    backdrop-filter: blur(12px);
}

.url-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    font-family: 'Inter', sans-serif;
    font-size: 0.975rem;
    color: #fff;
    min-width: 0;
}

.url-input::placeholder { color: rgba(255,255,255,.4); }

.url-input:disabled { cursor: not-allowed; opacity: .5; }

/* ─── Buttons ────────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    border: none;
    border-radius: 999px;
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease;
    white-space: nowrap;
}

.btn-primary {
    background: var(--brand);
    color: #fff;
}

.btn-primary:hover:not(:disabled) {
    background: var(--brand-dark);
    box-shadow: var(--shadow-lift);
    transform: translateY(-1px);
}

.btn-cta {
    background: var(--brand);
    color: #fff;
    padding: 14px 28px;
    font-size: 0.95rem;
}

.btn-cta:hover:not(:disabled) {
    background: var(--brand-dark);
    box-shadow: var(--shadow-lift);
    transform: translateY(-1px);
}

.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ─── Alerts ─────────────────────────────────────────────────────────────── */
.alert {
    margin-top: 16px;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    text-align: left;
    animation: slideUp 0.3s ease;
}

.alert-error {
    background: var(--error-bg);
    border: 1px solid var(--error-border);
    color: var(--error-text);
}

.alert-info {
    background: rgba(255,255,255,.1);
    border: 1px solid rgba(255,255,255,.18);
    color: rgba(255,255,255,.85);
}

/* ─── Main ───────────────────────────────────────────────────────────────── */
.main {
    max-width: 720px;
    margin: -40px auto 60px;
    padding: 0 20px;
    position: relative;
    z-index: 2;
}

/* ─── Empty state ────────────────────────────────────────────────────────── */
.empty-state {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    padding: 72px 32px;
    text-align: center;
}

.empty-icon {
    font-size: 2rem;
    color: var(--brand);
    margin-bottom: 16px;
    display: block;
}

.empty-headline {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--ink-2);
    margin-bottom: 8px;
}

.empty-hint {
    font-size: 0.9rem;
    color: var(--ink-3);
}

/* ─── Loading state ──────────────────────────────────────────────────────── */
.loading-state {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    padding: 80px 32px;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.muse-background {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.muse-image {
    width: 260px;
    height: 260px;
    object-fit: contain;
    opacity: 0.18;
    border-radius: var(--radius-lg);
    animation: fadeIn 0.5s ease;
}

.loading-text {
    margin-top: 20px;
    font-size: 1rem;
    color: var(--ink-3);
    position: relative;
    z-index: 1;
}

/* ─── Digest frame ───────────────────────────────────────────────────────── */
.digest-frame {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    overflow: hidden;
    animation: slideUp 0.4s ease;
}

/* Email client top bar */
.digest-header {
    background: var(--bg);
    border-bottom: 1px solid var(--rule);
    padding: 14px 24px;
}

.digest-meta {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.digest-from,
.digest-subject {
    font-size: 0.8rem;
    color: var(--ink-3);
}

.digest-from strong { color: var(--ink-2); font-weight: 600; }
.digest-subject { color: var(--ink-2); font-weight: 500; font-size: 0.85rem; }

/* ─── Feed / scrollable area ─────────────────────────────────────────────── */
.feed-container {
    max-height: 620px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--rule) transparent;
}

.feed-container::-webkit-scrollbar { width: 6px; }
.feed-container::-webkit-scrollbar-track { background: transparent; }
.feed-container::-webkit-scrollbar-thumb { background: var(--rule); border-radius: 4px; }

/* ─── Newsletter content ─────────────────────────────────────────────────── */
.newsletter-content {
    padding: 40px 48px 32px;
}

@media (max-width: 560px) {
    .newsletter-content { padding: 28px 24px; }
}

/* In-email brand banner */
.digest-top-banner {
    text-align: center;
    padding-bottom: 32px;
    margin-bottom: 36px;
    border-bottom: 2px solid var(--rule);
}

.digest-logo-small {
    display: inline-block;
    font-family: 'DM Serif Display', Georgia, serif;
    font-size: 1.5rem;
    color: var(--brand);
    letter-spacing: -0.5px;
    margin-bottom: 6px;
}

.digest-tagline {
    font-size: 0.8rem;
    color: var(--ink-3);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 500;
}

/* Article blurb */
.blurb {
    padding-bottom: 36px;
    margin-bottom: 36px;
    border-bottom: 1px solid var(--rule);
    position: relative;
}

.blurb:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.blurb-number {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 1.5px;
    color: var(--brand);
    text-transform: uppercase;
    margin-bottom: 10px;
}

.blurb-title {
    font-family: 'DM Serif Display', Georgia, serif;
    font-size: 1.55rem;
    font-weight: 400;
    color: var(--ink);
    line-height: 1.25;
    margin-bottom: 14px;
    letter-spacing: -0.3px;
}

.blurb-text {
    font-size: 1rem;
    color: var(--ink-2);
    line-height: 1.85;
    margin-bottom: 16px;
}

.read-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--brand);
    text-decoration: none;
    border-bottom: 1.5px solid var(--brand-light);
    padding-bottom: 1px;
    transition: border-color 0.15s ease, color 0.15s ease;
}

.read-link:hover {
    color: var(--brand-dark);
    border-bottom-color: var(--brand-dark);
}

/* Loading more */
.loading-indicator {
    text-align: center;
    padding: 24px;
}

/* ─── CTA section ────────────────────────────────────────────────────────── */
.cta-section {
    background: linear-gradient(160deg, #0F0E17 0%, #2B1F6B 100%);
    padding: 52px 48px;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.cta-section::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse 70% 80% at 50% 100%, rgba(91,76,245,.4) 0%, transparent 65%);
    pointer-events: none;
}

.cta-inner { position: relative; max-width: 480px; margin: 0 auto; }

.cta-eyebrow {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: #A99FFB;
    margin-bottom: 12px;
}

.cta-title {
    font-family: 'DM Serif Display', Georgia, serif;
    font-size: clamp(1.6rem, 4vw, 2.2rem);
    font-weight: 400;
    color: #fff;
    margin-bottom: 10px;
    letter-spacing: -0.3px;
    line-height: 1.2;
}

.cta-subtitle {
    font-size: 0.975rem;
    color: rgba(255,255,255,.6);
    margin-bottom: 32px;
    line-height: 1.6;
}

.email-form {
    display: flex;
    gap: 10px;
    background: rgba(255,255,255,.1);
    border: 1px solid rgba(255,255,255,.18);
    border-radius: 999px;
    padding: 8px 8px 8px 20px;
    backdrop-filter: blur(8px);
    margin-bottom: 16px;
}

.email-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    font-family: 'Inter', sans-serif;
    font-size: 0.95rem;
    color: #fff;
    min-width: 0;
}

.email-input::placeholder { color: rgba(255,255,255,.4); }

.subscribe-message {
    font-size: 0.9rem;
    color: rgba(255,255,255,.85);
    margin-bottom: 8px;
    font-weight: 500;
}

.cta-fine {
    font-size: 0.75rem;
    color: rgba(255,255,255,.35);
    margin-top: 4px;
}

/* ─── Stats panel ────────────────────────────────────────────────────────── */
.stats-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15,14,23,.65);
    backdrop-filter: blur(4px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 0.2s ease;
}

.stats-panel {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: 0 24px 64px rgba(0,0,0,.25);
    width: 100%;
    max-width: 640px;
    overflow: hidden;
    animation: slideUp 0.25s ease;
}

.stats-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 24px;
    border-bottom: 1px solid var(--rule);
}

.stats-header h4 {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--ink);
}

.stats-close {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    color: var(--ink-3);
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: background 0.15s;
}
.stats-close:hover { background: var(--bg); }

.stats-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.stats-table th {
    text-align: left;
    padding: 10px 16px;
    background: var(--bg);
    color: var(--ink-3);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--rule);
}

.stats-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--rule);
    color: var(--ink-2);
    vertical-align: top;
}

.stats-table tr:last-child td { border-bottom: none; }

.stats-table tr.stats-active td { background: var(--brand-light); }

.stats-id {
    font-weight: 700;
    color: var(--brand) !important;
    width: 32px;
}

.stats-copy {
    font-style: italic;
    color: var(--ink) !important;
    max-width: 240px;
}

.stats-actions {
    display: flex;
    gap: 10px;
    padding: 16px 24px;
    border-top: 1px solid var(--rule);
    background: var(--bg);
}

.btn-stats-export {
    padding: 9px 18px;
    background: var(--brand);
    color: #fff;
    border: none;
    border-radius: 999px;
    font-family: 'Inter', sans-serif;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
}
.btn-stats-export:hover { background: var(--brand-dark); transform: translateY(-1px); }

.btn-stats-reset {
    padding: 9px 18px;
    background: none;
    color: var(--error-text);
    border: 1px solid var(--error-border);
    border-radius: 999px;
    font-family: 'Inter', sans-serif;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}
.btn-stats-reset:hover { background: var(--error-bg); }

/* Make logo clickable */
.logo { cursor: pointer; user-select: none; }

/* ─── Footer ─────────────────────────────────────────────────────────────── */
.site-footer {
    text-align: center;
    padding: 32px 20px;
    font-size: 0.8rem;
    color: var(--ink-3);
}

/* ─── Spinner ────────────────────────────────────────────────────────────── */
.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--rule);
    border-top-color: var(--brand);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto;
    position: relative;
    z-index: 1;
}

.spinner-small {
    width: 22px;
    height: 22px;
    border: 2.5px solid var(--rule);
    border-top-color: var(--brand);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto;
}

/* ─── Animations ─────────────────────────────────────────────────────────── */
@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ─── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
    .hero { padding: 48px 16px 64px; }

    .search-bar {
        flex-direction: column;
        border-radius: var(--radius-lg);
        padding: 14px 16px;
        gap: 12px;
    }

    .btn-primary { width: 100%; border-radius: var(--radius-md); padding: 14px; }

    .digest-header { padding: 12px 16px; }

    .cta-section { padding: 40px 24px; }

    .email-form {
        flex-direction: column;
        border-radius: var(--radius-lg);
        padding: 14px 16px;
        gap: 12px;
    }

    .btn-cta { width: 100%; border-radius: var(--radius-md); }

    .blurb-title { font-size: 1.3rem; }
}
