/* Global Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary-color: #64748b;
    --secondary-hover: #475569;
    --success-color: #10b981;
    --error-color: #ef4444;
    --warning-color: #f59e0b;
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --border-color: #e2e8f0;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

main {
    display: flex;
    flex-direction: column;
}

#wizard-section:not(.hidden),
#done-section:not(.hidden) {
    order: -1;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 3rem;
    position: relative;
}

header h1 {
    font-size: 2.5rem;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

/* Sections */
.section {
    background: var(--card-bg);
    border-radius: 0.75rem;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-md);
}

.section h2 {
    font-size: 1.75rem;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
}

.section.hidden {
    display: none;
}

/* Input Section */
.input-wrapper {
    width: 100%;
}

/* Rich text toolbar */
.rich-toolbar {
    display: flex;
    gap: 0.25rem;
    padding: 0.4rem 0.5rem;
    border: 2px solid var(--border-color);
    border-bottom: none;
    border-radius: 0.5rem 0.5rem 0 0;
    background: #f8fafc;
}
.rich-toolbar button {
    padding: 0.2rem 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 0.25rem;
    background: white;
    cursor: pointer;
    font-size: 0.875rem;
    line-height: 1.4;
    color: var(--text-primary);
}
.rich-toolbar button:hover,
.rich-toolbar button.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}
.rich-toolbar button strong,
.rich-toolbar button em {
    font-size: inherit;
}

#input-text {
    width: 100%;
    min-height: 200px;
    padding: 1rem;
    border: 2px solid var(--border-color);
    border-radius: 0 0 0.5rem 0.5rem;
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.2s;
    outline: none;
    white-space: pre-wrap;
    overflow-wrap: break-word;
    overflow-y: auto;
    box-sizing: border-box;
}

#input-text:focus {
    border-color: var(--primary-color);
}

#input-text:empty::before {
    content: attr(data-placeholder);
    color: var(--text-secondary);
    pointer-events: none;
}

/* Heading & list styles in rich input, wizard preview, and result */
#input-text h1, #wizard-preview h1, #final-text-display h1 {
    font-size: 1.35rem;
    font-weight: 700;
    margin: 0.75rem 0 0.25rem;
    line-height: 1.3;
}
#input-text h2, #wizard-preview h2, #final-text-display h2 {
    font-size: 1.1rem;
    font-weight: 700;
    margin: 0.5rem 0 0.2rem;
    line-height: 1.3;
}
#input-text ul, #wizard-preview ul, #final-text-display ul {
    padding-left: 1.5rem;
    margin: 0.25rem 0;
}
#input-text li, #wizard-preview li, #final-text-display li {
    margin: 0.2rem 0;
}

/* Safety net for inline styles that slip past the paste normaliser (drag and
   drop, style spans the browser adds itself): text in the editors always uses
   the editor's own font and size and the full width — never a PDF's 7pt text
   in a half-width column. Headings keep their own size from the rules above. */
#input-text *, #wizard-preview *, #final-text-display * {
    font-family: inherit !important;
    width: auto !important;
    max-width: 100% !important;
    min-width: 0 !important;
    float: none !important;
    position: static !important;
    columns: auto !important;
    text-indent: 0 !important;
}
#input-text :not(h1):not(h2),
#wizard-preview :not(h1):not(h2),
#final-text-display :not(h1):not(h2) {
    font-size: inherit !important;
}

.input-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1rem;
}

