/* ══════════════════════════════════════════════════
   ManuscriptsAI — Premium Academic Proofreading UI
   ══════════════════════════════════════════════════ */

:root {
    /* Colors */
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --primary-light: rgba(99, 102, 241, 0.12);
    --accent: #8b5cf6;
    --success: #22c55e;
    --success-light: rgba(34, 197, 94, 0.12);
    --warning: #eab308;
    --warning-light: rgba(234, 179, 8, 0.12);
    --danger: #ef4444;
    --danger-light: rgba(239, 68, 68, 0.12);
    --info: #3b82f6;
    --info-light: rgba(59, 130, 246, 0.12);

    /* Surfaces */
    --bg: #0a0a0f;
    --bg-secondary: #111118;
    --bg-tertiary: #1a1a24;
    --surface: #16161f;
    --surface-hover: #1e1e2a;
    --surface-border: rgba(255, 255, 255, 0.06);
    --surface-border-hover: rgba(255, 255, 255, 0.12);

    /* Text */
    --text: #f0f0f5;
    --text-secondary: #9ca3af;
    --text-tertiary: #6b7280;
    --text-inverse: #0a0a0f;

    /* Misc */
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 48px rgba(0, 0, 0, 0.4);
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-serif: 'Source Serif 4', Georgia, serif;
    --font-mono: 'JetBrains Mono', monospace;
    --gauge-bg: rgba(255, 255, 255, 0.08);
    --max-width: 1200px;
}

[data-theme="light"] {
    --bg: #f8f9fc;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f1f3f9;
    --surface: #ffffff;
    --surface-hover: #f4f6fb;
    --surface-border: rgba(0, 0, 0, 0.08);
    --surface-border-hover: rgba(0, 0, 0, 0.15);
    --text: #111827;
    --text-secondary: #4b5563;
    --text-tertiary: #9ca3af;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 8px 48px rgba(0, 0, 0, 0.1);
    --gauge-bg: rgba(0, 0, 0, 0.08);
}

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

html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

/* ── Utilities ── */
.container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 24px;
}

.gradient-text {
    background: linear-gradient(135deg, var(--primary), var(--accent), #c084fc);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.optional-tag {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    font-weight: 400;
}

/* ══════════ BUTTONS ══════════ */
.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 28px;
    border: none;
    border-radius: var(--radius);
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #fff;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all var(--transition);
    font-family: var(--font);
    box-shadow: 0 2px 12px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.45);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-primary.btn-success {
    background: linear-gradient(135deg, #22c55e, #16a34a);
    box-shadow: 0 2px 12px rgba(34, 197, 94, 0.3);
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 22px;
    border: 1px solid var(--surface-border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    font-weight: 500;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all var(--transition);
    font-family: var(--font);
}

.btn-secondary:hover {
    border-color: var(--surface-border-hover);
    background: var(--surface-hover);
}

.btn-ghost {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 28px;
    border: 1px solid var(--surface-border);
    border-radius: var(--radius);
    background: transparent;
    color: var(--text);
    font-weight: 500;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all var(--transition);
    font-family: var(--font);
}

.btn-ghost:hover {
    background: var(--surface);
    border-color: var(--surface-border-hover);
}

.btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
}

.btn-icon:hover {
    color: var(--text);
    background: var(--surface);
}

.btn-lg {
    padding: 14px 32px;
    font-size: 1rem;
}

/* ══════════ NAVBAR ══════════ */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background: rgba(10, 10, 15, 0.8);
    backdrop-filter: blur(20px) saturate(1.6);
    border-bottom: 1px solid var(--surface-border);
    transition: all var(--transition);
}

[data-theme="light"] .navbar {
    background: rgba(248, 249, 252, 0.85);
}

