/* CSS Variables */
:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --error-color: #ef4444;
    --warning-color: #f59e0b;
    
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --text-color: #1e293b;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    
    --radius: 12px;
    --radius-sm: 8px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Container */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* Header */
.header {
    background: linear-gradient(135deg, var(--primary-color) 0%, #8b5cf6 100%);
    color: white;
    padding: 2rem 0;
    text-align: center;
}

.logo {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.tagline {
    opacity: 0.9;
    font-size: 1rem;
}

/* Main Content */
.main {
    flex: 1;
    padding: 2rem 0;
}

/* Cards */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

/* Form Styles */
.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-color);
}

.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.form-group textarea {
    resize: vertical;
    min-height: 200px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.875rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

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

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

.btn-secondary {
    background: var(--secondary-color);
    color: white;
}

.btn-secondary:hover {
    background: #475569;
}

/* Loading Spinner */
.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 0.8s linear infinite;
}

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

/* Loading Section */
.loading-section {
    text-align: center;
}

.loading-card {
    max-width: 400px;
    margin: 2rem auto;
    text-align: center;
}

.loading-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid var(--border-color);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    animation: spin 1s linear infinite;
    margin: 0 auto 1.5rem;
}

.loading-status {
    color: var(--text-muted);
    margin-top: 0.5rem;
}

.agent-indicators {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

.agent-dot {
    font-size: 1.5rem;
    animation: pulse 1.5s ease-in-out infinite;
}

.agent-dot:nth-child(2) { animation-delay: 0.1s; }
.agent-dot:nth-child(3) { animation-delay: 0.2s; }
.agent-dot:nth-child(4) { animation-delay: 0.3s; }
.agent-dot:nth-child(5) { animation-delay: 0.4s; }

@keyframes pulse {
    0%, 100% { opacity: 0.4; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.1); }
}

/* Results Section */
.results-section h2 {
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
}

/* Unified Summary */
.unified-summary {
    background: linear-gradient(135deg, #f0fdf4 0%, #ecfdf5 100%);
    border: 1px solid #86efac;
}

.unified-summary h3 {
    color: #166534;
    margin-bottom: 1rem;
}

.summary-content {
    line-height: 1.7;
}

.summary-content h1, .summary-content h2, .summary-content h3, 
.summary-content h4, .summary-content h5, .summary-content h6 {
    margin-top: 1.25rem;
    margin-bottom: 0.5rem;
}

.summary-content h1:first-child, .summary-content h2:first-child,
.summary-content h3:first-child {
    margin-top: 0;
}

.summary-content ul, .summary-content ol {
    margin-left: 1.5rem;
    margin-bottom: 1rem;
}

.summary-content li {
    margin-bottom: 0.25rem;
}

.summary-content strong {
    color: #166534;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 0.5rem;
}

.tab-btn {
    padding: 0.625rem 1.25rem;
    background: none;
    border: none;
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
}

.tab-btn:hover {
    background: var(--bg-color);
    color: var(--text-color);
}

.tab-btn.active {
    background: var(--primary-color);
    color: white;
}

/* Agent Cards Grid */
.agent-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 1rem;
}

.agent-card {
    background: var(--bg-color);
    border-radius: var(--radius-sm);
    padding: 1.25rem;
    border: 1px solid var(--border-color);
}

.agent-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.agent-icon {
    font-size: 1.5rem;
}

.agent-header h4 {
    margin: 0;
    font-size: 1rem;
    color: var(--text-color);
}

.agent-findings {
    font-size: 0.9375rem;
    line-height: 1.6;
    margin-bottom: 1rem;
}

.agent-findings p {
    margin-bottom: 0.75rem;
}

.agent-findings ul, .agent-findings ol {
    margin-left: 1.25rem;
    margin-bottom: 0.75rem;
}

.suggestions, .cross-refs {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px dashed var(--border-color);
}