.char-counter {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.char-counter.warning {
    color: var(--warning-color);
    font-weight: 600;
}

.char-counter.over-limit {
    color: var(--error-color);
    font-weight: 600;
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 0.5rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: var(--shadow-sm);
}

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

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

.btn-primary:hover:not(:disabled) {
    background-color: var(--primary-hover);
    box-shadow: var(--shadow-md);
}

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

.btn-secondary:hover:not(:disabled) {
    background-color: var(--secondary-hover);
}

/* Error Message */
.error-message {
    background-color: #fee2e2;
    border: 1px solid #fecaca;
    color: #991b1b;
    padding: 1rem;
    border-radius: 0.5rem;
    margin-top: 1rem;
}

.error-message.hidden {
    display: none;
}

/* Section intro text */
.section-description {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-bottom: 1.5rem;
}

/* Results Section */
.result-text-wrapper {
    position: relative;
    margin-bottom: 2rem;
}

.text-display {
    background-color: #f9fafb;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 1.5rem;
    min-height: 150px;
    line-height: 1.8;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.text-display.editable {
    background-color: #ffffff;
    border: 2px solid var(--border-color);
    border-radius: 0 0 0.5rem 0.5rem;
    cursor: text;
}

.text-display.editable:focus {
    outline: none;
    border-color: var(--primary-color);
}

.result-text-actions {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
}

.btn-icon {
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    padding: 0.4rem 0.5rem;
    cursor: pointer;
    font-size: 1rem;
    color: var(--text-secondary);
    transition: all 0.2s;
}

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

/* Info toggle button (in header) */
.btn-info-toggle {
    position: absolute;
    top: 1rem;
    right: 0;
    background: var(--primary-color);
    border: none;
    border-radius: 1.5rem;
    padding: 0.45rem 1.1rem;
    font-size: 0.88rem;
    font-weight: 500;
    color: #ffffff;
    cursor: pointer;
    transition: background 0.15s;
    letter-spacing: 0.01em;
}

.btn-info-toggle:hover {
    background: var(--primary-hover);
}

/* Info drawer backdrop */
.info-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    z-index: 998;
}

.info-backdrop.open {
    display: block;
}

/* Info drawer */
.info-panel {
    position: fixed;
    top: 0;
    right: -360px;
    width: 320px;
    height: 100vh;
    background: var(--card-bg);
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.15);
    z-index: 999;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 0 1.25rem 1.5rem;
    transition: right 0.28s ease;
}

.info-panel.open {
    right: 0;
}

.info-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.1rem 0 0.75rem;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 0.25rem;
    position: sticky;
    top: 0;
    background: var(--card-bg);
    z-index: 1;
}

.info-panel-title {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-primary);
}

.info-close {
    background: none;
    border: none;
    font-size: 1.4rem;
    line-height: 1;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0 0.2rem;
}

.info-close:hover {
    color: var(--text-primary);
}

.info-card {
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 0.6rem;
    padding: 0.85rem 1rem;
}

.info-card h3 {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin-bottom: 0.45rem;
}

.info-card p {
    font-size: 0.82rem;
    color: var(--text-primary);
    line-height: 1.5;
}

.info-steps {
    margin: 0;
    padding-left: 1.1rem;
    font-size: 0.82rem;
    color: var(--text-primary);
    line-height: 1.7;
}

.info-steps li {
    margin-bottom: 0.1rem;
}

.info-card-privacy {
    border-left: 3px solid var(--success-color);
}