.navbar-inner {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.brand-icon {
    display: flex;
}

.brand-text {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.brand-accent {
    color: var(--primary);
}

.navbar-progress {
    display: flex;
    align-items: center;
    gap: 4px;
}

.progress-step {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
    opacity: 0.4;
}

.progress-step.active {
    opacity: 1;
}

.progress-step.completed {
    opacity: 0.7;
}

.progress-step.completed .step-indicator {
    background: var(--success);
    color: #fff;
}

.step-indicator {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
    background: var(--surface);
    border: 1.5px solid var(--surface-border);
    transition: all var(--transition);
}

.progress-step.active .step-indicator {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.step-label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.progress-step.active .step-label {
    color: var(--text);
}

.progress-connector {
    width: 24px;
    height: 2px;
    background: var(--surface-border);
    border-radius: 1px;
}

.navbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

@media (max-width: 768px) {
    .navbar-progress {
        display: none;
    }

    .btn-secondary span,
    .step-label {
        display: none;
    }
}

/* ══════════ HERO ══════════ */
.hero {
    position: relative;
    min-height: 100vh;
    display: flex;
    align-items: center;
    padding: 100px 24px 60px;
    overflow: hidden;
}

.hero-bg-effects {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.hero-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(100px);
    opacity: 0.15;
    animation: orbFloat 20s ease-in-out infinite;
}

.hero-orb-1 {
    width: 600px;
    height: 600px;
    background: var(--primary);
    top: -200px;
    right: -100px;
}

.hero-orb-2 {
    width: 400px;
    height: 400px;
    background: var(--accent);
    bottom: -100px;
    left: -100px;
    animation-delay: -7s;
}

.hero-orb-3 {
    width: 300px;
    height: 300px;
    background: #c084fc;
    top: 50%;
    left: 50%;
    animation-delay: -14s;
}

.hero-grid {
    position: absolute;
    inset: 0;
    background-image: linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
    background-size: 60px 60px;
}

[data-theme="light"] .hero-grid {
    background-image: linear-gradient(rgba(0, 0, 0, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 0, 0, 0.03) 1px, transparent 1px);
}

@keyframes orbFloat {

    0%,
    100% {
        transform: translate(0, 0) scale(1);
    }

    33% {
        transform: translate(30px, -30px) scale(1.05);
    }

    66% {
        transform: translate(-20px, 20px) scale(0.95);
    }
}

.hero-content {
    position: relative;
    z-index: 1;
    max-width: 580px;
    flex-shrink: 0;
}

.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 100px;
    background: var(--primary-light);
    color: var(--primary);
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 24px;
    border: 1px solid rgba(99, 102, 241, 0.2);
}

.hero-title {
    font-size: clamp(2.2rem, 5vw, 3.2rem);
    font-weight: 800;
    line-height: 1.15;
    letter-spacing: -0.03em;
    margin-bottom: 20px;
}

.hero-subtitle {
    font-size: 1.1rem;
    color: var(--text-secondary);
    line-height: 1.7;
    margin-bottom: 32px;
}

.hero-cta {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 48px;
}

.hero-stats {
    display: flex;
    align-items: center;
    gap: 24px;
}

.stat-item {
    text-align: center;
}

.stat-number {
    display: block;
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text);
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-divider {
    width: 1px;
    height: 36px;
    background: var(--surface-border);
}

.hero-visual {
    position: relative;
    z-index: 1;
    flex: 1;
    min-width: 0;
    margin-left: 60px;
    display: flex;
    justify-content: center;
}

/* ── Manuscript Preview Card ── */
.manuscript-preview {
    width: 100%;
    max-width: 560px;
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    animation: previewFloat 6s ease-in-out infinite;
}

@keyframes previewFloat {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-8px);
    }
}

.preview-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--surface-border);
}

.preview-dots {
    display: flex;
    gap: 6px;
}