.suggestions h5, .cross-refs h5 {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.suggestions ul, .cross-refs ul {
    margin-left: 1.25rem;
    font-size: 0.875rem;
}

.suggestions li, .cross-refs li {
    margin-bottom: 0.375rem;
}

/* Error Section */
.error-card {
    background: #fef2f2;
    border: 1px solid #fecaca;
    text-align: center;
    max-width: 500px;
    margin: 2rem auto;
}

.error-card h3 {
    color: var(--error-color);
    margin-bottom: 0.75rem;
}

.error-card p {
    color: #991b1b;
    margin-bottom: 1.25rem;
}

/* Actions */
.actions {
    text-align: center;
    margin-top: 1.5rem;
}

/* Footer */
.footer {
    background: #1e293b;
    color: #94a3b8;
    padding: 1.5rem 0;
    text-align: center;
    font-size: 0.875rem;
}

/* Utility Classes */
.hidden {
    display: none !important;
}

/* Responsive */
@media (max-width: 768px) {
    .logo {
        font-size: 1.5rem;
    }
    
    .container {
        padding: 0 1rem;
    }
    
    .card {
        padding: 1.25rem;
    }
    
    .agent-cards {
        grid-template-columns: 1fr;
    }
    
    .tabs {
        flex-wrap: wrap;
    }
}

/* Print Styles */
@media print {
    .header, .footer, .btn, .tabs {
        display: none;
    }
    
    .card {
        box-shadow: none;
        border: 1px solid #ccc;
    }
}

/* ── Editing View ─────────────────────────────────────── */

.editing-view {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 1.5rem;
    align-items: start;
}

/* Document pane */
.editing-document {
    font-family: 'Georgia', 'Times New Roman', serif;
    font-size: 1.0625rem;
    line-height: 1.85;
    color: var(--text-color);
    padding: 1.5rem;
    background: #fffef8;
    border: 1px solid #e5e2d6;
    border-radius: var(--radius-sm);
    min-height: 200px;
}

.editing-document p {
    margin-bottom: 1rem;
}

/* Inline corrections */
.correction {
    position: relative;
    cursor: default;
}

.correction-original {
    text-decoration: line-through;
    color: #dc2626;
    background: #fef2f2;
    padding: 0 2px;
    border-radius: 2px;
}

.correction-replacement {
    color: #dc2626;
    font-weight: 600;
    background: #fef2f2;
    padding: 0 2px;
    border-radius: 2px;
    margin-left: 2px;
}

.correction-agent {
    display: none;
    position: absolute;
    bottom: 100%;
    left: 0;
    background: #1e293b;
    color: #f1f5f9;
    font-size: 0.6875rem;
    font-family: -apple-system, BlinkMacSystemFont, sans-serif;
    padding: 2px 8px;
    border-radius: 4px;
    white-space: nowrap;
    z-index: 10;
}

.correction:hover .correction-agent {
    display: block;
}

/* Comment anchors in text */
.comment-anchor {
    background: #fef9c3;
    border-bottom: 2px solid #facc15;
    padding: 0 1px;
    transition: background 0.2s;
    cursor: pointer;
}

.comment-anchor.highlight {
    background: #fde68a;
}

.comment-marker {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    background: #facc15;
    color: #1e293b;
    font-size: 0.6875rem;
    font-weight: 700;
    font-family: -apple-system, BlinkMacSystemFont, sans-serif;
    border-radius: 50%;
    margin-left: 2px;
    vertical-align: super;
    cursor: pointer;
    line-height: 1;
}

.comment-marker:hover {
    background: #eab308;
}

/* Comment sidebar */
.editing-comments {
    position: sticky;
    top: 1rem;
    max-height: calc(100vh - 4rem);
    overflow-y: auto;
    padding-right: 0.5rem;
}

.editing-comments h4 {
    font-size: 0.9375rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.no-comments {
    color: var(--text-muted);
    font-size: 0.875rem;
    font-style: italic;
}

.comment-bubble {
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-left: 3px solid #facc15;
    border-radius: var(--radius-sm);
    padding: 0.75rem;
    margin-bottom: 0.75rem;
    font-size: 0.8125rem;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.comment-bubble:hover {
    border-color: #eab308;
    box-shadow: var(--shadow-sm);
}

.comment-bubble.highlight {
    border-color: #eab308;
    border-left-color: #ca8a04;
    background: #fef3c7;
    box-shadow: 0 0 0 2px rgba(234, 179, 8, 0.25);
}

.comment-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.375rem;
}

.comment-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    background: #facc15;
    color: #1e293b;
    font-size: 0.6875rem;
    font-weight: 700;
    border-radius: 50%;
    flex-shrink: 0;
}

.comment-agent {
    font-weight: 600;
    font-size: 0.75rem;
}

.comment-category {
    font-size: 0.6875rem;
    background: var(--border-color);
    color: var(--text-muted);
    padding: 1px 6px;
    border-radius: 4px;
    margin-left: auto;
}

.comment-anchor-text {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-style: italic;
    margin-bottom: 0.25rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.comment-body {
    color: var(--text-color);
    line-height: 1.5;
}

@media (max-width: 768px) {
    .editing-view {
        grid-template-columns: 1fr;
    }
    
    .editing-comments {
        position: static;
        max-height: none;
    }
}

/* ── Editorial atelier visual treatment ─────────────────────────────── */

:root {
    --ink: #24211e;
    --paper: #fbf8f1;
    --paper-deep: #f2eadc;
    --plum: #5c385d;
    --plum-dark: #412842;
    --clay: #c96d4c;
    --gold: #c89a3c;
    --line: #ded3c0;
    --mist: #746c65;
    --primary-color: var(--plum);
    --primary-hover: var(--plum-dark);
    --secondary-color: #6d5d58;
    --success-color: #426b55;
    --bg-color: var(--paper);
    --card-bg: rgba(255, 253, 248, 0.88);
    --text-color: var(--ink);
    --text-muted: var(--mist);
    --border-color: var(--line);
    --radius: 18px;
    --radius-sm: 10px;
    --shadow: 0 16px 40px rgb(64 45 32 / 0.08);
    --shadow-lg: 0 24px 56px rgb(64 45 32 / 0.13);
}

body {
    background:
        radial-gradient(circle at 10% 2%, rgb(201 109 76 / 0.12), transparent 25rem),
        radial-gradient(circle at 88% 20%, rgb(92 56 93 / 0.1), transparent 30rem),
        var(--paper);
    font-family: Georgia, "Times New Roman", serif;
}

.container {
    max-width: 1280px;
}

.header {
    position: relative;
    overflow: hidden;
    background: var(--ink);
    padding: 2.4rem 0 2.1rem;
    text-align: left;
}

.header::after {
    position: absolute;
    inset: 0;
    background-image: linear-gradient(110deg, transparent 46%, rgb(255 255 255 / 0.07) 46.2%, transparent 46.5%);
    content: "";
    pointer-events: none;
}

.header .container {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 2rem;
}

.brand-lockup {
    display: flex;
    align-items: center;
    gap: 0.9rem;
}

.brand-mark {
    display: grid;
    width: 2.75rem;
    height: 2.75rem;
    place-items: center;
    border: 1px solid rgb(255 255 255 / 0.35);
    border-radius: 50%;
    color: #f5d994;
    font-family: system-ui, sans-serif;
    font-size: 1.25rem;
}

.eyebrow {
    margin-bottom: 0.35rem;
    color: var(--clay);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 0.68rem;
    font-weight: 750;
    letter-spacing: 0.14em;
    line-height: 1.2;
    text-transform: uppercase;
}

.header .eyebrow {
    color: #f1bd8c;
}

.logo {
    margin: 0;
    font-size: clamp(1.8rem, 3vw, 2.45rem);
    font-weight: 500;
    letter-spacing: -0.035em;
}

.tagline {
    max-width: 20rem;
    margin: 0;
    color: rgb(255 255 255 / 0.73);
    font-size: 0.95rem;
    line-height: 1.45;
    text-align: right;
}

.main {
    padding: 3.5rem 0 4.5rem;
}

.card {
    border: 1px solid rgb(222 211 192 / 0.9);
    box-shadow: var(--shadow);
}

.input-section {
    max-width: 980px;
    margin: 0 auto 2rem;
    padding: clamp(1.5rem, 4vw, 3rem);
}

.section-heading,
.results-heading {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 1.5rem;
}

.section-heading h2,
.results-heading h2 {
    font-size: clamp(1.8rem, 4vw, 2.7rem);
    font-weight: 500;
    letter-spacing: -0.04em;
    line-height: 1;
}

.section-intro {
    max-width: 38rem;
    margin: 1rem 0 2.25rem;
    color: var(--text-muted);
    font-size: 1.06rem;
}

.review-team {
    display: flex;
    max-width: 25rem;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.4rem;
}

.review-team span,
.results-badge {
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #fffaf0;
    color: #66524a;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 0.7rem;
    font-weight: 650;
    padding: 0.36rem 0.66rem;
}

.form-group label {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 0.82rem;
    letter-spacing: 0.02em;
}

.form-group select,
.form-group textarea {
    border-width: 1px;
    background: #fffdf8;
    color: var(--ink);
    box-shadow: inset 0 1px 2px rgb(53 38 28 / 0.03);
}

.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--plum);
    box-shadow: 0 0 0 3px rgb(92 56 93 / 0.12);
}

