/* ═══════════════════════════════════════════════════════════
   ParetoThesis — Professional Academic UI
   Dark-first design, mobile-responsive, KISS compliant
   ═══════════════════════════════════════════════════════════ */

:root {
    /* Dark Mode (Default) */
    --bg-color: #0a0e1a;
    --bg-secondary: #0f172a;
    --card-bg: #111827;
    --card-bg-hover: #1a2332;
    --surface: #1e293b;
    --border-color: #1e293b;
    --border-hover: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-tertiary: #64748b;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --accent-glow: rgba(59, 130, 246, 0.15);
    --success: #10b981;
    --success-hover: #059669;
    --danger: #ef4444;
    --warning: #f59e0b;
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
    --shadow-accent: 0 4px 24px rgba(59, 130, 246, 0.15);
    --transition: 0.2s ease;
    --font-body: 'Inter', system-ui, -apple-system, sans-serif;
    --font-heading: 'Outfit', 'Inter', system-ui, sans-serif;
}

[data-theme="light"] {
    --bg-color: #f8fafc;
    --bg-secondary: #f1f5f9;
    --card-bg: #ffffff;
    --card-bg-hover: #f8fafc;
    --surface: #f1f5f9;
    --border-color: #e2e8f0;
    --border-hover: #cbd5e1;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-tertiary: #94a3b8;
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --accent-glow: rgba(37, 99, 235, 0.1);
    --success: #059669;
    --success-hover: #047857;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
    --shadow-accent: 0 4px 24px rgba(37, 99, 235, 0.1);
}

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

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: var(--font-body);
    line-height: 1.6;
    padding: 1rem;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.hidden { display: none !important; }

/* ── Layout ───────────────────────────────────────────────── */
.app-container {
    width: 100%;
    max-width: 1080px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    padding-bottom: 3rem;
}

/* ── Header ───────────────────────────────────────────────── */
.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 0 1.25rem;
    border-bottom: 1px solid var(--border-color);
}

.logo-area { display: flex; align-items: center; }
.logo-link { display: flex; align-items: center; text-decoration: none; }
.logo-inline { height: 48px; width: auto; display: block; overflow: visible; }
[data-theme="light"] .logo-inline text { }
[data-theme="light"] .logo-inline tspan[fill="#f1f5f9"] { fill: #0f172a; }

.header-actions { display: flex; gap: 0.5rem; }
.icon-btn {
    width: 38px; height: 38px;
    display: flex; align-items: center; justify-content: center;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
}
.icon-btn:hover { background: var(--card-bg-hover); color: var(--text-primary); border-color: var(--border-hover); }

/* ── Progress System ──────────────────────────────────────── */
.progress-container { margin: 0.5rem 0; }
.step-progress {
    display: flex; justify-content: space-between;
    position: relative; padding: 0 1rem;
    isolation: isolate; /* create stacking context so z-index works */
}
/* The grey track line — sits BELOW circles */
.step-progress::before {
    content: ""; position: absolute;
    top: 18px; left: 2.5rem; right: 2.5rem;
    height: 2px; background: var(--border-color);
    z-index: 1;
}
/* The coloured fill line — sits BELOW circles too */
.progress-bar-fill {
    position: absolute; top: 18px; left: 2.5rem;
    height: 2px; background: var(--accent);
    z-index: 2;
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 0 8px var(--accent-glow);
    pointer-events: none;
}
/* Each step column sits ABOVE the line */
.step { position: relative; z-index: 3; text-align: center; flex: 1; }
/* The numbered circle — solid background always covers the line */
.step span {
    width: 36px; height: 36px;
    background: var(--bg-color); /* opaque — hides the line behind it */
    border: 2px solid var(--border-color);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 0.4rem;
    font-weight: 600; font-size: 0.8rem; color: var(--text-tertiary);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative; z-index: 4; /* highest — always on top */
}
.step.active span {
    border-color: var(--accent); color: var(--accent);
    background: var(--bg-color); /* keep opaque even when active */
    box-shadow: 0 0 0 4px var(--accent-glow);
    transform: scale(1.1);
}
.step.completed span {
    border-color: var(--success); color: var(--success);
    background: var(--bg-color); /* keep opaque */
}
.step label {
    font-size: 0.7rem; font-weight: 600;
    color: var(--text-tertiary); text-transform: uppercase;
    letter-spacing: 0.06em;
}
.step.active label { color: var(--text-primary); }

/* ── Cards ────────────────────────────────────────────────── */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 2rem;
    box-shadow: var(--shadow-sm);
    transition: border-color var(--transition);
}
.card:hover { border-color: var(--border-hover); }