.preview-dots span {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.preview-dots span:nth-child(1) {
    background: #ef4444;
}

.preview-dots span:nth-child(2) {
    background: #eab308;
}

.preview-dots span:nth-child(3) {
    background: #22c55e;
}

.preview-title {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    font-family: var(--font-mono);
}

.preview-body {
    padding: 8px 0;
    font-family: var(--font-mono);
    font-size: 0.78rem;
    position: relative;
}

.preview-line {
    display: flex;
    padding: 3px 16px;
    transition: background 0.15s;
}

.preview-line.highlight-green {
    background: rgba(34, 197, 94, 0.06);
}

.preview-line.highlight-yellow {
    background: rgba(234, 179, 8, 0.06);
}

.preview-line.highlight-blue {
    background: rgba(59, 130, 246, 0.06);
}

.line-num {
    color: var(--text-tertiary);
    width: 28px;
    flex-shrink: 0;
    text-align: right;
    margin-right: 16px;
    user-select: none;
    font-size: 0.7rem;
}

.line-text {
    color: var(--text-secondary);
}

.edit-mark.add {
    color: var(--success);
    font-weight: 600;
}

.edit-mark.del {
    color: var(--danger);
    text-decoration: line-through;
    opacity: 0.6;
    margin-left: 2px;
}

.comment-badge {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 4px;
    background: var(--warning-light);
    color: var(--warning);
    font-size: 0.65rem;
    font-weight: 600;
    margin-left: 4px;
}

.preview-sidebar {
    border-top: 1px solid var(--surface-border);
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.sidebar-comment {
    padding: 10px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
}

.comment-type {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 4px;
}

.comment-type.type-clarity {
    color: var(--success);
}

.comment-type.type-conciseness {
    color: var(--info);
}

.sidebar-comment p {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-family: var(--font);
    line-height: 1.5;
}

@media (max-width: 900px) {
    .hero {
        flex-direction: column;
        text-align: center;
        padding-top: 120px;
    }

    .hero-content {
        max-width: 100%;
    }

    .hero-cta {
        justify-content: center;
    }

    .hero-stats {
        justify-content: center;
    }

    .hero-visual {
        margin-left: 0;
        margin-top: 48px;
    }
}

/* ══════════ FEATURES SECTION ══════════ */
.features-section {
    padding: 100px 24px;
    position: relative;
}

.section-title {
    font-size: 2rem;
    font-weight: 800;
    text-align: center;
    letter-spacing: -0.02em;
    margin-bottom: 12px;
}

.section-subtitle {
    text-align: center;
    color: var(--text-secondary);
    max-width: 560px;
    margin: 0 auto 48px;
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 20px;
    max-width: var(--max-width);
    margin: 0 auto;
}

.feature-card {
    padding: 28px;
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-lg);
    transition: all 0.3s;
}

.feature-card:hover {
    border-color: var(--primary);
    transform: translateY(-4px);
    box-shadow: 0 8px 32px rgba(99, 102, 241, 0.1);
}

.feature-icon {
    width: 52px;
    height: 52px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-light);
    color: var(--primary);
    margin-bottom: 16px;
}

.feature-card h3 {
    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.feature-card p {
    font-size: 0.88rem;
    color: var(--text-secondary);
    margin-bottom: 16px;
    line-height: 1.6;
}

.feature-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.feature-list li {
    font-size: 0.82rem;
    color: var(--text-tertiary);
    padding-left: 18px;
    position: relative;
}

.feature-list li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 7px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--primary);
}

/* ══════════ APP CONTAINER ══════════ */
.app-container {
    padding: 84px 24px 48px;
    max-width: var(--max-width);
    margin: 0 auto;
}

.phase-panel {
    display: none;
    animation: fadeIn 0.4s ease;
}

