* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --ink: #0a0a0f;
    --paper: #faf8f4;
    --amber: #d4a251;
    --amber-light: #f0d9a8;
    --amber-dark: #b8893f;
    --slate: #6b6b78;
    --rule: #e0ddd6;
    --white: #ffffff;
    --red: #d44a4a;
    --green: #3d9970;
}

body {
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--paper);
    color: var(--ink);
    line-height: 1.6;
    overflow-x: hidden;
}

/* Grain texture */
body::before {
    content: '';
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.03'/%3E%3C/svg%3E");
    pointer-events: none;
    z-index: 0;
}

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 24px;
    position: relative;
    z-index: 1;
}

/* --- TYPOGRAPHY --- */
h1, h2, h3 { font-family: 'Space Grotesk', sans-serif; letter-spacing: -0.5px; line-height: 1.2; }
h1 { font-size: 3.2rem; font-weight: 700; }
h2 { font-size: 2rem; font-weight: 600; }
h3 { font-size: 1.25rem; font-weight: 600; }

.text-slate { color: var(--slate); }
.text-amber { color: var(--amber); }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }

/* --- NAV --- */
nav {
    padding: 20px 0;
    border-bottom: 1px solid var(--rule);
    position: relative;
    z-index: 10;
}
nav .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.logo {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: var(--ink);
    text-decoration: none;
    cursor: pointer;
}
.logo span { color: var(--amber); }
.nav-links { display: flex; gap: 12px; align-items: center; }
.nav-links a, .nav-links button {
    font-size: 0.9rem;
    text-decoration: none;
    color: var(--slate);
    cursor: pointer;
    background: none;
    border: none;
    font-family: inherit;
    transition: color 0.2s;
}
.nav-links a:hover, .nav-links button:hover { color: var(--ink); }

/* --- BUTTONS --- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
    text-decoration: none;
}
.btn-primary {
    background: var(--ink);
    color: var(--paper);
}
.btn-primary:hover { background: #1a1a2f; transform: translateY(-1px); }
.btn-amber {
    background: var(--amber);
    color: var(--white);
}
.btn-amber:hover { background: var(--amber-dark); }
.btn-outline {
    background: transparent;
    color: var(--ink);
    border: 1.5px solid var(--rule);
}
.btn-outline:hover { border-color: var(--ink); }
.btn-sm { padding: 8px 16px; font-size: 0.85rem; }
.btn-ghost {
    background: transparent;
    color: var(--slate);
    padding: 8px 12px;
}
.btn-ghost:hover { color: var(--ink); }
.btn-danger { background: var(--red); color: var(--white); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* --- FORMS --- */
.form-group { margin-bottom: 20px; }
.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--ink);
    margin-bottom: 6px;
}
.form-group input, .form-group select, .form-group textarea {
    width: 100%;
    padding: 12px 16px;
    border: 1.5px solid var(--rule);
    border-radius: 8px;
    font-size: 0.95rem;
    font-family: inherit;
    background: var(--white);
    color: var(--ink);
    transition: border-color 0.2s;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    outline: none;
    border-color: var(--amber);
}
.form-group textarea { resize: vertical; min-height: 80px; }
.form-group .hint { font-size: 0.8rem; color: var(--slate); margin-top: 4px; }

/* --- CARDS --- */
.card {
    background: var(--white);
    border: 1px solid var(--rule);
    border-radius: 12px;
    padding: 28px;
}
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--rule);
}

/* --- HERO (Landing) --- */
.hero {
    padding: 80px 0 60px;
    text-align: center;
}
.hero h1 { margin-bottom: 20px; max-width: 700px; margin-left: auto; margin-right: auto; }
.hero p { font-size: 1.15rem; color: var(--slate); max-width: 560px; margin: 0 auto 36px; }
.hero-cta { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

/* --- STEPS --- */
.steps {
    padding: 60px 0;
    border-top: 1px solid var(--rule);
}
.steps-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 40px;
    margin-top: 40px;
}
.step { text-align: center; }
.step-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--amber);
    color: var(--white);
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 1.2rem;
    margin-bottom: 16px;
}
.step h3 { margin-bottom: 8px; }
.step p { color: var(--slate); font-size: 0.95rem; }

/* --- FEATURES --- */
.features {
    padding: 60px 0;
    border-top: 1px solid var(--rule);
}
.features-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
    margin-top: 32px;
}
.feature-card {
    background: var(--white);
    border: 1px solid var(--rule);
    border-radius: 12px;
    padding: 32px;
}
.feature-card h3 { margin-bottom: 8px; }
.feature-card p { color: var(--slate); font-size: 0.95rem; }

/* --- FOOTER --- */
footer {
    padding: 40px 0;
    border-top: 1px solid var(--rule);
    text-align: center;
    color: var(--slate);
    font-size: 0.85rem;
}

