/* ─── Mode Select Screen ────────────────────────────────── */
#modeSelectScreen .app-container {
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.mode-select-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
}

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

.mode-select-title {
    font-size: 26px;
    font-weight: 700;
    color: var(--text);
    margin: 0 0 10px;
    letter-spacing: -0.01em;
}

.mode-select-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    margin: 0;
}

.mode-cards {
    display: flex;
    gap: 16px;
    max-width: 900px;
    width: 100%;
}

/* ─── Mode Card ─────────────────────────────────────────── */
.mode-card {
    flex: 1;
    background: var(--card);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-xl);
    padding: 24px;
    cursor: pointer;
    transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

.mode-card:hover {
    background: var(--surface-hover);
    transform: translateY(-4px) scale(1.012);
    box-shadow: 0 12px 32px rgba(0,0,0,0.35),
                inset 0 1px 0 rgba(255,255,255,0.05);
}

.mode-card--disabled {
    opacity: 0.45;
    cursor: default;
    pointer-events: none;
}

.mode-card[data-mode="analyze"]:hover { border-color: var(--yellow-border); }
.mode-card[data-mode="enrich"]:not(.mode-card--disabled):hover  { border-color: var(--green-border); }
.mode-card[data-mode="tailor"]:hover  { border-color: var(--accent-border); }

.mode-card-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
    transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
    transform: scale(1);
}

.mode-card:hover .mode-card-icon {
    transform: scale(1.1);
}

.mode-card:hover .mode-card-icon--yellow {
    box-shadow: 0 0 16px rgba(240, 194, 70, 0.4);
}

.mode-card:hover .mode-card-icon--green {
    box-shadow: 0 0 16px rgba(61, 214, 140, 0.4);
}

.mode-card:hover .mode-card-icon--accent {
    box-shadow: 0 0 16px rgba(108, 114, 203, 0.4);
}

.mode-card-icon--yellow {
    background: var(--yellow-bg);
    border: 1px solid var(--yellow-border);
    color: var(--yellow);
}

.mode-card-icon--green {
    background: var(--green-bg);
    border: 1px solid var(--green-border);
    color: var(--green);
}

.mode-card-icon--accent {
    background: var(--accent-bg);
    border: 1px solid var(--accent-border);
    color: var(--accent);
}

.mode-card-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 8px;
}

.mode-card-desc {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 20px;
}

.mode-card-steps {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.mode-card-step {
    display: flex;
    align-items: center;
    gap: 8px;
}

.mode-card-step span {
    font-size: 12px;
    color: var(--text-muted);
}

.mode-card-step-num {
    width: 18px;
    height: 18px;
    border-radius: 5px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    font-weight: 700;
}

.mode-card-step-num--yellow {
    background: var(--yellow-bg);
    border: 1px solid var(--yellow-border);
    color: var(--yellow);
}

.mode-card-step-num--green {
    background: var(--green-bg);
    border: 1px solid var(--green-border);
    color: var(--green);
}

.mode-card-step-num--accent {
    background: var(--accent-bg);
    border: 1px solid var(--accent-border);
    color: var(--accent);
}

.mode-card-cta {
    margin-top: 24px;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 500;
    opacity: 0.7;
    transition: opacity 0.15s ease, transform 0.15s ease;
}

.mode-card:hover .mode-card-cta { opacity: 1; }

.mode-card-cta--yellow { color: var(--yellow); }
.mode-card-cta--green  { color: var(--green); }
.mode-card-cta--accent { color: var(--accent); }

.mode-card:hover .mode-card-cta--yellow,
.mode-card:hover .mode-card-cta--green,
.mode-card:hover .mode-card-cta--accent {
    opacity: 1;
    transform: translateX(2px);
}

/* ─── Confirmation Modals ───────────────────────────────── */
.confirm-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
}

.confirm-card {
    background: var(--card);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    padding: 28px;
    width: 420px;
    box-shadow: 0 24px 48px rgba(0,0,0,0.5);
}

.confirm-card--sm {
    width: 380px;
}

.confirm-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.confirm-header h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    margin: 0;
}

.confirm-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.confirm-icon--red {
    background: var(--red-bg);
    border: 1px solid var(--red-border);
    color: var(--red);
}

.confirm-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    margin: 0 0 10px;
}

.confirm-text {
    font-size: 13.5px;
    color: var(--text-secondary);
    line-height: 1.6;
    margin: 0 0 20px;
}

.confirm-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.btn-confirm-cancel {
    padding: 9px 20px;
    border-radius: 8px;
    font-size: 13px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    font-family: var(--font);
    transition: all 0.15s ease;
}

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

.btn-confirm-danger {
    padding: 9px 20px;
    border-radius: 8px;
    font-size: 13px;
    border: 1px solid var(--red-border);
    background: var(--red-bg);
    color: var(--red);
    cursor: pointer;
    font-weight: 500;
    font-family: var(--font);
    transition: all 0.15s ease;
}

.btn-confirm-danger:hover {
    filter: brightness(1.1);
}