.form-group textarea {
    min-height: 260px;
    font-family: Georgia, "Times New Roman", serif;
    font-size: 1.08rem;
    line-height: 1.7;
}

.btn {
    border-radius: 999px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 0.86rem;
    letter-spacing: 0.01em;
    padding: 0.9rem 1.35rem;
}

.btn-primary {
    background: var(--plum);
    box-shadow: 0 8px 18px rgb(92 56 93 / 0.2);
}

.btn-primary:hover:not(:disabled) {
    box-shadow: 0 11px 22px rgb(92 56 93 / 0.28);
}

.form-note {
    margin-top: 1rem;
    color: var(--text-muted);
    font-size: 0.82rem;
    font-style: italic;
}

.loading-card {
    border-top: 3px solid var(--gold);
    background: #fffdf8;
}

.loading-seal {
    display: grid;
    width: 86px;
    height: 86px;
    margin: 0 auto 1.4rem;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: var(--paper);
}

.loading-spinner {
    width: 52px;
    height: 52px;
    margin: 0;
    border-color: #e9dfd0;
    border-top-color: var(--clay);
}

.loading-card h3 {
    font-size: 1.55rem;
    font-weight: 500;
}

.agent-indicators {
    gap: 0.55rem;
}

.agent-dot {
    display: grid;
    width: 2.35rem;
    height: 2.35rem;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: #fffdf8;
    font-size: 1rem;
}