.wizard-stage { display: none; }
.wizard-stage.active { display: block; animation: fadeSlideIn 0.4s ease; }

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

/* ── Form Elements ────────────────────────────────────────── */
.form-group { margin-bottom: 1.25rem; }
label {
    display: block; font-size: 0.8rem; font-weight: 600;
    color: var(--text-secondary); margin-bottom: 0.4rem;
    text-transform: uppercase; letter-spacing: 0.04em;
}

input[type="text"], input[type="email"], input[type="password"], select, textarea {
    width: 100%; padding: 0.75rem 1rem;
    background: var(--surface);
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.95rem; color: var(--text-primary);
    font-family: var(--font-body);
    transition: all var(--transition);
}

input:focus, select:focus, textarea:focus {
    border-color: var(--accent); outline: none;
    box-shadow: 0 0 0 3px var(--accent-glow);
}

textarea { resize: vertical; min-height: 100px; line-height: 1.6; }
select { cursor: pointer; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 0.75rem center; padding-right: 2.5rem; }

/* ── Buttons ──────────────────────────────────────────────── */
.btn-primary {
    background: var(--accent); color: #fff; border: none;
    padding: 0.75rem 1.5rem; border-radius: var(--radius-sm);
    font-weight: 600; cursor: pointer; width: 100%;
    transition: all var(--transition);
    font-family: var(--font-heading); letter-spacing: 0.02em;
    font-size: 0.9rem;
}
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); box-shadow: var(--shadow-accent); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-locked { background: var(--surface) !important; color: var(--text-tertiary) !important; cursor: not-allowed !important; transform: none !important; box-shadow: none !important; border: 1px solid var(--border-color); }

.btn-confirm {
    background: var(--success); color: #fff; border: none;
    padding: 0.75rem 1.5rem; border-radius: var(--radius-sm);
    font-weight: 600; cursor: pointer;
    transition: all var(--transition);
    font-family: var(--font-heading); letter-spacing: 0.02em;
    font-size: 0.9rem;
}
.btn-confirm:hover { background: var(--success-hover); transform: translateY(-1px); }
.btn-confirm:disabled { background: var(--text-tertiary); opacity: 0.4; cursor: not-allowed; transform: none; }

.btn-outline {
    background: transparent; color: var(--accent);
    border: 1.5px solid var(--accent); padding: 0.75rem 1.5rem;
    border-radius: var(--radius-sm); font-weight: 600; cursor: pointer;
    transition: all var(--transition);
    font-family: var(--font-heading); font-size: 0.9rem; width: 100%;
}
.btn-outline:hover { background: var(--accent-glow); }

.btn-ghost {
    background: transparent; border: none;
    color: var(--text-secondary); cursor: pointer;
    font-size: 0.85rem; font-weight: 500;
    padding: 0.5rem 1rem; border-radius: var(--radius-sm);
    transition: color var(--transition);
}
.btn-ghost:hover { color: var(--text-primary); }

.btn-lg { padding: 0.9rem 2rem; font-size: 0.95rem; }

/* ── Paywall Gate ─────────────────────────────────────────── */
.paywall-gate { text-align: center; padding: 3rem 1rem; }
.gate-icon { margin-bottom: 1.5rem; }
.gate-content h3 { font-family: var(--font-heading); font-size: 1.3rem; margin-bottom: 0.5rem; }
.gate-subtitle { color: var(--text-secondary); font-size: 0.9rem; margin-bottom: 1.5rem; }
.gate-form { display: flex; gap: 0.75rem; max-width: 400px; margin: 0 auto; }
.gate-form input { flex: 1; }
.gate-form .btn-primary { width: auto; padding: 0.75rem 1.5rem; }