.phase-panel.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(12px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.phase-header {
    text-align: center;
    margin-bottom: 40px;
}

.phase-badge {
    display: inline-block;
    padding: 4px 14px;
    border-radius: 100px;
    background: var(--primary-light);
    color: var(--primary);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 12px;
}

.phase-header h2 {
    font-size: 1.8rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    margin-bottom: 8px;
}

.phase-header p {
    color: var(--text-secondary);
    max-width: 520px;
    margin: 0 auto;
}

/* ── Phase 1 Form ── */
.init-form {
    max-width: 800px;
    margin: 0 auto;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 24px;
}

@media (max-width: 600px) {
    .form-grid {
        grid-template-columns: 1fr;
    }
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group.full-width {
    grid-column: 1 / -1;
    margin-bottom: 8px;
}

.form-group label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
}

.form-group label svg {
    color: var(--text-tertiary);
}

.form-group select,
.form-group input,
.form-group textarea {
    padding: 11px 14px;
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font-size: 0.9rem;
    font-family: var(--font);
    transition: border-color var(--transition), box-shadow var(--transition);
    outline: none;
}

.form-group select:focus,
.form-group input:focus,
.form-group textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.form-group textarea {
    resize: vertical;
}

.form-group select {
    cursor: pointer;
}

.manuscript-upload-section {
    margin-top: 8px;
}

.manuscript-upload-section h3 {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1rem;
    margin-bottom: 16px;
}

.upload-area {
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.upload-zone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 36px 24px;
    border-bottom: none;
    cursor: pointer;
    transition: background var(--transition);
}

.upload-zone:hover {
    background: var(--surface-hover);
}

.upload-icon {
    color: var(--text-tertiary);
    margin-bottom: 12px;
}

.upload-text {
    font-weight: 600;
    margin-bottom: 4px;
}

.upload-subtext {
    font-size: 0.82rem;
    color: var(--text-tertiary);
    margin-bottom: 16px;
}

.upload-divider {
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 16px;
}

.upload-divider::before,
.upload-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--surface-border);
}

.upload-divider span {
    font-size: 0.78rem;
    color: var(--text-tertiary);
    white-space: nowrap;
}

.upload-area textarea {
    width: 100%;
    border: none;
    border-top: 1px solid var(--surface-border);
    padding: 16px 20px;
    background: transparent;
    color: var(--text);
    font-family: var(--font-mono);
    font-size: 0.85rem;
    resize: vertical;
    outline: none;
    min-height: 200px;
}

.word-count-bar {
    display: flex;
    gap: 20px;
    padding: 10px 20px;
    font-size: 0.75rem;
    color: var(--text-tertiary);
    background: var(--bg-tertiary);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    border: 1px solid var(--surface-border);
    border-top: none;
}

.form-actions {
    display: flex;
    justify-content: center;
    margin-top: 32px;
}

/* ══════════ LOADING ANIMATION ══════════ */
.analysis-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 60px 24px;
}

.loading-animation {
    position: relative;
    width: 80px;
    height: 80px;
    margin-bottom: 24px;
}

.loading-ring {
    position: absolute;
    inset: 0;
    border: 3px solid var(--surface-border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.loading-icon {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
}

.loading-text {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 24px;
}

.loading-steps {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 280px;
}

.loading-step {
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    color: var(--text-tertiary);
    background: var(--surface);
    border: 1px solid var(--surface-border);
    transition: all 0.3s;
    opacity: 0.4;
}

.loading-step.active {
    opacity: 1;
    color: var(--primary);
    border-color: var(--primary);
    background: var(--primary-light);
}

.loading-step.done {
    opacity: 0.7;
    color: var(--success);
    border-color: var(--success);
    background: var(--success-light);
}

/* ══════════ PHASE 2 RESULTS ══════════ */
.results-grid {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.score-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
}

.score-card {
    padding: 20px;
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius);
    text-align: center;
    transition: all 0.3s;
}

.score-card:hover {
    border-color: var(--surface-border-hover);
}

.score-card .score-icon {
    font-size: 1.5rem;
    margin-bottom: 8px;
}

.score-card .score-title {
    font-size: 0.78rem;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 4px;
}

.score-card .score-value {
    font-size: 1.4rem;
    font-weight: 800;
}

.score-card .score-bar {
    height: 4px;
    border-radius: 2px;
    background: var(--surface-border);
    margin-top: 10px;
    overflow: hidden;
}

.score-card .score-bar-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 1s ease;
}

.observations-panel,
.suggestions-panel {
    padding: 28px;
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-lg);
}

