:root {
    /* --- Brand Colors --- */
    --primary: #3C71A8;          /* Primary Blue */
    --primary-hover: #2a5a8a;    
    
    --bg-app: #F3F4F6;           /* Light Grey Background */
    --bg-card: #FFFFFF;          /* White Card */
    --white: #FFFFFF;            /* Pure White */
    
    --text-main: #1F2937;        /* Dark Grey (Almost Black) */
    --text-muted: #6B7280;       /* Medium Grey */
    --border-color: #D1D5DB;     /* Light Grey Border */
    
    /* Success/Active States */
    --success: #065F46;          /* Dark Green */
    --success-medium: #047857;   /* Medium Green for active text */
    --success-bg: #ECFDF5;       /* Light Green background */
    --success-border: #A7F3D0;   /* Light Green border */
    
    /* Info States */
    --info-bg: #EFF6FF;          /* Light Blue background */
    --info-border: #BFDBFE;      /* Light Blue border */
    --info-text: #1E40AF;        /* Dark Blue text */
    
    /* Danger/Error States */
    --danger: #B91C1C;           /* Red for destructive/stop actions */
    --danger-hover: #991B1B;
    --danger-text: #991B1B;      /* Dark red text */
    --danger-bg: #FEF2F2;        /* Light red background */
    --danger-border: #FCA5A5;    /* Light red border */
    
    /* Warning States */
    --warning-bg: #FFFBEB;       /* Light yellow background */
    --warning-border: #FDE68A;   /* Light yellow border */
    --warning-text: #92400E;     /* Dark yellow text */

    /* --- Spacing & Radius --- */
    --max-width-container: 1200px;
    --radius-md: 8px;
    --radius-lg: 12px;
}

/* --- Global Reset --- */
* {
    box-sizing: border-box; /* Critical for correct sizing */
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-app);
    color: var(--text-main);
    margin: 0;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; color: inherit; }

.container {
    max-width: var(--max-width-container);
    margin: 0 auto;
    padding: 0 1rem;
}

main.container {
    padding-bottom: 3rem;
}

/* --- Header Styles --- */
.header {
    background-color: var(--primary);
    color: white;
    padding: 0.75rem 0;
    margin-bottom: 2rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header h1 {
    margin: 0;
}

.header h1 a {
    font-size: 1.5rem;
    font-weight: 700;
}

.user-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
    font-size: 0.9rem;
}

@media (max-width: 640px) {
    .header {
        margin-bottom: 1rem;
    }

    .header-content {
        gap: 0.75rem;
    }

    .user-controls {
        gap: 0.5rem;
    }

    .participant-dashboard-container {
        padding-top: 0;
    }

    .participant-dashboard-container .join-card-centered {
        margin: 0 auto 1rem auto;
        padding: 1.25rem;
        gap: 1rem;
    }

    .participant-dashboard-container .join-form-vertical {
        gap: 1rem;
    }

    .participant-dashboard-container .my-courses-section {
        padding-top: 1.25rem;
    }
}

.badge {
    background: rgba(255,255,255,0.2);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.8em;
}

.inline-form { display: inline-block; }

.btn-link {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.9);
    cursor: pointer;
    font-size: 0.9rem;
    padding: 0;
    font-weight: 500;
}
.btn-link:hover { text-decoration: underline; }

/* --- Base Card Components --- */
/* ADJUST CARD SPACING:
   - padding: Internal whitespace around all content.
   - gap: Vertical space between major card elements.
*/
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

.card-header {
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.75rem;
    margin-bottom: 0; /* Margin handled by gap */
}

.card-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-main);
    margin: 0;
}

.course-card > .card-title {
    margin-bottom: 0.75rem;
}

.card-body {
    padding: 0;
}

/* --- Compatibility Aliases --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
    border-radius: var(--radius-md);
    min-height: 48px;
    padding: 0.75rem 1.5rem;
    border: none;
    background-color: var(--primary);
    color: white;
    text-align: center;
    line-height: 1.2;
    white-space: normal;
}


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

.form-group {
    margin-bottom: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* --- Dashboard: Join Card --- */
.join-card-centered {
    background-color: var(--bg-card);
    max-width: 480px;
    margin: 4rem auto 3rem auto;
    padding: 2.5rem;
    border-radius: var(--radius-lg);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(0,0,0,0.05);
    transition: transform 0.2s ease;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.join-card-centered:hover {
    transform: translateY(-2px);
}

.join-card-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
    margin: 0;
    text-align: center;
}

.join-form-vertical {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.form-field {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    text-align: left;
}

.form-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-main);
}

/* Input Styling */
.form-input {
    width: 100%;
    height: 48px; /* Fixed height for touch targets */
    padding: 0 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 1rem;
    background-color: white;
    transition: all 0.2s ease-in-out;
}
.form-input-compact {
    width: auto;
    min-width: 12rem;
    max-width: 100%;
    flex: 0 1 auto;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(60, 113, 168, 0.15); /* Light blue glow */
}

/* Textarea variant for multiline input */
.form-textarea {
    width: 100%;
    min-height: 120px;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 1rem;
    background-color: white;
    transition: all 0.2s ease-in-out;
    font-family: inherit;
    line-height: 1.5;
    resize: vertical;
}

.form-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(60, 113, 168, 0.15);
}

/* Button Styling */
.btn-primary,
.btn-primary-full {
    background-color: var(--primary);
    color: white;
    font-weight: 600;
    font-size: 1rem;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    padding: 0.75rem 1.5rem;
    text-align: center;
    line-height: 1.2;
    white-space: normal;
}

.btn-primary:hover,
.btn-primary-full:hover {
    background-color: var(--primary-hover);
}

.btn-primary-full {
    width: 100%;
}

.btn-secondary,
.btn-secondary-full {
    background-color: transparent;
    color: var(--text-main);
    font-weight: 600;
    font-size: 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    padding: 0.75rem 1.5rem;
    text-align: center;
    line-height: 1.2;
    white-space: normal;
}

.btn-secondary:hover,
.btn-secondary-full:hover {
    background-color: var(--bg-app);
    border-color: var(--text-muted);
}

.btn-secondary-full {
    width: 100%;
}

.btn-danger,
.btn-danger-full {
    background-color: var(--danger);
    color: white;
    font-weight: 600;
    font-size: 1rem;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    padding: 0.75rem 1.5rem;
    text-align: center;
    line-height: 1.2;
    white-space: normal;
}

.btn-danger:hover,
.btn-danger-full:hover {
    background-color: var(--danger-hover);
}

.btn-danger-full {
    width: 100%;
}