.btn-confirm-accent {
    padding: 9px 20px;
    border-radius: 8px;
    font-size: 13px;
    border: none;
    background: var(--accent);
    color: #fff;
    cursor: pointer;
    font-weight: 500;
    font-family: var(--font);
    transition: all 0.15s ease;
}

.btn-confirm-accent:hover {
    filter: brightness(1.1);
}

/* ─── Stub Mode Layouts (Analyze / Enrich) ──────────────── */
#analyzeMode .app-container,
#enrichMode .app-container {
    height: 100vh;
    display: flex;
    flex-direction: column;
}

#analyzeMode .chat-messages,
#enrichMode .chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px 0;
    display: flex;
    flex-direction: column;
    gap: 16px;
    align-items: center;
}

/* ─── File Confirmed Block (for stubs) ──────────────────── */
.file-confirmed {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: 10px;
    background: var(--green-bg);
    border: 1px solid var(--green-border);
}

.file-confirmed-check {
    color: var(--green);
    font-size: 14px;
}

.file-confirmed-name {
    font-size: 13px;
    color: var(--text);
}

/* ─── Stub Upload Section Label ─────────────────────────── */
.stub-upload-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 6px;
}

/* ─── Responsive: Mode Cards ────────────────────────────── */
@media (max-width: 768px) {
    .mode-cards {
        flex-direction: column;
    }

    .mode-select-content {
        padding: 24px 16px;
    }
}

/* ─── Analyze Input Bar (hidden by default, shown via .visible) ── */
#analyzeInputBar {
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    opacity: 0;
    overflow: hidden;
    pointer-events: none;
    border-top-color: transparent;
    transition: max-height 0.35s cubic-bezier(0.16, 1, 0.3, 1),
                padding 0.35s cubic-bezier(0.16, 1, 0.3, 1),
                opacity 0.35s cubic-bezier(0.16, 1, 0.3, 1),
                border-top-color 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

#analyzeInputBar.visible {
    max-height: 80px;
    padding-top: 12px;
    padding-bottom: 12px;
    opacity: 1;
    overflow: visible;
    pointer-events: auto;
    border-top-color: var(--border-subtle);
}

/* ─── Analyze Mode ─────────────────────────────────────── */

.analyze-panels {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.analyze-chat-panel {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: flex 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.analyze-chat-panel--wide {
    flex: 1;
}

.analyze-chat-panel--narrow {
    flex: 0 0 42%;
    border-right: 1px solid var(--border-subtle);
}

.analyze-preview-panel {
    display: flex;
    flex-direction: column;
    flex: 0;
    min-width: 0;
    overflow: hidden;
    padding: 0;
    background: var(--bg);
    position: relative;
    opacity: 0;
    transform: translateX(20px);
    pointer-events: none;
    transition: flex 0.4s cubic-bezier(0.16, 1, 0.3, 1),
                opacity 0.4s cubic-bezier(0.16, 1, 0.3, 1),
                transform 0.4s cubic-bezier(0.16, 1, 0.3, 1),
                padding 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.analyze-preview-panel.visible {
    flex: 1;
    opacity: 1;
    transform: translateX(0);
    overflow-y: auto;
    padding: 20px;
    pointer-events: auto;
}

.analyze-preview-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 16px;
}

.analyze-preview-header h2 {
    font-size: 15px;
    font-weight: 600;
    margin: 0 0 3px;
}

.analyze-preview-subtitle {
    font-size: 12px;
    color: var(--text-muted);
}

.analyze-preview-legend {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 2px;
    font-size: 11px;
    color: var(--text-muted);
}

.analyze-legend-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--yellow);
}

.analyze-preview-loading {
    position: absolute;
    inset: 0;
    z-index: 10;
    background: rgba(14,15,19,0.65);
    backdrop-filter: blur(3px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.analyze-preview-loading-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--yellow), #D4950A);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #1a1a1a;
    animation: spinPulse 1.5s ease-in-out infinite;
}

.analyze-preview-loading span {
    font-size: 13px;
    color: var(--text-secondary);
}

.analyze-questions-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: opacity 0.3s ease;
}

.analyze-questions-container.dimmed {
    opacity: 0.4;
}

/* ── Question Groups ── */
.analyze-question-group {
    border-radius: 10px;
    border: 1px solid var(--card-border);
    background: var(--card);
    overflow: hidden;
}

.analyze-group-header {
    padding: 9px 16px;
    border-bottom: 1px solid var(--border-subtle);
    background: var(--surface);
    display: flex;
    align-items: center;
    gap: 8px;
}

.analyze-group-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--yellow);
    flex-shrink: 0;
}

.analyze-group-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text);
}

.analyze-group-count {
    font-size: 11px;
    color: var(--text-muted);
    margin-left: auto;
}