.observations-panel h3,
.suggestions-panel h3 {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1rem;
    margin-bottom: 16px;
    color: var(--text);
}

.observations-panel h3 svg,
.suggestions-panel h3 svg {
    color: var(--primary);
}

.observation-text {
    font-family: var(--font-serif);
    font-size: 0.95rem;
    color: var(--text-secondary);
    line-height: 1.8;
}

.observation-text p {
    margin-bottom: 12px;
}

.suggestion-item {
    display: flex;
    gap: 14px;
    padding: 16px;
    background: var(--bg-tertiary);
    border-radius: var(--radius);
    margin-bottom: 10px;
    border-left: 3px solid var(--primary);
}

.suggestion-num {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--primary-light);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
    flex-shrink: 0;
}

.suggestion-item h4 {
    font-size: 0.9rem;
    margin-bottom: 4px;
}

.suggestion-item p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* ══════════ PHASE 3 EDITOR ══════════ */
.editor-container {
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: var(--surface);
}

.editor-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--surface-border);
    flex-wrap: wrap;
    gap: 8px;
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: 4px;
}

.toolbar-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-tertiary);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    font-family: var(--font);
}

.toolbar-btn:hover {
    color: var(--text);
    background: var(--surface);
}

.toolbar-btn.active {
    color: var(--primary);
    background: var(--primary-light);
    border-color: rgba(99, 102, 241, 0.2);
}

.edit-stats {
    display: flex;
    gap: 8px;
}

.stat-badge {
    padding: 3px 10px;
    border-radius: 100px;
    font-size: 0.75rem;
    font-weight: 600;
    font-family: var(--font-mono);
}

.stat-badge.additions {
    background: var(--success-light);
    color: var(--success);
}

.stat-badge.deletions {
    background: var(--danger-light);
    color: var(--danger);
}

.stat-badge.comments {
    background: var(--info-light);
    color: var(--info);
}

.editor-split {
    display: grid;
    grid-template-columns: 1fr 320px;
    min-height: 500px;
}

@media (max-width: 800px) {
    .editor-split {
        grid-template-columns: 1fr;
    }

    .editor-sidebar {
        max-height: 300px;
    }
}

.editor-main {
    padding: 24px;
    font-family: var(--font-serif);
    font-size: 0.95rem;
    line-height: 1.9;
    overflow-y: auto;
    max-height: 70vh;
}

.editor-main .section-heading {
    font-family: var(--font);
    font-weight: 700;
    font-size: 1.1rem;
    margin: 24px 0 12px;
    color: var(--text);
}

.editor-main .section-heading:first-child {
    margin-top: 0;
}

.editor-main .edit-addition,
.editor-main .edit-deletion {
    padding: 1px 2px;
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.editor-main .edit-addition {
    background: rgba(34, 197, 94, 0.12);
    color: var(--success);
}

.editor-main .edit-addition:hover {
    background: rgba(34, 197, 94, 0.25);
    box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.2);
}

.editor-main .edit-deletion {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    text-decoration: line-through;
}

.editor-main .edit-deletion:hover {
    background: rgba(239, 68, 68, 0.2);
    box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.2);
}

/* Edit Tooltip */
.edit-tooltip {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translate(-50%, -10px);
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    padding: 12px;
    z-index: 100;
    width: 240px;
    pointer-events: all;
    animation: fadeIn 0.2s ease;
}

.edit-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -6px;
    border: 6px solid transparent;
    border-top-color: var(--surface-border);
}

.tooltip-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.tooltip-category {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 2px 6px;
    border-radius: 4px;
}

.tooltip-body {
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.4;
    margin-bottom: 10px;
}

.tooltip-actions {
    display: flex;
    gap: 8px;
}

.tooltip-btn {
    flex: 1;
    padding: 6px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid var(--surface-border);
    background: var(--bg-tertiary);
    transition: all 0.2s;
}

.tooltip-btn-accept {
    color: var(--success);
}

.tooltip-btn-accept:hover {
    background: var(--success-light);
    border-color: var(--success);
}