/* --- AUTH PAGES --- */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 80vh;
    padding: 40px 24px;
}
.auth-card {
    background: var(--white);
    border: 1px solid var(--rule);
    border-radius: 16px;
    padding: 40px;
    width: 100%;
    max-width: 420px;
}
.auth-card h2 { margin-bottom: 8px; }
.auth-card .subtitle { color: var(--slate); margin-bottom: 28px; }
.auth-card .error-msg {
    background: #fef2f2;
    color: var(--red);
    padding: 12px;
    border-radius: 8px;
    font-size: 0.9rem;
    margin-bottom: 16px;
    display: none;
}
.auth-card .switch-link { text-align: center; margin-top: 20px; font-size: 0.9rem; color: var(--slate); }
.auth-card .switch-link a { color: var(--amber); cursor: pointer; text-decoration: none; font-weight: 600; }

/* --- DASHBOARD --- */
.dashboard { padding: 40px 0; }
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 32px;
}
.stat-card {
    background: var(--white);
    border: 1px solid var(--rule);
    border-radius: 12px;
    padding: 24px;
    text-align: center;
}
.stat-card .stat-value {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 2rem;
    font-weight: 700;
    color: var(--ink);
}
.stat-card .stat-label {
    font-size: 0.8rem;
    color: var(--slate);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-top: 4px;
}

.newsletter-list { display: flex; flex-direction: column; gap: 16px; }
.newsletter-item {
    background: var(--white);
    border: 1px solid var(--rule);
    border-radius: 12px;
    padding: 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: border-color 0.2s;
}
.newsletter-item:hover { border-color: var(--amber); }
.newsletter-item .nl-info h3 { margin-bottom: 4px; }
.newsletter-item .nl-meta { display: flex; gap: 16px; font-size: 0.85rem; color: var(--slate); }
.newsletter-item .nl-actions { display: flex; gap: 8px; }

/* --- NEWSLETTER DETAIL --- */
.detail-page { padding: 40px 0; }
.detail-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 32px;
}
.detail-header h2 { margin-bottom: 4px; }

.tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--rule);
    margin-bottom: 24px;
}
.tab {
    padding: 12px 20px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--slate);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s;
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
    font-family: inherit;
}
.tab.active { color: var(--ink); border-bottom-color: var(--amber); }
.tab:hover { color: var(--ink); }

.issues-list { display: flex; flex-direction: column; gap: 12px; }
.issue-item {
    background: var(--white);
    border: 1px solid var(--rule);
    border-radius: 10px;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.issue-item .issue-info h4 { font-size: 1rem; margin-bottom: 4px; }
.issue-item .issue-meta { font-size: 0.8rem; color: var(--slate); }
.issue-item .issue-actions { display: flex; gap: 8px; }

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.badge-draft { background: #fef3c7; color: #92400e; }
.badge-sent { background: #d1fae5; color: #065f46; }
.badge-active { background: #d1fae5; color: #065f46; }

/* --- ISSUE PREVIEW --- */
.preview-page { padding: 40px 0; max-width: 700px; margin: 0 auto; }
.preview-content {
    background: var(--white);
    border: 1px solid var(--rule);
    border-radius: 12px;
    padding: 40px;
    margin: 24px 0;
}
.preview-content h2 { font-size: 1.5rem; margin-bottom: 16px; color: var(--ink); }
.preview-content p { margin-bottom: 16px; line-height: 1.7; }
.preview-content ul, .preview-content ol { margin-bottom: 16px; padding-left: 24px; }
.preview-content li { margin-bottom: 8px; }
.preview-content strong { color: var(--ink); }

.preview-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 24px;
}

/* --- SUBSCRIBE PAGE --- */
.subscribe-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 80vh;
    padding: 40px 24px;
}
.subscribe-card {
    background: var(--white);
    border: 1px solid var(--rule);
    border-radius: 16px;
    padding: 48px;
    width: 100%;
    max-width: 480px;
    text-align: center;
}
.subscribe-card h2 { margin-bottom: 8px; }
.subscribe-card .niche-tag {
    display: inline-block;
    background: var(--amber-light);
    color: var(--amber-dark);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 16px;
}
.subscribe-card .subscribe-form { display: flex; gap: 8px; margin-top: 24px; }
.subscribe-card .subscribe-form input { flex: 1; }
.subscribe-card .success-msg {
    background: #d1fae5;
    color: #065f46;
    padding: 16px;
    border-radius: 8px;
    margin-top: 16px;
    display: none;
}

/* --- EMPTY STATES --- */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--slate);
}
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 16px; }
.empty-state h3 { color: var(--ink); margin-bottom: 8px; }
.empty-state p { margin-bottom: 24px; }

/* --- MODAL --- */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(10, 10, 15, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 24px;
}
.modal {
    background: var(--white);
    border-radius: 16px;
    padding: 36px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}
.modal h2 { margin-bottom: 24px; }
.modal-actions { display: flex; gap: 12px; justify-content: flex-end; margin-top: 24px; }

/* --- LOADING --- */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--rule);
    border-top-color: var(--amber);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
}

/* --- RESPONSIVE --- */
@media (max-width: 768px) {
    h1 { font-size: 2.2rem; }
    .steps-grid { grid-template-columns: 1fr; gap: 32px; }
    .features-grid { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .hero { padding: 48px 0 40px; }
    .newsletter-item { flex-direction: column; align-items: flex-start; gap: 16px; }
    .detail-header { flex-direction: column; gap: 16px; }
    .subscribe-card .subscribe-form { flex-direction: column; }
}