.btn-primary:disabled,
.btn-primary-full:disabled,
.btn-secondary:disabled,
.btn-secondary-full:disabled,
.btn-danger:disabled,
.btn-danger-full:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary:disabled:hover,
.btn-primary-full:disabled:hover {
    background-color: var(--primary);
}

.btn-secondary:disabled:hover,
.btn-secondary-full:disabled:hover {
    background-color: transparent;
    border-color: var(--border-color);
}

.btn-danger:disabled:hover,
.btn-danger-full:disabled:hover {
    background-color: var(--danger);
}

.help-text {
    font-size: 0.875rem;
    color: var(--text-muted);
    text-align: center;
    margin-top: 0.5rem;
}

.help-text-left {
    font-size: 0.875rem;
    color: var(--text-muted);
    text-align: left;
    margin-top: 0;
    margin-bottom: 0;
}

.facilitator-dashboard-container,
.participant-dashboard-container {
    padding-top: 1rem;
}

.facilitator-dashboard-container .my-courses-section {
    border-top: none;
    padding-top: 0;
    margin-top: 0;
}

.participant-dashboard-container .join-card-centered {
    margin: 0 auto 1.5rem auto;
}

.participant-dashboard-container .my-courses-section {
    margin-top: 0;
    padding-top: 1.5rem;
}

.join-form-vertical .help-text {
    margin-top: 0;
}

.guest-cta {
    margin-top: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.guest-join-card {
    border: 1px solid var(--info-border);
    background: linear-gradient(180deg, rgba(239, 246, 255, 0.7), var(--bg-card));
}

.guest-join-badge {
    align-self: center;
    background-color: var(--info-bg);
    color: var(--info-text);
    border: 1px solid var(--info-border);
    border-radius: 999px;
    padding: 0.35rem 0.9rem;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-bottom: 1rem;
}

.guest-join-lead {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin: 0;
    text-align: center;
}

.course-participant-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.course-settings-link {
    margin-bottom: 0.75rem;
}

/* --- Status Indicators --- */
.status-active {
    color: var(--success);
}

.status-ready {
    color: var(--text-muted);
}

.status-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    max-width: 100%;
    padding: 0.2rem 0.5rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.2;
    text-align: center;
    white-space: nowrap;
    word-break: normal;
}

.status-pill-success {
    background-color: var(--success-bg);
    color: var(--success-medium);
    border: 1px solid var(--success-border);
}

.status-pill-info {
    background-color: var(--info-bg);
    color: var(--info-text);
    border: 1px solid var(--info-border);
}

.status-pill-warning {
    background-color: var(--warning-bg);
    color: var(--warning-text);
    border: 1px solid var(--warning-border);
}

.status-pill-danger {
    background-color: var(--danger-bg);
    color: var(--danger-text);
    border: 1px solid var(--danger-border);
}

.status-pill-multiline {
    white-space: normal;
    justify-content: flex-start;
    text-align: left;
    border-radius: var(--radius-md);
}

.status-pill-neutral {
    background-color: var(--bg-app);
    color: var(--text-main);
    border: 1px solid var(--border-color);
}

/* --- Dashboard: My Courses Section --- */
.my-courses-section {
    border-top: 1px solid var(--border-color);
    padding-top: 3rem;
    margin-top: 3rem;
}

.section-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 1.25rem;
}

.course-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.5rem;
}

/* ADJUST COURSE CARD SPACING:
   - padding: Internal whitespace around all content.
   - gap: Vertical space between major elements (header, title, stats, status).
*/
.course-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem; /* Reduced from 2rem */
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.course-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

.session-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    max-width: 40rem;
    width: 100%;
    margin-left: auto;
    margin-right: auto;
}

.session-card > .card-title,
.session-card > .card-header {
    margin: 0;
}

.session-card > [id$="session-status"] {
    display: contents;
}

.refocus-form {
    min-width: 0;
}

.course-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.course-code {
    font-size: 1.125rem;
    font-weight: 700;
    margin: 0;
    color: var(--text-main);
}

.course-title {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin: 0 0 1rem 0;
}

.course-detail-container {
    padding-bottom: 3rem;
}

.course-back-row {
    margin-bottom: 2rem;
}

.back-link {
    color: var(--primary);
    font-size: 0.875rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.chrome-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.chrome-toolbar-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
}

.facilitator-control-panel {
    padding-bottom: 2rem;
}

.facilitator-identity {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.facilitator-identity p:empty,
p.help-text:empty {
    display: none;
}

.phase-badge {
    display: inline-flex;
    align-items: center;
    margin: 0.35rem 0 0;
    padding: 0.2rem 0.65rem;
    border-radius: 999px;
    border: 1px solid var(--border-color);
    background: var(--bg-app);
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.2;
}

.completion-shell,
.results-shell {
    max-width: 800px;
    margin: 0 auto;
}

.completion-shell-header,
.results-shell-header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.results-shell-exit {
    flex-shrink: 0;
}

.results-shell:has(.viewport-workspace) {
    max-width: none;
    width: 100%;
}

@media (max-width: 640px) {
    .completion-shell-header,
    .results-shell-header {
        flex-direction: column;
        margin-bottom: 1rem;
    }

    .results-shell-header > .results-shell-exit {
        order: -1;
        align-self: flex-end;
    }
}

.course-title-block {
    margin-bottom: 2rem;
}

.course-code-title {
    font-size: 2rem;
    font-weight: 700;
    margin: 0 0 0.5rem 0;
    color: var(--text-main);
}

.course-name {
    color: var(--text-muted);
    font-size: 1.125rem;
    margin: 0;
}

.course-meta-card {
    display: flex;
    gap: 2rem;
    margin-bottom: 3rem;
    padding: 1.5rem;
    background-color: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
}

.course-meta-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.course-meta-label {
    color: var(--text-muted);
    font-size: 0.875rem;
}

.course-meta-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
}

.versions-section {
    padding-bottom: 3rem;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.course-card-header {
    margin-bottom: 1rem;
}

.course-card-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-main);
    margin: 0 0 0.5rem 0;
}

.course-card-subtitle {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin: 0 0 0.75rem 0;
}

.course-status-badge {
    display: inline-flex;
    align-self: flex-start;
    background-color: var(--success-bg);
    border: 1px solid var(--success-border);
    padding: 0.2rem 0.65rem;
    border-radius: 999px;
    margin-bottom: 1rem;
    text-align: center;
    color: var(--success);
    font-weight: 600;
    font-size: 0.75rem;
}

.guest-access-panel {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.dc-guest-access-top {
    margin: -0.5rem 0 2rem 0;
    max-width: 820px;
}

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

.guest-access-title {
    color: var(--info-text);
    font-weight: 700;
    margin: 0 0 0.5rem 0;
}

.guest-access-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 0.5rem;
}

.guest-access-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
}