.analyze-group-delete-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    opacity: 0;
    transition: opacity 0.15s ease, color 0.15s ease;
    flex-shrink: 0;
}
.analyze-group-header:hover .analyze-group-delete-btn { opacity: 0.6; }
.analyze-group-delete-btn:hover { opacity: 1 !important; color: var(--red, #e74c3c); }

/* ── Question Items ── */
.analyze-question-item {
    padding: 9px 16px;
    border-bottom: 1px solid var(--border-subtle);
}

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

.analyze-question-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 6px;
    margin: -4px -6px;
    transition: background 0.15s ease;
}

.analyze-question-row:hover {
    background: var(--surface-hover);
}

.analyze-question-num {
    font-size: 10.5px;
    color: var(--text-muted);
    font-weight: 600;
    margin-top: 2px;
    flex-shrink: 0;
    width: 16px;
    text-align: right;
}

.analyze-question-text {
    flex: 1;
    font-size: 13px;
    color: var(--text);
    line-height: 1.5;
}

.analyze-question-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.analyze-question-edit-icon {
    color: var(--text-muted);
    flex-shrink: 0;
    opacity: 0.4;
    display: flex;
}

.analyze-question-delete-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    opacity: 0;
    transition: opacity 0.15s ease, color 0.15s ease;
}
.analyze-question-row:hover .analyze-question-delete-btn { opacity: 0.5; }
.analyze-question-delete-btn:hover { opacity: 1 !important; color: var(--red, #e74c3c); }

/* ── Question Edit Mode ── */
.analyze-question-edit-mode {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.analyze-question-edit-mode textarea {
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--yellow);
    border-radius: 8px;
    padding: 8px 12px;
    color: var(--text);
    font-size: 13px;
    resize: vertical;
    outline: none;
    line-height: 1.5;
    font-family: var(--font);
    box-sizing: border-box;
}

.analyze-question-edit-actions {
    display: flex;
    gap: 6px;
    justify-content: flex-end;
}

.analyze-question-cancel-btn {
    padding: 5px 14px;
    border-radius: 6px;
    font-size: 12px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    font-family: var(--font);
}

.analyze-question-save-btn {
    padding: 5px 14px;
    border-radius: 6px;
    font-size: 12px;
    border: none;
    background: var(--yellow);
    color: #1a1a1a;
    cursor: pointer;
    font-weight: 600;
    font-family: var(--font);
}

/* ── Gap Cards ── */
.analyze-gap-card {
    border-radius: 8px;
    border: 1px solid var(--border);
    overflow: hidden;
    transition: all 0.2s ease;
    margin-bottom: 5px;
}

.analyze-gap-card:last-child {
    margin-bottom: 0;
}

.analyze-gap-card--expanded-high {
    border-color: var(--red-border);
    background: var(--red-bg);
}

.analyze-gap-card--expanded-low {
    border-color: var(--yellow-border);
    background: var(--yellow-bg);
}

.analyze-gap-header {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 9px 12px;
    cursor: pointer;
}

.analyze-gap-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 5px;
}

.analyze-gap-dot--high {
    background: var(--red);
}

.analyze-gap-dot--low {
    background: var(--yellow);
}

.analyze-gap-section {
    font-size: 10.5px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 2px;
}

.analyze-gap-description {
    font-size: 12.5px;
    color: var(--text);
    line-height: 1.4;
}

.analyze-gap-chevron {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 1px;
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

.analyze-gap-chevron.expanded {
    transform: rotate(90deg);
}

.analyze-gap-details {
    padding: 0 12px 12px 29px;
    border-top: 1px solid var(--border-subtle);
}

.analyze-gap-detail-block {
    padding-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.analyze-gap-detail-label {
    font-size: 10.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 4px;
    color: var(--text-muted);
}

.analyze-gap-detail-label--fix-high {
    color: var(--red);
}

.analyze-gap-detail-label--fix-low {
    color: var(--yellow);
}

.analyze-gap-detail-text {
    font-size: 12.5px;
    color: var(--text-secondary);
    line-height: 1.55;
}

/* ── Score Card ── */
.analyze-score-card {
    background: var(--surface);
    border-radius: 10px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    margin-bottom: 14px;
}

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

.analyze-score-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.analyze-score-value {
    font-size: 22px;
    font-weight: 700;
    line-height: 1;
}

.analyze-score-value span {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 400;
}

.analyze-score-bar-track {
    height: 5px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
}

.analyze-score-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.analyze-score-hint {
    font-size: 11.5px;
    color: var(--text-muted);
    margin-top: 6px;
}

/* ── Analyze Download Button (in chat) ── */
.analyze-download-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: 10px;
    background: var(--yellow-bg);
    border: 1px solid var(--yellow-border);
    color: var(--yellow);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    font-family: var(--font);
    width: 100%;
    margin-bottom: 10px;
    transition: all 0.15s ease;
}

.analyze-download-btn:hover {
    filter: brightness(1.1);
}

/* ── Analyze Hint Box ── */
.analyze-hint-box {
    font-size: 11.5px;
    color: var(--text-muted);
    padding: 8px 12px;
    background: var(--surface);
    border-radius: 8px;
    border: 1px solid var(--border);
}

.analyze-hint-box strong {
    color: var(--green);
}

/* ── Responsive ── */
@media (max-width: 768px) {
    .analyze-panels {
        flex-direction: column;
    }

    .analyze-chat-panel--narrow {
        flex: 1;
        border-right: none;
        border-bottom: 1px solid var(--border-subtle);
    }

    .analyze-preview-panel.visible {
        flex: 1;
        max-height: 50vh;
    }
}