/* ── File Drop Zone ───────────────────────────────────────── */
.file-drop-zone {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius);
    padding: 2rem; text-align: center;
    cursor: pointer; transition: all var(--transition);
    position: relative;
}
.file-drop-zone:hover, .file-drop-zone.dragover {
    border-color: var(--accent); background: var(--accent-glow);
}
.file-drop-zone input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.file-drop-zone p { color: var(--text-secondary); margin: 0.5rem 0 0.25rem; font-size: 0.9rem; }
.file-drop-zone .file-types { font-size: 0.75rem; color: var(--text-tertiary); }
.file-name { font-size: 0.85rem; color: var(--accent); padding: 0.5rem 0; font-weight: 500; }

/* ── Model Selector ───────────────────────────────────────── */
.dual-model-grid {
    display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem;
    margin-top: 1.5rem; border-top: 1px solid var(--border-color); padding-top: 1.5rem;
}
@media (max-width: 600px) {
    .dual-model-grid { grid-template-columns: 1fr; gap: 1rem; }
    .figure-count-pills { gap: .3rem; }
    .pill-btn { font-size: .75rem; padding: .28rem .7rem; }
}
.model-search-input {
    font-size: 0.8rem !important; padding: 0.5rem 0.75rem !important;
    margin-bottom: 0.5rem !important; border-style: dashed !important;
}
.select-full { font-size: 0.85rem !important; }

/* ── Figure count pill picker ─────────────────────────────── */
.label-hint { color: var(--text-tertiary); font-weight: 400; font-size: .78rem; margin-left: .3rem; }
.figure-count-row { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; margin-top: .3rem; }
.figure-count-label { font-size: .8rem; color: var(--text-secondary); white-space: nowrap; }
.figure-count-pills { display: flex; gap: .4rem; flex-wrap: wrap; }
.pill-btn {
    background: var(--surface); border: 1.5px solid var(--border-color);
    color: var(--text-secondary); border-radius: 20px;
    padding: .3rem .85rem; font-size: .8rem; font-weight: 600;
    cursor: pointer; transition: all var(--transition); white-space: nowrap;
    font-family: var(--font-body);
}
.pill-btn:hover { border-color: var(--accent); color: var(--accent); }
.pill-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ── Tags ─────────────────────────────────────────────────── */
.tags-container { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1.25rem; }
.tag {
    background: var(--accent-glow); color: var(--accent);
    padding: 0.3rem 0.75rem; border-radius: 20px;
    font-size: 0.75rem; font-weight: 600;
    border: 1px solid rgba(59, 130, 246, 0.2);
    letter-spacing: 0.02em;
}

/* ── DOI Add Row ──────────────────────────────────────────── */
.doi-add-row {
    display: flex; gap: 0.5rem; margin-bottom: 1.25rem;
    align-items: center;
}
.doi-add-row input { flex: 1; }

/* ── Badges ───────────────────────────────────────────────── */
.badge {
    display: inline-flex; align-items: center;
    background: var(--surface); color: var(--text-secondary);
    padding: 0.3rem 0.75rem; border-radius: 20px;
    font-size: 0.75rem; font-weight: 600;
    border: 1px solid var(--border-color);
}
.badge-sm { font-size: 0.7rem; padding: 0.2rem 0.5rem; }
.badge-muted { opacity: 0.6; }

.score-badge {
    display: inline-flex; align-items: center; gap: 0.3rem;
    font-size: 0.7rem; font-weight: 700; padding: 0.15rem 0.5rem;
    border-radius: 12px;
}
.score-high { background: rgba(16, 185, 129, 0.15); color: var(--success); }
.score-mid { background: rgba(245, 158, 11, 0.15); color: var(--warning); }
.score-low { background: rgba(239, 68, 68, 0.1); color: var(--danger); }

/* ── Section Header ───────────────────────────────────────── */
.section-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 1.5rem; flex-wrap: wrap; gap: 0.5rem;
}
.section-header h2 { font-family: var(--font-heading); font-size: 1.25rem; }
.section-header h3 { font-family: var(--font-heading); font-size: 1rem; }
.header-badges { display: flex; gap: 0.5rem; }

/* ── Format Row ───────────────────────────────────────────── */
.format-row {
    display: flex; align-items: center; gap: 1rem;
    margin-bottom: 1.25rem; padding: 0.75rem 1rem;
    background: var(--surface); border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
}
.format-row label { margin-bottom: 0; white-space: nowrap; flex-shrink: 0; }
.format-row select { flex: 1; max-width: 200px; }