.guest-access-value {
    font-weight: 600;
    color: var(--text-main);
}

.guest-access-link {
    color: var(--primary);
    font-weight: 600;
    word-break: break-all;
}

.guest-access-link-group {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
    min-width: 0;
}

.guest-access-copy-button {
    flex: 0 0 auto;
    border: none;
    border-radius: var(--radius-md);
    background-color: var(--primary);
    color: var(--white);
    cursor: pointer;
    font-weight: 700;
    min-height: 36px;
    padding: 0 0.85rem;
}

.guest-access-copy-button:hover {
    background-color: var(--primary-hover);
}

.guest-access-muted {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin: 0;
}

.guest-access-form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.toggle-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.9rem;
    color: var(--text-main);
}

.toggle-row input {
    width: 18px;
    height: 18px;
}

.toggle-control {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.9rem;
    color: var(--text-main);
    cursor: pointer;
}

.toggle-control input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.toggle-track {
    width: 42px;
    height: 24px;
    background-color: var(--border-color);
    border-radius: 999px;
    position: relative;
    transition: background-color 0.2s ease;
    flex-shrink: 0;
}

.toggle-track::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background-color: var(--white);
    transition: transform 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.toggle-control input:checked + .toggle-track {
    background-color: var(--primary);
}

.toggle-control input:checked + .toggle-track::after {
    transform: translateX(18px);
}

.toggle-control input:focus-visible + .toggle-track {
    box-shadow: 0 0 0 4px rgba(60, 113, 168, 0.15);
}

.toggle-text {
    font-weight: 500;
}

.guest-field {
    margin-top: 0.5rem;
}

.is-disabled {
    opacity: 0.5;
}

.guest-access-form input:disabled {
    background-color: var(--bg-app);
    color: var(--text-muted);
    cursor: not-allowed;
}

.guest-join-card .help-text-left {
    margin-bottom: 1.5rem;
}

/* Status Badges */
/* ADJUST LIVE STATUS BOX SPACING:
   - gap: Vertical space between "Live Activity", app name, and buttons.
*/
.course-status-live {
    background-color: var(--success-bg);
    border-left: 3px solid var(--success);
    padding: 0.4rem 0.85rem;
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.course-status-waiting {
    background-color: var(--bg-app);
    color: var(--text-muted);
    padding: 0.75rem;
    border-radius: 6px;
    text-align: center;
    font-size: 0.875rem;
    font-style: italic;
}

.empty-state-placeholder {
    grid-column: 1 / -1;
    text-align: center;
    padding: 1.5rem 1rem;
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-lg);
    color: var(--text-muted);
    background-color: white;
    margin-top: 0.5rem;
}

.empty-state-inline {
    color: var(--text-muted);
    margin: 0;
    padding: 0;
}

.empty-state-inline p {
    margin: 0;
}

@media (min-width: 768px) {
    .empty-state-placeholder {
        padding: 3rem;
    }
}

/* --- AI Reflection Chat --- */
.reflection-page {
    max-width: 900px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.reflection-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.reflection-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.reflection-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
    margin: 0 0 0.35rem 0;
}

.reflection-subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin: 0;
}