.tooltip-btn-reject {
    color: var(--danger);
}

.tooltip-btn-reject:hover {
    background: var(--danger-light);
    border-color: var(--danger);
}

.edit-accepted {
    background: transparent !important;
    text-decoration: none !important;
    color: var(--text-secondary) !important;
    border: none !important;
    box-shadow: none !important;
}

.edit-rejected {
    display: none !important;
}

.editor-main .edit-comment {
    display: inline-block;
    vertical-align: super;
    font-size: 0.6rem;
    font-family: var(--font);
    font-weight: 700;
    color: var(--info);
    cursor: pointer;
    margin-left: 2px;
}

.editor-main p {
    margin-bottom: 12px;
    color: var(--text-secondary);
}

.editor-sidebar {
    border-left: 1px solid var(--surface-border);
    padding: 16px;
    overflow-y: auto;
    max-height: 70vh;
    background: var(--bg-tertiary);
}

.editor-sidebar h4 {
    font-size: 0.85rem;
    margin-bottom: 12px;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.sidebar-notes {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.note-card {
    padding: 12px;
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--info);
}

.note-card .note-type {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 4px;
}

.note-card .note-type.clarity {
    color: var(--success);
}

.note-card .note-type.grammar {
    color: var(--danger);
}

.note-card .note-type.conciseness {
    color: var(--info);
}

.note-card .note-type.consistency {
    color: var(--warning);
}

.note-card .note-type.voice {
    color: var(--accent);
}

.note-card p {
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* ══════════ PHASE 4 POLISH ══════════ */
.polish-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 28px;
}

@media (max-width: 700px) {
    .polish-grid {
        grid-template-columns: 1fr;
    }
}

.polish-card {
    padding: 24px;
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-lg);
}

.polish-card.checklist-card {
    grid-column: 1 / -1;
}

.polish-card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}

.polish-card-header svg {
    color: var(--primary);
}

.polish-card-header h3 {
    font-size: 1rem;
}

.polish-card-body {
    font-size: 0.88rem;
    color: var(--text-secondary);
    line-height: 1.7;
}

.ref-example {
    padding: 12px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    margin-bottom: 10px;
    font-family: var(--font-mono);
    font-size: 0.78rem;
}

.ref-example .ref-before {
    color: var(--danger);
    text-decoration: line-through;
    display: block;
    margin-bottom: 4px;
}

.ref-example .ref-after {
    color: var(--success);
    display: block;
}

.abbr-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 8px;
}

.abbr-table th {
    text-align: left;
    font-size: 0.75rem;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 8px;
    border-bottom: 1px solid var(--surface-border);
}

.abbr-table td {
    padding: 8px;
    font-size: 0.85rem;
    border-bottom: 1px solid var(--surface-border);
}

.abbr-table td:first-child {
    font-weight: 600;
    font-family: var(--font-mono);
    color: var(--primary);
}

.checklist-items {
    list-style: none;
}

.checklist-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid var(--surface-border);
}

.checklist-item:last-child {
    border-bottom: none;
}

.checklist-checkbox {
    width: 20px;
    height: 20px;
    border: 2px solid var(--surface-border);
    border-radius: 4px;
    background: transparent;
    cursor: pointer;
    flex-shrink: 0;
    transition: all var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 2px;
}

.checklist-checkbox.checked {
    background: var(--success);
    border-color: var(--success);
}

.checklist-checkbox.checked::after {
    content: '✓';
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
}

.checklist-item p {
    font-size: 0.88rem;
}

.journal-audit {
    margin-top: 24px;
    padding: 20px;
    background: var(--bg-tertiary);
    border-radius: var(--radius);
    border: 1px solid var(--surface-border);
}

.journal-audit h4 {
    font-size: 0.85rem;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 16px;
}

.audit-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.audit-item {
    display: flex;
    gap: 12px;
    padding: 12px;
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-sm);
}

.audit-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-top: 4px;
    flex-shrink: 0;
}

.status-success .audit-status-dot {
    background: var(--success);
}