/* ── Reference Cards ──────────────────────────────────────── */
.selection-box { margin-bottom: 1.5rem; }
.selection-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 0.75rem 0; border-bottom: 1px solid var(--border-color);
    margin-bottom: 0.75rem;
}
.toggle-group { display: flex; align-items: center; gap: 0.5rem; }
.toggle-group label { margin-bottom: 0; text-transform: none; font-size: 0.85rem; }

.reference-scroll {
    max-height: 480px; overflow-y: auto;
    display: flex; flex-direction: column; gap: 0.5rem;
    padding-right: 0.25rem;
}
.reference-scroll::-webkit-scrollbar { width: 4px; }
.reference-scroll::-webkit-scrollbar-track { background: transparent; }
.reference-scroll::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 4px; }

.ref-card {
    display: flex; gap: 0.75rem; padding: 0.75rem;
    border: 1px solid var(--border-color); border-radius: var(--radius-sm);
    background: var(--surface); transition: all var(--transition);
    align-items: flex-start;
}
.ref-card:hover { border-color: var(--border-hover); background: var(--card-bg-hover); }
.ref-card-dim { opacity: 0.5; }
.ref-card-dim:hover { opacity: 0.8; }
.ref-card input[type="checkbox"] { margin-top: 0.3rem; flex-shrink: 0; accent-color: var(--accent); }
.ref-content { flex: 1; min-width: 0; }
.ref-title {
    font-weight: 600; font-size: 0.9rem; display: block;
    margin-bottom: 0.2rem; cursor: pointer; color: var(--text-primary);
    line-height: 1.4;
}
.ref-title:hover { color: var(--accent); }
.ref-meta {
    display: flex; flex-wrap: wrap; gap: 0.5rem;
    font-size: 0.75rem; color: var(--text-tertiary); margin-bottom: 0.35rem;
}
.ref-abstract {
    font-size: 0.8rem; color: var(--text-secondary); line-height: 1.5;
    font-style: italic;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.ref-notes {
    font-size: 0.75rem; color: var(--accent); margin-top: 0.3rem;
    padding: 0.3rem 0.5rem; background: var(--accent-glow); border-radius: 4px;
}

/* ── Synthesis ────────────────────────────────────────────── */
.grid-form { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1.5rem; }
.synthesis-results { margin-bottom: 1.5rem; }
.content-well {
    background: var(--surface); border: 1.5px solid var(--border-color);
    border-radius: var(--radius-sm); padding: 1rem;
    min-height: 60px; font-size: 0.9rem; line-height: 1.7;
    color: var(--text-primary);
}
.content-well.editable:focus {
    border-color: var(--accent); outline: none;
    box-shadow: 0 0 0 3px var(--accent-glow);
}

/* ── Journal Suggestions ──────────────────────────────────── */
.journal-box {
    margin-bottom: 1.5rem; padding: 1rem;
    background: var(--surface); border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
}
.journal-list { display: flex; flex-direction: column; gap: 0.5rem; margin-top: 0.75rem; }
.journal-item {
    display: flex; justify-content: space-between; align-items: center;
    padding: 0.5rem 0.75rem; background: var(--card-bg);
    border-radius: var(--radius-sm); border: 1px solid var(--border-color);
    font-size: 0.85rem;
}
.journal-item .journal-name { font-weight: 600; color: var(--text-primary); }
.journal-item .journal-reason { font-size: 0.75rem; color: var(--text-secondary); margin-top: 0.15rem; }
.journal-item .journal-impact { font-size: 0.7rem; color: var(--accent); font-weight: 600; white-space: nowrap; }

/* ── Actions Row ──────────────────────────────────────────── */
.actions-row { display: flex; gap: 0.75rem; align-items: center; }
.actions-row .btn-primary, .actions-row .btn-confirm { width: auto; flex: 1; }
.actions-row .btn-ghost { flex-shrink: 0; }

/* ── Draft Grid (Step 4) ─────────────────────────────────── */
.draft-grid { display: grid; grid-template-columns: 280px 1fr; gap: 1.25rem; }
.draft-sidebar { display: flex; flex-direction: column; gap: 1rem; position: sticky; top: 1rem; align-self: flex-start; }
.draft-sidebar h3 { font-family: var(--font-heading); font-size: 1.1rem; }

.draft-meta { display: flex; flex-direction: column; gap: 0.5rem; }
.mini-progress { font-size: 0.8rem; font-weight: 600; color: var(--text-secondary); }
.progress-bar-mini {
    height: 4px; background: var(--surface); border-radius: 2px; overflow: hidden;
}
.progress-bar-mini-fill {
    height: 100%; background: var(--accent); border-radius: 2px;
    transition: width 0.5s ease;
}

.section-nav { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.section-nav-item {
    padding: 0.35rem 0.6rem; font-size: 0.7rem; font-weight: 600;
    background: var(--surface); border: 1px solid var(--border-color);
    border-radius: var(--radius-sm); color: var(--text-tertiary);
    cursor: pointer; transition: all var(--transition);
    text-transform: uppercase; letter-spacing: 0.03em;
}
.section-nav-item:hover { color: var(--text-primary); border-color: var(--border-hover); }
.section-nav-item.active { background: var(--accent-glow); color: var(--accent); border-color: var(--accent); }
.section-nav-item.done { background: rgba(16, 185, 129, 0.1); color: var(--success); border-color: var(--success); }

.action-stack { display: flex; flex-direction: column; gap: 0.5rem; }

.draft-editor-container { padding: 0; overflow: hidden; display: flex; flex-direction: column; }
.editor-toolbar {
    display: flex; justify-content: space-between; align-items: center;
    padding: 0.6rem 1rem; border-bottom: 1px solid var(--border-color);
    background: var(--surface);
}
#live-editor {
    flex: 1; min-height: 500px; padding: 1.25rem;
    background: var(--card-bg); border: none; border-radius: 0;
    font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 0.85rem; line-height: 1.7; color: var(--text-primary);
    resize: none;
}
#live-editor:focus { box-shadow: none; }

/* ── Figure Preview ───────────────────────────────────────── */
.figure-preview { border-top: 1px solid var(--border-color); padding-top: 0.75rem; }
.figure-preview h4 { font-size: 0.8rem; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 0.5rem; }
#figure-gallery { display: flex; flex-direction: column; gap: 0.5rem; }
.figure-thumb {
    width: 100%; border-radius: var(--radius-sm);
    border: 1px solid var(--border-color); overflow: hidden;
}
.figure-thumb img { width: 100%; display: block; }
.figure-thumb .fig-caption { font-size: 0.7rem; padding: 0.3rem 0.5rem; color: var(--text-secondary); background: var(--surface); }

/* ── Success Card ─────────────────────────────────────────── */
.success-card { text-align: center; padding: 3rem 2rem; }
.success-icon { margin-bottom: 1.25rem; }
.success-card h3 { font-family: var(--font-heading); font-size: 1.3rem; margin-bottom: 0.5rem; }
.text-secondary { color: var(--text-secondary); font-size: 0.9rem; margin-bottom: 1.5rem; }
.delivery-row { display: flex; justify-content: center; gap: 1rem; flex-wrap: wrap; }
.delivery-row .btn-confirm { width: auto; }

/* ── Paywall Overlay ──────────────────────────────────────── */
#paywall-overlay {
    position: fixed; inset: 0; z-index: 15000;
    background: rgba(5,5,12,0.85); backdrop-filter: blur(8px);
    display: flex; align-items: center; justify-content: center;
}
.paywall-modal {
    background: var(--card-bg); border: 1px solid var(--border-hover);
    border-radius: var(--radius-lg); padding: 1.75rem 1.75rem 1.5rem;
    max-width: 400px; width: 92%; text-align: center;
    box-shadow: var(--shadow);
    max-height: 92vh; overflow-y: auto;
}
.paywall-modal-icon { margin-bottom: .75rem; }
.paywall-modal-icon svg { width: 36px; height: 36px; }
.paywall-modal h3 { font-family: var(--font-heading); font-size: 1.15rem; margin-bottom: .6rem; }
.paywall-modal p { color: var(--text-secondary); font-size: .9rem; margin-bottom: .4rem; }
.paywall-price { color: var(--text-primary) !important; font-size: 1rem !important; margin-top: .5rem !important; }
/* Price breakdown table inside checkout overlay */
.price-breakdown {
    background: var(--surface); border-radius: var(--radius-sm);
    padding: .6rem .85rem; margin: .5rem 0; text-align: left;
}
.pb-row { display: flex; justify-content: space-between; align-items: center;
    font-size: .82rem; color: var(--text-secondary); padding: .2rem 0; }