.reflection-badge {
    background-color: var(--success-bg);
    color: var(--success);
    border: 1px solid var(--success-border);
    padding: 0.35rem 0.75rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.reflection-chat {
    background-color: var(--bg-app);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1rem;
    overflow: hidden;
}

.reflection-page .reflection-chat {
    min-height: 28rem;
    height: 28rem;
}

.reflection-history {
    height: 100%;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding-right: 0.25rem;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.reflection-history::-webkit-scrollbar {
    width: 0;
    height: 0;
}

.reflection-message {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    max-width: 80%;
    animation: reflectionFade 0.2s ease-out;
}

.reflection-message-user {
    align-self: flex-end;
    align-items: flex-end;
}

.reflection-message-ai {
    align-self: flex-start;
    align-items: flex-start;
}

.reflection-bubble {
    padding: 0.75rem 1rem;
    border-radius: 14px;
    font-size: 0.95rem;
    line-height: 1.5;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.reflection-bubble p {
    margin: 0;
}

.reflection-message-user .reflection-bubble {
    background-color: var(--primary);
    color: white;
    border-color: var(--primary);
    border-bottom-right-radius: 4px;
}

.reflection-message-ai .reflection-bubble {
    border-bottom-left-radius: 4px;
}

.reflection-sender {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.reflection-time {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.reflection-composer {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.reflection-composer .form-input {
    flex: 1;
}

.reflection-composer .reflection-input {
    min-height: 48px;
    height: 48px;
    resize: none;
    overflow: hidden;
    padding-top: 0.6rem;
    padding-bottom: 0.6rem;
    font-family: inherit;
    font-size: 1rem;
}

.reflection-send-btn {
    height: 48px;
    padding: 0 20px;
    border-radius: 999px;
    background-color: var(--primary);
    color: white;
    border: none;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.reflection-send-btn:hover {
    background-color: var(--primary-hover);
}

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

.reflection-typing {
    display: flex;
    gap: 4px;
    align-items: center;
    padding: 0.6rem 0.85rem;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    border-bottom-left-radius: 4px;
    width: fit-content;
}

.reflection-typing span {
    width: 8px;
    height: 8px;
    background-color: var(--text-muted);
    border-radius: 50%;
    display: inline-block;
    animation: reflectionTyping 1.4s infinite ease-in-out both;
}

.reflection-typing span:nth-child(1) { animation-delay: -0.32s; }
.reflection-typing span:nth-child(2) { animation-delay: -0.16s; }

@keyframes reflectionTyping {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

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

/* --- Messages & Alerts (Toast Notifications) --- */
.messages-container {
    position: fixed;
    top: 4rem;
    right: 1rem;
    z-index: 9999;
    max-width: min(400px, calc(100vw - 2rem));
    pointer-events: none;
}

@media (max-width: 640px) {
    .messages-container {
        left: 1rem;
        right: 1rem;
        max-width: none;
    }
}

.message-alert {
    pointer-events: auto;
    padding: 1rem 1.25rem;
    border-radius: var(--radius-md);
    margin-bottom: 0.75rem;
    border: 1px solid;
    font-size: 0.9375rem;
    animation: toastSlideIn 0.3s ease-out;
    position: relative;
    overflow: hidden;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    backdrop-filter: blur(10px);
}

@keyframes toastSlideIn {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideUp {
    from {
        opacity: 1;
        transform: translateX(0);
        max-height: 100px;
    }
    to {
        opacity: 0;
        transform: translateX(100%);
        max-height: 0;
        margin-bottom: 0;
        padding-top: 0;
        padding-bottom: 0;
    }
}

.message-content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.message-icon {
    font-size: 1.125rem;
    flex-shrink: 0;
}

.message-text {
    flex: 1;
    line-height: 1.5;
}

.message-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.2s;
    padding: 0;
    margin-left: 0.5rem;
    color: inherit;
    flex-shrink: 0;
}

.message-close:hover {
    opacity: 1;
}

.message-timer-bar {
    position: absolute;
    top: 0;
    left: 0;
    height: 4px;
    width: 100%;
    background-color: currentColor;
    opacity: 0.5;
    transform-origin: left;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
}

/* --- Inline Alerts --- */
.alert {
    padding: 1rem 1.25rem;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    margin-bottom: 1.5rem;
}

.alert-info {
    background-color: var(--info-bg);
    border-color: var(--info-border);
    color: var(--info-text);
}

.alert-success {
    background-color: var(--success-bg);
    border-color: var(--success-border);
    color: var(--success);
}

.alert-warning {
    background-color: var(--warning-bg);
    border-color: var(--warning-border);
    color: var(--warning-text);
}

.alert-danger {
    background-color: var(--danger-bg);
    border-color: var(--danger-border);
    color: var(--danger-text);
}

@keyframes shrinkTimer {
    from {
        transform: scaleX(1);
    }
    to {
        transform: scaleX(0);
    }
}

/* Message Types */
.message-error,
.message-danger {
    background-color: var(--danger-bg);
    border-color: var(--danger-border);
    color: var(--danger-text);
}

.message-success {
    background-color: var(--success-bg);
    border-color: var(--success-border);
    color: var(--success);
}

.message-info {
    background-color: var(--info-bg);
    border-color: var(--info-border);
    color: var(--info-text);
}

.message-warning {
    background-color: var(--warning-bg);
    border-color: var(--warning-border);
    color: var(--warning-text);
}

/* --- Confirm Modal (native <dialog>) --- */
dialog.confirm-dialog {
    border: none;
    border-radius: var(--radius-lg);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.22);
    padding: 2rem;
    max-width: 420px;
    width: 100%;
    background: var(--bg-card);
}

dialog.confirm-dialog::backdrop {
    background-color: rgba(0, 0, 0, 0.45);
}

.modal-title {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--text-main);
    margin: 0 0 0.625rem;
}

.modal-body {
    font-size: 0.9375rem;
    color: var(--text-muted);
    line-height: 1.6;
    margin: 0 0 1.5rem;
}

.modal-actions {
    display: flex;
    gap: 1rem;
    margin-top: 0.5rem;
}

.modal-actions form {
    flex: 1;
}

/* --- App Exercise Components --- */
.progress-bar-container {
    margin-bottom: 1.5rem;
}

.progress-bar-labels {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.progress-bar-text-main {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
}

.progress-bar-text-accent {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--primary);
}

.progress-bar-track {
    width: 100%;
    background-color: var(--border-color);
    border-radius: 999px;
    height: 10px;
    overflow: hidden;
}

.progress-bar-fill {
    background-color: var(--primary);
    height: 100%;
    border-radius: 999px;
    transition: width 0.3s ease-out;
    width: var(--progress, 0%);
}

.exercise-question-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 1.5rem;
}

.argument-box {
    background-color: var(--bg-app);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
    padding-left: 1.5rem;
    padding-right: 1.5rem;
}

.options-grid {
    display: grid;
    gap: 1rem;
}

.option-btn {
    text-align: left;
    justify-content: flex-start;
    padding: 1rem 1.5rem;
    height: auto;
    font-weight: 500;
}

.option-btn:hover {
    background-color: var(--info-bg);
    border-color: var(--primary);
    color: var(--primary);
}

.choice-card-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.75rem;
}

.choice-card-grid-4 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
}

.choice-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    cursor: pointer;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    padding: 0.75rem 0.5rem;
    background-color: var(--white);
    text-align: center;
    min-height: 48px;
}

.choice-card:hover {
    background-color: var(--bg-app);
    border-color: var(--primary);
}

.choice-card:has(input[type="radio"]:checked) {
    background-color: var(--info-bg);
    border-color: var(--primary);
    color: var(--info-text);
}

.choice-card input[type="radio"] {
    width: 1.15rem;
    height: 1.15rem;
    cursor: pointer;
    accent-color: var(--primary);
}

.choice-card-caption {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.choice-card-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-main);
}

@media (min-width: 768px) {
    .choice-card-grid-4 {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 640px) {
    .choice-card-grid {
        grid-template-columns: repeat(5, minmax(0, 1fr));
        gap: 0.35rem;
    }

    .choice-card {
        padding: 0.5rem 0.2rem;
    }

    .choice-card-value {
        font-size: 1rem;
    }

    .choice-card-caption {
        font-size: 0.65rem;
        line-height: 1.2;
    }
}

.exercise-result-card {
    padding: 1.5rem;
    background-color: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    margin-bottom: 2rem;
}

.exercise-result-title {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 1rem;
}

/* --- Facilitator Results Components --- */
.facilitator-results-container {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.question-result-card {
    padding: 2rem;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
}

.question-result-header {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 2rem;
}

.question-number-badge {
    flex-shrink: 0;
    width: 2.5rem;
    height: 2.5rem;
    background-color: var(--info-bg);
    color: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

.question-result-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-main);
    margin: 0;
    padding-top: 0.25rem;
}

.results-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
}

@media (min-width: 1024px) {
    .results-grid {
        grid-template-columns: 1fr 1fr;
    }
}

.chart-container {
    display: flex;
    justify-content: center;
    align-items: center;
}

.chart-container img {
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.chart-img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-md);
}

@media (max-width: 640px) {
    .chart-narrow-hide {
        display: none;
    }

    .table-narrow-hide {
        display: none;
    }
}

.data-column {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.choice-result-row {
    margin-bottom: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.choice-info {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.75rem;
}

.choice-label {
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.25rem 0.5rem;
    background-color: var(--info-bg);
    color: var(--primary);
    border-radius: 999px;
}

.choice-stats {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-muted);
}

/* --- Table Components --- */
.course-table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
}

.course-table th {
    background-color: var(--bg-app);
    color: var(--text-main);
    font-weight: 600;
    text-align: left;
    padding: 0.75rem 1rem;
    border-bottom: 2px solid var(--border-color);
}

.course-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-muted);
}

.course-table tr:hover {
    background-color: var(--bg-app);
}

.table-wrapper .course-table {
    width: 100%;
    margin: 0;
}

.table-wrapper .course-table th,
.table-wrapper .course-table td {
    white-space: nowrap;
}

.table-wrapper .course-table td.text-muted,
.table-wrapper .course-table td.text-center.text-muted,
.table-wrapper .course-table .table-cell-wrap {
    white-space: normal;
    overflow-wrap: break-word;
    vertical-align: top;
}