/* Footer */
footer {
    text-align: center;
    padding: 2rem 0;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }

    .info-panel {
        width: 100%;
    }

    header h1 {
        font-size: 2rem;
    }

    .section {
        padding: 1.5rem;
    }

    .section h2 {
        font-size: 1.5rem;
    }

    .wizard-actions {
        width: 100%;
        flex-direction: column;
    }

    .btn {
        width: 100%;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus styles for keyboard navigation */
button:focus-visible,
input:focus-visible,
textarea:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Global hidden class - CRITICAL for popup/popover visibility */
.hidden {
    display: none !important;
    pointer-events: none !important;
}

/* Suggestion card content (used inside .lint-mark-popover / .suggestion-popover) */
.popup-change {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.3rem;
    font-size: 1rem;
    flex-wrap: wrap;
}

.popup-original {
    color: var(--text-primary);
    font-weight: 500;
}

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

.popup-replacement {
    color: var(--text-primary);
    font-weight: 600;
}

.popup-actions {
    display: flex;
    gap: 0.5rem;
    padding-top: 0.4rem;
}

.popup-actions .btn {
    flex: 1;
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.95rem;
}

@media (max-width: 640px) {
    .popup-change {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.3rem;
    }
}

/* Level dots in info panel */
.info-levels {
    list-style: none;
    padding: 0;
    margin: 0.5rem 0 0;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.info-levels li {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    font-size: 0.9rem;
}

.level-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 0.3em;
}

.level-dot.level-1 { background: #10b981; }
.level-dot.level-2 { background: #3b82f6; }
.level-dot.level-3 { background: #f59e0b; }
.level-dot.level-4 { background: #ef4444; }

/* ============================================================
   STEP WIZARD
   ============================================================ */

/* Two-column wizard body: editor left, sidebar right */
.lint-body {
    display: flex;
    gap: 1rem;
    align-items: stretch;
    height: clamp(420px, 65vh, 700px);
    margin-bottom: 0.75rem;
}

.lint-editor-col {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* Editable lint text area */
.lint-preview {
    font-family: inherit;
    font-size: 1rem;
    line-height: 1.6;
    padding: 1rem;
    border: 2px solid #cbd5e1;
    border-top: none;
    border-radius: 0 0 0.5rem 0.5rem;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    box-sizing: border-box;
    word-wrap: break-word;
    overflow-wrap: break-word;
    background: #ffffff;
    color: #1e293b;
    outline: none;
}

.lint-preview:focus {
    border-color: #3b82f6;
}

/* Toolbar sits flush above the editor */
#wizard-toolbar {
    border-radius: 0.5rem 0.5rem 0 0;
    border: 2px solid #cbd5e1;
    border-bottom: 1px solid #e2e8f0;
    margin-bottom: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.wizard-refresh-btn {
    padding: 0.3rem 0.75rem;
    border: 1px solid #f59e0b;
    border-radius: 1rem;
    background: #fffbeb;
    color: #92400e;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
}

.wizard-refresh-btn:hover {
    background: #fef3c7;
}

/* Sidebar */
.lint-sidebar {
    flex: 0 0 clamp(260px, 32%, 380px);
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    overflow: hidden;
    background: #ffffff;
    display: flex;
    flex-direction: column;
}

.lint-sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 0.9rem;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    gap: 0.5rem;
}

.lint-sidebar-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: #334155;
    min-width: 0;
}

.lint-sidebar-count {
    font-size: 0.78rem;
    color: #64748b;
    white-space: nowrap;
    flex-shrink: 0;
}

.lint-sidebar-desc-text {
    margin: 0 0 0.4rem;
    padding: 0 0.5rem;
    line-height: 1.45;
    font-size: 0.8rem;
    color: #374151;
}

.lint-sidebar-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.4rem;
}

.lint-sidebar-empty {
    font-size: 0.82rem;
    color: #94a3b8;
    padding: 0.75rem 0.5rem;
    margin: 0;
    text-align: center;
}

.lint-sidebar-item {
    padding: 0.55rem 0.65rem;
    border-radius: 0.35rem;
    cursor: pointer;
    margin-bottom: 3px;
    border: 1px solid transparent;
    transition: background 0.1s, border-color 0.1s;
}

.lint-sidebar-item:hover {
    background: #f1f5f9;
    border-color: #e2e8f0;
}

.lint-sidebar-item.resolved {
    opacity: 0.55;
}

.lint-sidebar-item.resolved .lint-sidebar-word {
    text-decoration: line-through;
}

.lint-sidebar-word {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: #1e293b;
    word-break: break-word;
}

.lint-sidebar-replacements {
    display: flex;
    flex-direction: column;
    gap: 1px;
    margin-top: 3px;
}

.lint-sidebar-replacement {
    display: block;
    font-size: 0.78rem;
    color: #059669;
}

.lint-sidebar-detail {
    display: block;
    font-size: 0.78rem;
    color: #64748b;
    margin-top: 2px;
}

/* Pulse animation when scrolling to a mark from the sidebar */
@keyframes lint-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.6); }
    70%  { box-shadow: 0 0 0 6px rgba(245, 158, 11, 0); }
    100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0); }
}

mark.lint-mark-pulse {
    animation: lint-pulse 1.2s ease-out;
}

/* Issue underline — grammar-checker style blue line below the flagged text */
mark.wizard-mark {
    background: transparent;
    color: inherit;
    border-bottom: 2px solid #3b82f6;
    text-decoration: none;
    cursor: pointer;
    padding: 0;
    transition: background-color 0.15s;
}

mark.wizard-mark:hover {
    background-color: rgba(59, 130, 246, 0.1);
}

/* Lint section header row */
.lint-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    gap: 1rem;
}

.lint-section-header h2 {
    margin-bottom: 0;
}

/* Compact readability indicator in lint header */
/* Score on top, level bar below it */
.lint-readability-compact {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.35rem;
    flex-shrink: 0;
}

.lint-gauge-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.lint-score-row {
    display: flex;
    align-items: baseline;
    gap: 0.4rem;
    cursor: help;
}