.pb-model { color: var(--text-tertiary); font-size: .75rem; padding-left: .5rem; }
.pb-total { border-top: 1px solid var(--border); margin-top: .35rem; padding-top: .45rem;
    font-weight: 600; color: var(--text-primary); font-size: .9rem; }

/* ── Toast Notifications ──────────────────────────────────── */
#toast-container {
    position: fixed; top: 1rem; right: 1rem;
    z-index: 20000; display: flex; flex-direction: column;
    gap: 0.5rem; pointer-events: none;
}
.toast {
    padding: 0.75rem 1.25rem; border-radius: var(--radius-sm);
    font-size: 0.85rem; font-weight: 500;
    box-shadow: var(--shadow);
    pointer-events: auto;
    animation: toastIn 0.3s ease, toastOut 0.3s ease 3.5s forwards;
    max-width: 400px;
}
.toast-success { background: var(--success); color: #fff; }
.toast-error { background: var(--danger); color: #fff; }
.toast-info { background: var(--accent); color: #fff; }

@keyframes toastIn { from { opacity: 0; transform: translateX(100%); } to { opacity: 1; transform: translateX(0); } }
@keyframes toastOut { from { opacity: 1; } to { opacity: 0; transform: translateY(-10px); } }

/* ── Loader ───────────────────────────────────────────────── */
.loader-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(5, 5, 12, 0.92); z-index: 10000;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    color: #fff; backdrop-filter: blur(8px);
}
.math-loader { width: 240px; height: 240px; margin-bottom: 1.5rem; overflow: visible; }
#loader-text {
    font-family: var(--font-heading); font-weight: 700;
    letter-spacing: 0.08em; text-transform: uppercase;
    font-size: 0.85rem; color: var(--text-secondary);
}

/* ── Footer ───────────────────────────────────────────────── */
.app-footer {
    text-align: center; padding: 1.5rem 0;
    border-top: 1px solid var(--border-color);
    color: var(--text-tertiary); font-size: 0.75rem;
}
.footer-nav {
    display: flex; justify-content: center; gap: 1.5rem;
    margin-bottom: 0.5rem;
}
.footer-nav a {
    color: var(--text-tertiary); text-decoration: none;
    font-size: 0.75rem; transition: color var(--transition);
}
.footer-nav a:hover { color: var(--accent); }



/* ── Checkbox Custom ──────────────────────────────────────── */
input[type="checkbox"] {
    width: 16px; height: 16px; cursor: pointer;
    accent-color: var(--accent);
}

/* ═══════════════════════════════════════════════════════════
   Responsive Design — Mobile First
   ═══════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
    body { padding: 0.75rem; }
    .card { padding: 1.25rem; }
    .dual-model-grid { grid-template-columns: 1fr; }
    .grid-form { grid-template-columns: 1fr; }
    .draft-grid { grid-template-columns: 1fr; }
    .draft-sidebar { position: static; }
    #live-editor { min-height: 350px; }
    .logo-text { font-size: 1.25rem; }
    .step label { font-size: 0.6rem; }
    .step span { width: 30px; height: 30px; font-size: 0.7rem; }
    .section-header { flex-direction: column; align-items: flex-start; }
    .actions-row { flex-direction: column; }
    .actions-row .btn-ghost { order: -1; align-self: flex-start; }
    .gate-form { flex-direction: column; }
    .gate-form .btn-primary { width: 100%; }
    .format-row { flex-direction: column; gap: 0.5rem; }
    .format-row select { max-width: 100%; }
    .delivery-row { flex-direction: column; align-items: center; }
}

@media (max-width: 400px) {
    .progress-container { padding: 0 0.25rem; }
    .step-progress { padding: 0 0.5rem; }
    .step label { display: none; }
}