.table-wrapper.table-fit .course-table {
    table-layout: fixed;
    width: 100%;
}

.table-wrapper.table-fit .course-table th,
.table-wrapper.table-fit .course-table td {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
}

.table-wrapper.table-fit .course-table th:not(.table-cell-wrap),
.table-wrapper.table-fit .course-table td:not(.table-cell-wrap) {
    width: 12%;
    white-space: nowrap;
    overflow-wrap: normal;
    word-break: normal;
    hyphens: none;
}

.table-wrapper.table-fit .course-table th:not(.table-cell-wrap) {
    font-size: 0.8125rem;
}

.table-wrapper.table-fit .course-table .table-cell-wrap {
    width: 40%;
    min-width: 0;
    max-width: none;
    white-space: normal;
    overflow-wrap: break-word;
    word-break: break-word;
    vertical-align: top;
}

.table-wrapper.table-fit-prose .course-table {
    table-layout: fixed;
    width: 100%;
}

.table-wrapper.table-fit-prose .course-table th,
.table-wrapper.table-fit-prose .course-table td {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
}

.table-wrapper.table-fit-prose .course-table th:not(.table-cell-wrap),
.table-wrapper.table-fit-prose .course-table td:not(.table-cell-wrap) {
    width: 12%;
    white-space: nowrap;
    overflow-wrap: normal;
    word-break: normal;
    hyphens: none;
}

.table-wrapper.table-fit-prose .course-table th:not(.table-cell-wrap) {
    font-size: 0.8125rem;
}

.table-wrapper.table-fit-prose .course-table .table-cell-wrap {
    width: auto;
    min-width: 0;
    max-width: none;
    white-space: normal;
    overflow-wrap: break-word;
    word-break: break-word;
    vertical-align: top;
}

.table-wrapper .status-pill {
    white-space: nowrap;
    word-break: normal;
}

/* --- Layout Utilities --- */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-1 { flex: 1; }
.flex-2 { flex: 2; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.flex-shrink-0 { flex-shrink: 0; }
.flex-wrap { flex-wrap: wrap; }
.items-stretch { align-items: stretch; }
.gap-2 { gap: 0.5rem; }
.gap-4 { gap: 1rem; }
.gap-6 { gap: 1.5rem; }
.gap-8 { gap: 2rem; }
.mt-0 { margin-top: 0 !important; }
.mt-2 { margin-top: 0.5rem !important; }
.mt-4 { margin-top: 1rem !important; }
.mt-6 { margin-top: 1.5rem !important; }
.mt-8 { margin-top: 2rem !important; }
.mt-10 { margin-top: 2.5rem !important; }
.mb-0 { margin-bottom: 0 !important; }
.mb-1 { margin-bottom: 0.25rem !important; }
.mb-2 { margin-bottom: 0.5rem !important; }
.mb-3 { margin-bottom: 0.75rem !important; }
.mb-4 { margin-bottom: 1rem !important; }
.mb-6 { margin-bottom: 1.5rem !important; }
.mb-8 { margin-bottom: 2rem !important; }
.mt-8 { margin-top: 2rem !important; }
.px-6 { padding-left: 1.5rem; padding-right: 1.5rem; }
.p-0 { padding: 0 !important; }
.p-2 { padding: 0.5rem !important; }
.p-4 { padding: 1rem !important; }
.p-6 { padding: 1.5rem !important; }
.p-8 { padding: 2rem !important; }
.ml-2 { margin-left: 0.5rem; }
.w-auto { width: auto !important; }
.w-full { width: 100%; }
.italic { font-style: italic; }
.text-center { text-align: center !important; }
.text-lg { font-size: 1.125rem; }
.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.leading-relaxed { line-height: 1.6; }
.hidden { display: none; }

.text-success { color: var(--success-medium); }
.text-warning { color: var(--warning-text); }
.text-danger { color: var(--danger); }
.border-danger { border-color: var(--danger); }
.form-input.border-danger:focus {
    border-color: var(--danger);
    box-shadow: 0 0 0 4px rgba(185, 28, 28, 0.15);
}
.text-muted { color: var(--text-muted); }
.bg-success { background-color: var(--success-medium); }
.bg-success-light { background-color: var(--success-bg); }
.bg-warning { background-color: #f59e0b; }
.bg-warning-light { background-color: var(--warning-bg); }
.bg-danger { background-color: var(--danger); }
.bg-danger-light { background-color: var(--danger-bg); }
.bg-info-light { background-color: var(--info-bg); }
.border-l-4 { border-left-width: 4px; border-left-style: solid; padding-left: 1rem; }
.border-l-success { border-left-color: var(--success-medium); }
.border-l-danger { border-left-color: var(--danger); }
.border-l-muted { border-left-color: var(--border-color); }


/* --- Animations --- */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}
.animate-pulse {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* --- Completion States --- */
.completion-container {
    text-align: center;
    padding: 3rem 1rem;
}

.success-icon-container {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 4rem;
    height: 4rem;
    background-color: var(--success-bg);
    color: var(--success);
    border-radius: 50%;
}

.completion-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 0.5rem;
}

.completion-text {
    color: var(--text-muted);
    margin-bottom: 2rem;
}

/* --- Document + rating split (case text beside sliders) --- */
.document-split-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
    margin-top: 1.5rem;
}

@media (min-width: 1024px) {
    .document-split-layout {
        grid-template-columns: 1fr 400px;
        grid-template-rows: minmax(0, 1fr);
        align-items: stretch;
        min-height: 0;
        height: 100%;
    }

    .document-split-layout .document-panel {
        display: flex;
        flex-direction: column;
        min-height: 0;
        height: 100%;
        overflow: hidden;
        padding: 1.5rem;
    }

    .document-split-layout .document-body {
        overflow-y: scroll;
        min-height: 0;
        flex: 1;
        padding-inline-end: 1rem;
        scrollbar-gutter: stable;
    }

    .document-split-layout .document-body::-webkit-scrollbar {
        width: 10px;
    }

    .document-split-layout .document-body::-webkit-scrollbar-thumb {
        background-color: var(--border-color);
        border-radius: 8px;
    }

    .document-split-layout .rating-panel {
        display: flex;
        flex-direction: column;
        padding: 1.5rem;
        min-height: 0;
        height: 100%;
    }

    .document-split-layout .range-slider-stack {
        flex: 1 1 auto;
        justify-content: space-evenly;
    }
}

.document-split-equal {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}