.lint-score-caption {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.lint-score-number {
    font-size: 1.6rem;
    font-weight: 700;
    line-height: 1;
    color: var(--lint-gauge-color, var(--text-primary));
    font-variant-numeric: tabular-nums;
    transition: color 0.2s;
}

.lint-readability-prefix {
    font-size: 0.8rem;
    font-weight: 500;
    color: #64748b;
    white-space: nowrap;
}

.lint-gauge-bar {
    display: flex;
    flex-direction: row;
    gap: 3px;
    padding: 3px;
    border: 2px solid #e2e8f0;
    border-radius: 6px;
}

.lint-gauge-seg {
    width: 14px;
    height: 18px;
    border-radius: 3px;
    background-color: var(--lint-gauge-color, #94a3b8);
    opacity: 0.15;
    transition: background-color 0.4s ease, opacity 0.4s ease;
}

.lint-gauge-seg.active {
    opacity: 1;
}

.lint-indicator-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--lint-gauge-label-color, #64748b);
    white-space: nowrap;
}

.result-readability-row {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.35rem;
    margin-top: 0.75rem;
}

.result-delta {
    font-size: 1rem;
    font-weight: 700;
    transition: opacity 0.3s;
}

.result-delta.hidden {
    display: none;
}

/* LiNT: a lower score is an easier text, so down is good news */
.result-delta-easier {
    color: var(--success-color);
}

.result-delta-harder {
    color: var(--error-color);
}

/* Hidden state textarea */
.lint-text-hidden {
    display: none;
}

.rich-toolbar-result {
    border-radius: 0.5rem 0.5rem 0 0;
}

.lint-actions {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    margin-top: 1.25rem;
}

.wizard-actions #wizard-prev-btn {
    margin-right: auto;
}

/* ------------------------------------------------------------------
   Mark popover (clicking highlighted spans in lint preview)
   ------------------------------------------------------------------ */

.lint-mark-popover {
    position: fixed;
    z-index: 200;
    background: #1e293b;
    color: #f8fafc;
    border-radius: 6px;
    padding: 0.6rem 0.8rem;
    max-width: 280px;
    min-width: 160px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.25);
    font-size: 0.82rem;
    line-height: 1.4;
    pointer-events: auto;
}

.lint-mark-popover-close {
    float: right;
    background: none;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    padding: 0 0 0 0.4rem;
    margin-left: 0.4rem;
}

.lint-mark-popover-close:hover {
    color: #f8fafc;
}

/* Suggestion popover — a light card variant of .lint-mark-popover, holding
   one or more accept/reject cards instead of a single detail line. */
.suggestion-popover {
    background: #ffffff;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 0.75rem 0.9rem;
    max-width: 340px;
    min-width: 260px;
    box-shadow: var(--shadow-lg);
}

.suggestion-popover .lint-mark-popover-close {
    color: var(--text-secondary);
}

.suggestion-popover .lint-mark-popover-close:hover {
    color: var(--text-primary);
}

.popover-card + .popover-card {
    border-top: 1px solid var(--border-color);
    margin-top: 0.5rem;
    padding-top: 0.5rem;
}

.popover-explanation {
    font-size: 0.82rem;
    color: var(--text-secondary);
    line-height: 1.4;
    margin: 0.2rem 0 0.3rem;
}

.popover-alternatives {
    margin-top: 0.35rem;
    padding-top: 0.35rem;
    border-top: 1px dashed var(--border-color);
}

.popover-alt {
    font-size: 0.78rem;
    color: var(--text-secondary);
    padding: 0.1rem 0;
}

/* Problem badges ("3 bijzinnen · 1 tangconstructie") */
.issue-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    margin-bottom: 0.4rem;
}

.issue-badge {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.1rem 0.4rem;
    border-radius: 0.75rem;
    background: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #bfdbfe;
    white-space: nowrap;
}

.lint-sidebar-item.resolved .issue-badge {
    background: #f1f5f9;
    color: var(--text-secondary);
    border-color: var(--border-color);
}

/* Word-level diff for sentence rewrites */
.popover-diff {
    font-size: 0.88rem;
    line-height: 1.5;
    max-height: 260px;
    overflow-y: auto;
    padding: 0.5rem 0.6rem;
    background: var(--bg-color);
    border-radius: 0.35rem;
    margin-bottom: 0.35rem;
}

.diff-same {
    color: var(--text-primary);
}

.diff-del {
    background: #fee2e2;
    color: #991b1b;
    text-decoration: line-through;
    border-radius: 2px;
}

.diff-ins {
    background: #d1fae5;
    color: #065f46;
    border-radius: 2px;
}

.popover-note {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.3rem;
}

.popover-warning {
    font-size: 0.78rem;
    line-height: 1.4;
    padding: 0.4rem 0.55rem;
    margin: 0.35rem 0;
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 0.35rem;
    color: #92400e;
}

/* A sentence-scope underline covers a lot of text — keep it lighter than a
   word-scope one so a flagged sentence doesn't read as one solid blue block. */
mark.wizard-mark-sentence {
    border-bottom-width: 1px;
    border-bottom-style: solid;
}

/* The sentence the open suggestion is about: a soft yellow background.
   ::highlight() colours the text without changing the DOM (CSS Custom Highlight
   API); .wizard-mark-focus is the fallback for browsers without it. */
