:root {
    --primary: #5B4FE8;
    --primary-dark: #4A3FD0;
    --ink: #161B2E;
    --bg: #F6F5F1;
    --panel-bg: #ffffff;
    --border: #E4E2DA;
    --text: #1F2430;
    --text-muted: #6B7280;
    --success: #059669;
    --error: #dc2626;
    --amber: #E8A23D;
    --radius: 10px;
    --font-display: 'Fraunces', Georgia, serif;
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--text);
}

/* ============================================================
   DASHBOARD LAYOUT
   ============================================================ */
.dashboard-body { background: var(--bg); }

.dash-shell {
    display: flex;
    min-height: 100vh;
}

.dash-sidebar {
    width: 240px;
    flex-shrink: 0;
    background: var(--ink);
    color: #fff;
    padding: 24px 18px;
    display: flex;
    flex-direction: column;
    gap: 28px;
}

.dash-brand { display: flex; align-items: center; gap: 10px; }
.brand-logo { width: 36px; height: 36px; object-fit: contain; border-radius: 6px; background: #fff; padding: 2px; }
.brand-name { font-size: 16px; font-weight: 600; line-height: 1.2; }
.brand-sub { font-size: 11.5px; color: #9BA0B5; margin-top: 2px; }

.dash-nav { display: flex; flex-direction: column; gap: 2px; }
.dash-nav-link {
    color: #C7CAD9;
    text-decoration: none;
    padding: 8px 0;
    font-size: 13.5px;
    font-weight: 500;
    text-align: left;
}
.dash-nav-link:hover { color: #fff; }
.dash-nav-link.active { color: var(--primary); }

.dash-cta {
    margin-top: auto;
    text-align: left;
    text-decoration: none;
    display: block;
    background: none;
    color: #C7CAD9;
    padding: 8px 0;
    font-size: 13.5px;
    font-weight: 600;
    width: auto;
}
.dash-cta:hover { color: #fff; }

.dash-nav-link { display: flex; align-items: center; gap: 10px; }
.nav-icon { width: 17px; height: 17px; flex-shrink: 0; }

.dash-main { flex: 1; padding: 32px 40px; max-width: 1100px; }

.dash-topline { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; gap: 20px; flex-wrap: wrap; }
.dash-topline-actions { display: flex; align-items: center; gap: 12px; }
.dash-greeting { font-size: 22px; font-weight: 600; color: var(--ink); }
.dash-search { display: flex; align-items: center; gap: 8px; background: var(--panel-bg); border: 1px solid var(--border); border-radius: 10px; padding: 8px 14px; width: 200px; flex-shrink: 0; }
.dash-search svg { width: 15px; height: 15px; color: var(--text-muted); flex-shrink: 0; }
.dash-search input { border: none; outline: none; font-size: 13px; width: 100%; background: transparent; }

.chart-card { flex: 1.6; min-width: 240px; flex-direction: column; align-items: stretch; gap: 8px; }
.chart-card-title { font-size: 12px; color: var(--text-muted); font-weight: 600; }
.chart-svg { width: 100%; height: 64px; display: block; }
.chart-labels { display: flex; justify-content: space-between; font-size: 10px; color: var(--text-muted); padding: 0 2px; }

.stat-card { display: flex; align-items: center; gap: 14px; }
.stat-icon { width: 44px; height: 44px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.stat-icon svg { width: 22px; height: 22px; }
.stat-icon-green { background: #E4F5EA; color: #1E9E5A; }
.stat-icon-indigo { background: #EDEBFC; color: var(--primary); }

.website-card-identity { display: flex; align-items: center; gap: 12px; }
.website-card-avatar {
    width: 38px; height: 38px; border-radius: 10px; flex-shrink: 0;
    background: linear-gradient(135deg, #7A6FF5, #5B4FE8);
    color: #fff; font-weight: 600; font-size: 16px;
    display: flex; align-items: center; justify-content: center;
}

.dash-hero {
    position: relative;
    border-radius: 16px;
    padding: 28px 30px;
    margin-bottom: 28px;
    color: #ffffff;
    background: radial-gradient(circle at 85% 20%, #7A6FF5, #5B4FE8 55%, #4436C4);
    box-shadow: 0 10px 26px rgba(76, 66, 204, 0.28);
    overflow: hidden;
}
.dash-hero-circle {
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    pointer-events: none;
}
.dash-hero-circle-1 { width: 160px; height: 160px; right: -30px; top: -40px; }
.dash-hero-circle-2 { width: 100px; height: 100px; right: 70px; bottom: -50px; background: rgba(255, 255, 255, 0.06); }
.dash-hero-content { position: relative; max-width: 65%; }
.hero-title { font-size: 22px; font-weight: 600; margin-bottom: 6px; color: #ffffff; }
.hero-sub { font-size: 13.5px; color: rgba(255, 255, 255, 0.85); }

.sidebar-stats { display: flex; flex-direction: column; gap: 10px; }
.sidebar-stat { border-radius: 10px; padding: 12px 14px; background: rgba(255, 255, 255, 0.05); }
.sidebar-stat-value { font-size: 22px; font-weight: 600; color: #ffffff; }
.sidebar-stat-label { font-size: 11px; color: #9BA0B5; margin-top: 2px; }

.website-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 14px;
    margin-bottom: 22px;
}
.website-card {
    display: block;
    background: var(--panel-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px 18px;
    text-decoration: none;
    color: var(--text);
    box-shadow: 0 2px 6px rgba(20, 20, 40, 0.04);
    transition: box-shadow 0.15s, transform 0.15s;
}
.website-card:hover { box-shadow: 0 8px 18px rgba(20, 20, 40, 0.09); transform: translateY(-2px); }
.website-card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.website-card-name { font-size: 14px; font-weight: 600; color: var(--ink); }
.website-card-industry { font-size: 12px; color: var(--text-muted); margin-top: 3px; }
.website-card-badge {
    font-size: 11px;
    font-weight: 600;
    color: var(--primary-dark);
    background: rgba(91, 79, 232, 0.1);
    padding: 4px 10px;
    border-radius: 999px;
    white-space: nowrap;
}

.pagination { display: flex; justify-content: center; gap: 6px; margin-top: 4px; }
.page-link {
    display: inline-block;
    min-width: 30px;
    text-align: center;
    padding: 6px 4px;
    border-radius: 6px;
    font-size: 13px;
    text-decoration: none;
    color: var(--text);
    border: 1px solid var(--border);
}
.page-link.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.page-link:hover:not(.active) { background: var(--bg); }

.detail-header { margin-bottom: 18px; }
.detail-header h2 { font-size: 22px; margin: 0 0 4px; color: var(--ink); }

.topic-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 10px;
    margin-bottom: 26px;
}
.topic-pill-card {
    display: block;
    background: var(--panel-bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px 14px;
    font-size: 13px;
    color: var(--text);
    text-decoration: none;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.03);
}
.topic-pill-card:hover { border-color: var(--primary); }
.topic-pill-meta { display: block; font-size: 11px; color: var(--text-muted); margin-top: 4px; }

.profile-card {
    background: var(--panel-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px 22px;
    margin-bottom: 26px;
}
.profile-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
    font-size: 13.5px;
}
.profile-grid .full-width { grid-column: 1 / -1; }
.profile-grid strong { display: block; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-muted); margin-bottom: 4px; }
.profile-grid p { margin: 0; color: var(--text); }
.profile-tag-row { margin-top: 14px; }
.profile-tag-row strong { display: block; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-muted); margin-bottom: 6px; }

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 20, 36, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 20px;
}
.modal-box {
    background: var(--panel-bg);
    border-radius: 14px;
    max-width: 720px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 20px 50px rgba(0,0,0,0.25);
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 22px;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: var(--panel-bg);
}
.modal-header h3 { font-size: 17px; margin: 0; }
.modal-close { background: none; border: none; font-size: 22px; line-height: 1; cursor: pointer; color: var(--text-muted); }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 20px 22px; }

/* ============================================================
   NEW BLOG WIZARD
   ============================================================ */
.wizard-shell { background: var(--panel-bg); border: 1px solid var(--border); border-radius: 14px; padding: 28px 32px; }

.wizard-track { display: flex; align-items: center; margin-bottom: 32px; }
.wiz-dot-wrap { display: flex; flex-direction: column; align-items: center; gap: 6px; flex-shrink: 0; }
.wiz-dot {
    width: 30px; height: 30px; border-radius: 50%;
    background: var(--bg); border: 1.5px solid var(--border); color: var(--text-muted);
    display: flex; align-items: center; justify-content: center;
    font-size: 12.5px; font-weight: 600;
}
.wiz-dot.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.wiz-dot.done { background: #E4F5EA; border-color: #1E9E5A; color: #1E9E5A; }
.wiz-dot-label { font-size: 10.5px; color: var(--text-muted); white-space: nowrap; }
.wiz-connector { flex: 1; height: 1.5px; background: var(--border); margin: 0 6px 18px; }

.wiz-panel.hidden { display: none; }
.wiz-title { font-size: 19px; font-weight: 700; color: var(--ink); margin: 0 0 4px; }
.wiz-sub { font-size: 13px; color: var(--text-muted); margin: 0 0 22px; }

.mode-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.mode-card {
    background: var(--bg); border: 1.5px solid var(--border); border-radius: 12px;
    padding: 24px 20px; text-align: left; cursor: pointer;
    display: flex; flex-direction: column; gap: 10px;
}
.mode-card:hover { border-color: var(--primary); background: #F4F3FF; }
.mode-card-icon { width: 40px; height: 40px; border-radius: 10px; background: #EDEBFC; color: var(--primary); display: flex; align-items: center; justify-content: center; }
.mode-card-icon svg { width: 20px; height: 20px; }
.mode-card-title { font-size: 15px; font-weight: 700; color: var(--ink); }
.mode-card-sub { font-size: 12.5px; color: var(--text-muted); }

.wiz-nav { display: flex; justify-content: space-between; margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--border); }
.wiz-nav:has(> :only-child) { justify-content: flex-end; }

.custom-title-row { display: flex; align-items: flex-end; gap: 10px; margin: 18px 0; }
.custom-title-row label { flex: 1; margin-bottom: 0; }
.custom-title-row button { flex-shrink: 0; margin-bottom: 1px; }

#wiz-details form, #wiz-analyze form { max-width: 560px; }

@media (max-width: 640px) {
    .mode-cards { grid-template-columns: 1fr; }
    .wizard-shell { padding: 20px; }
    .wiz-dot-label { display: none; }
}

.stat-row {
    display: flex;
    gap: 16px;
    margin-bottom: 36px;
    flex-wrap: wrap;
}
.stat-card {
    background: var(--panel-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 18px;
    min-width: 160px;
    flex: 1;
}
.stat-value { font-size: 24px; font-weight: 600; color: var(--ink); }
.stat-label { font-size: 12.5px; color: var(--text-muted); margin-top: 4px; }

.stat-row-top { margin-bottom: 32px; }
.recent-section h2, .section-heading-row h2 { font-size: 20px; font-weight: 700; color: var(--ink); margin: 0; }
.dash-main .muted { color: var(--text-muted); font-size: 13.5px; max-width: 60ch; }

.empty-block {
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    padding: 32px;
    text-align: center;
    color: var(--text-muted);
}

.blog-table { width: 100%; border-collapse: collapse; background: var(--panel-bg); border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); }
.blog-table th { text-align: left; font-size: 12px; color: var(--text-muted); font-weight: 600; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.blog-table td { padding: 12px 14px; font-size: 13.5px; border-bottom: 1px solid var(--border); }
.blog-table tr:last-child td { border-bottom: none; }
.table-link { color: var(--text); text-decoration: none; font-weight: 500; }
.table-link:hover { color: var(--primary); text-decoration: underline; }

.app-shell-single { max-width: 900px; margin: 0 auto; }
.app-shell-single .output-panel { min-height: 0; }

.status-pill { padding: 3px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 600; text-decoration: none; }
.status-draft { background: #F1F0EB; color: var(--text-muted); }
.status-published { background: #E6F4EC; color: var(--success); }

.back-link { color: var(--text-muted); text-decoration: none; font-size: 13px; display: inline-block; margin-bottom: 4px; }

/* ============================================================
   ONBOARDING
   ============================================================ */
.onboarding-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--ink);
}
.onboarding-card {
    background: #fff;
    border-radius: 14px;
    padding: 36px;
    max-width: 460px;
    width: 90%;
}
.onboarding-card h1 { font-size: 24px; margin: 0 0 8px; }
.onboarding-sub { color: var(--text-muted); font-size: 13.5px; margin-bottom: 22px; }
.ob-status { font-size: 13px; color: var(--text-muted); margin-top: 10px; }
.ob-review h3 { font-size: 16px; }
.ob-review button { margin-top: 8px; width: 100%; }

.settings-form { display: flex; flex-direction: column; gap: 4px; max-width: 420px; }
.settings-form button { align-self: flex-start; margin-top: 8px; }

.badge {
    font-size: 11px;
    font-weight: 500;
    color: var(--success);
    text-transform: none;
    margin-left: 6px;
}

.publish-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.topbar {
    background: var(--panel-bg);
    border-bottom: 1px solid var(--border);
    padding: 16px 24px;
}
.topbar-inner h1 { margin: 0; font-size: 20px; font-weight: 600; }
.topbar .tagline { font-size: 13px; color: var(--text-muted); }
.tabs-single { background: transparent; padding: 0; }
.tabs-single .tab-btn { background: var(--bg); box-shadow: none; }
.topbar-brand-row { display: flex; align-items: center; gap: 10px; }
.topbar-logo { height: 32px; width: auto; object-fit: contain; }

#btn-more-topics {
    background: var(--primary);
    color: #fff;
    border: none;
}
#btn-more-topics:hover { background: var(--primary-dark); }
#btn-more-topics:disabled { background: var(--border); color: var(--text-muted); cursor: not-allowed; }

.seed-keywords-label { font-size: 12.5px; font-weight: 500; margin-bottom: 14px; display: block; }
.seed-keywords-label textarea { margin-top: 6px; max-width: 420px; width: 100%; resize: vertical; font-family: inherit; }

.app-shell {
    display: flex;
    gap: 20px;
    padding: 20px;
    align-items: flex-start;
}

.config-panel {
    width: 460px;
    flex-shrink: 0;
    background: var(--panel-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    position: sticky;
    top: 20px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
}

.output-panel {
    flex: 1;
    min-width: 0;
    background: var(--panel-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    min-height: 500px;
}

.tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
    background: var(--bg);
    border-radius: 8px;
    padding: 4px;
}
.tab-btn {
    flex: 1;
    padding: 8px 10px;
    border: none;
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
    color: var(--text-muted);
}
.tab-btn.active { background: var(--panel-bg); color: var(--primary); box-shadow: 0 1px 3px rgba(0,0,0,0.08); }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text);
}
.opt { font-weight: 400; color: var(--text-muted); font-size: 12px; }

input[type=text], input[type=number], select, textarea {
    width: 100%;
    margin-top: 6px;
    padding: 9px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 13px;
    font-family: inherit;
    background: #fff;
}
textarea { resize: vertical; }

.field-row {
    display: flex;
    gap: 10px;
}
.field-row > label { flex: 1; }

.btn-primary, .btn-secondary, .btn-tertiary {
    cursor: pointer;
    border-radius: 8px;
    font-weight: 600;
    font-size: 13px;
    border: none;
    padding: 10px 16px;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}
.btn-primary {
    width: 100%;
    background: var(--primary);
    color: #fff;
    margin-top: 6px;
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary {
    width: 100%;
    background: var(--text);
    color: #fff;
}
.btn-tertiary {
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
}
.btn-tertiary:hover { background: #eef0f4; }
button:disabled { opacity: 0.6; cursor: not-allowed; }

.analysis-card {
    background: #f4f5ff;
    border: 1px solid #dcdcff;
    border-radius: 8px;
    padding: 12px;
    font-size: 12.5px;
    margin: 14px 0;
    line-height: 1.6;
}
.analysis-card h4 { margin: 0 0 6px; font-size: 13px; }
.analysis-card .tag {
    display: inline-block;
    background: #fff;
    border: 1px solid #dcdcff;
    border-radius: 999px;
    padding: 2px 8px;
    margin: 2px 3px 0 0;
    font-size: 11px;
}

.section-heading-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 14px 0 8px;
}
.section-heading-row h3 { margin: 0; font-size: 14px; }

.topic-card {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 12px;
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}
.topic-card .topic-meta { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.topic-card button {
    flex-shrink: 0;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 12px;
    cursor: pointer;
}

.hidden { display: none !important; }

.empty-state, .loading-state, .error-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 400px;
    color: var(--text-muted);
    text-align: center;
}
.error-state { color: var(--error); }

.spinner {
    width: 32px; height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.output-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.output-block { margin-bottom: 28px; }
.output-block h3 { font-size: 15px; margin-bottom: 10px; border-left: 3px solid var(--primary); padding-left: 8px; }

.blog-render { line-height: 1.75; font-size: 16px; max-width: 72ch; color: #2A2F3A; }
.blog-render h1 { font-family: var(--font-display); font-size: 28px; margin-bottom: 14px; font-weight: 600; line-height: 1.25; }
.blog-render h2 { font-family: var(--font-display); font-size: 21px; margin-top: 30px; margin-bottom: 10px; font-weight: 600; }
.blog-render h3 { font-size: 16.5px; margin-top: 20px; margin-bottom: 8px; font-weight: 700; }
.blog-render p { margin: 12px 0; color: #333; }
.blog-render ul, .blog-render ol { padding-left: 22px; margin: 12px 0; }
.blog-render li { margin-bottom: 6px; }
.blog-render strong { color: var(--ink); }
.blog-render blockquote {
    border-left: 3px solid var(--primary);
    margin: 14px 0;
    padding: 6px 14px;
    background: #f7f7ff;
    color: #444;
}

.seo-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    font-size: 13.5px;
}
.seo-grid .full-width { grid-column: 1 / -1; }
.seo-grid strong { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-muted); margin-bottom: 4px; }
.char-count { font-size: 11px; color: var(--text-muted); }

.keyword-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.keyword-tags span {
    background: #eef0ff;
    color: var(--primary-dark);
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 12px;
}

.image-prompt-box {
    background: #f4f5f7;
    border-radius: 8px;
    padding: 10px 12px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 12.5px;
    white-space: pre-wrap;
}

@media (max-width: 900px) {
    .app-shell { flex-direction: column; }
    .config-panel { width: 100%; position: static; max-height: none; }
    .seo-grid { grid-template-columns: 1fr; }
}