.viewport-workspace {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.viewport-workspace > [hx-ext="sse"],
.viewport-workspace [id$="session-status"] {
    display: contents;
}

.viewport-workspace > [id$="-broadcast"] {
    display: contents;
}

.split-view-tabs {
    flex-shrink: 0;
    margin-bottom: 0;
}

.document-split-equal .document-panel,
.document-split-equal .chat-panel {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.document-split-equal .document-panel {
    overflow: hidden;
    padding: 1.5rem;
    gap: 1.5rem;
}

.document-split-equal .card-header {
    flex-shrink: 0;
    padding: 0 0 0.75rem;
}

.document-split-equal .document-body {
    overflow-y: scroll;
    min-height: 0;
    flex: 1;
    padding: 0;
    padding-block-start: 0.25rem;
    padding-inline-end: 1rem;
    scrollbar-gutter: stable;
}

.document-split-equal .document-body::-webkit-scrollbar {
    width: 10px;
}

.document-split-equal .document-body::-webkit-scrollbar-thumb {
    background-color: var(--border-color);
    border-radius: 8px;
}

.document-split-equal .chat-panel {
    min-width: 0;
}

.document-split-equal .chat-embed-frame {
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

@media (min-width: 1024px) {
    body:has(.viewport-workspace) {
        height: 100dvh;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    body:has(.viewport-workspace) .header,
    body:has(.viewport-workspace) .header + .container {
        flex-shrink: 0;
    }

    body:has(.viewport-workspace) main.container {
        flex: 1 1 auto;
        min-height: 0;
        display: flex;
        flex-direction: column;
        padding-bottom: 0;
        overflow: hidden;
    }

    body:has(.viewport-workspace) > [hx-ext="sse"] {
        flex: 0 0 0;
        width: 0;
        height: 0;
        overflow: hidden;
    }

    .viewport-workspace {
        flex: 1 1 auto;
        min-height: 0;
        padding-bottom: 1.5rem;
        box-sizing: border-box;
    }

    .viewport-workspace > .course-card {
        flex: 0 0 auto;
        margin-bottom: 0;
    }

    body:has(.viewport-workspace) .results-shell {
        flex: 1 1 auto;
        min-height: 0;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    body:has(.viewport-workspace) .results-shell-header {
        flex-shrink: 0;
    }

    body:has(.viewport-workspace) .results-shell > .viewport-workspace {
        flex: 1 1 auto;
        min-height: 0;
    }

    .viewport-workspace > .course-card:has(.document-split-layout) {
        flex: 1 1 auto;
        min-height: 0;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    .viewport-workspace > .document-split-equal {
        flex: 1 1 auto;
        min-height: 0;
    }

    .tab-bar.split-view-tabs {
        display: none;
    }

    .document-split-equal [data-split-panel] {
        display: flex;
    }

    .viewport-workspace .document-split-layout {
        flex: 1 1 auto;
        min-height: 0;
    }

    .document-split-equal {
        grid-template-columns: 1fr 1fr;
        grid-template-rows: minmax(0, 1fr);
        align-items: stretch;
        min-height: 0;
        height: 100%;
    }

    .document-split-equal .document-panel,
    .document-split-equal .chat-panel {
        overflow: hidden;
        min-height: 0;
        height: 100%;
        max-height: none;
    }

    .document-split-equal .chat-embed-frame {
        flex: 1;
        min-height: 0;
        max-height: none;
        height: 100%;
    }

    .document-split-equal.document-split-stack {
        grid-template-columns: 1fr;
        grid-template-rows: auto minmax(0, 1fr);
    }

    .document-split-equal.document-split-stack > .document-panel {
        height: auto;
        overflow: visible;
    }

    .document-split-equal.document-split-stack > .document-panel > .card-title {
        margin: 0;
    }

    .document-split-equal.document-split-stack .document-body {
        overflow: visible;
        flex: 0 0 auto;
        min-height: 0;
        padding-inline-end: 0;
        scrollbar-gutter: auto;
    }

    .document-split-equal.document-split-stack > .chat-panel {
        min-height: 0;
        overflow: hidden;
    }
}

@media (max-width: 1023px) {
    body:has(.document-split-equal) {
        height: 100dvh;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    body:has(.document-split-equal) .header,
    body:has(.document-split-equal) .header + .container {
        flex-shrink: 0;
    }

    body:has(.document-split-equal) main.container {
        flex: 1 1 0;
        min-height: 0;
        display: flex;
        flex-direction: column;
        padding-bottom: 0;
        overflow: hidden;
    }

    body:has(.document-split-equal) > [hx-ext="sse"] {
        flex: 0 0 0;
        width: 0;
        height: 0;
        overflow: hidden;
    }

    body:has(.document-split-equal) .viewport-workspace {
        flex: 1 1 0;
        min-height: 0;
        gap: 0.75rem;
        padding-bottom: 1.5rem;
        box-sizing: border-box;
    }

    body:has(.document-split-equal) .results-shell {
        flex: 1 1 0;
        min-height: 0;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        max-width: none;
        width: 100%;
    }

    body:has(.document-split-equal) .results-shell-header {
        flex-shrink: 0;
    }

    body:has(.document-split-equal) .results-shell > .viewport-workspace {
        flex: 1 1 0;
        min-height: 0;
    }

    .split-view-tabs .tab-bar-link {
        padding: 0.35rem 0.85rem;
    }

    .document-split-equal {
        flex: 1 1 0;
        min-height: 0;
        grid-template-rows: minmax(0, 1fr);
    }

    .document-split-equal [data-split-panel] {
        display: none;
    }

    .document-split-equal [data-split-panel].is-active {
        display: flex;
        min-height: 0;
        height: 100%;
        overflow: hidden;
        max-height: none;
    }

    .document-split-equal .chat-embed-frame {
        flex: 1;
        min-height: 0;
        height: 100%;
        max-height: none;
    }

    .document-split-equal.document-split-stack [data-split-panel="deal"].is-active {
        height: auto;
        max-height: 100%;
        overflow: auto;
    }

    .document-split-equal.document-split-stack [data-split-panel="deal"].is-active .document-body {
        overflow: visible;
        flex: 0 0 auto;
        min-height: 0;
        padding-inline-end: 0;
        scrollbar-gutter: auto;
    }
}

.chat-panel {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.document-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
}

.document-panel > h3 {
    margin: 0 0 1rem 0;
}

.document-body {
    font-size: 1.1rem;
    line-height: 1.65;
    color: var(--text-main);
}

.document-body p {
    margin: 0 0 0.75rem 0;
}

.document-body p:last-child {
    margin-bottom: 0;
}

.document-headline {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1.35;
    margin: 0 0 0.5rem 0;
}

.rating-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
}

.range-slider-stack {
    min-height: 0;
}

.range-slider-label-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.range-slider-label-row label {
    font-weight: 600;
    color: var(--text-main);
}

.range-slider-badge {
    background: var(--info-bg);
    color: var(--info-text);
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 700;
    font-size: 0.9rem;
}

.range-slider,
.eq-custom-slider {
    width: 100%;
    height: 6px;
    background: var(--border-color);
    border-radius: 3px;
    outline: none;
    appearance: none;
}

.range-slider::-webkit-slider-thumb,
.eq-custom-slider::-webkit-slider-thumb {
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    transition: transform 0.1s;
}

.range-slider::-webkit-slider-thumb:hover,
.eq-custom-slider::-webkit-slider-thumb:hover {
    transform: scale(1.1);
}

.range-slider::-moz-range-thumb,
.eq-custom-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    border: none;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.decision-agenda-evaluation {
    max-width: 840px;
    margin-inline: auto;
}

.decision-agenda-evaluation-item {
    margin-bottom: 1.5rem;
}

.decision-agenda-evaluation-item details {
    margin-bottom: 1.5rem;
    color: var(--text-muted);
}

.decision-agenda-rating-unrated {
    opacity: 0.45;
    filter: grayscale(1);
}

.decision-agenda-rating-endpoints {
    gap: 1rem;
}

.decision-agenda-rating-endpoints span:last-child {
    text-align: right;
}

.decision-agenda-evaluation-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

.decision-agenda-evaluation-actions > * {
    flex: 1 1 12rem;
}

.decision-agenda-results-list {
    margin-bottom: 1.5rem;
}

.decision-agenda-results-list-header {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
    justify-content: space-between;
}

.decision-agenda-results-list-header h2 {
    margin: 0;
}

.decision-agenda-results-table-wrapper {
    margin-top: 0.75rem;
}

.decision-agenda-results-table {
    min-width: 48rem;
}

.decision-agenda-results-table th,
.decision-agenda-results-table td {
    vertical-align: top;
}

.decision-agenda-results-table tbody th {
    min-width: 11rem;
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-main);
    text-align: left;
}

.decision-agenda-results-table tbody tr:last-child th {
    border-bottom: 0;
}

.decision-agenda-results-table td:nth-child(2) {
    min-width: 18rem;
    overflow-wrap: anywhere;
}

.decision-agenda-result-rating {
    min-width: 6rem;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.decision-agenda-chart-enlarge,
.decision-agenda-chart-enlarge img {
    display: block;
    width: 100%;
    max-width: 100%;
}

.decision-agenda-chart-enlarge img {
    height: auto;
    object-fit: contain;
}

.decision-agenda-result-item {
    margin-bottom: 1rem;
    padding: 1rem;
    gap: 0.5rem;
}

.decision-agenda-result-item h3 {
    margin: 0;
}

.decision-agenda-result-ratings {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
    gap: 0.625rem;
    margin: 0.25rem 0;
}

.decision-agenda-result-score {
    min-width: 0;
    padding: 0.625rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-app);
}

.decision-agenda-result-score dt {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.025em;
}

.decision-agenda-result-score dd {
    margin: 0.1rem 0 0.35rem;
    color: var(--text-main);
    font-variant-numeric: tabular-nums;
    line-height: 1;
}

.decision-agenda-result-score dd strong {
    font-size: 1.25rem;
}

.decision-agenda-result-score dd span {
    margin-left: 0.15rem;
    color: var(--text-muted);
    font-size: 0.75rem;
}

.decision-agenda-result-score progress {
    display: block;
    width: 100%;
    height: 0.375rem;
    overflow: hidden;
    border: 0;
    border-radius: 999px;
    background: var(--border-color);
    appearance: none;
}

.decision-agenda-result-score progress::-webkit-progress-bar {
    border-radius: 999px;
    background: var(--border-color);
}

.decision-agenda-result-score progress::-webkit-progress-value {
    border-radius: 999px;
    background: currentColor;
}

.decision-agenda-result-score progress::-moz-progress-bar {
    border-radius: 999px;
    background: currentColor;
}

.decision-agenda-result-score-urgency,
.decision-agenda-result-score-urgency progress {
    color: var(--primary);
}

.decision-agenda-result-score-importance,
.decision-agenda-result-score-importance progress {
    color: var(--success-medium);
}

.decision-agenda-result-score-complexity,
.decision-agenda-result-score-complexity progress {
    color: var(--warning-text);
}

.decision-agenda-result-description {
    margin-top: 0.125rem;
    border-top: 1px solid var(--border-color);
}

.decision-agenda-result-description summary {
    display: flex;
    gap: 0.35rem;
    align-items: center;
    width: max-content;
    padding-top: 0.5rem;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    list-style: none;
}

.decision-agenda-result-description summary::-webkit-details-marker {
    display: none;
}

.decision-agenda-result-description summary::after {
    content: "⌄";
    transition: transform 0.15s ease;
}

.decision-agenda-result-description[open] summary::after {
    transform: rotate(180deg);
}

.decision-agenda-result-description p {
    margin: 0.5rem 0 0;
    color: var(--text-muted);
    font-size: 0.9rem;
}
/* Added for integrative_negotiation */
.mb-8 { margin-bottom: 2rem; }
.mb-6 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 1rem; }
.mt-12 { margin-top: 3rem; }
.mt-6 { margin-top: 1.5rem; }
.mt-4 { margin-top: 1rem; }
.mt-2 { margin-top: 0.5rem; }
.ml-6 { margin-left: 1.5rem; }
.ml-2 { margin-left: 0.5rem; }
.m-0 { margin: 0; }
.bg-app { background: var(--bg-app); }
.bg-primary { background: var(--primary); }
.text-center { text-align: center; }
.text-primary { color: var(--primary); }
.text-danger { color: var(--danger); }
.text-muted { color: var(--text-muted); }
.text-white { color: white; }
.flex-row-center { display: flex; gap: 1rem; align-items: center; margin-top: 1rem; }
.flex-1 { flex: 1; }
.flex-2 { flex: 2; }
.w-auto { width: auto; }
.hidden { display: none; }
.flex-gap-4 { display: flex; gap: 1rem; }
.flex-gap-4-mt-6 { display: flex; gap: 1rem; margin-top: 1.5rem; }
.flex-gap-4-mb-6 { display: flex; gap: 1rem; margin-bottom: 1.5rem; }
.text-sm { font-size: 0.9rem; }
.text-xs { font-size: 0.8em; }
.py-1-px-2 { padding: 2px 6px; }
.block { display: block; }
.font-semibold { font-weight: 600; }
.italic { font-style: italic; }
.grid-auto-fit { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1rem; }
.grid-auto-fit-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
@media (max-width: 640px) {
    .grid-auto-fit-3 { grid-template-columns: 1fr; }
}
.inline { display: inline; }

.htmx-indicator {
    display: none;
}
.htmx-request.htmx-indicator,
.htmx-request .htmx-indicator {
    display: block;
}

.contents-split {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
    align-items: start;
}
@media (min-width: 1024px) {
    .contents-split {
        grid-template-columns: 16rem 1fr;
    }
    .contents-split > nav {
        position: sticky;
        top: 1rem;
    }
}
.contents-nav {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.contents-nav a {
    color: var(--primary);
    text-decoration: none;
}
.contents-nav a:hover {
    text-decoration: underline;
}

/* --- Data Table Styles --- */
.table-wrapper {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
}

@media (max-width: 768px) {
    .table-wrapper {
        scrollbar-gutter: stable;
        background:
            linear-gradient(to right, var(--bg-card), var(--bg-card)),
            linear-gradient(to right, var(--bg-card), var(--bg-card)),
            linear-gradient(to right, rgba(0, 0, 0, 0.08), transparent),
            linear-gradient(to left, rgba(0, 0, 0, 0.08), transparent);
        background-position: left center, right center, left center, right center;
        background-repeat: no-repeat;
        background-size: 1.5rem 100%, 1.5rem 100%, 0.75rem 100%, 0.75rem 100%;
        background-attachment: local, local, scroll, scroll;
    }
}

.table-wrapper::-webkit-scrollbar {
    height: 8px;
}

.table-wrapper::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 999px;
}
.data-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.95rem;
}
.data-table th {
    background-color: var(--bg-app);
    color: var(--text-muted);
    font-weight: 600;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
}
.data-table td {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-main);
    vertical-align: middle;
}
.data-table tr:last-child td {
    border-bottom: none;
}
.data-table tr:hover {
    background-color: rgba(0, 0, 0, 0.02);
}
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-col { display: flex; flex-direction: column; }
.border-b { border-bottom: 1px solid var(--border-color); }
.pb-2 { padding-bottom: 0.5rem; }
.gap-2 { gap: 0.5rem; }

/* --- 2 Column Grid --- */
.grid-2-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}
@media (max-width: 768px) {
    .grid-2-col {
        grid-template-columns: 1fr;
    }
}
.justify-center { justify-content: center; }
.items-center { align-items: center; }
.items-end { align-items: flex-end; }
.overflow-x-auto {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-gutter: stable;
}

.result-stack {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.chart-narrow-only {
    display: none;
}

@media (max-width: 640px) {
    .chart-narrow-only {
        display: flex;
        flex-direction: column;
        gap: 0.75rem;
    }
}

.result-stack-item {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.result-stack-item:last-child {
    padding-bottom: 0;
    border-bottom: none;
}

/* Seed HTML tables (role briefs, case copy) */
.rich-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
    font-size: 0.9rem;
}
.rich-content th,
.rich-content td {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color);
    text-align: left;
}
.rich-content th {
    background-color: var(--bg-app);
    font-weight: 700;
    color: var(--text-main);
}

/* Compact outcome tiles (equity split, similar stats) */
.stat-box {
    padding: 1rem;
    background-color: var(--bg-app);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    text-align: center;
}
.stat-box-start {
    text-align: left;
}
.stat-box-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 0.25rem;
}
.stat-box-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-main);
}