::highlight(issue-focus) {
    background-color: #fef3c7;
}

mark.wizard-mark.wizard-mark-focus {
    background-color: #fef3c7;
}

/* Accepted suggestion — still clickable so it can be put back. */
mark.wizard-mark-accepted {
    border-bottom: 1px dashed var(--success-color);
}

.lint-sidebar-status {
    display: block;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-top: 0.15rem;
}

/* ------------------------------------------------------------------
   Step progress bar
   ------------------------------------------------------------------ */

.wizard-progress {
    display: flex;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 0.25rem;
}

.wizard-progress-step {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.3rem 0.7rem 0.3rem 0.3rem;
    border-radius: 2rem;
    background: #f1f5f9;
}

.wizard-progress-step + .wizard-progress-step {
    margin-left: 0.5rem;
}

.wizard-progress-num {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #cbd5e1;
    color: #ffffff;
    font-size: 0.75rem;
    font-weight: 700;
    flex-shrink: 0;
}

.wizard-progress-label {
    font-size: 0.8rem;
    font-weight: 500;
    color: #64748b;
    white-space: nowrap;
}

.wizard-progress-step.active {
    background: #dbeafe;
}

.wizard-progress-step.active .wizard-progress-num {
    background: var(--primary-color);
}

.wizard-progress-step.active .wizard-progress-label {
    color: var(--primary-color);
    font-weight: 700;
}

.wizard-progress-step.done .wizard-progress-num {
    background: var(--success-color);
}

.wizard-progress-step.done .wizard-progress-label {
    color: var(--text-primary);
}

/* Earlier step that was jumped over */
.wizard-progress-step.skipped .wizard-progress-num {
    background: #ffffff;
    color: #94a3b8;
    box-shadow: inset 0 0 0 2px #cbd5e1;
    border: 1px dashed #94a3b8;
}

.wizard-progress-step.skipped .wizard-progress-label {
    color: #94a3b8;
    font-style: italic;
}

/* Visited later step: reachable again without redoing it */
.wizard-progress-step.visited .wizard-progress-num {
    background: #ffffff;
    color: var(--success-color);
    box-shadow: inset 0 0 0 2px var(--success-color);
}

.wizard-progress-step.visited .wizard-progress-label {
    color: var(--text-primary);
}

/* Clickable orbs (earlier and visited steps) */
button.wizard-progress-step {
    border: none;
    font: inherit;
    cursor: pointer;
    transition: background-color 0.15s;
}

button.wizard-progress-step:hover:not(:disabled) {
    background: #e2e8f0;
}

button.wizard-progress-step:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

button.wizard-progress-step:disabled {
    cursor: progress;
    opacity: 0.7;
}

@media (max-width: 640px) {
    .wizard-progress-label {
        display: none;
    }
}

/* ------------------------------------------------------------------
   LLM loading overlay — covers the page while a step is analysed
   ------------------------------------------------------------------ */

.llm-loading-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(15, 23, 42, 0.35);
    cursor: progress;
}

.llm-loading-overlay.hidden {
    display: none;
}

.llm-loading-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    max-width: 320px;
    padding: 1.5rem 2rem;
    border-radius: 0.75rem;
    background: #ffffff;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.2);
    text-align: center;
}

.llm-spinner {
    width: 40px;
    height: 40px;
    margin-bottom: 0.5rem;
    border: 4px solid #dbeafe;
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: llm-spin 0.9s linear infinite;
}

.llm-loading-title {
    margin: 0;
    font-weight: 600;
    color: var(--text-primary);
}

.llm-loading-text {
    margin: 0;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

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

@keyframes llm-pulse {
    50% { opacity: 0.4; }
}

@media (prefers-reduced-motion: reduce) {
    .llm-spinner {
        animation: llm-pulse 2s ease-in-out infinite;
    }
}

/* Access code form (static/js/access.js) — above every other overlay */
.access-gate {
    position: fixed;
    inset: 0;
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: var(--bg-color);
}

.access-gate.hidden {
    display: none;
}

.access-card {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    width: 100%;
    max-width: 360px;
    padding: 2rem;
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    background: var(--card-bg);
    box-shadow: var(--shadow-lg);
}

.access-card h2 {
    margin: 0;
    color: var(--text-primary);
}

.access-card p {
    margin: 0;
    color: var(--text-secondary);
}

.access-input {
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    font-size: 1rem;
}

.access-input:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 1px;
}

.access-card .access-error {
    color: var(--error-color);
    font-size: 0.875rem;
}