.results-heading {
    max-width: 1180px;
    margin: 0 auto 1.4rem;
}

.results-badge {
    flex-shrink: 0;
    border-color: #d9c597;
    background: #f8efdc;
    color: #76582a;
}

.unified-summary {
    border: 1px solid #d6c49a;
    border-left: 4px solid var(--gold);
    background: linear-gradient(125deg, #fffdf7, #faf2e4);
}

.unified-summary h3 {
    margin-bottom: 0.9rem;
    color: var(--ink);
    font-size: 1.5rem;
    font-weight: 500;
}

.summary-content strong {
    color: var(--plum);
}

.agent-results {
    padding: clamp(1rem, 3vw, 1.8rem);
}

.tabs {
    gap: 0.25rem;
    border-bottom-color: var(--line);
}

.tab-btn {
    border-bottom: 2px solid transparent;
    border-radius: 0;
    color: var(--mist);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 0.78rem;
    font-weight: 650;
    letter-spacing: 0.01em;
}

.tab-btn:hover {
    background: #f5eee3;
}

.tab-btn.active {
    border-bottom-color: var(--clay);
    background: transparent;
    color: var(--plum);
}

.agent-card {
    border-top: 3px solid var(--clay);
    background: #fffdf8;
}

.agent-header h4 {
    font-family: Georgia, "Times New Roman", serif;
    font-size: 1.15rem;
    font-weight: 500;
}

.editing-document {
    background: #fffdf8;
    box-shadow: 6px 7px 0 #eee4d4;
}

.editing-comments h4 {
    color: var(--plum);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 0.75rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.comment-bubble {
    border-left-color: var(--clay);
    background: #fff8eb;
}

.comment-number,
.comment-marker {
    background: #f0c96f;
}

.footer {
    background: var(--ink);
    color: #c8bdb1;
}

@media (max-width: 768px) {
    .header .container,
    .section-heading,
    .results-heading {
        align-items: flex-start;
        flex-direction: column;
    }

    .tagline {
        text-align: left;
    }

    .review-team {
        justify-content: flex-start;
    }

    .main {
        padding-top: 2rem;
    }
}

/* Mode banner: live backend versus pre-recorded sample review */

.mode-banner {
    max-width: 980px;
    margin: 0 auto 1.5rem;
    padding: 0.85rem 1.1rem;
    border: 1px solid var(--line);
    border-left: 4px solid var(--mist);
    border-radius: var(--radius-sm);
    background: #fffdf8;
    color: #5b524b;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 0.84rem;
    line-height: 1.55;
}

.mode-banner strong {
    color: var(--ink);
}

.mode-banner code {
    padding: 0.1rem 0.35rem;
    border-radius: 4px;
    background: var(--paper-deep);
    font-size: 0.8rem;
}

.mode-banner-sample {
    border-left-color: var(--gold);
    background: #fdf7e9;
}

.mode-banner-live {
    border-left-color: var(--success-color);
    background: #f2f7f3;
}