/* Group / set switcher (wraps on 390px) */
.tab-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}
.tab-bar-link {
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background-color: var(--white);
    color: var(--text-main);
    font-weight: 600;
    text-decoration: none;
}
.tab-bar-link:hover {
    background-color: var(--bg-app);
}
.tab-bar-link-active {
    background-color: var(--primary);
    color: var(--white);
    border-color: var(--primary);
}

/* Chat embed: fills width, does not clip on 390px */
.chat-embed-frame {
    min-height: 28rem;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.chat-embed-frame > .reflection-card {
    flex: 1;
    min-height: 0;
    height: 100%;
    margin: 0;
}

.chat-embed-frame .reflection-header {
    flex-shrink: 0;
    padding-bottom: 0.75rem;
}

.chat-embed-frame .reflection-title {
    font-size: 1.25rem;
}

.chat-embed-frame .reflection-subtitle {
    font-size: 0.9rem;
}

.chat-embed-frame .reflection-chat {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-embed-frame .reflection-history {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    scrollbar-width: thin;
    padding-right: 0.5rem;
    scrollbar-gutter: stable;
}

.chat-embed-frame .reflection-history::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.chat-embed-frame .reflection-composer {
    flex-shrink: 0;
}

/* Pairing / assignment boards */
.pairing-board {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}
.pairing-board .card-title {
    margin-bottom: 0.75rem;
}
.pairing-pool {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    min-height: 4rem;
    padding: 1rem;
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-app);
}
.pairing-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
.pairing-slot {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-app);
    min-height: 4.5rem;
}
.pairing-slot.is-drop-target {
    border-color: var(--primary);
    background: var(--info-bg);
}
.pairing-slot-body {
    flex: 1;
}
.pairing-person {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.75rem;
}
.pairing-person[draggable="true"] {
    cursor: grab;
}
.pairing-person.is-dragging,
.sortable-item.is-dragging {
    opacity: 0.5;
}
.role-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.5rem;
    height: 1.5rem;
    padding: 0 0.4rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
    background: var(--bg-app);
    color: var(--text-main);
}
.role-badge-a {
    background: var(--info-bg);
    color: var(--info-text);
}
.role-badge-b {
    background: var(--primary);
    color: var(--white);
}