.status-warning .audit-status-dot {
    background: var(--warning);
}

.status-danger .audit-status-dot {
    background: var(--danger);
}

.status-info .audit-status-dot {
    background: var(--info);
}

.audit-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.audit-info strong {
    font-size: 0.8rem;
    color: var(--text);
}

.audit-info span {
    font-size: 0.72rem;
    color: var(--text-tertiary);
    line-height: 1.4;
}

/* ── Readiness Gauge ── */
.readiness-section {
    margin-bottom: 28px;
}

.readiness-card {
    padding: 32px;
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-lg);
    text-align: center;
}

.readiness-card h3 {
    font-size: 1.1rem;
    margin-bottom: 20px;
}

.readiness-gauge {
    position: relative;
}

.gauge-svg {
    width: 220px;
    height: 130px;
}

.gauge-value {
    font-size: 2.2rem;
    font-weight: 800;
    margin-top: -20px;
}

.gauge-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* ══════════ PHASE NAV ══════════ */
.phase-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--surface-border);
}

/* ══════════ FOOTER ══════════ */
.footer {
    padding: 48px 24px;
    border-top: 1px solid var(--surface-border);
    margin-top: 60px;
}

.footer-inner {
    max-width: var(--max-width);
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    text-align: center;
}

.footer-links {
    display: flex;
    gap: 24px;
}

.footer-links a {
    color: var(--text-tertiary);
    font-size: 0.85rem;
    text-decoration: none;
    transition: color var(--transition);
}

.footer-links a:hover {
    color: var(--text);
}

.footer-copy {
    font-size: 0.78rem;
    color: var(--text-tertiary);
}

/* ══════════ TOAST ══════════ */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    animation: toastIn 0.3s ease;
    min-width: 280px;
}

.toast.toast-success {
    border-left: 3px solid var(--success);
}

.toast.toast-error {
    border-left: 3px solid var(--danger);
}

.toast.toast-info {
    border-left: 3px solid var(--info);
}

.toast p {
    font-size: 0.85rem;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(20px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ══════════ MODAL ══════════ */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 300;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

.modal-content {
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-lg);
    padding: 32px;
    max-width: 540px;
    width: 90%;
    position: relative;
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: none;
    border: none;
    color: var(--text-tertiary);
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
}

.modal-content h3 {
    font-size: 1.2rem;
    margin-bottom: 8px;
}

.modal-content>p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 24px;
}

.export-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.export-option {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 18px;
    border: 1px solid var(--surface-border);
    border-radius: var(--radius);
    background: var(--bg-tertiary);
    color: var(--text);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    font-family: var(--font);
}

.export-option:hover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.export-option svg {
    color: var(--primary);
    flex-shrink: 0;
}

.export-option-pdf {
    border-color: rgba(239, 68, 68, 0.25);
    background: linear-gradient(135deg, var(--bg-tertiary), rgba(239, 68, 68, 0.04));
    position: relative;
}

.export-option-pdf:hover {
    border-color: #ef4444;
    background: rgba(239, 68, 68, 0.08);
}

.export-option-pdf svg {
    color: #ef4444;
}

.export-option-word {
    border-color: rgba(59, 130, 246, 0.25);
    background: linear-gradient(135deg, var(--bg-tertiary), rgba(59, 130, 246, 0.04));
}

.export-option-word:hover {
    border-color: #3b82f6;
    background: rgba(59, 130, 246, 0.08);
}

.export-option-word svg {
    color: #3b82f6;
}

.export-badge {
    margin-left: auto;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 3px 8px;
    border-radius: 100px;
    background: linear-gradient(135deg, #ef4444, #f97316);
    color: #fff;
}

.export-option.exporting {
    pointer-events: none;
    opacity: 0.7;
}

.export-option.exporting span:first-of-type::after {
    content: ' — Generating...';
    color: var(--text-tertiary);
    font-style: italic;
}

/* ══════════ SCROLLBAR ══════════ */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--surface-border);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-tertiary);
}