/* Goal list / ranking */
.goal-item {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    align-items: flex-start;
}
.goal-item .form-textarea {
    flex: 1 1 12rem;
    min-width: 0;
}
.sortable-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-card);
    cursor: grab;
    touch-action: none;
    user-select: none;
}
.sortable-item.is-drop-target {
    border-color: var(--primary);
}

/* Issue sliders */
.issue-slider-labels {
    display: flex;
    justify-content: space-between;
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-top: 0.35rem;
}
.issue-slider-value {
    font-weight: 700;
    margin: 0 0 0.35rem;
}

/* In-page tab panels */
.tab-panel {
    display: none;
}
.tab-panel.is-active {
    display: block;
}

/* Scatter / Pareto plot */
.scatter-plot {
    width: 100%;
    max-width: 40rem;
    height: auto;
    display: block;
    margin: 0 auto;
}
.scatter-plot-tick,
.scatter-plot-label {
    fill: var(--text-muted);
    font-size: 12px;
}
.chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
}
.chart-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}
.chart-swatch {
    width: 0.75rem;
    height: 0.75rem;
    border-radius: 2px;
    display: inline-block;
}
.chart-swatch-a {
    background: var(--info-text);
}
.chart-swatch-b {
    background: var(--primary);
}
.chart-swatch-missed {
    background: var(--border-color);
}
.analytics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
    gap: 1.5rem;
}
