/* Material Design 3 (M3) System Theme - Palatinate Edition */
:root {
    color-scheme: light dark;

    /* Light Theme Tokens (Default) */
    --md-sys-color-primary: #68246D;
    --md-sys-color-on-primary: #FFFFFF;
    --md-sys-color-primary-container: #FBD7FC;
    --md-sys-color-on-primary-container: #2A0033;
    --md-sys-color-surface: #FDF7FD;
    --md-sys-color-on-surface: #1E1A1E;
    --md-sys-color-surface-variant: #EDE0EC;
    --md-sys-color-on-surface-variant: #4D444D;
    --md-sys-color-outline: #7F747E;
    --md-sys-color-outline-variant: #D0C3CF;
    --md-sys-color-background: #FDF7FD;
    --md-sys-color-on-background: #1E1A1E;
    --md-sys-color-surface-container-lowest: #FFFFFF;
    --md-sys-color-surface-container-low: #FBF1FA;
    --md-sys-color-surface-container: #F7EFF7;
    --md-sys-color-surface-container-high: #F2EAF2;
    --md-sys-color-surface-container-highest: #EBE4EB;
    --md-sys-color-error: #BA1A1A;
    --md-sys-color-on-error: #FFFFFF;
    --md-sys-color-error-container: #FFDAD6;
    --md-sys-color-on-error-container: #410002;
    --md-sys-color-success: #1B6D2F;
    --md-sys-color-on-success: #FFFFFF;
    --md-sys-color-success-container: #A4F5A8;
    --md-sys-color-inverse-surface: #332F33;
    --md-sys-color-inverse-on-surface: #F6EEF5;

    /* Brand Palette Token */
    --palavibe-purple: #68246D;

    /* Secondary and Tertiary M3 Tonal Palettes */
    --md-sys-color-secondary: #625b71;
    --md-sys-color-on-secondary: #ffffff;
    --md-sys-color-secondary-container: #e8def8;
    --md-sys-color-on-secondary-container: #1d192b;
    --md-sys-color-tertiary: #7d5260;
    --md-sys-color-on-tertiary: #ffffff;
    --md-sys-color-tertiary-container: #ffd8e4;
    --md-sys-color-on-tertiary-container: #31111d;

    /* Desktop background */
    --md-desktop-bg: #ECE5EC;

    /* Shimmer tokens */
    --skeleton-shimmer-base: #EDE0EC;
    --skeleton-shimmer-highlight: #FBF1FA;

    /* M3 Elevation Shadows */
    --md-elevation-1: 0 1px 3px 1px rgba(0,0,0,0.15), 0 1px 2px 0 rgba(0,0,0,0.30);
    --md-elevation-2: 0 2px 6px 2px rgba(0,0,0,0.15), 0 1px 2px 0 rgba(0,0,0,0.30);
    --md-elevation-3: 0 4px 8px 3px rgba(0,0,0,0.15), 0 1px 3px 0 rgba(0,0,0,0.30);
    --md-elevation-4: 0 8px 24px rgba(0,0,0,0.18);

    /* M3 System Elevation Aliases */
    --md-sys-elevation-1: var(--md-elevation-1);
    --md-sys-elevation-2: var(--md-elevation-2);
    --md-sys-elevation-3: var(--md-elevation-3);
    --md-sys-elevation-4: var(--md-elevation-4);

    /* Shape Radii */
    --md-shape-corner-small: 8px;
    --md-shape-corner-medium: 16px;
    --md-shape-corner-large: 28px;
    --md-shape-corner-extra-large: 28px;
    --md-shape-corner-full: 9999px;
}

/* System Dark Theme Preference */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --md-sys-color-primary: #E8B5ED;
        --md-sys-color-on-primary: #4A0751;
        --md-sys-color-primary-container: #5E1A63;
        --md-sys-color-on-primary-container: #FBD7FC;
        --md-sys-color-surface: #161216;
        --md-sys-color-on-surface: #E8E0E7;
        --md-sys-color-surface-variant: #4D444D;
        --md-sys-color-on-surface-variant: #D0C3CF;
        --md-sys-color-outline: #998D98;
        --md-sys-color-outline-variant: #4D444D;
        --md-sys-color-background: #161216;
        --md-sys-color-on-background: #E8E0E7;
        --md-sys-color-surface-container-lowest: #110E11;
        --md-sys-color-surface-container-low: #1C171D;
        --md-sys-color-surface-container: #221D23;
        --md-sys-color-surface-container-high: #2D272E;
        --md-sys-color-surface-container-highest: #383139;
        --md-sys-color-error: #FFB4AB;
        --md-sys-color-on-error: #690005;
        --md-sys-color-error-container: #93000A;
        --md-sys-color-on-error-container: #FFDAD6;
        --md-sys-color-success: #88D98D;
        --md-sys-color-on-success: #003911;
        --md-sys-color-success-container: #00531D;
        --md-sys-color-inverse-surface: #E8E0E7;
        --md-sys-color-inverse-on-surface: #1E1A1E;

        --palavibe-purple: #E8B5ED;

        --md-sys-color-secondary: #ccc2dc;
        --md-sys-color-on-secondary: #332d41;
        --md-sys-color-secondary-container: #4a4458;
        --md-sys-color-on-secondary-container: #e8def8;
        --md-sys-color-tertiary: #efb8c8;
        --md-sys-color-on-tertiary: #492532;
        --md-sys-color-tertiary-container: #633b48;
        --md-sys-color-on-tertiary-container: #ffd8e4;

        --md-desktop-bg: #0D0A0E;

        --skeleton-shimmer-base: #2D272E;
        --skeleton-shimmer-highlight: #3D353E;
    }
}

/* Explicit Dark Theme */
[data-theme="dark"] {
    color-scheme: dark;
    --md-sys-color-primary: #E8B5ED;
    --md-sys-color-on-primary: #4A0751;
    --md-sys-color-primary-container: #5E1A63;
    --md-sys-color-on-primary-container: #FBD7FC;
    --md-sys-color-surface: #161216;
    --md-sys-color-on-surface: #E8E0E7;
    --md-sys-color-surface-variant: #4D444D;
    --md-sys-color-on-surface-variant: #D0C3CF;
    --md-sys-color-outline: #998D98;
    --md-sys-color-outline-variant: #4D444D;
    --md-sys-color-background: #161216;
    --md-sys-color-on-background: #E8E0E7;
    --md-sys-color-surface-container-lowest: #110E11;
    --md-sys-color-surface-container-low: #1C171D;
    --md-sys-color-surface-container: #221D23;
    --md-sys-color-surface-container-high: #2D272E;
    --md-sys-color-surface-container-highest: #383139;
    --md-sys-color-error: #FFB4AB;
    --md-sys-color-on-error: #690005;
    --md-sys-color-error-container: #93000A;
    --md-sys-color-on-error-container: #FFDAD6;
    --md-sys-color-success: #88D98D;
    --md-sys-color-on-success: #003911;
    --md-sys-color-success-container: #00531D;
    --md-sys-color-inverse-surface: #E8E0E7;
    --md-sys-color-inverse-on-surface: #1E1A1E;

    --palavibe-purple: #E8B5ED;

    --md-sys-color-secondary: #ccc2dc;
    --md-sys-color-on-secondary: #332d41;
    --md-sys-color-secondary-container: #4a4458;
    --md-sys-color-on-secondary-container: #e8def8;
    --md-sys-color-tertiary: #efb8c8;
    --md-sys-color-on-tertiary: #492532;
    --md-sys-color-tertiary-container: #633b48;
    --md-sys-color-on-tertiary-container: #ffd8e4;

    --md-desktop-bg: #0D0A0E;

    --skeleton-shimmer-base: #2D272E;
    --skeleton-shimmer-highlight: #3D353E;
}

[data-theme="light"] {
    color-scheme: light;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
    font-family: Roboto, -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}

body {
    background-color: var(--md-desktop-bg);
    color: var(--md-sys-color-on-background);
    overflow: hidden;
    transition: background-color 0.25s ease, color 0.25s ease;
}

#app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    max-width: 480px;
    margin: 0 auto;
    background: var(--md-sys-color-background);
    box-shadow: 0 0 24px rgba(0, 0, 0, 0.08);
}

/* Material Symbols Font Setup */
@font-face {
    font-family: 'Material Symbols Rounded';
    font-style: normal;
    font-weight: 100 700;
    font-display: block;
    src: url('/fonts/material-symbols-rounded.ttf') format('truetype');
}

.material-symbols-rounded {
    font-family: 'Material Symbols Rounded' !important;
    font-weight: normal;
    font-style: normal;
    font-size: 24px;
    line-height: 1;
    letter-spacing: normal;
    text-transform: none;
    display: inline-block;
    white-space: nowrap;
    word-wrap: normal;
    direction: ltr;
    vertical-align: middle;
    -webkit-font-smoothing: antialiased;
    font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}

/* Top App Bar */
#app-header {
    height: 58px;
    background: var(--md-sys-color-surface);
    color: var(--md-sys-color-on-surface);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    flex-shrink: 0;
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
}

.top-bar-leading {
    display: flex;
    align-items: center;
    gap: 8px;
}

.app-logo-icon {
    color: var(--md-sys-color-primary);
    font-size: 26px;
    font-variation-settings: 'FILL' 1;
}

#app-header h1 {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.2px;
    display: inline-flex;
    align-items: center;
}

/* Insidur Brand Portmanteau Typography */
.brand-insidur {
    display: inline-flex;
    align-items: baseline;
    letter-spacing: -0.01em;
    font-feature-settings: "kern" 1;
    font-family: inherit;
    line-height: 1.1;
}

.brand-insidur .brand-insi {
    color: var(--md-sys-color-primary, #68246D);
    font-weight: 800;
    letter-spacing: -0.02em;
}

.brand-insidur .brand-dur {
    color: #8C5B00; /* WCAG AA high-contrast warm gold/amber against light surfaces (7.2:1 contrast) */
    font-weight: 600;
    letter-spacing: 0.02em;
    margin-left: 1px;
}

/* System Dark Theme Preference */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .brand-insidur .brand-insi {
        color: #F8D3FA;
    }
    :root:not([data-theme="light"]) .brand-insidur .brand-dur {
        color: #FCD867; /* Crisp, high-contrast gold against dark surfaces (12.5:1 contrast) */
    }
}

[data-theme="dark"] .brand-insidur .brand-insi {
    color: #F8D3FA;
}

[data-theme="dark"] .brand-insidur .brand-dur {
    color: #FCD867;
}

.m3-icon-button {
    background: transparent;
    border: none;
    position: relative;
    width: 40px;
    height: 40px;
    border-radius: var(--md-shape-corner-full);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--md-sys-color-on-surface-variant);
    cursor: pointer;
    transition: background 0.2s;
}

.m3-icon-button:hover {
    background: rgba(0, 0, 0, 0.05);
}

/* App Viewport */
#app-viewport {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    position: relative;
}

.view-panel {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

#home-view {
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

#auth-view {
    flex: 1;
    min-height: 0;
    padding: 24px 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

#auth-view .m3-card {
    max-width: 440px;
    width: 100%;
}

.auth-footer-badge {
    margin-top: 24px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--md-sys-color-outline);
    font-size: 0.82rem;
    font-weight: 500;
    opacity: 0.85;
}

.auth-footer-badge .auth-footer-icon {
    font-size: 18px;
    color: var(--md-sys-color-primary);
}

#settings-view {
    flex: 1;
    min-height: 0;
    padding: 20px 16px calc(var(--nav-height, 68px) + 48px);
    overflow-y: auto;
}

/* M3 Elevated Card */
.m3-card.elevated {
    background: var(--md-sys-color-surface-container);
    border-radius: var(--md-shape-corner-large);
    padding: 24px;
    box-shadow: var(--md-elevation-1);
}

.card-icon-header {
    margin-bottom: 14px;
}

.icon-circle {
    background: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
    padding: 12px;
    border-radius: var(--md-shape-corner-medium);
    font-size: 30px;
}

.m3-card h2 {
    font-size: 1.35rem;
    font-weight: 600;
    margin-bottom: 6px;
}

.body-medium {
    font-size: 0.9rem;
    color: var(--md-sys-color-on-surface-variant);
    line-height: 1.4;
    margin-bottom: 20px;
}

/* M3 Outlined Text Field with Floating Labels */
.m3-text-field {
    position: relative;
    margin-top: 18px;
}

.m3-text-field input {
    width: 100%;
    padding: 16px 16px 16px 44px;
    font-size: 1rem;
    color: var(--md-sys-color-on-surface);
    background: transparent;
    border: 1px solid var(--md-sys-color-outline);
    border-radius: var(--md-shape-corner-small);
    outline: none;
    transition: border 0.2s, box-shadow 0.2s;
}

.m3-text-field label {
    position: absolute;
    left: 44px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.95rem;
    color: var(--md-sys-color-outline);
    background: var(--md-sys-color-surface-container);
    padding: 0 4px;
    pointer-events: none;
    transition: 0.2s ease all;
}

.m3-text-field .field-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--md-sys-color-outline);
}

.m3-text-field input:focus,
.m3-text-field input:not(:placeholder-shown) {
    border-color: var(--md-sys-color-primary);
    box-shadow: 0 0 0 1px var(--md-sys-color-primary);
}

.m3-text-field input:focus ~ label,
.m3-text-field input:not(:placeholder-shown) ~ label {
    top: 0;
    transform: translateY(-50%) scale(0.85);
    left: 12px;
    color: var(--md-sys-color-primary);
}

.m3-text-field input:focus ~ .field-icon {
    color: var(--md-sys-color-primary);
}

/* Custom Outlined Select Box */
.m3-select-wrapper {
    margin-top: 18px;
}

.select-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--md-sys-color-outline);
    margin-bottom: 6px;
    margin-left: 4px;
}

.m3-select-box {
    position: relative;
}

.m3-select-box select {
    width: 100%;
    padding: 16px 16px 16px 44px;
    font-size: 0.95rem;
    background: transparent;
    border: 1px solid var(--md-sys-color-outline);
    border-radius: var(--md-shape-corner-small);
    color: var(--md-sys-color-on-surface);
    outline: none;
    appearance: none;
}

.m3-select-box select:focus {
    border-color: var(--md-sys-color-primary);
    box-shadow: 0 0 0 1px var(--md-sys-color-primary);
}

.m3-select-box .select-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--md-sys-color-outline);
    pointer-events: none;
}

/* M3 Buttons */
.m3-btn {
    width: 100%;
    height: 48px;
    border-radius: var(--md-shape-corner-full);
    font-size: 0.95rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    border: none;
    margin-top: 18px;
    transition: box-shadow 0.2s, background-color 0.2s;
}

.m3-btn.filled {
    background: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
    box-shadow: var(--md-elevation-1);
}

.m3-btn.filled:hover {
    box-shadow: var(--md-elevation-2);
}

.m3-btn.text-btn {
    background: transparent;
    color: var(--md-sys-color-primary);
}

.m3-btn.tonal {
    background: var(--md-sys-color-surface-container-high);
    color: var(--md-sys-color-on-surface);
    border: 1px solid var(--md-sys-color-outline-variant);
    box-shadow: none;
}

.m3-btn.tonal:hover {
    background: var(--md-sys-color-surface-container-highest);
    color: var(--md-sys-color-on-surface);
}

.m3-btn.outlined {
    background: transparent;
    color: var(--md-sys-color-primary);
    border: 1px solid var(--md-sys-color-outline);
}

.m3-btn.outlined:hover {
    background: var(--md-sys-color-surface-container-low);
}

/* Compact Button Variant — 36px visual height with 48dp touch target */
.m3-btn.compact {
    height: 36px;
    min-height: 48px;
    padding: 0 16px;
    font-size: 0.85rem;
    margin-top: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: auto;
}

.btn-icon {
    font-size: 20px;
}

.m3-btn:disabled,
.m3-btn[aria-busy="true"] {
    opacity: 0.65;
    cursor: not-allowed;
    pointer-events: none;
}

.m3-btn.is-success {
    background: var(--md-sys-color-success) !important;
    color: var(--md-sys-color-on-success) !important;
    transition: background-color 0.25s ease, color 0.25s ease;
}

/* Material 3 Circular Progress Spinner for Buttons */
.m3-btn-spinner {
    width: 20px;
    height: 20px;
    border: 2.5px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    display: inline-block;
    animation: m3-spin 0.75s linear infinite;
    flex-shrink: 0;
}

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

@media (prefers-reduced-motion: reduce) {
    .m3-btn-spinner {
        animation-duration: 2s;
    }
}

/* M3 Settings Theme Selector */
.m3-settings-section {
    margin-top: 20px;
    margin-bottom: 6px;
}

.theme-selector {
    display: flex;
    border-radius: var(--md-shape-corner-full);
    border: 1px solid var(--md-sys-color-outline-variant);
    overflow: hidden;
    background: var(--md-sys-color-surface-container);
    padding: 3px;
    gap: 3px;
}

.theme-selector .segment-btn {
    flex: 1;
    height: 38px;
    border: none;
    border-radius: var(--md-shape-corner-full);
    background: transparent;
    color: var(--md-sys-color-on-surface-variant);
    font-size: 0.85rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
}

.theme-selector .segment-btn.active {
    background: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
    font-weight: 600;
}

.theme-selector .segment-btn .btn-icon {
    font-size: 18px;
}

/* Action Button Mini Spinner */
.btn-feed-action.is-loading {
    opacity: 0.75;
    pointer-events: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-feed-action .mini-spinner {
    width: 14px;
    height: 14px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    display: inline-block;
    animation: m3-spin 0.75s linear infinite;
}

/* Material Design 3 Skeleton Shimmer */
.m3-skeleton {
    background: linear-gradient(90deg, var(--skeleton-shimmer-base) 25%, var(--skeleton-shimmer-highlight) 50%, var(--skeleton-shimmer-base) 75%);
    background-size: 200% 100%;
    animation: m3-skeleton-shimmer 1.5s infinite ease-in-out;
    border-radius: var(--md-shape-corner-small);
}

@keyframes m3-skeleton-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

@media (prefers-reduced-motion: reduce) {
    .m3-skeleton {
        animation: none;
        opacity: 0.8;
    }
}

/* Chat Stream Skeleton Messages */
.skeleton-msg-group {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 16px 8px;
    width: 100%;
}

.skeleton-msg {
    display: flex;
    gap: 10px;
    max-width: 82%;
}

.skeleton-msg.incoming {
    align-self: flex-start;
}

.skeleton-msg.outgoing {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.skeleton-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    flex-shrink: 0;
}

.skeleton-bubble {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px 16px;
    border-radius: var(--md-shape-corner-medium);
    min-width: 130px;
    background: var(--md-sys-color-surface-container);
}

.skeleton-msg.incoming .skeleton-bubble {
    border-bottom-left-radius: 4px;
}

.skeleton-msg.outgoing .skeleton-bubble {
    border-bottom-right-radius: 4px;
    background: var(--md-sys-color-primary-container);
    opacity: 0.75;
}

.skeleton-line {
    height: 12px;
    border-radius: 4px;
}

.skeleton-line.short { width: 65px; }
.skeleton-line.medium { width: 130px; }
.skeleton-line.long { width: 195px; }

/* Discover Feeds Skeleton */
.skeleton-feed-card {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 14px 16px;
    background: var(--md-sys-color-surface-container);
    border-radius: var(--md-shape-corner-medium);
    border: 1px solid var(--md-sys-color-outline-variant);
    margin-bottom: 12px;
}

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

/* Material 3 Toast / Snackbar System */
#m3-toast-container {
    position: fixed;
    bottom: calc(var(--nav-height, 68px) + 14px);
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 32px);
    max-width: 440px;
    z-index: 11000;
    pointer-events: none;
    display: flex;
    flex-direction: column-reverse;
    gap: 10px;
    align-items: center;
}

.m3-toast {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 14px 18px;
    border-radius: var(--md-shape-corner-small);
    background: var(--md-sys-color-inverse-surface);
    color: var(--md-sys-color-inverse-on-surface);
    box-shadow: var(--md-elevation-3);
    font-size: 0.92rem;
    line-height: 1.4;
    pointer-events: auto;
    cursor: pointer;
    opacity: 0;
    transform: translateY(16px) scale(0.96);
    transition: opacity 0.22s cubic-bezier(0.2, 0, 0, 1), transform 0.22s cubic-bezier(0.2, 0, 0, 1);
}

.m3-toast.show {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.m3-toast.hide {
    opacity: 0;
    transform: translateY(16px) scale(0.96);
}

.m3-toast-icon {
    font-size: 22px;
    flex-shrink: 0;
}

.m3-toast.success .m3-toast-icon {
    color: var(--md-sys-color-success);
}

.m3-toast.error .m3-toast-icon {
    color: var(--md-sys-color-error);
}

.m3-toast.info .m3-toast-icon {
    color: var(--md-sys-color-primary);
}

.m3-toast-message {
    flex: 1;
    word-break: break-word;
}

.m3-toast-close {
    background: transparent;
    border: none;
    color: inherit;
    opacity: 0.7;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    border-radius: 50%;
}

.m3-toast-close:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.1);
}

/* M3 Filter Chips Row */
.m3-filter-row {
    display: flex;
    gap: 8px;
    padding: 10px 14px;
    background: var(--md-sys-color-surface);
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
    overflow-x: auto;
    flex-shrink: 0;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}
.m3-filter-row::-webkit-scrollbar {
    display: none;
}

.m3-filter-chip {
    height: 36px;
    min-height: 48px;
    padding: 0 14px;
    border-radius: var(--md-shape-corner-small);
    border: 1px solid var(--md-sys-color-outline-variant);
    background: var(--md-sys-color-surface);
    color: var(--md-sys-color-on-surface-variant);
    font-size: 0.84rem;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.chip-icon {
    font-size: 17px;
}

.m3-filter-chip.active {
    background: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
    border-color: var(--md-sys-color-primary);
    font-weight: 600;
}

.m3-filter-chip.active .chip-icon {
    font-variation-settings: 'FILL' 1;
}

/* Course Specific Filter Chip Polish */
.m3-filter-chip.chip-course {
    border-color: rgba(124, 58, 237, 0.25);
}

.m3-filter-chip.chip-course:not(.active):hover {
    background: var(--md-sys-color-surface-container-low);
    border-color: var(--palavibe-purple);
}

/* Inline Variant Pills within Chips */
.chip-variant-pill {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 9999px;
    line-height: 1.2;
    letter-spacing: 0.02em;
    margin-left: 2px;
}

.chip-variant-pill .material-symbols-rounded {
    font-size: 11px;
}

.chip-variant-pill.chip-tag-placement {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fde68a;
}
.dark-mode .chip-variant-pill.chip-tag-placement,
[data-theme="dark"] .chip-variant-pill.chip-tag-placement {
    background: rgba(245, 158, 11, 0.2);
    color: #fbbf24;
    border-color: rgba(245, 158, 11, 0.35);
}

.chip-variant-pill.chip-tag-abroad {
    background: #e0f2fe;
    color: #0369a1;
    border: 1px solid #bae6fd;
}
.dark-mode .chip-variant-pill.chip-tag-abroad,
[data-theme="dark"] .chip-variant-pill.chip-tag-abroad {
    background: rgba(14, 165, 233, 0.2);
    color: #38bdf8;
    border-color: rgba(14, 165, 233, 0.35);
}

.chip-variant-pill.chip-tag-foundation {
    background: #ecfdf5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}
.dark-mode .chip-variant-pill.chip-tag-foundation,
[data-theme="dark"] .chip-variant-pill.chip-tag-foundation {
    background: rgba(16, 185, 129, 0.2);
    color: #34d399;
    border-color: rgba(16, 185, 129, 0.35);
}

/* Academic Course Hub Switcher Button */
.chip-courses-hub {
    background: var(--md-sys-color-surface-container-low, rgba(124, 58, 237, 0.06));
    border-color: rgba(124, 58, 237, 0.3);
    color: var(--palavibe-purple, #7c3aed);
    font-weight: 600;
}
.chip-courses-hub.has-active-course {
    border-color: var(--palavibe-purple, #7c3aed);
}
.chip-courses-hub .chip-chevron {
    font-size: 16px;
    margin-left: -2px;
    transition: transform 0.2s ease;
}

/* Course Switcher Bottom Sheet */
.course-switcher-sheet {
    max-width: 520px;
}
.course-switcher-hint {
    font-size: 0.8125rem;
    color: var(--md-sys-color-on-surface-variant);
    margin-bottom: 12px;
    line-height: 1.4;
}
.course-switcher-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 55vh;
    overflow-y: auto;
    padding-bottom: 8px;
}
.course-switcher-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    background: var(--md-sys-color-surface-container-low, #f8fafc);
    border: 1.5px solid var(--md-sys-color-outline-variant, #e2e8f0);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
}
.dark-mode .course-switcher-card,
[data-theme="dark"] .course-switcher-card {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.1);
}
.course-switcher-card:hover {
    border-color: var(--palavibe-purple);
    transform: translateY(-1px);
}
.course-switcher-card.is-active {
    background: var(--md-sys-color-primary-container, rgba(124, 58, 237, 0.12));
    border-color: var(--palavibe-purple, #7c3aed);
}
.course-switcher-card-left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    flex: 1;
}
.course-switcher-info {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
    flex: 1;
}
.course-switcher-title-row {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}
.course-switcher-title {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--md-sys-color-on-surface);
    line-height: 1.3;
    word-break: break-word;
}
.course-switcher-meta {
    font-size: 0.75rem;
    color: var(--md-sys-color-on-surface-variant);
    display: flex;
    align-items: center;
    gap: 4px;
}
.course-active-status {
    color: var(--palavibe-purple, #7c3aed);
    font-weight: 600;
}
.course-switcher-card-right {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: 10px;
    flex-shrink: 0;
}
.course-switcher-chevron {
    font-size: 18px;
    color: var(--md-sys-color-on-surface-variant);
}
.course-switcher-card.is-active .course-switcher-chevron {
    color: var(--palavibe-purple);
}

/* Primary Degree Badge */
.course-primary-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.6875rem;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 999px;
    background: rgba(245, 158, 11, 0.12);
    color: #b45309;
    border: 1px solid rgba(245, 158, 11, 0.28);
    letter-spacing: 0.01em;
}
.course-primary-badge .material-symbols-rounded {
    font-size: 13px;
    color: #d97706;
}
.dark-mode .course-primary-badge,
[data-theme="dark"] .course-primary-badge {
    background: rgba(245, 158, 11, 0.18);
    color: #fbbf24;
    border-color: rgba(245, 158, 11, 0.35);
}
.dark-mode .course-primary-badge .material-symbols-rounded,
[data-theme="dark"] .course-primary-badge .material-symbols-rounded {
    color: #fcd34d;
}

/* Leave Course Community Button */
.btn-leave-course {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px 10px;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 600;
    border: 1px solid var(--md-sys-color-outline-variant, #cbd5e1);
    background: var(--md-sys-color-surface, #ffffff);
    color: var(--md-sys-color-error, #dc2626);
    cursor: pointer;
    transition: all 0.15s ease;
    min-height: 26px;
    white-space: nowrap;
}
.btn-leave-course:hover {
    background: var(--md-sys-color-error-container, #fee2e2);
    border-color: var(--md-sys-color-error, #dc2626);
}
.dark-mode .btn-leave-course,
[data-theme="dark"] .btn-leave-course {
    background: rgba(220, 38, 38, 0.12);
    border-color: rgba(220, 38, 38, 0.3);
    color: #fca5a5;
}
.dark-mode .btn-leave-course:hover,
[data-theme="dark"] .btn-leave-course:hover {
    background: rgba(220, 38, 38, 0.22);
    border-color: #f87171;
}

/* Open Course Directory Button in Switcher Sheet */
.btn-open-add-course {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 10px 16px;
    border-radius: 12px;
    font-size: 0.875rem;
    font-weight: 600;
    border: 1.5px dashed var(--palavibe-purple, #7c3aed);
    background: rgba(124, 58, 237, 0.04);
    color: var(--palavibe-purple, #7c3aed);
    cursor: pointer;
    transition: all 0.2s ease;
}
.btn-open-add-course:hover {
    background: rgba(124, 58, 237, 0.1);
}
.btn-open-add-course.at-capacity {
    border-style: solid;
    border-color: var(--md-sys-color-outline-variant, #cbd5e1);
    background: var(--md-sys-color-surface-container, #f1f5f9);
    color: var(--md-sys-color-on-surface-variant, #64748b);
    cursor: default;
}
.dark-mode .btn-open-add-course,
[data-theme="dark"] .btn-open-add-course {
    background: rgba(124, 58, 237, 0.12);
    color: #c4b5fd;
    border-color: rgba(124, 58, 237, 0.45);
}
.dark-mode .btn-open-add-course.at-capacity,
[data-theme="dark"] .btn-open-add-course.at-capacity {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.15);
    color: rgba(255, 255, 255, 0.5);
}

/* Join Course Bottom Sheet & Directory */
.join-course-sheet {
    max-width: 520px;
}
.course-search-bar input::placeholder {
    color: var(--md-sys-color-on-surface-variant, #94a3b8);
}
.dark-mode .course-search-bar,
[data-theme="dark"] .course-search-bar {
    background: rgba(255, 255, 255, 0.05) !important;
    border-color: rgba(255, 255, 255, 0.1) !important;
}
.course-filter-pill {
    padding: 6px 14px;
    border-radius: 999px;
    font-size: 0.8125rem;
    font-weight: 500;
    white-space: nowrap;
    border: 1px solid var(--md-sys-color-outline-variant, #cbd5e1);
    background: var(--md-sys-color-surface, #ffffff);
    color: var(--md-sys-color-on-surface-variant, #64748b);
    cursor: pointer;
    transition: all 0.15s ease;
}
.course-filter-pill.is-active {
    background: var(--palavibe-purple, #7c3aed);
    color: #ffffff;
    border-color: var(--palavibe-purple, #7c3aed);
    font-weight: 600;
}
.dark-mode .course-filter-pill,
[data-theme="dark"] .course-filter-pill {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.7);
}
.dark-mode .course-filter-pill.is-active,
[data-theme="dark"] .course-filter-pill.is-active {
    background: var(--palavibe-purple, #7c3aed);
    color: #ffffff;
    border-color: var(--palavibe-purple, #7c3aed);
}

.join-course-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 11px 13px;
    background: var(--md-sys-color-surface-container-low, #f8fafc);
    border: 1px solid var(--md-sys-color-outline-variant, #e2e8f0);
    border-radius: 12px;
    gap: 10px;
    transition: all 0.15s ease;
}
.dark-mode .join-course-card,
[data-theme="dark"] .join-course-card {
    background: rgba(255, 255, 255, 0.03);
    border-color: rgba(255, 255, 255, 0.09);
}
.join-course-card-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    flex: 1;
}
.join-course-card-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}
.join-course-card-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--md-sys-color-on-surface);
    line-height: 1.25;
    word-break: break-word;
}
.join-course-card-meta {
    font-size: 0.75rem;
    color: var(--md-sys-color-on-surface-variant);
}

.btn-course-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 5px 12px;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    border: none;
    min-width: 64px;
    height: 28px;
    white-space: nowrap;
}
.btn-course-action.join {
    background: var(--palavibe-purple, #7c3aed);
    color: #ffffff;
}
.btn-course-action.join:hover {
    background: #6d28d9;
}
.btn-course-action.leave {
    background: transparent;
    color: var(--md-sys-color-error, #dc2626);
    border: 1px solid var(--md-sys-color-outline-variant, #cbd5e1);
}
.btn-course-action.leave:hover {
    background: var(--md-sys-color-error-container, #fee2e2);
}
.dark-mode .btn-course-action.leave,
[data-theme="dark"] .btn-course-action.leave {
    border-color: rgba(220, 38, 38, 0.35);
    color: #fca5a5;
}
.btn-course-action.disabled {
    background: var(--md-sys-color-surface-container, #e2e8f0);
    color: var(--md-sys-color-on-surface-variant, #94a3b8);
    cursor: not-allowed;
    border: none;
}
.dark-mode .btn-course-action.disabled,
[data-theme="dark"] .btn-course-action.disabled {
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.35);
}

/* Chat Container */
.chat-container {
    display: flex;
    flex-direction: column;
    flex: 1;
    height: 100%;
    min-height: 0;
    overflow: hidden;
    position: relative;
}

/* Drag and Drop Dropzone Overlay */
.chat-dropzone,
.chat-dropzone * {
    pointer-events: none !important;
}

.chat-dropzone {
    position: absolute;
    inset: 0;
    z-index: 50;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    animation: fadeIn 0.15s ease-out;
}

.chat-dropzone.hidden {
    display: none !important;
}

.dropzone-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 2.5px dashed var(--md-sys-color-primary);
    border-radius: var(--md-shape-corner-large);
    background: var(--md-sys-color-primary-container);
    width: 100%;
    height: 100%;
    max-width: 440px;
    max-height: 280px;
    padding: 32px 24px;
    box-shadow: var(--md-elevation-2);
    text-align: center;
}

.dropzone-icon {
    font-size: 56px;
    color: var(--md-sys-color-primary);
    animation: dropzoneBounce 1.4s infinite ease-in-out;
}

.dropzone-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--md-sys-color-on-primary-container);
}

.dropzone-sub {
    font-size: 0.85rem;
    color: var(--md-sys-color-on-surface-variant);
}

@keyframes dropzoneBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

.chat-banner {
    padding: 10px 16px;
    background: #FFEFD4;
    color: #633F00;
    font-size: 0.85rem;
    text-align: center;
    border-bottom: 1px solid #FFE0A3;
}

.chat-messages-area {
    flex: 1 1 0%;
    min-height: 0;
    overflow-y: auto;
    padding: 16px 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: var(--md-sys-color-background);
}

.empty-feed {
    text-align: center;
    margin: auto;
    font-size: 0.9rem;
    color: var(--md-sys-color-outline);
}

/* Chat Message Bubbles */
.chat-message {
    display: flex;
    flex-direction: column;
    max-width: 82%;
}

.chat-message.incoming {
    align-self: flex-start;
}

.chat-message.outgoing {
    align-self: flex-end;
}

.chat-message.optimistic {
    opacity: 0.88;
    transition: opacity 0.2s ease;
}

.chat-message.optimistic .msg-time {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
}

.msg-author {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--md-sys-color-on-surface-variant);
    margin-bottom: 4px;
    padding-left: 6px;
}

.msg-college {
    font-weight: 400;
    color: var(--md-sys-color-outline);
}

.msg-bubble {
    padding: 12px 16px;
    border-radius: var(--md-shape-corner-medium);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    word-break: break-word;
}

.incoming .msg-bubble {
    background: var(--md-sys-color-surface-container-high);
    color: var(--md-sys-color-on-surface);
    border-bottom-left-radius: 4px;
}

.outgoing .msg-bubble {
    background: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
    border-bottom-right-radius: 4px;
}

.msg-text {
    font-size: 0.95rem;
    line-height: 1.4;
}

.msg-time {
    font-size: 0.68rem;
    text-align: right;
    margin-top: 4px;
    opacity: 0.8;
}

/* Jumbo Emoji Messages (1-3 Emojis without body text) */
.msg-bubble.is-emoji-only {
    background: transparent !important;
    box-shadow: none !important;
    padding: 2px 4px !important;
    display: inline-flex;
    flex-direction: column;
}

.outgoing .msg-bubble.is-emoji-only {
    align-items: flex-end;
}

.incoming .msg-bubble.is-emoji-only {
    align-items: flex-start;
}

.msg-bubble.is-emoji-only .msg-text {
    font-size: 2.8rem;
    line-height: 1.15;
    letter-spacing: 2px;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.15));
}

.msg-bubble.is-emoji-only .msg-time {
    font-size: 0.65rem;
    margin-top: 3px;
    padding: 1px 6px;
    border-radius: 9999px;
    background: rgba(0, 0, 0, 0.35);
    color: #ffffff;
    font-weight: 500;
    line-height: 1.2;
    align-self: flex-end;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

[data-theme="light"] .msg-bubble.is-emoji-only .msg-time {
    background: rgba(0, 0, 0, 0.08);
    color: var(--md-sys-color-on-surface-variant);
}

[data-theme="dark"] .msg-bubble.is-emoji-only .msg-time {
    background: rgba(255, 255, 255, 0.18);
    color: var(--md-sys-color-on-surface);
}

/* Chat Input Bar */
.m3-chat-bar {
    display: flex;
    align-items: center;
    padding: 10px 14px;
    background: var(--md-sys-color-surface-container);
    gap: 10px;
    flex-shrink: 0;
    border-top: 1px solid var(--md-sys-color-outline-variant);
}

.chat-input-wrapper {
    flex: 1;
    background: var(--md-sys-color-surface);
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--md-shape-corner-full);
    padding: 2px 16px;
    display: flex;
    align-items: center;
}

.chat-input-wrapper input {
    width: 100%;
    height: 40px;
    border: none;
    outline: none;
    font-size: 0.95rem;
    background: transparent;
    color: var(--md-sys-color-on-surface);
}

.m3-fab-send {
    width: 44px;
    height: 44px;
    border-radius: var(--md-shape-corner-full);
    background: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--md-elevation-1);
    cursor: pointer;
    transition: box-shadow 0.2s;
}

.m3-fab-send:hover {
    box-shadow: var(--md-elevation-2);
}

/* Bottom Navigation Bar (M3 Standard Pill Spec) */
.m3-navigation-bar {
    display: flex;
    height: 68px;
    background: var(--md-sys-color-surface-container);
    border-top: 1px solid var(--md-sys-color-outline-variant);
    flex-shrink: 0;
}

.m3-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    cursor: pointer;
    gap: 4px;
    padding: 6px 0;
}

.m3-nav-indicator {
    width: 56px;
    height: 30px;
    border-radius: var(--md-shape-corner-full);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--md-sys-color-on-surface-variant);
    transition: background-color 0.2s, color 0.2s;
}

.m3-nav-indicator .material-symbols-rounded {
    font-size: 24px;
}

.m3-nav-label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--md-sys-color-on-surface-variant);
}

.m3-nav-item.active .m3-nav-indicator {
    background: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
}

.m3-nav-item.active .m3-nav-indicator .material-symbols-rounded {
    font-variation-settings: 'FILL' 1;
}

.m3-nav-item.active .m3-nav-label {
    color: var(--md-sys-color-primary);
    font-weight: 700;
}

.feedback-msg {
    margin-top: 12px;
    font-size: 0.85rem;
    text-align: center;
}

.location-status-badge {
    margin-top: 8px;
    font-size: 0.78rem;
    color: var(--md-sys-color-outline);
    text-align: center;
}

.hidden { display: none !important; }
/* Durham Heraldic Badge */
.durham-crest-badge {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #F4E8F4;
    border-radius: var(--md-shape-corner-small);
    padding: 2px;
    box-shadow: 0 1px 3px rgba(104, 36, 109, 0.15);
}

.cuthbert-cross {
    width: 24px;
    height: 24px;
    filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.15));
}

/* Material 3 Notification Badges */
.m3-badge {
    background-color: var(--md-sys-color-error);
    color: var(--md-sys-color-on-error);
    font-size: 0.68rem;
    font-weight: 700;
    line-height: 1;
    border-radius: var(--md-shape-corner-full);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.chip-badge {
    margin-left: 4px;
}

.m3-nav-indicator {
    position: relative;
}

.nav-badge {
    position: absolute;
    top: -2px;
    right: 8px;
}


/* Message Reactions UX Overhaul */
.chat-message {
    position: relative;
    display: flex;
    flex-direction: column;
    max-width: 82%;
    margin-bottom: 6px;
}

.msg-bubble-container {
    position: relative;
    display: inline-block;
}

/* Hover-reveal action bar for desktop messages */
.msg-hover-actions {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    gap: 4px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease;
    z-index: 10;
}

.incoming .msg-hover-actions {
    right: -68px;
}

.incoming .msg-hover-actions::before {
    content: '';
    position: absolute;
    top: -10px;
    bottom: -10px;
    right: 100%;
    width: 20px;
}

.outgoing .msg-hover-actions {
    left: -68px;
}

.outgoing .msg-hover-actions::before {
    content: '';
    position: absolute;
    top: -10px;
    bottom: -10px;
    left: 100%;
    width: 20px;
}

.chat-message:hover .msg-hover-actions,
.msg-hover-actions:hover {
    opacity: 1;
    pointer-events: auto;
}

.msg-hover-btn,
.msg-hover-trigger {
    background: var(--md-sys-color-surface-container);
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--md-shape-corner-full);
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--md-sys-color-outline);
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0,0,0,0.12);
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.msg-hover-btn:hover,
.msg-hover-trigger:hover {
    color: var(--md-sys-color-primary);
    background: var(--md-sys-color-surface);
    border-color: var(--md-sys-color-primary);
    transform: scale(1.08);
}

.msg-hover-btn .material-symbols-rounded,
.msg-hover-trigger .material-symbols-rounded {
    font-size: 16px;
}

/* Fallback if single msg-hover-trigger is attached directly to container */
.msg-bubble-container > .msg-hover-trigger {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0;
    pointer-events: none;
}
.incoming .msg-bubble-container > .msg-hover-trigger {
    right: -32px;
}
.outgoing .msg-bubble-container > .msg-hover-trigger {
    left: -32px;
}
.chat-message:hover .msg-bubble-container > .msg-hover-trigger,
.msg-bubble-container > .msg-hover-trigger:hover {
    opacity: 1;
    pointer-events: auto;
}
/* Floating Quick Reaction Picker Popover */
.reaction-picker-popover {
    position: absolute;
    bottom: calc(100% + 8px);
    background: var(--md-sys-color-surface-container-high);
    border: 1px solid var(--md-sys-color-outline-variant);
    box-shadow: var(--md-elevation-3);
    border-radius: var(--md-shape-corner-full);
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 4px 8px;
    z-index: 100;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    animation: reactionPopIn 0.16s cubic-bezier(0.2, 0, 0, 1);
    user-select: none;
    -webkit-user-select: none;
}

@keyframes reactionPopIn {
    from {
        transform: scale(0.75) translateY(6px);
        opacity: 0;
    }
    to {
        transform: scale(1) translateY(0);
        opacity: 1;
    }
}

.incoming .reaction-picker-popover {
    left: 4px;
}

.outgoing .reaction-picker-popover {
    right: 4px;
}

.picker-emojis-list {
    display: flex;
    align-items: center;
    gap: 2px;
}

.picker-emoji-btn {
    background: transparent;
    border: none;
    font-size: 1.35rem;
    cursor: pointer;
    line-height: 1;
    padding: 6px 7px;
    border-radius: var(--md-shape-corner-full);
    transition: transform 0.15s cubic-bezier(0.2, 0, 0, 1), background-color 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.picker-emoji-btn:hover {
    transform: scale(1.32);
    background: var(--md-sys-color-surface-container-highest);
}

.picker-emoji-btn:active {
    transform: scale(1.1);
}

.picker-divider {
    width: 1px;
    height: 22px;
    background: var(--md-sys-color-outline-variant);
    margin: 0 4px;
    opacity: 0.7;
    flex-shrink: 0;
}

.picker-more-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid var(--md-sys-color-outline-variant);
    background: var(--md-sys-color-surface-container);
    color: var(--md-sys-color-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s ease, background-color 0.15s ease;
    flex-shrink: 0;
}

.picker-more-btn:hover {
    transform: scale(1.14);
    background: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
}

.picker-more-btn .material-symbols-rounded {
    font-size: 18px;
}

/* Docked Reaction Pills */
.reaction-pills-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    margin-top: -6px;
    z-index: 2;
    padding: 0 8px;
}

.incoming .reaction-pills-row {
    justify-content: flex-start;
}

.outgoing .reaction-pills-row {
    justify-content: flex-end;
}

.reaction-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    height: 25px;
    background: var(--md-sys-color-surface-container-high);
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--md-shape-corner-full);
    padding: 0 8px 0 6px;
    font-size: 0.78rem;
    color: var(--md-sys-color-on-surface);
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    transition: transform 0.12s ease, border-color 0.12s ease, background-color 0.12s ease;
}

.reaction-pill.just-added {
    animation: pillPop 0.22s cubic-bezier(0.2, 0, 0, 1);
}

@keyframes pillPop {
    0% { transform: scale(0.75); }
    70% { transform: scale(1.14); }
    100% { transform: scale(1); }
}

.reaction-pill:hover {
    transform: scale(1.08);
    background: var(--md-sys-color-surface-container-highest);
}

.reaction-pill:active {
    transform: scale(0.95);
}

.reaction-pill.user-active {
    background: var(--md-sys-color-primary-container);
    border-color: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary-container);
    font-weight: 600;
}

.reaction-pill .emoji-glyph {
    font-size: 0.95rem;
    line-height: 1;
}

.reaction-pill .count {
    font-size: 0.72rem;
    font-weight: 600;
    margin-left: 1px;
}

.reaction-add-pill {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--md-sys-color-surface-container);
    border: 1px dashed var(--md-sys-color-outline-variant);
    color: var(--md-sys-color-on-surface-variant);
    cursor: pointer;
    transition: transform 0.15s ease, background-color 0.15s ease, color 0.15s ease;
}

.reaction-add-pill:hover {
    transform: scale(1.12);
    background: var(--md-sys-color-surface-container-highest);
    color: var(--md-sys-color-primary);
    border-style: solid;
}

.reaction-add-pill .material-symbols-rounded {
    font-size: 15px;
}

/* Message text selectable across desktop and mobile */
.chat-message,
.msg-bubble-container,
.msg-bubble {
    -webkit-touch-callout: default;
}

.msg-text {
    -webkit-user-select: text;
    user-select: text;
    cursor: text;
}

.msg-bubble {
    touch-action: pan-y;
    transition: transform 0.15s cubic-bezier(0.2, 0, 0, 1);
}

.msg-media-img {
    -webkit-user-drag: none !important;
    user-drag: none !important;
}

.msg-bubble.is-long-pressing {
    transform: scale(0.96);
    filter: brightness(0.92);
}

/* Full Material 3 Emoji Picker Sheet & Modal */
.emoji-picker-sheet {
    max-width: 460px;
    max-height: 82vh;
    max-height: 82dvh;
    display: flex;
    flex-direction: column;
}

.emoji-search-bar-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--md-sys-color-surface-container-high);
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--md-shape-corner-full);
    padding: 6px 14px;
    margin: 8px 16px 10px;
}

.emoji-search-icon {
    font-size: 20px;
    color: var(--md-sys-color-on-surface-variant);
    flex-shrink: 0;
}

#emoji-search-input {
    border: none;
    background: transparent;
    color: var(--md-sys-color-on-surface);
    font-size: 0.92rem;
    width: 100%;
    outline: none;
}

#emoji-search-input::placeholder {
    color: var(--md-sys-color-on-surface-variant);
    opacity: 0.75;
}

.emoji-search-clear {
    border: none;
    background: transparent;
    color: var(--md-sys-color-on-surface-variant);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.emoji-search-clear .material-symbols-rounded {
    font-size: 18px;
}

.emoji-category-chips {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding: 2px 16px 10px;
    scrollbar-width: none;
    -ms-overflow-style: none;
    flex-shrink: 0;
}

.emoji-category-chips::-webkit-scrollbar {
    display: none;
}

.emoji-cat-chip {
    padding: 5px 12px;
    border-radius: var(--md-shape-corner-full);
    border: 1px solid var(--md-sys-color-outline-variant);
    background: var(--md-sys-color-surface-container-low);
    color: var(--md-sys-color-on-surface-variant);
    font-size: 0.8rem;
    font-weight: 500;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.15s ease;
}

.emoji-cat-chip:hover {
    background: var(--md-sys-color-surface-container-high);
    color: var(--md-sys-color-on-surface);
}

.emoji-cat-chip.active {
    background: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
    border-color: var(--md-sys-color-primary);
    font-weight: 600;
}

.emoji-grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(44px, 1fr));
    gap: 6px;
    padding: 6px 16px 20px;
    overflow-y: auto;
    max-height: 360px;
    scrollbar-width: thin;
}

.emoji-grid-item {
    width: 44px;
    height: 44px;
    font-size: 1.55rem;
    border: none;
    background: transparent;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.12s cubic-bezier(0.2, 0, 0, 1), background-color 0.12s ease;
    user-select: none;
}

.emoji-grid-item:hover {
    background: var(--md-sys-color-surface-container-highest);
    transform: scale(1.24);
}

.emoji-grid-item:active {
    transform: scale(0.92);
}

.emoji-grid-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 30px 16px;
    color: var(--md-sys-color-on-surface-variant);
    font-size: 0.9rem;
}
/* Top Bar Actions Container */
.top-bar-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}


/* Modal Bottom Sheet */
.m3-sheet-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: flex-end;
    animation: fadeIn 0.15s ease-out;
}

.m3-bottom-sheet {
    background: var(--md-sys-color-surface-container, #F3EDF7);
    width: 100%;
    max-width: 500px;
    height: auto;
    max-height: 85vh;
    max-height: 85dvh;
    border-radius: var(--md-shape-corner-large, 24px) var(--md-shape-corner-large, 24px) 0 0;
    display: flex;
    flex-direction: column;
    box-shadow: var(--md-elevation-3, 0 8px 24px rgba(0,0,0,0.25));
    animation: slideUp 0.22s ease-out;
    padding-bottom: max(16px, env(safe-area-inset-bottom, 16px));
    box-sizing: border-box;
    overflow: hidden;
}

.sheet-drag-handle {
    width: 36px;
    height: 4px;
    background: var(--md-sys-color-outline-variant, #CAC4D0);
    border-radius: var(--md-shape-corner-full, 9999px);
    margin: 10px auto 4px;
    flex-shrink: 0;
}

.sheet-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 18px 8px 20px;
    flex-shrink: 0;
}

.sheet-header h2 {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--md-sys-color-on-surface, #1D1B20);
    margin: 0;
}

.sheet-content {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 8px 18px 16px;
}

/* Segmented Tab Bar */
.m3-segmented-control {
    display: flex;
    background: var(--md-sys-color-surface-container-high, #E6E0E9);
    border-radius: var(--md-shape-corner-full, 9999px);
    padding: 3px;
    margin-bottom: 16px;
    gap: 4px;
}

.segment-btn {
    flex: 1;
    padding: 8px 0;
    border: none;
    background: transparent;
    border-radius: var(--md-shape-corner-full, 9999px);
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--md-sys-color-on-surface-variant, #49454F);
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
    text-align: center;
}

.segment-btn.active {
    background: var(--md-sys-color-surface, #FEF7FF);
    color: var(--md-sys-color-primary, #68246D);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

/* Feed Cards List */
.feeds-card-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.feed-item-card {
    background: var(--md-sys-color-surface, #FEF7FF);
    border: 1px solid var(--md-sys-color-outline-variant, #CAC4D0);
    border-radius: var(--md-shape-corner-medium, 16px);
    padding: 12px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.feed-meta {
    flex: 1;
    min-width: 0;
}

.btn-feed-action {
    padding: 6px 16px;
    border-radius: var(--md-shape-corner-full, 9999px);
    font-size: 0.8rem;
    font-weight: 600;
    border: 1px solid var(--md-sys-color-primary, #68246D);
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s ease;
}

.btn-feed-action.join {
    background: var(--md-sys-color-primary, #68246D);
    color: #FFFFFF;
}

.btn-feed-action.leave {
    background: transparent;
    color: var(--md-sys-color-primary, #68246D);
}

.sheet-tab-panel {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
/* Feed Card Header & Hierarchy */
.feed-header-line {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.feed-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--md-sys-color-on-surface, #1D1B20);
    line-height: 1.25;
}

.feed-category-pill {
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: capitalize;
    background: var(--md-sys-color-surface-container-high, #E6E0E9);
    color: var(--md-sys-color-on-surface-variant, #49454F);
    padding: 2px 8px;
    border-radius: 9999px;
    line-height: 1.2;
}

.feed-desc {
    font-size: 0.8rem;
    color: var(--md-sys-color-on-surface-variant, #49454F);
    margin-top: 4px;
    line-height: 1.35;
}

.feed-stats {
    font-size: 0.72rem;
    color: var(--md-sys-color-outline, #79747E);
    margin-top: 4px;
}
/* Ensure chat-stream is the definitive scrolling container */
.chat-messages-area,
#chat-stream {
    flex: 1 1 0% !important;
    min-height: 0 !important;
    overflow-y: auto !important;
    overflow-x: hidden;
    scroll-behavior: auto !important;
    -webkit-overflow-scrolling: touch;
}
/* --- Viewport & Persistent Header/Footer Pinning --- */
html, body {
    height: 100%;
    height: 100dvh;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

#app-shell,
#app-viewport {
    height: 100%;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
    position: relative;
}

.view-panel {
    height: 100%;
    min-height: 0;
}

#home-view {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    overflow: hidden;
    flex: 1;
}

/* Persistent Filter Chips Bar */
.m3-filter-row {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    white-space: nowrap;
    padding: 8px 12px;
    background: var(--md-sys-color-surface, #FEF7FF);
    border-bottom: 1px solid var(--md-sys-color-outline-variant, #CAC4D0);
    z-index: 20;
    -webkit-overflow-scrolling: touch;
}

.m3-filter-row::-webkit-scrollbar {
    display: none;
}

/* Chat Viewport & Messages */
.chat-container {
    flex: 1 1 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.chat-messages-area,
#chat-stream {
    flex: 1 1 0% !important;
    min-height: 0 !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    padding: 12px 14px;
    -webkit-overflow-scrolling: touch;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Persistent Input Bar */
.m3-chat-bar {
    flex-shrink: 0;
    background: var(--md-sys-color-surface, #FEF7FF);
    border-top: 1px solid var(--md-sys-color-outline-variant, #CAC4D0);
    z-index: 20;
}

.m3-nav-bar {
    flex-shrink: 0;
    z-index: 20;
}

/* Unread Messages Separator */
.unread-separator {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    margin: 16px 0 10px;
    gap: 12px;
    user-select: none;
}

.unread-separator::before,
.unread-separator::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--md-sys-color-primary, #68246D);
    opacity: 0.28;
}

.unread-separator span {
    display: inline-flex;
    align-items: center;
    padding: 3px 12px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    border-radius: 9999px;
    background: var(--md-sys-color-primary-container, #F3DAFF);
    color: var(--md-sys-color-on-primary-container, #2B0038);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
    white-space: nowrap;
}
/* Scroll Padding and Bottom Settlement */
.chat-messages-area {
    scroll-padding-top: 16px;
    scroll-padding-bottom: 16px;
}

#chat-stream {
    padding-bottom: 4px;
}
/* Clear Search Button */
.m3-icon-button.small {
    width: 28px;
    height: 28px;
    min-width: 28px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    border-radius: 9999px;
    cursor: pointer;
    color: var(--md-sys-color-on-surface-variant, #49454F);
}

.m3-icon-button.small:hover {
    background: var(--md-sys-color-surface-container-high, #E6E0E9);
}

/* Browse Feeds Search & Filtering */
.browse-filter-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 12px;
    width: 100%;
    box-sizing: border-box;
}

.m3-search-input-box {
    display: flex;
    align-items: center;
    background: var(--md-sys-color-surface, #FEF7FF);
    border: 1px solid var(--md-sys-color-outline-variant, #CAC4D0);
    border-radius: 9999px;
    padding: 0 14px;
    height: 44px;
    box-sizing: border-box;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    width: 100%;
}

.m3-search-input-box:focus-within {
    border-color: var(--md-sys-color-primary, #68246D);
    box-shadow: 0 0 0 1px var(--md-sys-color-primary, #68246D);
}

.search-box-icon {
    color: var(--md-sys-color-on-surface-variant, #49454F);
    font-size: 20px;
    margin-right: 8px;
    user-select: none;
}

.m3-search-input-box input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-size: 0.9rem;
    color: var(--md-sys-color-on-surface, #1D1B20);
    padding: 0;
    font-family: inherit;
}

.modal-category-chips {
    display: flex;
    align-items: center;
    gap: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    white-space: nowrap;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
}

.modal-category-chips::-webkit-scrollbar {
    display: none;
}

.modal-cat-chip {
    padding: 6px 14px;
    border-radius: 9999px;
    border: 1px solid var(--md-sys-color-outline-variant, #CAC4D0);
    background: var(--md-sys-color-surface, #FEF7FF);
    color: var(--md-sys-color-on-surface-variant, #49454F);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
    font-family: inherit;
}

.modal-cat-chip.active {
    background: var(--md-sys-color-primary, #68246D);
    color: #FFFFFF;
    border-color: var(--md-sys-color-primary, #68246D);
}

.m3-icon-button.small {
    width: 28px;
    height: 28px;
    min-width: 28px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    border-radius: 9999px;
    cursor: pointer;
    color: var(--md-sys-color-on-surface-variant, #49454F);
}

.feed-no-results {
    text-align: center;
    padding: 24px 16px;
    background: var(--md-sys-color-surface, #FEF7FF);
    border-radius: var(--md-shape-corner-medium, 16px);
    border: 1px dashed var(--md-sys-color-outline-variant, #CAC4D0);
    margin-top: 4px;
}

.feed-no-results p {
    margin: 0 0 12px;
    font-size: 0.85rem;
    color: var(--md-sys-color-on-surface-variant, #49454F);
}
/* Browse Feeds Search & Category Filter Pills */
.browse-controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 8px;
    flex-shrink: 0;
}

.m3-search-box {
    position: relative;
    display: flex;
    align-items: center;
    background: var(--md-sys-color-surface, #FEF7FF);
    border: 1px solid var(--md-sys-color-outline-variant, #CAC4D0);
    border-radius: 9999px;
    padding: 2px 14px;
    transition: border-color 0.15s ease;
}

.m3-search-box:focus-within {
    border-color: var(--md-sys-color-primary, #68246D);
}

.m3-search-box .search-icon {
    font-size: 20px;
    color: var(--md-sys-color-on-surface-variant, #49454F);
    margin-right: 8px;
    flex-shrink: 0;
}

.m3-search-box input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 0.88rem;
    color: var(--md-sys-color-on-surface, #1D1B20);
    outline: none;
    padding: 8px 0;
}

.m3-search-box .m3-icon-button {
    width: 26px;
    height: 26px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.m3-search-box .m3-icon-button .material-symbols-rounded {
    font-size: 18px;
}

.browse-category-pills {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding: 2px 0 6px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.browse-category-pills::-webkit-scrollbar {
    display: none;
}

.browse-pill {
    flex-shrink: 0;
    padding: 5px 12px;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 9999px;
    border: 1px solid var(--md-sys-color-outline-variant, #CAC4D0);
    background: var(--md-sys-color-surface, #FEF7FF);
    color: var(--md-sys-color-on-surface-variant, #49454F);
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.browse-pill.active {
    background: var(--md-sys-color-primary, #68246D);
    color: #FFFFFF;
    border-color: var(--md-sys-color-primary, #68246D);
}
/* Empty Search Results Call-to-Action Card */
.empty-feed-action-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 24px 16px;
    gap: 14px;
    background: var(--md-sys-color-surface, #FEF7FF);
    border: 1px dashed var(--md-sys-color-outline-variant, #CAC4D0);
    border-radius: var(--md-shape-corner-medium, 16px);
    margin-top: 8px;
}

.empty-feed-action-card p {
    font-size: 0.88rem;
    color: var(--md-sys-color-on-surface-variant, #49454F);
    margin: 0;
    line-height: 1.4;
}

.empty-feed-action-card p strong {
    color: var(--md-sys-color-on-surface, #1D1B20);
}

.empty-feed-action-card .m3-btn {
    width: 100%;
    max-width: 280px;
}
/* Typing Indicator Styling & Pulse Animation */
.chat-typing-indicator {
    padding: 4px 16px 2px;
    min-height: 22px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.76rem;
    color: var(--md-sys-color-on-surface-variant, #49454F);
    animation: fadeIn 0.15s ease-out;
    background: transparent;
    user-select: none;
    box-sizing: border-box;
}

.chat-typing-indicator.hidden {
    display: none;
}

.typing-indicator-inner {
    display: flex;
    align-items: center;
    gap: 8px;
}

.typing-dots {
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

.typing-dots .dot {
    width: 5px;
    height: 5px;
    background-color: var(--md-sys-color-primary, #68246D);
    border-radius: 50%;
    animation: typingBounce 1.2s infinite ease-in-out;
}

.typing-dots .dot:nth-child(1) { animation-delay: 0s; }
.typing-dots .dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dots .dot:nth-child(3) { animation-delay: 0.4s; }

.typing-label {
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.typing-label strong {
    color: var(--md-sys-color-on-surface, #1D1B20);
    font-weight: 600;
}

@keyframes typingBounce {
    0%, 80%, 100% {
        transform: translateY(0);
        opacity: 0.35;
    }
    40% {
        transform: translateY(-3.5px);
        opacity: 1;
    }
}

/* ==========================================================================
   Feature 1: User Profile Sheet & Mention Trigger
   ========================================================================== */
.msg-author-trigger {
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    border-radius: 4px;
    padding: 2px 6px;
    margin-left: -4px;
    transition: background-color 0.15s ease, color 0.15s ease;
    user-select: none;
}

.msg-author-trigger:hover {
    background-color: rgba(104, 36, 109, 0.08);
    color: var(--md-sys-color-primary);
}

.msg-author-trigger:active {
    background-color: rgba(104, 36, 109, 0.16);
}

.user-profile-sheet {
    max-width: 480px;
    margin: 0 auto;
}

.profile-sheet-content {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 8px 16px 24px;
}

.profile-header-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: var(--md-sys-color-surface-container);
    border-radius: var(--md-shape-corner-medium);
}

.profile-avatar-circle {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--md-sys-color-primary);
    color: #FFFFFF;
    font-size: 1.4rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    text-transform: uppercase;
    flex-shrink: 0;
    box-shadow: var(--md-elevation-1);
}

.profile-header-text h3 {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--md-sys-color-on-surface);
    margin-bottom: 2px;
}

.profile-name-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 2px;
}

.profile-name-row h3 {
    margin-bottom: 0;
}

.chat-timeout-banner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--md-sys-color-error-container, #ffdad6);
    color: var(--md-sys-color-on-error-container, #410002);
    border-radius: var(--md-shape-corner-medium, 12px);
    font-size: 0.85rem;
    font-weight: 500;
    margin: 4px 12px 8px 12px;
    border: 1px solid rgba(186, 26, 26, 0.25);
    animation: fadeIn 0.2s ease-in-out;
}

.chat-timeout-banner.slow-mode {
    background: var(--md-sys-color-tertiary-container, #ffd8e4);
    color: var(--md-sys-color-on-tertiary-container, #31111d);
    border-color: rgba(125, 82, 96, 0.25);
}

.chat-timeout-banner .timeout-icon {
    font-size: 18px;
}

.profile-email-badge {
    font-size: 0.8rem;
    color: var(--md-sys-color-outline);
}

.profile-status-box {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: var(--md-sys-color-surface);
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--md-shape-corner-small);
}

.status-box-icon {
    color: var(--md-sys-color-primary);
    font-size: 20px;
    flex-shrink: 0;
}

.profile-status-text {
    font-size: 0.88rem;
    color: var(--md-sys-color-on-surface);
    font-style: italic;
    word-break: break-word;
}

.profile-details-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.profile-detail-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: var(--md-shape-corner-small);
    background: var(--md-sys-color-surface-container);
}

.detail-icon {
    color: var(--md-sys-color-primary);
    font-size: 22px;
    flex-shrink: 0;
}

.detail-info label {
    display: block;
    font-size: 0.72rem;
    color: var(--md-sys-color-outline);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.detail-info span {
    display: block;
    font-size: 0.92rem;
    font-weight: 500;
    color: var(--md-sys-color-on-surface);
    margin-top: 2px;
}

.profile-sheet-actions {
    margin-top: 4px;
}

/* ==========================================================================
   Feature 2: Infinite Scroll & Older Messages
   ========================================================================== */
.chat-loading-older {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--md-sys-color-outline);
    animation: fadeIn 0.15s ease-out;
}

.chat-loading-spinner {
    width: 14px;
    height: 14px;
    border: 2px solid var(--md-sys-color-outline-variant);
    border-top-color: var(--md-sys-color-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ==========================================================================
   Feature 3: Media Upload, Thumbnails, & Lightbox
   ========================================================================== */
.chat-attach-btn {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    color: var(--md-sys-color-on-surface-variant);
    transition: color 0.15s ease, background-color 0.15s ease;
}

.chat-attach-btn:hover {
    color: var(--md-sys-color-primary);
    background-color: rgba(104, 36, 109, 0.08);
}

.chat-media-preview-container {
    padding: 6px 14px 2px;
    background: var(--md-sys-color-surface-container);
    display: flex;
    align-items: center;
    border-top: 1px solid var(--md-sys-color-outline-variant);
}

.chat-media-preview-container.hidden {
    display: none;
}

.chat-media-preview-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--md-sys-color-surface);
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--md-shape-corner-medium);
    padding: 4px 8px 4px 4px;
    max-width: 100%;
    box-shadow: var(--md-elevation-1);
    animation: fadeIn 0.15s ease-out;
}

.preview-thumb {
    width: 36px;
    height: 36px;
    border-radius: var(--md-shape-corner-small);
    object-fit: cover;
}

.preview-name {
    font-size: 0.78rem;
    color: var(--md-sys-color-on-surface);
    max-width: 180px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.preview-cancel-btn {
    background: transparent;
    border: none;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--md-sys-color-outline);
    transition: background-color 0.15s ease, color 0.15s ease;
}

.preview-cancel-btn:hover {
    background-color: rgba(0, 0, 0, 0.08);
    color: var(--md-sys-color-error);
}

.preview-cancel-btn .material-symbols-rounded {
    font-size: 18px;
}

/* Chat Message Media Card with Anti-Jitter Placeholder */
.msg-media-wrap {
    margin-bottom: 6px;
    border-radius: var(--md-shape-corner-small);
    overflow: hidden;
    max-width: 280px;
    min-width: 140px;
    cursor: zoom-in;
    position: relative;
    display: block;
    width: fit-content;
    height: auto;
    background: transparent;
}

.msg-media-wrap:not(.is-loaded) {
    min-height: 100px;
    min-width: 140px;
    width: 240px;
    background: linear-gradient(110deg, rgba(0, 0, 0, 0.04) 8%, rgba(0, 0, 0, 0.08) 18%, rgba(0, 0, 0, 0.04) 33%);
    background-size: 200% 100%;
    animation: shimmer 1.8s linear infinite;
}

.outgoing .msg-media-wrap:not(.is-loaded) {
    background: linear-gradient(110deg, rgba(255, 255, 255, 0.12) 8%, rgba(255, 255, 255, 0.22) 18%, rgba(255, 255, 255, 0.12) 33%);
    background-size: 200% 100%;
    animation: shimmer 1.8s linear infinite;
}

.msg-media-wrap.is-loaded {
    background: transparent !important;
    animation: none !important;
    min-height: 0 !important;
    width: auto !important;
}

@keyframes shimmer {
    to { background-position-x: -200%; }
}

.msg-media-img {
    width: 100%;
    height: auto;
    max-height: 260px;
    object-fit: cover;
    display: block;
    border-radius: var(--md-shape-corner-small);
    transition: opacity 0.25s ease, transform 0.2s ease;
}

.msg-media-img:hover {
    opacity: 0.96;
    transform: scale(1.01);
}

/* Fullscreen Image Lightbox & Toolbar */
.image-lightbox-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.92);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    animation: fadeIn 0.15s ease-out;
}

.image-lightbox-backdrop.hidden {
    display: none !important;
}

/* M3 Fullscreen Lightbox Header & Author Meta */
.lightbox-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 72px;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.78) 0%, rgba(0, 0, 0, 0.35) 60%, rgba(0, 0, 0, 0) 100%);
    z-index: 2010;
    pointer-events: none;
}

.lightbox-header > * {
    pointer-events: auto;
}

.lightbox-author-badge {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.lightbox-author-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--md-sys-color-primary, #7e22ce);
    color: var(--md-sys-color-on-primary, #ffffff);
    font-weight: 700;
    font-size: 1.05rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
    text-transform: uppercase;
    user-select: none;
}

.lightbox-author-meta {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.lightbox-author-name {
    color: #FFFFFF;
    font-weight: 600;
    font-size: 0.95rem;
    line-height: 1.25;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 220px;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.75);
}

.lightbox-meta-sub {
    color: rgba(255, 255, 255, 0.76);
    font-size: 0.78rem;
    font-weight: 500;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 220px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.75);
}

.lightbox-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.lightbox-counter {
    background: rgba(255, 255, 255, 0.16);
    color: #FFFFFF;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 5px 12px;
    border-radius: 9999px;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    margin-right: 2px;
    user-select: none;
    letter-spacing: 0.02em;
}

.lightbox-tool-btn {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.18);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #FFFFFF;
    text-decoration: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease, transform 0.15s ease;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.lightbox-tool-btn:hover {
    background: rgba(255, 255, 255, 0.32);
    transform: scale(1.06);
}

.lightbox-tool-btn.close-btn:hover {
    background: rgba(255, 60, 60, 0.5);
}

.lightbox-tool-btn .material-symbols-rounded {
    font-size: 22px;
}

/* Lightbox Carousel Navigation Buttons (Previous / Next) */
.lightbox-nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2008;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(28, 24, 28, 0.68);
    border: 1px solid rgba(255, 255, 255, 0.18);
    color: #FFFFFF;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.45);
    transition: background-color 0.2s ease, transform 0.15s ease, opacity 0.2s ease;
}

.lightbox-nav-btn.prev-btn {
    left: 18px;
}

.lightbox-nav-btn.next-btn {
    right: 18px;
}

.lightbox-nav-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.32);
    transform: translateY(-50%) scale(1.08);
}

.lightbox-nav-btn:active:not(:disabled) {
    transform: translateY(-50%) scale(0.96);
}

.lightbox-nav-btn:disabled {
    opacity: 0.22;
    cursor: not-allowed;
    pointer-events: none;
}

.lightbox-nav-btn .material-symbols-rounded {
    font-size: 28px;
}

/* Floating Caption Bottom Sheet Card */
.lightbox-caption-sheet {
    position: absolute;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2008;
    width: calc(100% - 32px);
    max-width: 620px;
    background: rgba(24, 20, 24, 0.82);
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: var(--md-shape-corner-large, 16px);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.55);
    padding: 12px 18px;
    pointer-events: auto;
    animation: slideUpCaption 0.22s cubic-bezier(0.2, 0, 0, 1);
}

.lightbox-caption-sheet.hidden {
    display: none !important;
}

@keyframes slideUpCaption {
    from {
        opacity: 0;
        transform: translate(-50%, 14px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translate(-50%, 0) scale(1);
    }
}

.lightbox-caption-text {
    color: #FFFFFF;
    font-size: 0.92rem;
    line-height: 1.48;
    max-height: 110px;
    overflow-y: auto;
    word-break: break-word;
    font-family: inherit;
}

/* Material 3 Floating Action Button: Jump to Latest / Scroll to Bottom */
.m3-scroll-bottom-fab {
    position: absolute;
    bottom: 78px;
    right: 16px;
    z-index: 950;
    display: flex;
    align-items: center;
    gap: 8px;
    height: 42px;
    padding: 0 16px 0 12px;
    border-radius: 9999px;
    background: var(--md-sys-color-surface-container-high, #efe8f0);
    color: var(--md-sys-color-primary, #7e22ce);
    border: 1px solid var(--md-sys-color-outline-variant, rgba(126, 34, 206, 0.2));
    box-shadow: var(--md-elevation-3, 0 4px 14px rgba(0, 0, 0, 0.2));
    cursor: pointer;
    font-size: 0.84rem;
    font-weight: 600;
    letter-spacing: 0.015em;
    user-select: none;
    transition: opacity 0.22s ease, transform 0.22s cubic-bezier(0.2, 0, 0, 1), background-color 0.2s ease, box-shadow 0.2s ease;
}

.m3-scroll-bottom-fab:hover {
    background: var(--md-sys-color-surface-container-highest, #e9e1eb);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.24);
}

.m3-scroll-bottom-fab:active {
    transform: translateY(0);
}

.m3-scroll-bottom-fab.hidden {
    opacity: 0;
    transform: translateY(14px) scale(0.92);
    pointer-events: none;
}

.m3-scroll-bottom-fab .material-symbols-rounded {
    font-size: 20px;
}

/* Chat Message Highlight Glow upon Lightbox Exit */
@keyframes msgPulseGlow {
    0% {
        box-shadow: 0 0 0 0 rgba(126, 34, 206, 0.7), 0 4px 16px rgba(126, 34, 206, 0.35);
    }
    40% {
        box-shadow: 0 0 0 6px rgba(126, 34, 206, 0.45), 0 8px 26px rgba(126, 34, 206, 0.4);
    }
    100% {
        box-shadow: 0 0 0 0 transparent;
    }
}

.chat-message.msg-highlight-pulse .msg-bubble {
    animation: msgPulseGlow 2.2s cubic-bezier(0.2, 0, 0, 1) forwards !important;
}

.lightbox-content {
    width: 100vw;
    width: 100dvw;
    height: 100vh;
    height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    padding: 0;
    margin: 0;
}

.lightbox-content img {
    max-width: 96vw;
    max-height: 80vh;
    max-height: 80dvh;
    object-fit: contain;
    border-radius: 6px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
    user-select: none;
    -webkit-user-select: none;
    pointer-events: auto;
    will-change: transform, filter;
    transform-origin: center center;
    transition: transform 0.25s cubic-bezier(0.2, 0, 0, 1), filter 0.2s ease-out;
    cursor: zoom-in;
}

.lightbox-content img.is-thumbnail {
    filter: blur(0.5px);
}

.lightbox-content img.is-sharpened {
    filter: none;
    animation: sharpenIn 0.2s ease-out;
}

@keyframes sharpenIn {
    0% { filter: blur(2px); }
    100% { filter: blur(0); }
}

.lightbox-content.is-zoomed img {
    cursor: grab;
}

.lightbox-content.is-dragging img {
    cursor: grabbing;
    transition: none !important;
}

/* ==========================================================================
   Upload Progress, Button Spinner, & Optimistic Message Bubbles
   ========================================================================== */
.btn-spinner {
    width: 20px;
    height: 20px;
    border: 2.5px solid rgba(255, 255, 255, 0.35);
    border-top-color: #FFFFFF;
    border-radius: 50%;
    animation: spin 0.75s linear infinite;
    display: inline-block;
}

.chat-media-preview-chip.uploading {
    background: var(--md-sys-color-primary-container);
    border-color: var(--md-sys-color-primary);
    position: relative;
}

.preview-info-col {
    display: flex;
    flex-direction: column;
    min-width: 120px;
    max-width: 200px;
    gap: 3px;
}

.preview-status-label {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--md-sys-color-primary);
    line-height: 1.1;
}

.preview-progress-track {
    width: 100%;
    height: 4px;
    background: rgba(104, 36, 109, 0.15);
    border-radius: 2px;
    overflow: hidden;
}

.preview-progress-fill {
    height: 100%;
    width: 0%;
    background: var(--md-sys-color-primary);
    border-radius: 2px;
    transition: width 0.12s ease-out;
}

/* Optimistic Outgoing Message Bubble */
.chat-message.optimistic {
    transition: opacity 0.2s ease;
}

.chat-message.optimistic .msg-bubble {
    box-shadow: 0 2px 8px rgba(104, 36, 109, 0.25);
    position: relative;
}

.msg-media-wrap.uploading {
    position: relative;
    overflow: hidden;
}

.msg-media-wrap.uploading .msg-media-img {
    filter: brightness(0.65) blur(0.5px);
}

.media-upload-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: #FFFFFF;
    background: rgba(0, 0, 0, 0.25);
    z-index: 2;
}

.media-upload-spinner {
    width: 30px;
    height: 30px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: #FFFFFF;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.media-upload-text {
    font-size: 0.76rem;
    font-weight: 600;
    letter-spacing: 0.3px;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
    color: #FFFFFF;
}

.upload-retry-btn {
    background: #BA1A1A;
    color: #FFFFFF;
    border: none;
    border-radius: 9999px;
    padding: 6px 14px;
    font-size: 0.76rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
    transition: background-color 0.15s ease;
}

.upload-retry-btn:hover {
    background: #93000A;
}

.optimistic-status {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-style: italic;
    opacity: 0.9;
}

/* ==========================================================================
   Comprehensive Moderation & RBAC Styling (Material Design 3)
   ========================================================================== */

/* 1. Badges & Indicators */
#btn-admin-dashboard {
    position: relative;
    overflow: visible;
}

.admin-badge {
    position: absolute;
    top: 0px;
    right: 0px;
    background: var(--md-sys-color-error);
    color: var(--md-sys-color-on-error);
    font-size: 0.65rem;
    font-weight: 700;
    min-width: 17px;
    height: 17px;
    border-radius: 9999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    border: 2px solid var(--md-sys-color-surface);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
    z-index: 2;
    pointer-events: none;
}

.role-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    padding: 2px 7px;
    border-radius: 9999px;
    line-height: 1.2;
    vertical-align: middle;
}

.role-badge.owner {
    background: rgba(194, 155, 56, 0.16);
    color: #936B0F;
    border: 1px solid rgba(194, 155, 56, 0.4);
}

[data-theme="dark"] .role-badge.owner {
    background: rgba(229, 194, 102, 0.18);
    color: #E5C266;
    border-color: rgba(229, 194, 102, 0.45);
}

.role-badge.moderator {
    background: rgba(104, 36, 109, 0.12);
    color: var(--md-sys-color-primary);
    border: 1px solid rgba(104, 36, 109, 0.28);
}

[data-theme="dark"] .role-badge.moderator {
    background: rgba(240, 178, 255, 0.14);
    color: #F0B2FF;
    border-color: rgba(240, 178, 255, 0.35);
}

.role-badge.suspended {
    background: rgba(186, 26, 26, 0.12);
    color: var(--md-sys-color-error);
    border: 1px solid rgba(186, 26, 26, 0.3);
}

.role-badge.muted {
    background: rgba(100, 100, 100, 0.12);
    color: var(--md-sys-color-on-surface-variant);
    border: 1px solid rgba(100, 100, 100, 0.25);
}

/* 2. Pinned Announcement Banner */
.chat-pinned-banner {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--md-sys-color-surface-container-high);
    border: 1px solid var(--md-sys-color-outline-variant);
    border-left: 4px solid var(--md-sys-color-primary);
    border-radius: var(--md-shape-corner-medium);
    padding: 8px 12px;
    margin: 4px 16px 8px;
    box-shadow: var(--md-sys-elevation-1);
    cursor: pointer;
    transition: background-color 0.15s ease, transform 0.1s ease;
    flex-shrink: 0;
}

.chat-pinned-banner:hover {
    background: var(--md-sys-color-surface-container-highest);
}

.pinned-banner-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(104, 36, 109, 0.12);
    color: var(--md-sys-color-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.pinned-banner-body {
    flex: 1;
    min-width: 0;
}

.pinned-banner-header {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.72rem;
    line-height: 1.2;
}

.pinned-label {
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: var(--md-sys-color-primary);
}

.pinned-author {
    color: var(--md-sys-color-on-surface-variant);
    font-weight: 500;
}

.pinned-snippet {
    font-size: 0.84rem;
    color: var(--md-sys-color-on-surface);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
}

.pinned-unpin-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--md-sys-color-on-surface-variant);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: background-color 0.15s ease;
}

.pinned-unpin-btn:hover {
    background: var(--md-sys-color-surface-variant);
    color: var(--md-sys-color-on-surface);
}

/* 3. Soft-Deleted Message Tombstone */
.msg-bubble.is-deleted {
    background: var(--md-sys-color-surface-container-low) !important;
    border: 1px dashed var(--md-sys-color-outline-variant) !important;
    color: var(--md-sys-color-on-surface-variant) !important;
    box-shadow: none !important;
}

.msg-deleted-tombstone {
    display: flex;
    align-items: center;
    gap: 6px;
    font-style: italic;
    font-size: 0.85rem;
    color: var(--md-sys-color-on-surface-variant);
    padding: 2px 0;
}

.msg-deleted-tombstone .material-symbols-rounded {
    font-size: 16px;
    opacity: 0.7;
}

.msg-deleted-mod-view {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.msg-deleted-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--md-sys-color-error);
}

.msg-deleted-badge .material-symbols-rounded {
    font-size: 14px;
}

.msg-deleted-original {
    font-size: 0.88rem;
    opacity: 0.85;
}

/* Message highlighting when jumped to */
.chat-message.highlight-target .msg-bubble {
    animation: highlightPulse 2s ease-out;
}

@keyframes highlightPulse {
    0% {
        box-shadow: 0 0 0 4px var(--md-sys-color-primary);
        transform: scale(1.02);
    }
    100% {
        box-shadow: none;
        transform: scale(1);
    }
}

/* 4. Popover Menu Moderation & Report Actions */
.picker-divider {
    width: 1px;
    height: 20px;
    background: var(--md-sys-color-outline-variant);
    margin: 0 2px;
}

.picker-action-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--md-sys-color-on-surface-variant);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.picker-action-btn .material-symbols-rounded {
    font-size: 18px;
}

.picker-action-btn:hover {
    background: var(--md-sys-color-surface-container-highest);
    color: var(--md-sys-color-on-surface);
}

.picker-action-btn.report:hover {
    color: var(--md-sys-color-error);
    background: rgba(186, 26, 26, 0.12);
}

.picker-action-btn.delete:hover {
    color: var(--md-sys-color-error);
    background: rgba(186, 26, 26, 0.12);
}

.picker-action-btn.pin:hover {
    color: var(--md-sys-color-primary);
    background: rgba(104, 36, 109, 0.12);
}

/* 5. Report Message Modal */
.report-sheet {
    max-width: 500px;
}

.report-preview-box {
    background: var(--md-sys-color-surface-container-high);
    border: 1px solid var(--md-sys-color-outline-variant);
    border-left: 3px solid var(--md-sys-color-primary);
    border-radius: var(--md-shape-corner-medium);
    padding: 8px 12px;
    margin-bottom: 14px;
}

.report-preview-header {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.76rem;
    font-weight: 600;
    color: var(--md-sys-color-on-surface-variant);
    margin-bottom: 4px;
}

.report-preview-body {
    font-size: 0.88rem;
    color: var(--md-sys-color-on-surface);
    line-height: 1.35;
    max-height: 80px;
    overflow-y: auto;
}

.form-section-label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--md-sys-color-on-surface-variant);
    margin-bottom: 8px;
}

.report-categories-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

@media (max-width: 480px) {
    .report-categories-grid {
        grid-template-columns: 1fr;
    }
}

.report-category-card {
    display: flex;
    align-items: center;
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--md-shape-corner-medium);
    padding: 8px 10px;
    cursor: pointer;
    background: var(--md-sys-color-surface);
    transition: all 0.15s ease;
    user-select: none;
}

.report-category-card input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.report-category-card:has(input[type="radio"]:checked) {
    background: var(--md-sys-color-primary-container);
    border-color: var(--md-sys-color-primary);
    box-shadow: 0 0 0 1px var(--md-sys-color-primary);
}

.category-card-content {
    display: flex;
    align-items: center;
    gap: 8px;
}

.category-icon {
    font-size: 20px;
    color: var(--md-sys-color-on-surface-variant);
}

.report-category-card:has(input[type="radio"]:checked) .category-icon {
    color: var(--md-sys-color-primary);
}

.category-title {
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--md-sys-color-on-surface);
}

.report-modal-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 16px;
}

.m3-btn.error-fill {
    background: var(--md-sys-color-error);
    color: var(--md-sys-color-on-error);
}

.m3-btn.error-fill:hover {
    background: #93000A;
}

/* 6. Feed Management Modal */
.feed-manage-sheet {
    max-width: 580px;
    max-height: 85vh;
    max-height: 85dvh;
    display: flex;
    flex-direction: column;
}

.sheet-subtitle {
    font-size: 0.78rem;
    color: var(--md-sys-color-on-surface-variant);
    display: block;
    margin-top: -2px;
}

.feed-manage-tab-panel {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 12px;
}

.feed-members-toolbar {
    margin-bottom: 4px;
}

.m3-search-box.compact {
    padding: 4px 10px;
    background: var(--md-sys-color-surface-container-high);
    border-radius: var(--md-shape-corner-full);
    border: 1px solid var(--md-sys-color-outline-variant);
    display: flex;
    align-items: center;
    gap: 6px;
}

.m3-search-box.compact input {
    border: none;
    background: transparent;
    color: var(--md-sys-color-on-surface);
    font-size: 0.85rem;
    width: 100%;
    outline: none;
}

.feed-members-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 50vh;
    overflow-y: auto;
    padding-right: 4px;
}

.feed-member-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--md-sys-color-surface-container-low);
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--md-shape-corner-medium);
    padding: 8px 12px;
    gap: 10px;
}

.feed-member-info {
    flex: 1;
    min-width: 0;
}

.feed-member-header {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.feed-member-name {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--md-sys-color-on-surface);
}

.feed-member-sub {
    font-size: 0.76rem;
    color: var(--md-sys-color-on-surface-variant);
    margin-top: 2px;
}

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

.feed-member-actions .m3-btn {
    padding: 4px 8px;
    font-size: 0.74rem;
    min-height: 28px;
}

@media (max-width: 480px) {
    .feed-member-row {
        flex-wrap: wrap;
        padding: 10px 12px;
        gap: 8px;
    }
    .feed-member-info {
        flex: 1 1 calc(100% - 50px);
        min-width: 0;
    }
    .feed-member-actions {
        width: 100%;
        justify-content: flex-end;
        padding-top: 6px;
        margin-top: 2px;
        border-top: 1px solid var(--md-sys-color-outline-variant, rgba(0, 0, 0, 0.08));
    }
}

/* Settings Group Cards */
.settings-group-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--md-sys-color-surface-container-low);
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--md-shape-corner-medium);
    padding: 12px 14px;
    gap: 12px;
    margin-bottom: 10px;
}

.settings-group-header {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
}

.settings-group-header .material-symbols-rounded {
    font-size: 24px;
    color: var(--md-sys-color-primary);
    flex-shrink: 0;
}

.settings-group-title {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--md-sys-color-on-surface);
}

.settings-group-desc {
    font-size: 0.76rem;
    color: var(--md-sys-color-on-surface-variant);
    margin-top: 2px;
}

/* M3 Switch Component */
.m3-switch-row {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 28px;
    flex-shrink: 0;
}

.m3-switch-input {
    opacity: 0;
    width: 0;
    height: 0;
}

.m3-switch-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background-color: var(--md-sys-color-surface-container-highest);
    border: 2px solid var(--md-sys-color-outline);
    border-radius: 28px;
    transition: 0.2s cubic-bezier(0.2, 0, 0, 1);
}

.m3-switch-slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 4px;
    bottom: 4px;
    background-color: var(--md-sys-color-outline);
    border-radius: 50%;
    transition: 0.2s cubic-bezier(0.2, 0, 0, 1);
}

.m3-switch-input:checked + .m3-switch-slider {
    background-color: var(--md-sys-color-primary);
    border-color: var(--md-sys-color-primary);
}

.m3-switch-input:checked + .m3-switch-slider:before {
    transform: translateX(20px);
    background-color: var(--md-sys-color-on-primary);
}

/* 7. Campus Admin Fullscreen Window */
.admin-dashboard-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(6px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.admin-dashboard-window {
    width: 100%;
    max-width: 1000px;
    height: 90vh;
    height: 90dvh;
    background: var(--md-sys-color-surface);
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: 24px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: var(--md-sys-elevation-3);
    animation: m3SheetIn 0.2s ease-out;
}

.tab-label-short {
    display: none;
}

.admin-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
    background: var(--md-sys-color-surface-container-low);
    flex-shrink: 0;
}

.admin-header-leading {
    display: flex;
    align-items: center;
    gap: 12px;
}

.admin-shield-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-primary);
    display: flex;
    align-items: center;
    justify-content: center;
}

.admin-shield-icon .material-symbols-rounded {
    font-size: 24px;
}

.admin-header h2 {
    font-size: 1.15rem;
    font-weight: 700;
    margin: 0;
    color: var(--md-sys-color-on-surface);
}

.admin-role-indicator {
    font-size: 0.74rem;
    color: var(--md-sys-color-primary);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.admin-nav-tabs {
    display: flex;
    gap: 6px;
    padding: 0 16px;
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
    background: var(--md-sys-color-surface-container-lowest);
    flex-shrink: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.admin-nav-tabs::-webkit-scrollbar {
    display: none;
}

.admin-tab-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 12px 14px;
    border: none;
    background: transparent;
    color: var(--md-sys-color-on-surface-variant);
    font-size: 0.88rem;
    font-weight: 600;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s ease;
}

.admin-tab-btn .material-symbols-rounded {
    font-size: 18px;
}

.admin-tab-btn.active {
    color: var(--md-sys-color-primary);
    border-bottom-color: var(--md-sys-color-primary);
}

.admin-tab-badge {
    background: var(--md-sys-color-error);
    color: var(--md-sys-color-on-error);
    font-size: 0.68rem;
    padding: 1px 6px;
    border-radius: 9999px;
    font-weight: 700;
}

.admin-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
}

@media (max-width: 768px) {
    .tab-label-full {
        display: none;
    }
    .tab-label-short {
        display: inline;
    }
    .admin-dashboard-backdrop {
        padding: 0;
    }
    .admin-dashboard-window {
        height: 100vh;
        height: 100dvh;
        border-radius: 0;
        border: none;
    }
    .admin-header {
        padding: 10px 14px;
    }
    .admin-header h2 {
        font-size: 1.05rem;
    }
    .admin-nav-tabs {
        padding: 0 4px;
        gap: 0;
        display: flex;
        justify-content: space-between;
    }
    .admin-tab-btn {
        flex: 1 1 0;
        justify-content: center;
        padding: 10px 4px;
        font-size: 0.78rem;
        gap: 4px;
        min-width: 0;
    }
    .admin-tab-btn .material-symbols-rounded {
        font-size: 16px;
    }
    .admin-body {
        padding: 12px 12px calc(32px + env(safe-area-inset-bottom, 0px));
    }
}

.admin-panel-subbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.admin-search {
    flex: 1 1 220px;
    max-width: 480px;
}

.admin-filter-pills {
    display: flex;
    gap: 6px;
}

.admin-filter-pill,
.admin-user-role-pill {
    padding: 4px 12px;
    border-radius: var(--md-shape-corner-full);
    border: 1px solid var(--md-sys-color-outline-variant);
    background: var(--md-sys-color-surface);
    color: var(--md-sys-color-on-surface-variant);
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
}

.admin-filter-pill.active,
.admin-user-role-pill.active {
    background: var(--md-sys-color-primary-container);
    border-color: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary-container);
    font-weight: 600;
}

/* Reports Grid & Cards */
.admin-reports-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.admin-report-card {
    background: var(--md-sys-color-surface-container-low);
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--md-shape-corner-medium);
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.admin-report-card.pending {
    border-left: 4px solid var(--md-sys-color-error);
}

.admin-report-card.resolved {
    border-left: 4px solid #388E3C;
    opacity: 0.9;
}

.admin-report-card.dismissed {
    border-left: 4px solid var(--md-sys-color-outline);
    opacity: 0.75;
}

.report-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
}

.report-category-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(186, 26, 26, 0.12);
    color: var(--md-sys-color-error);
    font-size: 0.74rem;
    font-weight: 700;
    text-transform: uppercase;
    padding: 3px 8px;
    border-radius: var(--md-shape-corner-full);
}

.report-meta-text {
    font-size: 0.76rem;
    color: var(--md-sys-color-on-surface-variant);
}

/* Student & Transgression Infraction Strip */
.report-student-strip {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
    background: var(--md-sys-color-surface-container);
    border-radius: 10px;
    padding: 8px 12px;
    border: 1px solid var(--md-sys-color-outline-variant);
}

.report-student-info {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.84rem;
    flex-wrap: wrap;
}

.report-student-name {
    font-weight: 600;
    color: var(--md-sys-color-on-surface);
}

.report-student-email {
    font-size: 0.76rem;
    color: var(--md-sys-color-on-surface-variant);
}

/* Transgression Infraction Pill Button */
.admin-transgression-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: var(--md-shape-corner-full, 9999px);
    font-size: 0.74rem;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.18s ease;
    text-decoration: none;
    line-height: 1.2;
}

.admin-transgression-chip .chip-icon {
    font-size: 15px;
}

.admin-transgression-chip .chip-chevron {
    font-size: 14px;
    opacity: 0.7;
    margin-left: 2px;
}

.admin-transgression-chip.warning {
    background: rgba(186, 26, 26, 0.1);
    color: var(--md-sys-color-error, #ba1a1a);
    border-color: rgba(186, 26, 26, 0.3);
}

.admin-transgression-chip.warning:hover {
    background: rgba(186, 26, 26, 0.18);
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(186, 26, 26, 0.2);
}

.admin-transgression-chip.clean {
    background: rgba(46, 125, 50, 0.09);
    color: #2e7d32;
    border-color: rgba(46, 125, 50, 0.3);
}

.admin-transgression-chip.clean:hover {
    background: rgba(46, 125, 50, 0.16);
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(46, 125, 50, 0.15);
}

.report-message-preview {
    background: var(--md-sys-color-surface);
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--md-shape-corner-medium);
    padding: 10px 12px;
    font-size: 0.88rem;
}

.report-message-preview .message-content {
    word-break: break-word;
    line-height: 1.45;
}

.report-reason-box {
    font-size: 0.82rem;
    color: var(--md-sys-color-on-surface-variant);
    font-style: italic;
    background: rgba(0,0,0,0.03);
    padding: 6px 10px;
    border-radius: 6px;
    border-left: 3px solid var(--md-sys-color-outline-variant);
}

/* Context Expander Bar & Micro-Timeline */
.report-context-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: 2px;
}

.btn-toggle-context {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--md-sys-color-primary);
    background: var(--md-sys-color-surface-container-high);
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: 8px;
    padding: 6px 12px;
    cursor: pointer;
    transition: all 0.18s ease;
}

.btn-toggle-context:hover {
    background: var(--md-sys-color-surface-container-highest);
}

.btn-toggle-context.expanded .context-chevron {
    transform: rotate(180deg);
}

.context-chevron {
    font-size: 16px;
    transition: transform 0.2s ease;
}

.report-context-drawer {
    margin-top: 4px;
    background: var(--md-sys-color-surface-container);
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: 12px;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    animation: m3SheetIn 0.2s ease-out;
}

.context-stream {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 280px;
    overflow-y: auto;
    padding-right: 4px;
}

.context-msg-item {
    padding: 8px 12px;
    border-radius: 10px;
    background: var(--md-sys-color-surface);
    border: 1px solid var(--md-sys-color-outline-variant);
    font-size: 0.82rem;
}

.context-msg-item.target-msg {
    border: 2px solid var(--md-sys-color-error);
    background: rgba(186, 26, 26, 0.06);
    box-shadow: 0 0 0 2px rgba(186, 26, 26, 0.12);
}

.context-msg-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.72rem;
    margin-bottom: 4px;
    color: var(--md-sys-color-on-surface-variant);
}

.context-msg-author {
    font-weight: 600;
    color: var(--md-sys-color-on-surface);
}

.context-target-badge {
    background: var(--md-sys-color-error);
    color: #ffffff;
    font-size: 0.68rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    text-transform: uppercase;
}

/* Report Action Toolbar (Zero-Gap Layout) */
.report-actions-row {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
    padding-top: 8px;
    border-top: 1px solid var(--md-sys-color-outline-variant);
    margin-top: 4px;
}

.report-actions-row .btn-triage-dismiss {
    border: 1px solid var(--md-sys-color-outline-variant) !important;
    background: transparent !important;
    color: var(--md-sys-color-on-surface-variant) !important;
}

.report-actions-row .btn-triage-dismiss:hover {
    background: var(--md-sys-color-surface-container-high) !important;
    color: var(--md-sys-color-on-surface) !important;
}

.report-actions-row .m3-btn {
    padding: 6px 14px;
    font-size: 0.8rem;
    min-height: 36px;
}

.triage-primary-btn,
#btn-execute-triage {
    background: #ba1a1a !important;
    color: #ffffff !important;
    font-weight: 600 !important;
    border: none !important;
}

.triage-primary-btn:hover,
#btn-execute-triage:hover {
    background: #93000a !important;
    color: #ffffff !important;
}

[data-theme="dark"] .triage-primary-btn,
[data-theme="dark"] #btn-execute-triage {
    background: #ffb4ab !important;
    color: #690005 !important;
    font-weight: 700 !important;
}

[data-theme="dark"] .triage-primary-btn:hover,
[data-theme="dark"] #btn-execute-triage:hover {
    background: #ffdad6 !important;
    color: #410002 !important;
}

.triage-dialog {
    max-width: 580px;
    max-height: 90vh;
    max-height: 90dvh;
    overflow-y: auto;
    padding: 22px 22px 28px 22px !important;
    box-sizing: border-box;
}

@media (max-width: 600px) {
    .report-actions-row {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        width: 100%;
    }
    .report-actions-row .m3-btn {
        width: 100%;
        justify-content: center;
    }
    .report-actions-row .triage-primary-btn {
        grid-column: 1 / -1;
        width: 100%;
        justify-content: center;
    }
}

/* Dossier Modal Styles */
.dossier-stat-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 14px;
}

@media (max-width: 500px) {
    .dossier-stat-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

.dossier-stat-card {
    background: var(--md-sys-color-surface-container);
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: 10px;
    padding: 10px;
    text-align: center;
}

.dossier-stat-card .stat-num {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--md-sys-color-primary);
}

.dossier-stat-card.stat-warn .stat-num {
    color: var(--md-sys-color-error);
}

.dossier-stat-card .stat-label {
    font-size: 0.72rem;
    color: var(--md-sys-color-on-surface-variant);
    text-transform: uppercase;
    font-weight: 600;
    margin-top: 2px;
}

.dossier-active-penalty {
    background: rgba(186, 26, 26, 0.1);
    border: 1px solid rgba(186, 26, 26, 0.3);
    border-radius: 10px;
    padding: 10px 14px;
    margin-bottom: 14px;
    font-size: 0.84rem;
    color: var(--md-sys-color-error);
    display: flex;
    align-items: center;
    gap: 10px;
}

.dossier-history-section {
    margin-top: 14px;
}

.dossier-section-title {
    font-size: 0.84rem;
    font-weight: 700;
    color: var(--md-sys-color-on-surface);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.dossier-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 220px;
    overflow-y: auto;
    padding-right: 4px;
}

.dossier-item {
    background: var(--md-sys-color-surface-container);
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 0.8rem;
}

/* Student Directory Grid */
.admin-users-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.admin-user-card {
    display: flex;
    flex-direction: column;
    background: var(--md-sys-color-surface-container-low);
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--md-shape-corner-medium);
    padding: 12px 14px;
    gap: 10px;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.admin-user-card:hover {
    background: var(--md-sys-color-surface-container);
    border-color: var(--md-sys-color-outline);
}

.admin-user-card-main {
    display: flex;
    align-items: center;
    gap: 12px;
}

.admin-user-avatar-wrap {
    position: relative;
    flex-shrink: 0;
}

.admin-user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--md-sys-color-surface-container-high);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--md-sys-color-primary);
    overflow: hidden;
}

.admin-user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.admin-user-info {
    flex: 1;
    min-width: 0;
}

.admin-user-name {
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--md-sys-color-on-surface);
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.admin-user-email {
    font-size: 0.78rem;
    color: var(--md-sys-color-on-surface-variant);
    margin-top: 1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.admin-user-sub {
    font-size: 0.76rem;
    color: var(--md-sys-color-on-surface-variant);
    margin-top: 2px;
}

.admin-user-meta-strip {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.admin-meta-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 0.74rem;
    font-weight: 500;
    background: var(--md-sys-color-surface-container-high);
    color: var(--md-sys-color-on-surface-variant);
}

.admin-meta-chip .material-symbols-rounded {
    font-size: 14px;
    color: var(--md-sys-color-outline);
}

.admin-meta-chip.warning {
    background: var(--md-sys-color-error-container);
    color: var(--md-sys-color-on-error-container);
    font-weight: 600;
}

.admin-meta-chip.warning .material-symbols-rounded {
    color: var(--md-sys-color-error);
}

.admin-meta-chip.presence {
    gap: 6px;
}

.admin-user-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--md-sys-color-outline-variant);
}

.admin-user-actions .m3-btn {
    padding: 4px 12px;
    font-size: 0.76rem;
    min-height: 30px;
}

@media (min-width: 640px) {
    .admin-user-card {
        display: grid;
        grid-template-columns: 1fr auto;
        grid-template-areas:
            "main actions"
            "meta actions";
        align-items: center;
        gap: 8px 16px;
    }
    .admin-user-card-main {
        grid-area: main;
    }
    .admin-user-meta-strip {
        grid-area: meta;
    }
    .admin-user-actions {
        grid-area: actions;
        padding-top: 0;
        border-top: none;
    }
}

/* Audit Trail */
.audit-summary-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--md-sys-color-on-surface-variant);
}

.admin-audit-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.admin-audit-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    background: var(--md-sys-color-surface-container-low);
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--md-shape-corner-medium);
    padding: 8px 12px;
    gap: 10px;
    font-size: 0.82rem;
}

.admin-audit-main {
    flex: 1;
}

.audit-action-chip {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--md-sys-color-surface-container-highest);
    color: var(--md-sys-color-primary);
    margin-right: 6px;
}

.audit-time {
    font-size: 0.74rem;
    color: var(--md-sys-color-on-surface-variant);
    white-space: nowrap;
}

/* ==========================================================================
   Material 3 Dialog: Role Assignment Modal
   ========================================================================== */
#role-assignment-modal {
    z-index: 2500 !important;
    align-items: center !important;
}

.role-assignment-dialog {
    background: var(--md-sys-color-surface);
    border-radius: var(--md-shape-corner-extra-large, 28px);
    max-width: 520px;
    width: 92%;
    margin: auto;
    padding: 24px;
    box-shadow: var(--md-sys-elevation-3);
    border: 1px solid var(--md-sys-color-outline-variant);
    display: flex;
    flex-direction: column;
    gap: 18px;
    animation: m3DialogEnter 0.22s cubic-bezier(0.1, 0.9, 0.2, 1);
}

@keyframes m3DialogEnter {
    from { opacity: 0; transform: scale(0.92) translateY(12px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.role-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.role-modal-leading {
    display: flex;
    align-items: center;
    gap: 14px;
}

.role-icon-circle {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.role-icon-circle .material-symbols-rounded {
    font-size: 24px;
}

.role-modal-header h2 {
    font-size: 1.15rem;
    font-weight: 700;
    margin: 0;
    color: var(--md-sys-color-on-surface);
}

.role-modal-subtitle {
    font-size: 0.8rem;
    color: var(--md-sys-color-on-surface-variant);
    display: block;
    margin-top: 2px;
}

.role-modal-form {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

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

.role-option-card {
    display: block;
    position: relative;
    border: 1.5px solid var(--md-sys-color-outline-variant);
    border-radius: var(--md-shape-corner-medium, 16px);
    background: var(--md-sys-color-surface-container-low);
    padding: 14px 16px;
    cursor: pointer;
    transition: all 0.18s cubic-bezier(0.2, 0, 0, 1);
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.role-option-card input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.role-option-card:hover {
    border-color: var(--md-sys-color-outline);
    background: var(--md-sys-color-surface-container);
}

.role-option-card:has(input[type="radio"]:checked) {
    border-color: var(--md-sys-color-primary);
    background: var(--md-sys-color-primary-container);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.role-card-content {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.role-card-header {
    display: flex;
    align-items: center;
    gap: 10px;
}

.role-card-icon {
    font-size: 22px;
    color: var(--md-sys-color-on-surface-variant);
    transition: color 0.18s ease;
}

.role-option-card:has(input[type="radio"]:checked) .role-card-icon {
    color: var(--md-sys-color-on-primary-container);
}

.role-card-icon.role-gold {
    color: #e69500;
}

.role-card-icon.role-blue {
    color: #0077c2;
}

.role-card-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--md-sys-color-on-surface);
    flex: 1;
}

.role-option-card:has(input[type="radio"]:checked) .role-card-title {
    color: var(--md-sys-color-on-primary-container);
}

.role-card-badge {
    font-size: 0.68rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 9999px;
    letter-spacing: 0.3px;
    text-transform: uppercase;
}

.role-card-badge.owner {
    background: #fff0d4;
    color: #8c5b00;
    border: 1px solid #ffd180;
}

.role-card-badge.moderator {
    background: #e1f0fa;
    color: #005a9e;
    border: 1px solid #b3d7f2;
}

.role-card-badge.member {
    background: var(--md-sys-color-surface-container-highest);
    color: var(--md-sys-color-on-surface-variant);
    border: 1px solid var(--md-sys-color-outline-variant);
}

.role-card-desc {
    font-size: 0.8rem;
    line-height: 1.35;
    color: var(--md-sys-color-on-surface-variant);
    margin-left: 32px;
}

.role-option-card:has(input[type="radio"]:checked) .role-card-desc {
    color: var(--md-sys-color-on-primary-container);
}

.role-modal-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 6px;
}

/* ==========================================================================
   Material 3 Moderation & Feed Admin GUI Overhaul
   ========================================================================== */
.m3-dialog-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 2500 !important;
    display: flex;
    align-items: center !important;
    justify-content: center !important;
    padding: 16px;
    box-sizing: border-box;
}

.m3-dialog {
    background: var(--md-sys-color-surface, #ffffff);
    border-radius: var(--md-shape-corner-extra-large, 28px);
    max-width: 520px;
    width: 100%;
    margin: auto;
    padding: 24px;
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.3);
    border: 1px solid var(--md-sys-color-outline-variant, rgba(0, 0, 0, 0.12));
    display: flex;
    flex-direction: column;
    gap: 16px;
    animation: m3DialogEnter 0.22s cubic-bezier(0.1, 0.9, 0.2, 1);
    box-sizing: border-box;
}

.m3-dialog-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.m3-dialog-header > div:first-of-type {
    display: flex;
    align-items: center;
    gap: 14px;
    flex: 1;
    min-width: 0;
}

.m3-dialog-header h2 {
    font-size: 1.15rem;
    font-weight: 700;
    margin: 0;
    color: var(--md-sys-color-on-surface, #1d1b20);
}

.dialog-subtitle {
    font-size: 0.8rem;
    color: var(--md-sys-color-on-surface-variant, #49454f);
    display: block;
    margin-top: 2px;
}

.dialog-icon-circle {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.dialog-icon-circle .material-symbols-rounded {
    font-size: 24px;
}

.dialog-icon-circle.timeout-amber {
    background: #fff8e1;
    color: #b26a00;
}

.dialog-icon-circle.kick-orange {
    background: #fff3e0;
    color: #e65100;
}

.dialog-icon-circle.ban-red {
    background: #ffebee;
    color: #c62828;
}

.dialog-icon-circle.unmute-green {
    background: #e8f5e9;
    color: #2e7d32;
}

.dialog-body-text {
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--md-sys-color-on-surface-variant, #49454f);
    margin: 4px 0;
}

.dialog-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.m3-dialog-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 8px;
}

/* Member Moderation Action Sheet */
.member-action-dialog {
    max-width: 480px;
    padding: 20px;
    gap: 16px;
}

.member-action-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--md-sys-color-outline-variant, #e0e0e0);
}

.member-action-profile-card {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
}

.member-action-avatar {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--md-sys-color-primary, #6750a4), var(--md-sys-color-secondary, #625b71));
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.15rem;
    flex-shrink: 0;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.member-action-identity {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}

.member-action-name-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.member-action-name-row h3 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--md-sys-color-on-surface, #1d1b20);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.member-action-sub {
    font-size: 0.78rem;
    color: var(--md-sys-color-on-surface-variant, #49454f);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.member-action-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.member-action-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 14px;
    background: var(--md-sys-color-surface-container-low, #f7f2fa);
    border: 1.5px solid var(--md-sys-color-outline-variant, #e7e0ec);
    border-radius: var(--md-shape-corner-medium, 16px);
    cursor: pointer;
    text-align: left;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.12s ease;
    width: 100%;
    box-sizing: border-box;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.member-action-item:hover {
    background: var(--md-sys-color-surface-container, #f3edf7);
    border-color: var(--md-sys-color-outline, #79747e);
    transform: translateY(-1px);
}

.member-action-item:active {
    transform: scale(0.99);
}

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

.action-item-icon.role-gold {
    background: #fff8e1;
    color: #b26a00;
}

.action-item-icon.timeout-amber {
    background: #fff3e0;
    color: #e65100;
}

.action-item-icon.unmute-green {
    background: #e8f5e9;
    color: #2e7d32;
}

.action-item-icon.kick-orange {
    background: #fff0eb;
    color: #d84315;
}

.action-item-icon.ban-red {
    background: #ffebee;
    color: #c62828;
}

.action-item-content {
    flex: 1;
    min-width: 0;
}

.action-item-title {
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--md-sys-color-on-surface, #1d1b20);
}

.action-item-desc {
    font-size: 0.76rem;
    color: var(--md-sys-color-on-surface-variant, #49454f);
    margin-top: 2px;
    line-height: 1.3;
}

.action-item-chevron {
    color: var(--md-sys-color-outline, #79747e);
    font-size: 20px;
    flex-shrink: 0;
}

.member-action-item.danger-item:hover {
    background: #fff5f5;
    border-color: #ffcdd2;
}

.member-action-item.danger-item:hover .action-item-title {
    color: #c62828;
}

/* Duration Quick Select Chips */
.duration-chips-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 4px 0 8px 0;
}

.duration-chip {
    padding: 8px 16px;
    border-radius: var(--md-shape-corner-full, 9999px);
    border: 1px solid var(--md-sys-color-outline-variant, #cac4d0);
    background: var(--md-sys-color-surface-container-low, #f7f2fa);
    color: var(--md-sys-color-on-surface, #1d1b20);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.duration-chip:hover {
    background: var(--md-sys-color-surface-container, #f3edf7);
    border-color: var(--md-sys-color-outline, #79747e);
}

.duration-chip.active {
    background: var(--md-sys-color-primary, #6750a4);
    color: var(--md-sys-color-on-primary, #ffffff);
    border-color: var(--md-sys-color-primary, #6750a4);
    box-shadow: 0 2px 6px rgba(103, 80, 164, 0.3);
}

.error-fill {
    background: var(--md-sys-color-error, #b3261e) !important;
    color: var(--md-sys-color-on-error, #ffffff) !important;
}

.error-fill:hover {
    background: #8c1d18 !important;
}

.feed-member-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--md-sys-color-primary, #6750a4), var(--md-sys-color-secondary, #625b71));
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    flex-shrink: 0;
}

/* Feed Management Tabs with Icons */
#feed-manage-tabs .segment-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    justify-content: center;
}

/* Message Action Sheet & Modal (Mobile Bottom Sheet & Desktop Dialog) */
.msg-action-sheet-panel {
    max-width: 480px;
    width: 100%;
    margin: 0 auto;
    border-top-left-radius: 28px;
    border-top-right-radius: 28px;
    background: var(--md-sys-color-surface, #ffffff);
    box-shadow: var(--md-elevation-4, 0 8px 24px rgba(0,0,0,0.18));
    padding: 12px 18px 26px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    animation: m3SheetSlideUp 0.24s cubic-bezier(0.2, 0, 0, 1);
}

@media (min-width: 768px) {
    #msg-action-sheet.m3-sheet-backdrop {
        align-items: center;
        justify-content: center;
    }
    .msg-action-sheet-panel {
        border-radius: 28px;
        padding: 20px 24px;
        max-width: 440px;
        animation: m3ModalPopIn 0.2s cubic-bezier(0.2, 0, 0, 1);
    }
    .msg-action-sheet-panel .m3-sheet-drag-handle {
        display: none;
    }
}

.msg-sheet-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border-bottom: 1px solid var(--md-sys-color-outline-variant, #e0e0e0);
    padding-bottom: 10px;
}

.msg-sheet-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow: hidden;
    min-width: 0;
}

.msg-sheet-author {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--md-sys-color-on-surface, #1d1b20);
}

.msg-sheet-snippet {
    font-size: 0.82rem;
    color: var(--md-sys-color-on-surface-variant, #49454f);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Quick Emoji Reactions row inside the action sheet */
.msg-sheet-reactions {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: var(--md-sys-color-surface-container-low, #f7f2fa);
    border-radius: 9999px;
    overflow-x: auto;
    scrollbar-width: none;
    justify-content: space-around;
}

.msg-sheet-reactions::-webkit-scrollbar {
    display: none;
}

.msg-sheet-emoji-btn {
    background: none;
    border: none;
    font-size: 1.4rem;
    line-height: 1;
    padding: 6px;
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.15s ease, background 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.msg-sheet-emoji-btn:hover,
.msg-sheet-emoji-btn:active {
    transform: scale(1.22);
    background: var(--md-sys-color-surface-container-high, #ece6f0);
}

.msg-sheet-more-emoji {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--md-sys-color-surface-container, #f3edf7);
    border: 1px solid var(--md-sys-color-outline-variant, #cac4d0);
    color: var(--md-sys-color-on-surface-variant, #49454f);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
    flex-shrink: 0;
}

.msg-sheet-more-emoji:hover {
    background: var(--md-sys-color-primary-container, #eaddff);
    color: var(--md-sys-color-on-primary-container, #21005d);
}

/* Action items list inside the action sheet */
.msg-sheet-actions-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.msg-sheet-action-item {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    padding: 10px 14px;
    border-radius: 14px;
    border: none;
    background: transparent;
    cursor: pointer;
    text-align: left;
    transition: background 0.15s ease;
}

.msg-sheet-action-item:hover,
.msg-sheet-action-item:active {
    background: var(--md-sys-color-surface-container-high, #ece6f0);
}

.sheet-action-icon {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background: var(--md-sys-color-surface-container-high, #ece6f0);
    color: var(--md-sys-color-on-surface-variant, #49454f);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sheet-action-icon .material-symbols-rounded {
    font-size: 20px;
}

.sheet-action-icon.pin-purple {
    background: rgba(103, 80, 164, 0.14);
    color: var(--md-sys-color-primary, #6750a4);
}

.sheet-action-icon.flag-amber {
    background: rgba(245, 124, 0, 0.14);
    color: #e65100;
}

.sheet-action-icon.ban-red {
    background: var(--md-sys-color-error-container, #ffdad6);
    color: var(--md-sys-color-error, #b3261e);
}

.sheet-action-content {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-width: 0;
}

.sheet-action-title {
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--md-sys-color-on-surface, #1d1b20);
}

.sheet-action-desc {
    font-size: 0.78rem;
    color: var(--md-sys-color-on-surface-variant, #49454f);
}

.msg-sheet-action-item.danger-item .sheet-action-title {
    color: var(--md-sys-color-error, #b3261e);
}

/* Delete confirmation preview card */
.msg-delete-preview {
    margin-top: 14px;
    padding: 10px 14px;
    background: var(--md-sys-color-surface-container-low, #f7f2fa);
    border-left: 3px solid var(--md-sys-color-error, #b3261e);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.msg-delete-preview-author {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--md-sys-color-on-surface, #1d1b20);
}

.msg-delete-preview-text {
    font-size: 0.85rem;
    color: var(--md-sys-color-on-surface-variant, #49454f);
    word-break: break-word;
    max-height: 80px;
    overflow-y: auto;
}

/* Mobile Touch Optimizations for Message Action Triggers:
   Message interaction on touch screens is cleanly handled via tap/long-press bottom sheet */
@media (max-width: 768px) {
    .msg-hover-actions,
    .msg-bubble-container > .msg-hover-trigger {
        display: none !important;
    }
}

/* ==========================================================================
   Feed Analytics & Activity Hub (Admin Dashboard)
   ========================================================================== */

/* 1. Platform Summary Metric Cards */
.admin-feed-summary-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-bottom: 16px;
}

@media (max-width: 768px) {
    .admin-feed-summary-row {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
}

.admin-stat-card {
    background: var(--md-sys-color-surface-container-low, #f7f2fa);
    border: 1px solid var(--md-sys-color-outline-variant, #cac4d0);
    border-radius: 16px;
    padding: 10px 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.admin-stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.06);
}

.admin-stat-card .stat-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.admin-stat-card .stat-icon.flame-orange {
    background: rgba(245, 124, 0, 0.14);
    color: #e65100;
}

.admin-stat-card .stat-icon.active-green {
    background: rgba(46, 125, 50, 0.14);
    color: #2e7d32;
}

.admin-stat-card .stat-icon.chatters-purple {
    background: rgba(103, 80, 164, 0.14);
    color: var(--md-sys-color-primary, #6750a4);
}

.admin-stat-card .stat-icon.total-blue {
    background: rgba(2, 136, 209, 0.14);
    color: #0288d1;
}

.admin-stat-card .stat-content {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.admin-stat-card .stat-num {
    font-size: 1.25rem;
    font-weight: 700;
    line-height: 1.15;
    color: var(--md-sys-color-on-surface, #1d1b20);
}

.admin-stat-card .stat-label {
    font-size: 0.75rem;
    color: var(--md-sys-color-on-surface-variant, #49454f);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 2. Toolbar: Search & Sort */
.admin-feeds-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.admin-feeds-search-wrap {
    flex: 1;
    min-width: 220px;
    position: relative;
    display: flex;
    align-items: center;
}

.admin-feeds-search-wrap .search-icon {
    position: absolute;
    left: 12px;
    color: var(--md-sys-color-outline, #79747e);
    font-size: 20px;
    pointer-events: none;
}

.admin-feeds-search-wrap input {
    width: 100%;
    height: 40px;
    padding: 0 36px 0 40px;
    border-radius: var(--md-shape-corner-full, 9999px);
    border: 1px solid var(--md-sys-color-outline-variant, #cac4d0);
    background: var(--md-sys-color-surface-container-high, #ece6f0);
    color: var(--md-sys-color-on-surface, #1d1b20);
    font-size: 0.88rem;
    outline: none;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.admin-feeds-search-wrap input:focus {
    border-color: var(--md-sys-color-primary, #6750a4);
    background: var(--md-sys-color-surface, #ffffff);
}

.admin-feeds-search-wrap .clear-search-btn {
    position: absolute;
    right: 10px;
    background: none;
    border: none;
    color: var(--md-sys-color-outline, #79747e);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
}

.admin-feeds-sort-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.admin-feeds-sort-wrap .sort-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--md-sys-color-on-surface-variant, #49454f);
}

.admin-sort-select {
    height: 38px;
    padding: 0 12px;
    border-radius: 12px;
    border: 1px solid var(--md-sys-color-outline-variant, #cac4d0);
    background: var(--md-sys-color-surface-container, #f3edf7);
    color: var(--md-sys-color-on-surface, #1d1b20);
    font-size: 0.84rem;
    font-weight: 600;
    cursor: pointer;
    outline: none;
}

/* 3. Category Filter Chips */
.admin-feed-chips-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    overflow-x: auto;
    scrollbar-width: none;
    margin-bottom: 12px;
    padding-bottom: 2px;
}

.admin-feed-chips-bar::-webkit-scrollbar {
    display: none;
}

.admin-feed-chip {
    padding: 6px 14px;
    border-radius: var(--md-shape-corner-full, 9999px);
    border: 1px solid var(--md-sys-color-outline-variant, #cac4d0);
    background: var(--md-sys-color-surface-container-low, #f7f2fa);
    color: var(--md-sys-color-on-surface-variant, #49454f);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s ease;
}

.admin-feed-chip:hover {
    background: var(--md-sys-color-surface-container-high, #ece6f0);
}

.admin-feed-chip.active {
    background: var(--md-sys-color-primary, #6750a4);
    color: var(--md-sys-color-on-primary, #ffffff);
    border-color: var(--md-sys-color-primary, #6750a4);
}

.admin-feeds-count-bar {
    font-size: 0.78rem;
    color: var(--md-sys-color-on-surface-variant, #49454f);
    margin-bottom: 10px;
    padding-left: 2px;
}

/* 4. Interactive Feed Cards */
.admin-feed-card {
    background: var(--md-sys-color-surface, #ffffff);
    border: 1px solid var(--md-sys-color-outline-variant, #cac4d0);
    border-radius: 18px;
    padding: 14px 16px;
    margin-bottom: 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    cursor: pointer;
    transition: all 0.18s cubic-bezier(0.2, 0, 0, 1);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.admin-feed-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
    border-color: var(--md-sys-color-primary, #6750a4);
}

.admin-feed-card:active {
    transform: scale(0.99);
}

.admin-feed-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.feed-title-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.feed-title-wrap h3 {
    font-size: 1.05rem;
    font-weight: 700;
    margin: 0;
    color: var(--md-sys-color-on-surface, #1d1b20);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.feed-status-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    flex-shrink: 0;
}

.feed-status-dot.active {
    background: #2e7d32;
    box-shadow: 0 0 6px rgba(46, 125, 50, 0.6);
}

.feed-status-dot.recent {
    background: #f57c00;
    box-shadow: 0 0 6px rgba(245, 124, 0, 0.5);
}

.feed-status-dot.quiet {
    background: #9e9e9e;
}

.feed-header-badges {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

/* Activity Metrics Strip inside Card */
.feed-card-metrics-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.metric-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 8px;
    font-size: 0.78rem;
    font-weight: 600;
    background: var(--md-sys-color-surface-container-low, #f7f2fa);
    color: var(--md-sys-color-on-surface-variant, #49454f);
}

.metric-pill.hot {
    background: rgba(245, 124, 0, 0.12);
    color: #e65100;
}

.metric-pill.active {
    background: rgba(46, 125, 50, 0.12);
    color: #2e7d32;
}

.metric-pill.members {
    background: rgba(103, 80, 164, 0.1);
    color: var(--md-sys-color-primary, #6750a4);
}

.admin-feed-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.76rem;
    color: var(--md-sys-color-on-surface-variant, #49454f);
    border-top: 1px solid var(--md-sys-color-surface-container, #f3edf7);
    padding-top: 8px;
}

.view-stats-cue {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-weight: 600;
    color: var(--md-sys-color-primary, #6750a4);
}

/* ==========================================================================
   Feed Deep-Dive Analytics Modal (#feed-analytics-modal)
   ========================================================================== */

.feed-analytics-panel {
    max-width: 740px;
    width: 100%;
    margin: 0 auto;
    border-top-left-radius: 28px;
    border-top-right-radius: 28px;
    background: var(--md-sys-color-surface, #ffffff);
    box-shadow: var(--md-elevation-4, 0 8px 24px rgba(0,0,0,0.18));
    padding: 14px 20px 28px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    max-height: 90vh;
    overflow-y: auto;
    animation: m3SheetSlideUp 0.24s cubic-bezier(0.2, 0, 0, 1);
}

@media (min-width: 768px) {
    #feed-analytics-modal.m3-sheet-backdrop {
        align-items: center;
        justify-content: center;
    }
    .feed-analytics-panel {
        border-radius: 28px;
        padding: 24px 28px;
        max-height: 85vh;
        animation: m3ModalPopIn 0.2s cubic-bezier(0.2, 0, 0, 1);
    }
    .feed-analytics-panel .m3-sheet-drag-handle {
        display: none;
    }
}

.analytics-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border-bottom: 1px solid var(--md-sys-color-outline-variant, #e0e0e0);
    padding-bottom: 12px;
    flex-wrap: wrap;
}

.analytics-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.analytics-icon-circle {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--md-sys-color-primary, #6750a4), var(--md-sys-color-secondary, #625b71));
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.analytics-title-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.analytics-title-row h2 {
    font-size: 1.2rem;
    font-weight: 700;
    margin: 0;
    color: var(--md-sys-color-on-surface, #1d1b20);
}

.analytics-subtitle {
    font-size: 0.78rem;
    color: var(--md-sys-color-on-surface-variant, #49454f);
}

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

.analytics-modal-body {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Modal Metrics Grid */
.analytics-metrics-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

@media (max-width: 640px) {
    .analytics-metrics-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

.fa-metric-card {
    background: var(--md-sys-color-surface-container-low, #f7f2fa);
    border: 1px solid var(--md-sys-color-outline-variant, #cac4d0);
    border-radius: 14px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.fa-metric-val {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--md-sys-color-on-surface, #1d1b20);
    line-height: 1.1;
}

.fa-metric-sub {
    font-size: 0.72rem;
    color: var(--md-sys-color-on-surface-variant, #49454f);
}

.fa-metric-title {
    font-size: 0.76rem;
    font-weight: 600;
    color: var(--md-sys-color-primary, #6750a4);
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

/* 14-Day Activity Bar Chart */
.analytics-section {
    background: var(--md-sys-color-surface-container-low, #f7f2fa);
    border: 1px solid var(--md-sys-color-outline-variant, #cac4d0);
    border-radius: 18px;
    padding: 14px 16px;
}

.analytics-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 12px;
}

.section-title-with-icon {
    display: flex;
    align-items: center;
    gap: 6px;
}

.section-title-with-icon h3 {
    font-size: 0.95rem;
    font-weight: 700;
    margin: 0;
    color: var(--md-sys-color-on-surface, #1d1b20);
}

.chart-header-icon {
    font-size: 20px;
    color: var(--md-sys-color-primary, #6750a4);
}

.section-caption {
    font-size: 0.74rem;
    color: var(--md-sys-color-on-surface-variant, #49454f);
}

.analytics-chart-wrap {
    overflow-x: auto;
    padding: 6px 0 2px;
}

.analytics-bar-chart {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    height: 140px;
    min-width: 480px;
    padding-bottom: 22px;
    position: relative;
    border-bottom: 1px solid var(--md-sys-color-outline-variant, #cac4d0);
}

.chart-bar-col {
    flex: 1;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    position: relative;
    cursor: pointer;
}

.chart-bar-fill {
    width: 100%;
    max-width: 24px;
    background: linear-gradient(180deg, var(--md-sys-color-primary, #6750a4), rgba(103, 80, 164, 0.5));
    border-radius: 4px 4px 0 0;
    transition: height 0.3s ease, background 0.15s ease;
    min-height: 3px;
}

.chart-bar-col:hover .chart-bar-fill {
    background: var(--md-sys-color-primary, #6750a4);
    box-shadow: 0 0 8px rgba(103, 80, 164, 0.4);
}

.chart-bar-label {
    position: absolute;
    bottom: -20px;
    font-size: 0.68rem;
    color: var(--md-sys-color-on-surface-variant, #49454f);
    white-space: nowrap;
}

.chart-bar-tooltip {
    position: absolute;
    top: -26px;
    background: var(--md-sys-color-inverse-surface, #313033);
    color: var(--md-sys-color-inverse-on-surface, #f4eff4);
    padding: 2px 6px;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 700;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease;
    z-index: 10;
}

.chart-bar-col:hover .chart-bar-tooltip {
    opacity: 1;
}

/* Two-column insight cards */
.analytics-two-col {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

@media (max-width: 640px) {
    .analytics-two-col {
        grid-template-columns: 1fr;
    }
}

.analytics-card-box {
    background: var(--md-sys-color-surface-container-low, #f7f2fa);
    border: 1px solid var(--md-sys-color-outline-variant, #cac4d0);
    border-radius: 16px;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.card-box-header {
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-box-header h4 {
    font-size: 0.88rem;
    font-weight: 700;
    margin: 0;
    color: var(--md-sys-color-on-surface, #1d1b20);
}

.card-box-header .amber-icon { color: #f57c00; font-size: 18px; }
.card-box-header .red-icon { color: #b3261e; font-size: 18px; }
.card-box-header .purple-icon { color: var(--md-sys-color-primary, #6750a4); font-size: 18px; }
.card-box-header .green-icon { color: #2e7d32; font-size: 18px; }

.peak-time-badge {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 8px;
    background: rgba(245, 124, 0, 0.12);
    color: #e65100;
    font-weight: 700;
    font-size: 0.88rem;
}

.card-box-desc {
    font-size: 0.72rem;
    color: var(--md-sys-color-on-surface-variant, #49454f);
    margin: 4px 0 0;
}

.mod-health-stats {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.mod-pill {
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    background: var(--md-sys-color-surface-container-high, #ece6f0);
    color: var(--md-sys-color-on-surface, #1d1b20);
}

.leader-item-pill, .contributor-item-pill {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 5px 8px;
    border-radius: 8px;
    background: var(--md-sys-color-surface, #ffffff);
    border: 1px solid var(--md-sys-color-outline-variant, #cac4d0);
    margin-bottom: 4px;
    font-size: 0.78rem;
}

.leader-item-pill strong, .contributor-item-pill strong {
    color: var(--md-sys-color-on-surface, #1d1b20);
}

/* Feed cards list container */
.admin-feeds-grid {
    display: flex;
    flex-direction: column;
    gap: 0;
    overflow-y: auto;
}

/* Keyboard focus ring for feed cards */
.admin-feed-card:focus-visible {
    outline: 2px solid var(--md-sys-color-primary, #6750a4);
    outline-offset: 2px;
}

/* Small empty/loading state text inside boxes */
.empty-sub {
    font-size: 0.78rem;
    color: var(--md-sys-color-on-surface-variant, #49454f);
    padding: 6px 0;
    text-align: center;
}

/* Scrollbar styling for the feed cards grid inside admin body */
#admin-panel-feeds {
    overflow-y: auto;
    max-height: 100%;
    padding-bottom: 20px;
}

/* ==========================================================================
   Profile Images & Real-Time Presence System
   ========================================================================== */

/* Top App Bar Subtitle */
.top-bar-leading {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    flex: 1 1 auto;
    overflow: hidden;
}

.durham-crest-badge {
    flex-shrink: 0;
}

.top-title-group {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
    overflow: hidden;
}

#app-header h1,
#view-title {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.25;
    margin: 0;
}

.view-subtitle {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--md-sys-color-on-surface-variant, #49454f);
    line-height: 1;
    margin-top: 1px;
    white-space: nowrap;
}

/* Presence Indicators */
.presence-dot {
    position: absolute;
    bottom: -1px;
    right: -1px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 2px solid var(--md-sys-color-surface, #ffffff);
    display: block;
    z-index: 2;
    box-sizing: border-box;
}

.presence-dot.online {
    background: #2e7d32;
    box-shadow: 0 0 0 1px rgba(46, 125, 50, 0.4);
}

.presence-dot.away {
    background: #f57c00;
}

.presence-dot.offline {
    background: #9e9e9e;
}

.presence-dot.mini {
    position: static;
    display: inline-block;
    width: 7px;
    height: 7px;
    border: none;
    flex-shrink: 0;
}

/* Presence Chip (Profile modal & settings) */
.presence-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: 9999px;
    font-size: 0.74rem;
    font-weight: 600;
    line-height: 1;
}

.presence-chip .presence-dot {
    position: static;
    border: none;
    width: 7px;
    height: 7px;
}

.presence-chip.online {
    background: rgba(46, 125, 50, 0.12);
    color: #2e7d32;
    border: 1px solid rgba(46, 125, 50, 0.25);
}

.presence-chip.away {
    background: rgba(245, 124, 0, 0.12);
    color: #e65100;
    border: 1px solid rgba(245, 124, 0, 0.25);
}

.presence-chip.offline {
    background: rgba(121, 116, 126, 0.12);
    color: #49454f;
    border: 1px solid rgba(121, 116, 126, 0.25);
}

/* Settings: Profile Photo Card */
.settings-avatar-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    margin-bottom: 20px;
    background: var(--md-sys-color-surface-container-low, #f7f2fa);
    border: 1px solid var(--md-sys-color-outline-variant, #cac4d0);
    border-radius: 20px;
}

.settings-avatar-wrap {
    position: relative;
    flex-shrink: 0;
}

.settings-avatar-circle {
    width: 76px;
    height: 76px;
    border-radius: 50%;
    background: var(--md-sys-color-primary, #6750a4);
    color: #ffffff;
    font-size: 1.8rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    border: 3px solid var(--md-sys-color-surface, #ffffff);
    transition: filter 0.18s ease;
}

.settings-avatar-circle:hover {
    filter: brightness(0.94);
}

.settings-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.settings-avatar-initials {
    text-transform: uppercase;
}

.avatar-camera-btn {
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--md-sys-color-primary, #6750a4);
    color: var(--md-sys-color-on-primary, #ffffff);
    border: 2px solid var(--md-sys-color-surface, #ffffff);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.15);
    transition: transform 0.15s ease;
}

.avatar-camera-btn:hover {
    transform: scale(1.1);
}

.avatar-camera-btn .material-symbols-rounded {
    font-size: 15px;
}

.settings-avatar-meta {
    flex: 1;
    min-width: 0;
}

.settings-avatar-title-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
    flex-wrap: wrap;
}

.avatar-label {
    font-size: 0.96rem;
    font-weight: 700;
    color: var(--md-sys-color-on-surface, #1d1b20);
}

.avatar-hint {
    font-size: 0.78rem;
    color: var(--md-sys-color-on-surface-variant, #49454f);
    margin: 0 0 10px 0;
    line-height: 1.35;
}

.settings-avatar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

/* User Profile Modal Header Avatar & Presence */
.profile-avatar-circle-wrap {
    position: relative;
    flex-shrink: 0;
}

.profile-avatar-circle-wrap .presence-dot {
    width: 14px;
    height: 14px;
    border-width: 2.5px;
    bottom: 2px;
    right: 2px;
}

.profile-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.profile-sub-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 2px;
}

/* Chat Messages: Incoming Message Avatar */
.msg-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    max-width: 100%;
}

.msg-row .msg-bubble-container {
    min-width: 0;
    flex: 1 1 auto;
}

.msg-avatar-wrap {
    position: relative;
    width: 34px !important;
    height: 34px !important;
    min-width: 34px !important;
    min-height: 34px !important;
    max-width: 34px !important;
    max-height: 34px !important;
    flex: 0 0 34px !important;
    flex-shrink: 0 !important;
    cursor: pointer;
    margin-bottom: 2px;
    display: block !important;
    padding: 0 !important;
    box-sizing: border-box !important;
}

/* Guard against .msg-author-trigger styles if applied */
.msg-avatar-wrap.msg-author-trigger,
.msg-avatar-wrap.msg-avatar-trigger {
    padding: 0 !important;
    margin-left: 0 !important;
    gap: 0 !important;
    display: block !important;
    background: transparent !important;
}

.msg-avatar {
    width: 34px !important;
    height: 34px !important;
    min-width: 34px !important;
    min-height: 34px !important;
    max-width: 34px !important;
    max-height: 34px !important;
    aspect-ratio: 1 / 1;
    border-radius: 50%;
    background: var(--md-sys-color-primary-container, #eaddff);
    color: var(--md-sys-color-on-primary-container, #21005d);
    font-size: 0.85rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border: 1.5px solid var(--md-sys-color-surface, #ffffff);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    transition: transform 0.15s ease;
    text-transform: uppercase;
    flex-shrink: 0 !important;
    box-sizing: border-box !important;
}

.msg-avatar-wrap:hover .msg-avatar {
    transform: scale(1.08);
}

.msg-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Feed Member Roster Avatar & Presence */
.feed-member-avatar-wrap {
    position: relative;
    flex-shrink: 0;
    display: inline-flex;
}

.feed-member-avatar-wrap .presence-dot {
    position: absolute !important;
    width: 8px !important;
    height: 8px !important;
    bottom: -1px !important;
    right: -1px !important;
    border: 1.5px solid var(--md-sys-color-surface) !important;
    border-radius: 50% !important;
    z-index: 2;
}

.feed-member-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.member-presence-sub {
    font-size: 0.72rem;
    margin-left: 4px;
}

.member-presence-sub.online {
    color: #2e7d32;
    font-weight: 600;
}

.member-presence-sub.away {
    color: #e65100;
}

.member-presence-sub.offline {
    color: var(--md-sys-color-outline, #79747e);
}

/* Admin Directory Student Avatar & Presence */
.admin-user-avatar-wrap {
    position: relative;
    width: 42px;
    height: 42px;
    flex-shrink: 0;
}

.admin-user-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--md-sys-color-surface-container-high, #ece6f0);
    color: var(--md-sys-color-primary, #6750a4);
    font-size: 1rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border: 2px solid var(--md-sys-color-surface, #ffffff);
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    text-transform: uppercase;
}

.admin-user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.admin-user-avatar-wrap .presence-dot {
    width: 11px;
    height: 11px;
    bottom: 0px;
    right: 0px;
}

/* Mobile App Header & Top Bar Optimization */
@media (max-width: 768px) {
    #app-header {
        padding: 0 10px;
        height: 56px;
    }

    .top-bar-leading {
        gap: 6px;
        min-width: 0;
        flex: 1 1 auto;
        overflow: hidden;
    }

    .top-title-group {
        min-width: 0;
        overflow: hidden;
    }

    .durham-crest-badge {
        width: 28px;
        height: 28px;
        flex-shrink: 0;
    }

    .cuthbert-cross {
        width: 20px;
        height: 20px;
    }

    #app-header h1,
    #view-title {
        font-size: 1.05rem;
        line-height: 1.2;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .view-subtitle {
        font-size: 0.68rem;
        line-height: 1;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .top-bar-actions {
        gap: 2px;
        flex-shrink: 0;
    }

    .m3-icon-button {
        width: 36px;
        height: 36px;
        min-width: 48px;
        min-height: 48px;
        box-sizing: content-box;
    }

    #nav-logout-btn {
        display: none !important;
    }
}

/* Settings Danger Zone & Sign Out */
.settings-danger-zone {
    margin-top: 28px;
    padding-top: 20px;
    border-top: 1px solid var(--md-sys-color-outline-variant);
    display: flex;
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    box-sizing: border-box;
}

.settings-danger-zone .select-label {
    display: block;
    width: 100%;
    margin-bottom: 8px;
    margin-left: 2px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--md-sys-color-error, #ba1a1a);
    letter-spacing: 0.02em;
}

.settings-danger-zone .m3-btn {
    margin-top: 0;
    width: 100%;
}

.m3-btn.btn-danger {
    color: var(--md-sys-color-error) !important;
    background: transparent !important;
    border: 1.5px solid var(--md-sys-color-error) !important;
    font-weight: 600;
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.m3-btn.btn-danger:hover {
    background: var(--md-sys-color-error-container, #ffdad6) !important;
    color: var(--md-sys-color-on-error-container, #410002) !important;
    border-color: var(--md-sys-color-error, #ba1a1a) !important;
}

.settings-danger-zone .danger-subtext {
    display: block;
    margin-top: 6px;
    margin-left: 4px;
    font-size: 12px;
    color: var(--md-sys-color-on-surface-variant);
}

/* ==========================================================================
   Push Notifications & Feed Mute Controls (Material Design 3)
   ========================================================================== */

.notif-settings-card {
    margin-top: 18px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.notif-header-wrap {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 4px;
}

.notif-icon-circle {
    background: var(--md-sys-color-primary-container, #eaddff);
    color: var(--md-sys-color-on-primary-container, #21005d);
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--md-shape-corner-medium, 16px);
    flex-shrink: 0;
}

.notif-permission-banner {
    background: var(--md-sys-color-secondary-container, #e8def8);
    color: var(--md-sys-color-on-secondary-container, #1d192b);
    border: 1px solid var(--md-sys-color-outline-variant, #cac4d0);
    border-radius: var(--md-shape-corner-medium, 16px);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.permission-banner-text {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 200px;
}

.permission-banner-text .material-symbols-rounded {
    font-size: 24px;
    color: var(--md-sys-color-primary, #6750a4);
    flex-shrink: 0;
}

.permission-banner-text strong {
    display: block;
    font-size: 0.92rem;
    font-weight: 600;
}

.permission-banner-text p {
    font-size: 0.78rem;
    margin: 2px 0 0;
    opacity: 0.85;
}

.notif-setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 8px 0;
    border-bottom: 1px solid var(--md-sys-color-surface-container-high, #ece6f0);
}

.notif-setting-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid var(--md-sys-color-surface-container-high, #ece6f0);
}

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

.notif-row-title {
    font-size: 0.94rem;
    font-weight: 600;
    color: var(--md-sys-color-on-surface, #1d1b20);
}

.notif-row-desc {
    font-size: 0.78rem;
    color: var(--md-sys-color-on-surface-variant, #49454f);
}

.duration-chips-group,
.notif-chip-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 6px;
}

.duration-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 14px;
    border-radius: var(--md-shape-corner-small, 8px);
    border: 1px solid var(--md-sys-color-outline, #79747e);
    background: transparent;
    color: var(--md-sys-color-on-surface, #1d1b20);
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s cubic-bezier(0.2, 0, 0, 1);
}

.duration-chip:hover {
    background: var(--md-sys-color-surface-container-high, #ece6f0);
}

.duration-chip.active {
    background: var(--md-sys-color-secondary-container, #e8def8);
    border-color: var(--md-sys-color-secondary, #625b71);
    color: var(--md-sys-color-on-secondary-container, #1d192b);
    font-weight: 600;
}

.notif-card-actions {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding-top: 6px;
}

/* Feed Notification Sheet / Modal */
#feed-notif-modal.m3-sheet-backdrop {
    z-index: 12000;
}

.feed-notif-sheet {
    max-width: 460px;
    padding: 16px 20px 24px;
    border-radius: 28px 28px 0 0;
    box-shadow: var(--md-elevation-3, 0 8px 24px rgba(0,0,0,0.25));
}

@media (min-width: 768px) {
    #feed-notif-modal.m3-sheet-backdrop {
        align-items: center;
        justify-content: center;
    }
    .feed-notif-sheet {
        border-radius: 28px;
        padding: 24px;
        animation: m3ModalPopIn 0.2s cubic-bezier(0.2, 0, 0, 1);
    }
    .feed-notif-sheet .m3-sheet-drag-handle {
        display: none;
    }
}

.feed-notif-sheet .m3-sheet-drag-handle {
    width: 36px;
    height: 4px;
    background: var(--md-sys-color-outline-variant, #CAC4D0);
    border-radius: 9999px;
    margin: 0 auto 12px;
    flex-shrink: 0;
}

.feed-notif-sheet .m3-sheet-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.feed-notif-title-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.feed-notif-title-row h3 {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--md-sys-color-on-surface, #1d1b20);
}

#feed-notif-status-badge {
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--md-sys-color-primary, #6750a4);
    margin-top: 2px;
}

.feed-notif-body {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.feed-notif-icon {
    font-size: 24px;
    color: var(--md-sys-color-primary, #6750a4);
}

.feed-notif-section {
    margin-bottom: 4px;
}

.feed-notif-mode-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
}

.feed-notif-mode-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 14px;
    border-radius: var(--md-shape-corner-medium, 16px);
    border: 1.5px solid var(--md-sys-color-outline-variant, #cac4d0);
    background: var(--md-sys-color-surface, #ffffff);
    color: var(--md-sys-color-on-surface, #1d1b20);
    cursor: pointer;
    text-align: left;
    transition: all 0.15s ease;
    width: 100%;
}

.feed-notif-mode-item:hover {
    background: var(--md-sys-color-surface-container-low, #f7f2fa);
}

.feed-notif-mode-item.active {
    background: var(--md-sys-color-primary-container, #eaddff);
    border-color: var(--md-sys-color-primary, #6750a4);
    color: var(--md-sys-color-on-primary-container, #21005d);
}

.feed-notif-mode-item .check-icon {
    margin-left: auto;
    font-size: 20px;
    color: var(--md-sys-color-primary, #6750a4);
    display: none;
}

.feed-notif-mode-item.active .check-icon {
    display: block;
}

.mode-item-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.mode-item-text strong {
    font-size: 0.9rem;
}

.mode-item-text small {
    font-size: 0.74rem;
    opacity: 0.8;
}

/* Header Notification Bell States */
#btn-feed-notif.is-muted {
    color: var(--md-sys-color-outline, #79747e);
    position: relative;
}

#btn-feed-notif.is-muted::after {
    content: '';
    position: absolute;
    top: 6px;
    right: 6px;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--md-sys-color-error, #ba1a1a);
    border: 1.5px solid var(--md-sys-color-surface, #ffffff);
}

/* Feed Chip Mute Badge */
.chip-mute-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 13px !important;
    margin-left: 4px;
    color: var(--md-sys-color-outline, #79747e);
    opacity: 0.85;
}

/* -------------------------------------------------------------
 * Moderation Live Feed Navigation & Return Banner
 * ------------------------------------------------------------- */
.chat-mod-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 16px;
    background: var(--md-sys-color-surface-container-highest, #332d36);
    border-bottom: 2px solid var(--palavibe-purple, #68246D);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
    z-index: 15;
    flex-shrink: 0;
    animation: slideDownModBanner 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideDownModBanner {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.mod-banner-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.mod-shield-icon {
    font-size: 20px;
    color: #ffffff;
    background: var(--palavibe-purple, #68246D);
    padding: 6px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 2px 6px rgba(104, 36, 109, 0.4);
}

.mod-banner-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.mod-banner-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--md-sys-color-on-surface);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mod-banner-subtitle {
    font-size: 0.72rem;
    color: var(--md-sys-color-on-surface-variant);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mod-banner-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.btn-return-to-report {
    background: var(--palavibe-purple, #68246D) !important;
    color: #ffffff !important;
    font-size: 0.82rem !important;
    font-weight: 600 !important;
    padding: 0 14px !important;
    height: 34px !important;
    border-radius: 17px !important;
    box-shadow: 0 2px 6px rgba(104, 36, 109, 0.35);
    display: inline-flex !important;
    align-items: center !important;
    gap: 6px !important;
    cursor: pointer;
    transition: transform 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}

.btn-return-to-report:hover {
    background: #521d56 !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(104, 36, 109, 0.45);
}

.btn-return-to-report:active {
    transform: translateY(0);
}

.btn-dismiss-mod-banner {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--md-sys-color-on-surface-variant);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.btn-dismiss-mod-banner:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--md-sys-color-on-surface);
}

/* Reported message highlight animation in feed stream */
.chat-message.reported-target-glow .msg-bubble {
    animation: reportedTargetPulse 3.5s ease-out;
    outline: 2.5px solid var(--palavibe-purple, #68246D) !important;
    outline-offset: 3px !important;
}

@keyframes reportedTargetPulse {
    0% {
        box-shadow: 0 0 0 8px rgba(104, 36, 109, 0.6), 0 8px 24px rgba(104, 36, 109, 0.4);
        transform: scale(1.025);
    }
    30% {
        box-shadow: 0 0 0 10px rgba(104, 36, 109, 0.35), 0 6px 18px rgba(104, 36, 109, 0.25);
        transform: scale(1.015);
    }
    70% {
        box-shadow: 0 0 0 5px rgba(104, 36, 109, 0.2);
    }
    100% {
        box-shadow: none;
        transform: scale(1);
    }
}

/* Returning to Report Card in Admin Dashboard */
.admin-report-card.report-card-focused {
    animation: cardFocusPulse 3s ease-out;
    border-color: var(--palavibe-purple, #68246D) !important;
    box-shadow: 0 0 0 3px rgba(104, 36, 109, 0.45), 0 8px 24px rgba(0, 0, 0, 0.25) !important;
}

@keyframes cardFocusPulse {
    0% {
        transform: translateY(-3px) scale(1.01);
        box-shadow: 0 0 0 6px rgba(104, 36, 109, 0.6), 0 12px 30px rgba(0, 0, 0, 0.35);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(104, 36, 109, 0.3);
    }
    100% {
        transform: translateY(0) scale(1);
        box-shadow: 0 0 0 3px rgba(104, 36, 109, 0.45);
    }
}

/* ==========================================================================
   Campus Onboarding Experience & Permissions Primer Wizard
   ========================================================================== */
.onboarding-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 12000;
    padding: 16px;
    box-sizing: border-box;
    animation: fadeIn 0.2s ease-out;
}

.onboarding-window {
    width: 100%;
    max-width: 660px;
    max-height: 90vh;
    max-height: 90dvh;
    background: var(--md-sys-color-surface, #FFFFFF);
    color: var(--md-sys-color-on-surface, #1C1B1F);
    border-radius: 28px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.35);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideUpModal 0.25s cubic-bezier(0.2, 0, 0, 1);
}

.onboarding-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px 14px 24px;
    border-bottom: 1px solid var(--md-sys-color-outline-variant, rgba(0, 0, 0, 0.08));
}

.onboarding-header-brand {
    display: flex;
    align-items: center;
    gap: 14px;
}

.onboarding-crest-icon {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--palavibe-purple, #68246D), #8E3A94);
    color: #FFFFFF;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(104, 36, 109, 0.3);
}

.onboarding-crest-icon .material-symbols-rounded {
    font-size: 26px;
}

.onboarding-header h2 {
    font-size: 20px;
    font-weight: 700;
    margin: 0;
    color: var(--md-sys-color-on-surface, #1C1B1F);
}

.onboarding-step-indicator {
    font-size: 13px;
    font-weight: 600;
    color: var(--palavibe-purple, #68246D);
    background: rgba(104, 36, 109, 0.1);
    padding: 2px 8px;
    border-radius: 8px;
    display: inline-block;
    margin-top: 3px;
}

.onboarding-progress-track {
    width: 100%;
    height: 4px;
    background: var(--md-sys-color-surface-variant, #E7E0EC);
    overflow: hidden;
}

.onboarding-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--palavibe-purple, #68246D), #A450A8);
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.onboarding-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px;
    display: flex;
    flex-direction: column;
}

.onboarding-step-intro {
    margin-bottom: 20px;
}

.onboarding-step-intro h3 {
    font-size: 20px;
    font-weight: 700;
    margin: 0 0 6px 0;
    color: var(--md-sys-color-on-surface, #1C1B1F);
}

.onboarding-step-intro p {
    font-size: 14px;
    line-height: 1.5;
    margin: 0;
    color: var(--md-sys-color-on-surface-variant, #49454F);
}

.onboarding-avatar-section {
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 14px 16px;
    background: var(--md-sys-color-surface-container-low, rgba(0, 0, 0, 0.03));
    border-radius: 18px;
    margin-bottom: 12px;
}

.onboarding-avatar-wrap {
    position: relative;
    width: 68px;
    height: 68px;
    border-radius: 50%;
    overflow: hidden;
    background: var(--palavibe-purple, #68246D);
    color: #FFFFFF;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.avatar-placeholder-circle {
    font-size: 30px;
    font-weight: 700;
}

.avatar-img-circle {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.avatar-upload-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #FFFFFF;
    border-radius: 50%;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    z-index: 2;
}

.onboarding-avatar-actions {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.onboarding-subtext {
    font-size: 12px;
    color: var(--md-sys-color-on-surface-variant, #49454F);
}

.onboarding-error-msg {
    font-size: 13px;
    color: var(--md-sys-color-error, #BA1A1A);
    min-height: 18px;
    margin-top: 4px;
}

.onboarding-status-presets {
    margin-top: 14px;
}

.onboarding-presets-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--md-sys-color-on-surface-variant, #49454F);
    margin-bottom: 6px;
    display: block;
}

.onboarding-pills-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.onboarding-status-pill {
    background: var(--md-sys-color-surface-container-low, rgba(0, 0, 0, 0.04));
    border: 1px solid var(--md-sys-color-outline-variant, rgba(0, 0, 0, 0.12));
    border-radius: 12px;
    padding: 6px 12px;
    font-size: 12.5px;
    font-weight: 500;
    color: var(--md-sys-color-on-surface, #1C1B1F);
    cursor: pointer;
    transition: all 0.15s ease;
}

.onboarding-status-pill:hover {
    background: rgba(104, 36, 109, 0.1);
    border-color: var(--palavibe-purple, #68246D);
}

/* College Search & Selection Grid */
.onboarding-college-search-box {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--md-sys-color-surface-container-low, rgba(0, 0, 0, 0.04));
    border: 1px solid var(--md-sys-color-outline-variant, rgba(0, 0, 0, 0.12));
    border-radius: 14px;
    padding: 8px 14px;
    margin-bottom: 12px;
}

.onboarding-college-search-box input {
    border: none;
    background: transparent;
    width: 100%;
    outline: none;
    font-size: 14px;
    color: var(--md-sys-color-on-surface, #1C1B1F);
}

.onboarding-feedback-note {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 10px;
}

.onboarding-colleges-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
    max-height: 340px;
    overflow-y: auto;
    padding: 4px;
    margin-bottom: 12px;
    scrollbar-width: thin;
}

.onboarding-college-card {
    background: var(--md-sys-color-surface-container-low, rgba(0, 0, 0, 0.03));
    border: 1.5px solid var(--md-sys-color-outline-variant, rgba(0, 0, 0, 0.12));
    border-radius: 14px;
    padding: 10px 12px;
    cursor: pointer;
    transition: all 0.18s ease;
    display: flex;
    flex-direction: column;
    position: relative;
    user-select: none;
}

.onboarding-college-card:hover {
    border-color: var(--palavibe-purple, #68246D);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.onboarding-college-card.selected {
    border-color: var(--palavibe-purple, #68246D);
    background: rgba(104, 36, 109, 0.1);
    box-shadow: 0 0 0 2px var(--palavibe-purple, #68246D);
}

.college-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 5px;
}

.college-card-header .college-icon {
    font-size: 22px;
    color: var(--palavibe-purple, #68246D);
}

.college-cluster-badge {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 2px 6px;
    border-radius: 6px;
    background: rgba(104, 36, 109, 0.12);
    color: var(--palavibe-purple, #68246D);
}

.college-cluster-badge.hill {
    background: rgba(104, 36, 109, 0.14);
    color: var(--palavibe-purple, #68246D);
}

.college-cluster-badge.bailey {
    background: rgba(186, 26, 26, 0.12);
    color: #BA1A1A;
}

.college-cluster-badge.riverside {
    background: rgba(0, 106, 106, 0.12);
    color: #006A6A;
}

.college-cluster-badge.postgraduate {
    background: rgba(103, 80, 164, 0.14);
    color: #6750A4;
}

.college-card-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--md-sys-color-on-surface, #1C1B1F);
    line-height: 1.3;
    margin-bottom: 3px;
}

.college-card-motto {
    font-size: 10.5px;
    color: var(--md-sys-color-on-surface-variant, #49454F);
    line-height: 1.25;
}

.college-select-indicator {
    align-self: flex-end;
    margin-top: auto;
    padding-top: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.college-select-indicator .material-symbols-rounded {
    font-size: 22px;
}

.college-select-indicator .check-icon {
    display: none;
    color: var(--palavibe-purple, #68246D);
    font-variation-settings: 'FILL' 1;
}

.college-select-indicator .uncheck-icon {
    display: inline-block;
    color: var(--md-sys-color-outline-variant, #CAC4D0);
}

.onboarding-college-card.selected .college-select-indicator .check-icon {
    display: inline-block;
}

.onboarding-college-card.selected .college-select-indicator .uncheck-icon {
    display: none;
}

/* Permissions Primers Stack */
.onboarding-primers-stack {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.onboarding-primer-card {
    background: var(--md-sys-color-surface-container-low, rgba(0, 0, 0, 0.02));
    border: 1px solid var(--md-sys-color-outline-variant, rgba(0, 0, 0, 0.12));
    border-radius: 18px;
    padding: 16px 18px;
    transition: all 0.2s ease;
}

.onboarding-primer-card:hover {
    border-color: rgba(104, 36, 109, 0.35);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
}

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

.primer-icon-bubble {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.primer-icon-bubble.notif {
    background: rgba(104, 36, 109, 0.14);
    color: var(--palavibe-purple, #68246D);
}

.primer-icon-bubble.loc {
    background: rgba(0, 137, 123, 0.14);
    color: #00897B;
}

.primer-icon-bubble .material-symbols-rounded {
    font-size: 24px;
}

.primer-header-text h4 {
    font-size: 15.5px;
    font-weight: 700;
    margin: 0 0 4px 0;
    color: var(--md-sys-color-on-surface, #1C1B1F);
}

.primer-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11.5px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 8px;
}

.primer-status-badge.granted {
    background: #E6F4EA;
    color: #137333;
}

.primer-status-badge.pending {
    background: #FEF7E0;
    color: #B06000;
}

.primer-status-badge.denied {
    background: #FCE8E6;
    color: #C5221F;
}

.primer-status-badge .material-symbols-rounded {
    font-size: 14px;
}

.primer-body {
    margin-bottom: 12px;
}

.primer-reason {
    font-size: 13px;
    line-height: 1.45;
    margin: 0 0 8px 0;
    color: var(--md-sys-color-on-surface, #1C1B1F);
}

.primer-benefits {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.primer-benefits li {
    font-size: 12.5px;
    color: var(--md-sys-color-on-surface-variant, #49454F);
    display: flex;
    align-items: center;
    gap: 6px;
}

.primer-benefits li .material-symbols-rounded {
    font-size: 16px;
    color: #137333;
    flex-shrink: 0;
}

.primer-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    padding-top: 8px;
    border-top: 1px dashed var(--md-sys-color-outline-variant, rgba(0, 0, 0, 0.08));
}

.primer-skip-hint {
    font-size: 11.5px;
    color: var(--md-sys-color-outline, #79747E);
}

/* Step 4: Summary Card */
.onboarding-theme-box {
    margin-bottom: 20px;
}

.onboarding-theme-label {
    font-size: 13px;
    font-weight: 600;
    display: block;
    margin-bottom: 8px;
}

.onboarding-summary-card {
    background: var(--md-sys-color-surface-container-low, rgba(0, 0, 0, 0.03));
    border: 1.5px solid var(--md-sys-color-outline-variant, rgba(0, 0, 0, 0.12));
    border-radius: 18px;
    padding: 18px;
}

.summary-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
    color: var(--palavibe-purple, #68246D);
}

.summary-header h4 {
    font-size: 16px;
    font-weight: 700;
    margin: 0;
    color: var(--md-sys-color-on-surface, #1C1B1F);
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.summary-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.summary-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--md-sys-color-outline, #79747E);
}

.summary-val {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--md-sys-color-on-surface, #1C1B1F);
}

.summary-val.highlight {
    color: var(--palavibe-purple, #68246D);
}

.onboarding-footer {
    display: flex;
    align-items: center;
    padding: 16px 24px;
    border-top: 1px solid var(--md-sys-color-outline-variant, rgba(0, 0, 0, 0.08));
    gap: 12px;
}

.onboarding-footer-spacer {
    flex: 1;
}

.m3-btn.is-launch {
    background: linear-gradient(135deg, var(--palavibe-purple, #68246D), #8E3A94);
    box-shadow: 0 4px 14px rgba(104, 36, 109, 0.35);
}

/* Dark Mode Overrides for Onboarding */
[data-theme="dark"] .onboarding-window {
    background: #1E1B22;
    color: #E6E1E5;
    border: 1px solid rgba(255, 255, 255, 0.12);
}

[data-theme="dark"] .onboarding-header,
[data-theme="dark"] .onboarding-footer {
    border-color: rgba(255, 255, 255, 0.08);
}

[data-theme="dark"] .onboarding-header h2,
[data-theme="dark"] .onboarding-step-intro h3,
[data-theme="dark"] .college-card-title,
[data-theme="dark"] .primer-header-text h4,
[data-theme="dark"] .summary-header h4,
[data-theme="dark"] .summary-val {
    color: #F4EFF4;
}

[data-theme="dark"] .onboarding-step-intro p,
[data-theme="dark"] .college-card-motto,
[data-theme="dark"] .primer-benefits li {
    color: #CAC4D0;
}

[data-theme="dark"] .onboarding-avatar-section,
[data-theme="dark"] .onboarding-college-search-box,
[data-theme="dark"] .onboarding-college-card,
[data-theme="dark"] .onboarding-primer-card,
[data-theme="dark"] .onboarding-summary-card,
[data-theme="dark"] .onboarding-status-pill {
    background: #2B2730;
    border-color: rgba(255, 255, 255, 0.08);
}

[data-theme="dark"] .onboarding-college-card.selected {
    background: rgba(142, 58, 148, 0.25);
    border-color: #D0BCFF;
    box-shadow: 0 0 0 2px #D0BCFF;
}

[data-theme="dark"] .primer-status-badge.granted {
    background: rgba(19, 115, 51, 0.3);
    color: #81C995;
}

[data-theme="dark"] .primer-status-badge.pending {
    background: rgba(176, 96, 0, 0.3);
    color: #FDD663;
}

[data-theme="dark"] .primer-status-badge.denied {
    background: rgba(197, 34, 31, 0.3);
    color: #F28B82;
}

[data-theme="dark"] .onboarding-college-card.selected .college-select-indicator .check-icon {
    color: #D0BCFF;
}

[data-theme="dark"] .college-select-indicator .uncheck-icon {
    color: rgba(255, 255, 255, 0.25);
}

@media (max-width: 600px) {
    .onboarding-backdrop {
        padding: 6px;
    }

    .onboarding-window {
        max-height: 98vh;
        max-height: 98dvh;
        border-radius: 20px;
    }

    .onboarding-header {
        padding: 12px 14px 10px 14px;
    }

    .onboarding-header-brand {
        gap: 10px;
    }

    .onboarding-crest-icon {
        width: 36px;
        height: 36px;
        border-radius: 10px;
    }

    .onboarding-crest-icon .material-symbols-rounded {
        font-size: 20px;
    }

    .onboarding-header h2 {
        font-size: 16.5px;
    }

    .onboarding-step-indicator {
        font-size: 11.5px;
        padding: 1px 6px;
    }

    .onboarding-body {
        padding: 12px 14px;
    }

    .onboarding-step-intro {
        margin-bottom: 10px;
    }

    .onboarding-step-intro h3 {
        font-size: 17px;
        margin: 0 0 2px 0;
    }

    .onboarding-step-intro p {
        font-size: 12px;
        line-height: 1.35;
        margin: 0;
    }

    .onboarding-college-search-box {
        padding: 6px 12px;
        margin-bottom: 8px;
        border-radius: 12px;
    }

    .onboarding-college-search-box input {
        font-size: 13px;
    }

    .onboarding-feedback-note {
        font-size: 12px;
        margin-bottom: 6px;
    }

    .onboarding-colleges-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
        max-height: 48vh;
        max-height: 48dvh;
        padding: 2px;
        margin-bottom: 8px;
    }

    .onboarding-college-card {
        padding: 8px 10px;
        border-radius: 12px;
    }

    .college-card-header {
        margin-bottom: 3px;
    }

    .college-card-header .college-icon {
        font-size: 19px;
    }

    .college-cluster-badge {
        font-size: 9px;
        padding: 1px 5px;
    }

    .college-card-title {
        font-size: 12.5px;
        margin-bottom: 2px;
    }

    .college-card-motto {
        font-size: 10px;
        line-height: 1.2;
    }

    .college-select-indicator {
        padding-top: 4px;
    }

    .college-select-indicator .material-symbols-rounded {
        font-size: 20px;
    }

    .onboarding-footer {
        padding: 10px 14px calc(10px + env(safe-area-inset-bottom, 0px)) 14px;
    }

    .onboarding-footer .m3-btn {
        height: 42px;
        font-size: 13.5px;
    }

    .summary-grid {
        grid-template-columns: 1fr;
    }
}

/* ==========================================================================
   Material 3 Interactive Course Picker Component
   ========================================================================== */

.onboarding-course-tile {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border: 1.5px solid var(--md-sys-color-outline-variant, rgba(0, 0, 0, 0.12));
    border-radius: 14px;
    background: var(--md-sys-color-surface, #FFFFFF);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    user-select: none;
}

.onboarding-course-tile:hover {
    border-color: var(--palavibe-purple, #68246D);
    background: rgba(104, 36, 109, 0.03);
    box-shadow: 0 2px 8px rgba(104, 36, 109, 0.08);
}

.onboarding-course-tile:focus-visible,
.course-tile-main:focus-visible {
    outline: 2px solid var(--palavibe-purple, #68246D);
    outline-offset: 2px;
}

.course-tile-main {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
    cursor: pointer;
    border-radius: 8px;
}

.course-tile-leading {
    width: 38px;
    height: 38px;
    min-width: 38px;
    border-radius: 10px;
    background: rgba(104, 36, 109, 0.08);
    color: var(--palavibe-purple, #68246D);
    display: flex;
    align-items: center;
    justify-content: center;
}

.course-tile-leading .material-symbols-rounded {
    font-size: 20px;
}

.course-tile-text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.course-tile-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--md-sys-color-outline, #79747E);
}

.course-tile-val {
    font-size: 13.5px;
    font-weight: 500;
    color: var(--md-sys-color-outline, #79747E);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.course-tile-val.has-value {
    color: var(--md-sys-color-on-surface, #1C1B1F);
    font-weight: 600;
}

.course-tile-trailing {
    display: flex;
    align-items: center;
    gap: 4px;
}

.course-tile-clear-btn {
    background: transparent;
    border: none;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--md-sys-color-outline, #79747E);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.course-tile-clear-btn:hover {
    background: rgba(0, 0, 0, 0.08);
    color: var(--md-sys-color-on-surface, #1C1B1F);
}

.course-tile-clear-btn .material-symbols-rounded {
    font-size: 18px;
}

.course-tile-chevron {
    color: var(--md-sys-color-outline, #79747E);
    font-size: 22px;
    transition: transform 0.2s ease;
}

/* Course Picker Bottom Sheet / Dialog */
#course-picker-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 13000 !important;
    opacity: 1;
    transition: opacity 0.2s ease;
}

#course-picker-modal.hidden {
    display: none !important;
    opacity: 0;
    pointer-events: none;
}

.course-picker-sheet {
    background: var(--md-sys-color-surface, #FFFFFF);
    color: var(--md-sys-color-on-surface, #1C1B1F);
    border-radius: 20px;
    width: 92%;
    max-width: 580px;
    max-height: 82vh;
    max-height: 82dvh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.28);
    overflow: hidden;
    animation: coursePickerEnter 0.22s cubic-bezier(0.2, 0, 0, 1);
}

@keyframes coursePickerEnter {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.course-picker-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px 12px 20px;
    border-bottom: 1px solid var(--md-sys-color-outline-variant, rgba(0, 0, 0, 0.08));
    flex-shrink: 0;
}

.course-picker-header-text {
    display: flex;
    align-items: center;
    gap: 12px;
}

.course-picker-icon-badge {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background: linear-gradient(135deg, rgba(104, 36, 109, 0.12), rgba(104, 36, 109, 0.04));
    color: var(--palavibe-purple, #68246D);
    display: flex;
    align-items: center;
    justify-content: center;
}

.course-picker-icon-badge .material-symbols-rounded {
    font-size: 22px;
}

.course-picker-header h3 {
    margin: 0;
    font-size: 17px;
    font-weight: 700;
    letter-spacing: -0.2px;
}

.course-picker-sub {
    font-size: 11.5px;
    color: var(--md-sys-color-outline, #79747E);
}

.course-picker-search-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 12px 16px 8px 16px;
    padding: 8px 14px;
    background: var(--md-sys-color-surface-container, #F3EDF7);
    border: 1.5px solid transparent;
    border-radius: 14px;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.course-picker-search-bar:focus-within {
    border-color: var(--palavibe-purple, #68246D);
    background: #FFFFFF;
    box-shadow: 0 0 0 3px rgba(104, 36, 109, 0.12);
}

.course-picker-search-bar .material-symbols-rounded {
    color: var(--md-sys-color-outline, #79747E);
    font-size: 20px;
}

.course-picker-search-bar input {
    flex: 1;
    min-width: 0;
    border: none;
    background: transparent;
    font-size: 14px;
    color: var(--md-sys-color-on-surface, #1C1B1F);
    outline: none;
}

.course-picker-search-bar input::placeholder {
    color: var(--md-sys-color-outline, #79747E);
}

.course-picker-clear-search {
    background: transparent;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--md-sys-color-outline, #79747E);
    cursor: pointer;
}

.course-picker-clear-search .material-symbols-rounded {
    font-size: 16px;
}

.course-faculty-chips-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
    min-width: 0;
    flex-shrink: 0;
}

.course-faculty-chips-wrapper.has-scroll-left::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 8px;
    width: 38px;
    background: linear-gradient(to right, var(--md-sys-color-surface, #FFFFFF) 20%, transparent);
    pointer-events: none;
    z-index: 4;
}

.course-faculty-chips-wrapper.has-scroll-right::after {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    bottom: 8px;
    width: 44px;
    background: linear-gradient(to left, var(--md-sys-color-surface, #FFFFFF) 20%, transparent);
    pointer-events: none;
    z-index: 4;
}

[data-theme="dark"] .course-faculty-chips-wrapper.has-scroll-left::before,
.dark-mode .course-faculty-chips-wrapper.has-scroll-left::before {
    background: linear-gradient(to right, var(--md-sys-color-surface, #1C1B1F) 20%, transparent);
}

[data-theme="dark"] .course-faculty-chips-wrapper.has-scroll-right::after,
.dark-mode .course-faculty-chips-wrapper.has-scroll-right::after {
    background: linear-gradient(to left, var(--md-sys-color-surface, #1C1B1F) 20%, transparent);
}

.course-chips-scroll-btn {
    position: absolute;
    top: calc(50% - 4px);
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--md-sys-color-surface, #FFFFFF);
    border: 1px solid var(--md-sys-color-outline-variant, rgba(0, 0, 0, 0.14));
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
    color: var(--md-sys-color-on-surface, #1C1B1F);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    transition: all 0.18s cubic-bezier(0.2, 0, 0, 1);
    padding: 0;
    outline: none;
}

.course-chips-scroll-btn:hover {
    background: var(--palavibe-purple, #68246D);
    color: #FFFFFF;
    border-color: var(--palavibe-purple, #68246D);
    box-shadow: 0 3px 10px rgba(104, 36, 109, 0.35);
    transform: translateY(-50%) scale(1.08);
}

.course-chips-scroll-btn.prev {
    left: 4px;
}

.course-chips-scroll-btn.next {
    right: 4px;
}

.course-chips-scroll-btn.hidden {
    display: none !important;
}

.course-chips-scroll-btn .material-symbols-rounded {
    font-size: 18px;
}

[data-theme="dark"] .course-chips-scroll-btn,
.dark-mode .course-chips-scroll-btn {
    background: var(--md-sys-color-surface-container-high, #2B2930);
    color: var(--md-sys-color-on-surface, #E6E1E5);
    border-color: var(--md-sys-color-outline-variant, rgba(255, 255, 255, 0.14));
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
}

[data-theme="dark"] .course-chips-scroll-btn:hover,
.dark-mode .course-chips-scroll-btn:hover {
    background: var(--palavibe-purple, #A450A7);
    color: #FFFFFF;
    border-color: var(--palavibe-purple, #A450A7);
}

.course-faculty-chips {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 34px 10px 34px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    flex: 1 1 auto;
    min-width: 0;
    scroll-behavior: smooth;
    user-select: none;
}

.course-faculty-chips.is-dragging {
    cursor: grabbing;
    scroll-behavior: auto;
}

@media (hover: hover) and (pointer: fine) {
    .course-faculty-chips {
        scrollbar-width: thin;
        scrollbar-color: var(--md-sys-color-outline-variant, rgba(104, 36, 109, 0.25)) transparent;
    }
    .course-faculty-chips::-webkit-scrollbar {
        height: 4px;
        display: block;
    }
    .course-faculty-chips::-webkit-scrollbar-track {
        background: transparent;
    }
    .course-faculty-chips::-webkit-scrollbar-thumb {
        background: var(--md-sys-color-outline-variant, rgba(104, 36, 109, 0.25));
        border-radius: 4px;
    }
    .course-faculty-chips::-webkit-scrollbar-thumb:hover {
        background: var(--palavibe-purple, #68246D);
    }
}

@media (hover: none) or (pointer: coarse) {
    .course-faculty-chips {
        scrollbar-width: none;
    }
    .course-faculty-chips::-webkit-scrollbar {
        display: none;
    }
}

.course-faculty-chip {
    padding: 5px 12px;
    border-radius: 100px;
    font-size: 12px;
    font-weight: 600;
    border: 1px solid var(--md-sys-color-outline-variant, rgba(0, 0, 0, 0.12));
    background: var(--md-sys-color-surface, #FFFFFF);
    color: var(--md-sys-color-on-surface-variant, #49454F);
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
}

.course-faculty-chip:hover {
    background: var(--md-sys-color-surface-container, #F3EDF7);
}

.course-faculty-chip.active {
    background: var(--palavibe-purple, #68246D);
    color: #FFFFFF;
    border-color: var(--palavibe-purple, #68246D);
    box-shadow: 0 2px 6px rgba(104, 36, 109, 0.25);
}

.course-picker-list {
    flex: 1 1 auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 4px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-height: 0;
}

.course-picker-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px 16px;
    text-align: center;
    color: var(--md-sys-color-outline, #79747E);
    gap: 6px;
}

.course-picker-empty .material-symbols-rounded {
    font-size: 32px;
    opacity: 0.6;
}

.course-picker-empty p {
    margin: 0;
    font-size: 13px;
}

/* Course Level Filter (Undergraduate / Postgraduate / All) */
.course-level-filter {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 2px 16px 8px 16px;
    user-select: none;
}

.level-filter-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    border: 1px solid var(--md-sys-color-outline-variant, rgba(0, 0, 0, 0.12));
    background: var(--md-sys-color-surface-container-low, #FAF8FB);
    color: var(--md-sys-color-on-surface-variant, #49454F);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
}

.level-filter-btn:hover {
    background: var(--md-sys-color-surface-container-high, #ECE6F0);
    color: var(--md-sys-color-on-surface, #1C1B1F);
}

.level-filter-btn.active {
    background: var(--palavibe-purple, #68246D);
    color: #FFFFFF;
    border-color: var(--palavibe-purple, #68246D);
    box-shadow: 0 2px 6px rgba(104, 36, 109, 0.25);
}

.level-count-pill {
    font-size: 10.5px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.08);
    color: inherit;
    line-height: 1.2;
}

.level-filter-btn.active .level-count-pill {
    background: rgba(255, 255, 255, 0.25);
    color: #FFFFFF;
}

[data-theme="dark"] .level-filter-btn,
.dark-mode .level-filter-btn {
    background: var(--md-sys-color-surface-container, #211F26);
    border-color: var(--md-sys-color-outline-variant, rgba(255, 255, 255, 0.12));
    color: var(--md-sys-color-on-surface-variant, #CAC4D0);
}

[data-theme="dark"] .level-filter-btn:hover,
.dark-mode .level-filter-btn:hover {
    background: var(--md-sys-color-surface-container-high, #2B2930);
    color: var(--md-sys-color-on-surface, #E6E1E5);
}

[data-theme="dark"] .level-filter-btn.active,
.dark-mode .level-filter-btn.active {
    background: var(--palavibe-purple, #A450A7);
    border-color: var(--palavibe-purple, #A450A7);
    color: #FFFFFF;
}

[data-theme="dark"] .level-count-pill,
.dark-mode .level-count-pill {
    background: rgba(255, 255, 255, 0.12);
}

.course-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: 14px;
    cursor: pointer;
    border: 1px solid var(--md-sys-color-outline-variant, rgba(0, 0, 0, 0.06));
    background: var(--md-sys-color-surface, #FFFFFF);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
    transition: all 0.18s cubic-bezier(0.4, 0, 0.2, 1);
    margin-bottom: 2px;
    flex-shrink: 0;
    height: auto;
    min-height: 52px;
    box-sizing: border-box;
}

.course-item:hover {
    background: rgba(104, 36, 109, 0.04);
    border-color: rgba(104, 36, 109, 0.2);
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(104, 36, 109, 0.08);
}

.course-item.selected {
    background: rgba(104, 36, 109, 0.09);
    border-color: var(--palavibe-purple, #68246D);
    box-shadow: 0 0 0 1px var(--palavibe-purple, #68246D), 0 2px 8px rgba(104, 36, 109, 0.15);
}

/* Award Badge */
.course-award-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 68px;
    padding: 6px 8px;
    border-radius: 8px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.2px;
    text-align: center;
    flex-shrink: 0;
    line-height: 1.15;
    align-self: center;
}

.badge-ug {
    background: rgba(0, 114, 133, 0.1);
    color: #006070;
    border: 1px solid rgba(0, 114, 133, 0.22);
}

.badge-pgt {
    background: rgba(104, 36, 109, 0.1);
    color: #68246D;
    border: 1px solid rgba(104, 36, 109, 0.25);
}

[data-theme="dark"] .badge-ug,
.dark-mode .badge-ug {
    background: rgba(77, 208, 225, 0.15);
    color: #80deea;
    border-color: rgba(77, 208, 225, 0.3);
}

[data-theme="dark"] .badge-pgt,
.dark-mode .badge-pgt {
    background: rgba(206, 147, 216, 0.18);
    color: #e1bee7;
    border-color: rgba(206, 147, 216, 0.35);
}

/* Middle info container */
.course-item-main {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1 1 auto;
    min-width: 0;
}

.course-item-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
}

.course-title-text {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--md-sys-color-on-surface, #1C1B1F);
    line-height: 1.35;
    flex: 1 1 auto;
    min-width: 0;
    word-break: break-word;
}

.course-ucas-tag {
    font-size: 10px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 4px;
    background: var(--md-sys-color-surface-container-high, #ECE6F0);
    color: var(--md-sys-color-on-surface-variant, #49454F);
    border: 1px solid var(--md-sys-color-outline-variant, rgba(0, 0, 0, 0.08));
    letter-spacing: 0.3px;
    flex-shrink: 0;
    margin-top: 1px;
}

.course-variant-tags {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
    margin-top: 1px;
}

.course-variant-tag {
    font-size: 10px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 4px;
    white-space: nowrap;
    letter-spacing: 0.2px;
}

.course-variant-tag.tag-placement {
    background: rgba(230, 126, 34, 0.12);
    color: #b94a00;
    border: 1px solid rgba(230, 126, 34, 0.28);
}

.course-variant-tag.tag-abroad {
    background: rgba(41, 128, 185, 0.12);
    color: #1a6da0;
    border: 1px solid rgba(41, 128, 185, 0.28);
}

.course-variant-tag.tag-joint {
    background: rgba(142, 68, 173, 0.1);
    color: #6c2e8c;
    border: 1px solid rgba(142, 68, 173, 0.25);
}

[data-theme="dark"] .course-variant-tag.tag-placement,
.dark-mode .course-variant-tag.tag-placement {
    background: rgba(243, 156, 18, 0.18);
    color: #f39c12;
    border-color: rgba(243, 156, 18, 0.35);
}

[data-theme="dark"] .course-variant-tag.tag-abroad,
.dark-mode .course-variant-tag.tag-abroad {
    background: rgba(52, 152, 219, 0.18);
    color: #74b9ff;
    border-color: rgba(52, 152, 219, 0.35);
}

[data-theme="dark"] .course-variant-tag.tag-joint,
.dark-mode .course-variant-tag.tag-joint {
    background: rgba(155, 89, 182, 0.18);
    color: #d980fa;
    border-color: rgba(155, 89, 182, 0.35);
}

.course-item-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: var(--md-sys-color-outline, #79747E);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.course-meta-dept {
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
    flex-shrink: 1;
}

.course-meta-dot {
    opacity: 0.4;
    font-weight: 900;
    flex-shrink: 0;
}

.course-meta-duration {
    flex-shrink: 0;
    font-weight: 500;
}

.course-meta-faculty {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
}

.course-item-check {
    color: var(--palavibe-purple, #68246D);
    font-size: 20px;
    margin-left: 4px;
    opacity: 0;
    transform: scale(0.8);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
}

.course-item.selected .course-item-check {
    opacity: 1;
    transform: scale(1);
}

/* Dark mode for course item */
[data-theme="dark"] .course-item,
.dark-mode .course-item {
    background: var(--md-sys-color-surface-container, #211F26);
    border-color: var(--md-sys-color-outline-variant, rgba(255, 255, 255, 0.08));
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}

[data-theme="dark"] .course-item:hover,
.dark-mode .course-item:hover {
    background: var(--md-sys-color-surface-container-high, #2B2930);
    border-color: rgba(164, 80, 167, 0.35);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .course-item.selected,
.dark-mode .course-item.selected {
    background: rgba(164, 80, 167, 0.16);
    border-color: var(--palavibe-purple, #A450A7);
    box-shadow: 0 0 0 1px var(--palavibe-purple, #A450A7), 0 2px 8px rgba(0, 0, 0, 0.5);
}

[data-theme="dark"] .course-title-text,
.dark-mode .course-title-text {
    color: var(--md-sys-color-on-surface, #E6E1E5);
}

[data-theme="dark"] .course-ucas-tag,
.dark-mode .course-ucas-tag {
    background: var(--md-sys-color-surface-container-highest, #36343B);
    color: var(--md-sys-color-on-surface-variant, #CAC4D0);
    border-color: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .course-item-check,
.dark-mode .course-item-check {
    color: var(--palavibe-purple, #A450A7);
}

.course-picker-custom-card {
    margin: 8px 4px 12px 4px;
    padding: 10px 14px;
    border-radius: 14px;
    background: var(--md-sys-color-surface-container-low, #FAF8FB);
    border: 1px dashed var(--md-sys-color-outline-variant, rgba(104, 36, 109, 0.25));
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.course-picker-custom-card.is-active {
    background: var(--md-sys-color-surface-container, #F3EDF7);
    border: 1.5px solid var(--palavibe-purple, #68246D);
    box-shadow: 0 4px 14px rgba(104, 36, 109, 0.12);
}

.course-picker-custom-trigger {
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 12px;
    width: 100%;
    font-size: 13px;
    font-weight: 600;
    color: var(--palavibe-purple, #68246D);
    border-radius: 10px;
    transition: background 0.15s ease, color 0.15s ease;
}

.course-picker-custom-trigger:hover {
    background: rgba(104, 36, 109, 0.08);
}

.course-picker-custom-trigger .material-symbols-rounded {
    font-size: 18px;
}

.course-custom-chip {
    border-style: dashed !important;
    display: inline-flex !important;
    align-items: center;
    gap: 2px;
    color: var(--palavibe-purple, #68246D) !important;
}

.course-custom-chip:hover {
    background: rgba(104, 36, 109, 0.08) !important;
}

/* Custom Input Box Inside Card */
.course-custom-input-box {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
}

.course-custom-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

.course-custom-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--palavibe-purple, #68246D);
}

.course-custom-close-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 4px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--md-sys-color-outline, #79747E);
    transition: background 0.15s;
}

.course-custom-close-btn:hover {
    background: rgba(0, 0, 0, 0.06);
    color: var(--md-sys-color-on-surface, #1C1B1F);
}

.course-custom-close-btn .material-symbols-rounded {
    font-size: 18px;
}

.course-custom-form-row {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
}

.course-custom-field {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    background: #FFFFFF;
    border: 1.5px solid var(--md-sys-color-outline-variant, rgba(0, 0, 0, 0.18));
    border-radius: 12px;
    padding: 0 12px;
    height: 42px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.course-custom-field:focus-within {
    border-color: var(--palavibe-purple, #68246D);
    box-shadow: 0 0 0 3px rgba(104, 36, 109, 0.12);
}

.course-custom-field-icon {
    font-size: 18px;
    color: var(--md-sys-color-outline, #79747E);
    flex-shrink: 0;
}

.course-custom-field input {
    flex: 1;
    min-width: 0;
    border: none;
    background: transparent;
    font-size: 13.5px;
    color: var(--md-sys-color-on-surface, #1C1B1F);
    outline: none;
    padding: 0;
    margin: 0;
    height: 100%;
}

.course-custom-field input::placeholder {
    color: var(--md-sys-color-outline, #79747E);
}

.course-custom-submit-btn {
    height: 42px;
    padding: 0 18px;
    border-radius: 12px;
    background: var(--palavibe-purple, #68246D);
    color: #FFFFFF;
    border: none;
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(104, 36, 109, 0.25);
    transition: background-color 0.15s, transform 0.1s;
}

.course-custom-submit-btn:hover {
    background: #501955;
}

.course-custom-submit-btn:active {
    transform: scale(0.98);
}

.course-custom-hint {
    font-size: 11px;
    color: var(--md-sys-color-outline, #79747E);
    padding-left: 2px;
}

.course-empty-add-btn {
    margin-top: 10px;
    padding: 10px 18px;
    border-radius: 100px;
    background: var(--palavibe-purple, #68246D);
    color: #FFFFFF;
    border: none;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 2px 6px rgba(104, 36, 109, 0.25);
    transition: all 0.15s ease;
}

.course-empty-add-btn:hover {
    background: #501955;
    transform: translateY(-1px);
}

.course-empty-add-btn .material-symbols-rounded {
    font-size: 18px;
}

/* Dark Mode Overrides for Course Picker */
[data-theme="dark"] .onboarding-course-tile {
    background: #2B2730;
    border-color: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .onboarding-course-tile:hover {
    border-color: #D0BCFF;
    background: rgba(208, 188, 255, 0.05);
}

[data-theme="dark"] .course-tile-leading {
    background: rgba(208, 188, 255, 0.12);
    color: #D0BCFF;
}

[data-theme="dark"] .course-tile-val.has-value {
    color: #F4EFF4;
}

[data-theme="dark"] .course-picker-sheet {
    background: #1E1B22;
    color: #E6E1E5;
    border: 1px solid rgba(255, 255, 255, 0.12);
}

[data-theme="dark"] .course-picker-header,
[data-theme="dark"] .course-picker-custom-footer {
    border-color: rgba(255, 255, 255, 0.08);
}

[data-theme="dark"] .course-picker-icon-badge {
    background: rgba(208, 188, 255, 0.12);
    color: #D0BCFF;
}

[data-theme="dark"] .course-picker-search-bar {
    background: #2B2730;
}

[data-theme="dark"] .course-picker-search-bar:focus-within {
    background: #332E3A;
    border-color: #D0BCFF;
    box-shadow: 0 0 0 3px rgba(208, 188, 255, 0.15);
}

[data-theme="dark"] .course-picker-search-bar input {
    color: #F4EFF4;
}

[data-theme="dark"] .course-faculty-chip {
    background: #2B2730;
    color: #CAC4D0;
    border-color: rgba(255, 255, 255, 0.08);
}

[data-theme="dark"] .course-faculty-chip:hover {
    background: #383340;
}

[data-theme="dark"] .course-faculty-chip.active {
    background: #D0BCFF;
    color: #381E72;
    border-color: #D0BCFF;
}



[data-theme="dark"] .course-picker-custom-card {
    background: #231F2A;
    border-color: rgba(208, 188, 255, 0.2);
}

[data-theme="dark"] .course-picker-custom-card.is-active {
    background: #2B2533;
    border-color: #D0BCFF;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .course-picker-custom-trigger {
    color: #D0BCFF;
}

[data-theme="dark"] .course-picker-custom-trigger:hover {
    background: rgba(208, 188, 255, 0.08);
}

[data-theme="dark"] .course-custom-chip {
    color: #D0BCFF !important;
    border-color: rgba(208, 188, 255, 0.35) !important;
}

[data-theme="dark"] .course-custom-title {
    color: #D0BCFF;
}

[data-theme="dark"] .course-custom-close-btn {
    color: #CAC4D0;
}

[data-theme="dark"] .course-custom-close-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #FFFFFF;
}

[data-theme="dark"] .course-custom-field {
    background: #1C1B1F;
    border-color: rgba(255, 255, 255, 0.15);
}

[data-theme="dark"] .course-custom-field:focus-within {
    border-color: #D0BCFF;
    box-shadow: 0 0 0 3px rgba(208, 188, 255, 0.15);
}

[data-theme="dark"] .course-custom-field-icon {
    color: #938F99;
}

[data-theme="dark"] .course-custom-field input {
    color: #F4EFF4;
}

[data-theme="dark"] .course-custom-submit-btn {
    background: #D0BCFF;
    color: #381E72;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .course-custom-submit-btn:hover {
    background: #E8DEF8;
}

[data-theme="dark"] .course-custom-hint {
    color: #938F99;
}

[data-theme="dark"] .course-empty-add-btn {
    background: #D0BCFF;
    color: #381E72;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

[data-theme="dark"] .course-empty-add-btn:hover {
    background: #E8DEF8;
}

/* Mobile Adjustments for Course Picker Sheet */
@media (max-width: 600px) {
    #course-picker-modal {
        align-items: flex-end;
        padding: 0;
    }

    .course-picker-sheet {
        width: 100%;
        max-width: 100%;
        border-radius: 24px 24px 0 0;
        max-height: 88vh;
        max-height: 88dvh;
        height: auto;
        display: flex;
        flex-direction: column;
        animation: coursePickerSlideUp 0.25s cubic-bezier(0.2, 0, 0, 1);
    }

    .course-picker-header {
        padding: 12px 16px 10px 16px;
    }

    .course-picker-icon-badge {
        width: 34px;
        height: 34px;
        border-radius: 10px;
    }

    .course-picker-icon-badge .material-symbols-rounded {
        font-size: 20px;
    }

    .course-picker-header h3 {
        font-size: 16px;
    }

    .course-picker-sub {
        font-size: 11px;
    }

    .course-picker-search-bar {
        margin: 8px 14px 6px 14px;
        padding: 7px 12px;
    }

    .course-faculty-chips {
        padding: 2px 14px 6px 14px;
        gap: 5px;
    }

    .course-faculty-chip {
        padding: 4px 10px;
        font-size: 11.5px;
    }

    .course-picker-list {
        padding: 4px 12px calc(14px + env(safe-area-inset-bottom, 0px)) 12px;
        gap: 6px;
    }

    .course-item {
        padding: 9px 12px;
        min-height: 50px;
        height: auto;
        flex-shrink: 0;
        gap: 10px;
    }

    .course-award-badge {
        min-width: 62px;
        padding: 5px 6px;
        font-size: 10.5px;
    }

    .course-title-text {
        font-size: 13px;
    }

    .course-item-meta {
        font-size: 10.5px;
        gap: 4px;
    }

    @keyframes coursePickerSlideUp {
        from {
            transform: translateY(100%);
        }
        to {
            transform: translateY(0);
        }
    }
}

/* Settings Profile Course Selector Tile */
.settings-course-wrapper {
    margin-bottom: 18px;
}

.settings-course-wrapper .select-label {
    display: block;
    margin-bottom: 6px;
    font-size: 12px;
    font-weight: 600;
    color: var(--md-sys-color-on-surface-variant, #49454F);
}

[data-theme="dark"] .settings-course-wrapper .select-label {
    color: #CAC4D0;
}

/* ==========================================================================
   Material 3 Redesigned Profile Settings & College Picker Modal
   ========================================================================== */

#settings-view {
    padding-bottom: calc(96px + env(safe-area-inset-bottom, 20px));
}

/* Settings Category Tabs Bar */
.settings-tabs-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px;
    margin-bottom: 20px;
    background: var(--md-sys-color-surface-container-low, rgba(0, 0, 0, 0.04));
    border-radius: 16px;
    border: 1px solid var(--md-sys-color-outline-variant, rgba(0, 0, 0, 0.08));
}

.settings-tab-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 44px;
    padding: 0 12px;
    background: transparent;
    border: none;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 600;
    color: var(--md-sys-color-on-surface-variant, #49454F);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.2, 0, 0, 1);
    white-space: nowrap;
    user-select: none;
}

.settings-tab-btn .material-symbols-rounded {
    font-size: 20px;
    transition: transform 0.2s ease;
}

.settings-tab-btn:focus {
    outline: none;
}

.settings-tab-btn:focus-visible {
    outline: 2px solid var(--palavibe-purple, #68246D);
    outline-offset: 2px;
}

.settings-tab-btn:hover:not(.active) {
    background: rgba(104, 36, 109, 0.06);
    color: var(--palavibe-purple, #68246D);
}

.settings-tab-btn.active,
.settings-tab-btn.active:hover,
.settings-tab-btn.active:focus {
    background: var(--palavibe-purple, #68246D) !important;
    color: #FFFFFF !important;
    box-shadow: 0 2px 6px rgba(104, 36, 109, 0.25);
}

.settings-tab-btn.active .material-symbols-rounded,
.settings-tab-btn.active:hover .material-symbols-rounded,
.settings-tab-btn.active:focus .material-symbols-rounded {
    color: #FFFFFF !important;
    transform: scale(1.08);
}

.settings-tab-pane {
    animation: settingsPaneFadeIn 0.22s cubic-bezier(0.2, 0, 0, 1);
}

.settings-tab-pane.hidden {
    display: none !important;
}

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

/* Settings Status Suggestion Pills */
.settings-status-presets {
    margin-top: 6px;
    margin-bottom: 18px;
}

.settings-presets-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--md-sys-color-outline, #79747E);
    margin-bottom: 6px;
}

.settings-pills-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.settings-status-pill {
    background: var(--md-sys-color-surface-container-low, rgba(104, 36, 109, 0.06));
    border: 1px solid var(--md-sys-color-outline-variant, rgba(0, 0, 0, 0.1));
    border-radius: 20px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 500;
    color: var(--md-sys-color-on-surface, #1C1B1F);
    cursor: pointer;
    transition: all 0.15s ease;
    user-select: none;
}

.settings-status-pill:hover {
    background: rgba(104, 36, 109, 0.12);
    border-color: var(--palavibe-purple, #68246D);
    transform: translateY(-1px);
}

/* Settings College Selector Tile */
.settings-college-wrapper {
    margin-bottom: 16px;
}

.settings-college-wrapper .select-label {
    display: block;
    margin-bottom: 6px;
    font-size: 12px;
    font-weight: 600;
    color: var(--md-sys-color-on-surface-variant, #49454F);
}

.college-tile-title-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* College Picker Modal & Sheet */
#college-picker-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.52);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 13000 !important;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

#college-picker-modal.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.college-picker-sheet {
    background: var(--md-sys-color-surface, #FFFFFF);
    border-radius: 24px;
    width: 100%;
    max-width: 540px;
    max-height: 82vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.22);
    overflow: hidden;
    animation: collegePickerPopIn 0.22s cubic-bezier(0.2, 0, 0, 1);
}

@keyframes collegePickerPopIn {
    from {
        opacity: 0;
        transform: scale(0.96) translateY(10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.college-picker-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px 14px 20px;
    border-bottom: 1px solid var(--md-sys-color-outline-variant, rgba(0, 0, 0, 0.08));
    flex-shrink: 0;
}

.college-picker-header-text {
    display: flex;
    align-items: center;
    gap: 12px;
}

.college-picker-icon-badge {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: rgba(104, 36, 109, 0.1);
    color: var(--palavibe-purple, #68246D);
    display: flex;
    align-items: center;
    justify-content: center;
}

.college-picker-icon-badge .material-symbols-rounded {
    font-size: 24px;
}

.college-picker-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    color: var(--md-sys-color-on-surface, #1C1B1F);
}

.college-picker-sub {
    font-size: 12px;
    color: var(--md-sys-color-outline, #79747E);
}

.college-picker-search-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 12px 18px 8px 18px;
    padding: 10px 14px;
    background: var(--md-sys-color-surface-container-low, rgba(0, 0, 0, 0.04));
    border: 1.5px solid transparent;
    border-radius: 12px;
    transition: border-color 0.2s ease, background 0.2s ease;
    flex-shrink: 0;
}

.college-picker-search-bar:focus-within {
    border-color: var(--palavibe-purple, #68246D);
    background: #FFFFFF;
}

.college-picker-search-bar .material-symbols-rounded {
    font-size: 20px;
    color: var(--md-sys-color-outline, #79747E);
}

.college-picker-search-bar input {
    flex: 1;
    border: none;
    background: transparent;
    outline: none;
    font-size: 14px;
    color: var(--md-sys-color-on-surface, #1C1B1F);
}

.college-picker-search-bar input::placeholder {
    color: var(--md-sys-color-outline, #79747E);
}

.college-picker-clear-search {
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--md-sys-color-outline, #79747E);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2px;
}

.college-cluster-chips-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
    min-width: 0;
    flex-shrink: 0;
}

.college-cluster-chips-wrapper.has-scroll-left::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 8px;
    width: 38px;
    background: linear-gradient(to right, var(--md-sys-color-surface, #FFFFFF) 20%, transparent);
    pointer-events: none;
    z-index: 4;
}

.college-cluster-chips-wrapper.has-scroll-right::after {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    bottom: 8px;
    width: 44px;
    background: linear-gradient(to left, var(--md-sys-color-surface, #FFFFFF) 20%, transparent);
    pointer-events: none;
    z-index: 4;
}

[data-theme="dark"] .college-cluster-chips-wrapper.has-scroll-left::before,
.dark-mode .college-cluster-chips-wrapper.has-scroll-left::before {
    background: linear-gradient(to right, var(--md-sys-color-surface, #1C1B1F) 20%, transparent);
}

[data-theme="dark"] .college-cluster-chips-wrapper.has-scroll-right::after,
.dark-mode .college-cluster-chips-wrapper.has-scroll-right::after {
    background: linear-gradient(to left, var(--md-sys-color-surface, #1C1B1F) 20%, transparent);
}

.college-chips-scroll-btn {
    position: absolute;
    top: calc(50% - 4px);
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--md-sys-color-surface, #FFFFFF);
    border: 1px solid var(--md-sys-color-outline-variant, rgba(0, 0, 0, 0.14));
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
    color: var(--md-sys-color-on-surface, #1C1B1F);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    transition: all 0.18s cubic-bezier(0.2, 0, 0, 1);
    padding: 0;
    outline: none;
}

.college-chips-scroll-btn:hover {
    background: var(--palavibe-purple, #68246D);
    color: #FFFFFF;
    border-color: var(--palavibe-purple, #68246D);
    box-shadow: 0 3px 10px rgba(104, 36, 109, 0.35);
    transform: translateY(-50%) scale(1.08);
}

.college-chips-scroll-btn.prev {
    left: 4px;
}

.college-chips-scroll-btn.next {
    right: 4px;
}

.college-chips-scroll-btn.hidden {
    display: none !important;
}

.college-chips-scroll-btn .material-symbols-rounded {
    font-size: 18px;
}

[data-theme="dark"] .college-chips-scroll-btn,
.dark-mode .college-chips-scroll-btn {
    background: var(--md-sys-color-surface-container-high, #2B2930);
    color: var(--md-sys-color-on-surface, #E6E1E5);
    border-color: var(--md-sys-color-outline-variant, rgba(255, 255, 255, 0.14));
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
}

[data-theme="dark"] .college-chips-scroll-btn:hover,
.dark-mode .college-chips-scroll-btn:hover {
    background: var(--palavibe-purple, #A450A7);
    color: #FFFFFF;
    border-color: var(--palavibe-purple, #A450A7);
}

.college-cluster-chips {
    display: flex;
    gap: 6px;
    padding: 4px 34px 10px 34px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    flex: 1 1 auto;
    min-width: 0;
    scroll-behavior: smooth;
    user-select: none;
}

.college-cluster-chips.is-dragging {
    cursor: grabbing;
    scroll-behavior: auto;
}

@media (hover: hover) and (pointer: fine) {
    .college-cluster-chips {
        scrollbar-width: thin;
        scrollbar-color: var(--md-sys-color-outline-variant, rgba(104, 36, 109, 0.25)) transparent;
    }
    .college-cluster-chips::-webkit-scrollbar {
        height: 4px;
        display: block;
    }
    .college-cluster-chips::-webkit-scrollbar-track {
        background: transparent;
    }
    .college-cluster-chips::-webkit-scrollbar-thumb {
        background: var(--md-sys-color-outline-variant, rgba(104, 36, 109, 0.25));
        border-radius: 4px;
    }
    .college-cluster-chips::-webkit-scrollbar-thumb:hover {
        background: var(--palavibe-purple, #68246D);
    }
}

@media (hover: none) or (pointer: coarse) {
    .college-cluster-chips {
        scrollbar-width: none;
    }
    .college-cluster-chips::-webkit-scrollbar {
        display: none;
    }
}

.college-cluster-chip {
    flex-shrink: 0;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    background: var(--md-sys-color-surface-container-low, rgba(0, 0, 0, 0.05));
    border: 1px solid var(--md-sys-color-outline-variant, rgba(0, 0, 0, 0.08));
    color: var(--md-sys-color-on-surface-variant, #49454F);
    cursor: pointer;
    transition: all 0.15s ease;
}

.college-cluster-chip:hover {
    background: rgba(104, 36, 109, 0.08);
}

.college-cluster-chip.active {
    background: var(--palavibe-purple, #68246D);
    color: #FFFFFF;
    border-color: var(--palavibe-purple, #68246D);
}

.college-picker-list {
    flex: 1 1 auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 4px 18px 18px 18px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 0;
}

.college-picker-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 14px;
    border: 1px solid var(--md-sys-color-outline-variant, rgba(0, 0, 0, 0.08));
    background: var(--md-sys-color-surface, #FFFFFF);
    cursor: pointer;
    transition: all 0.15s ease;
}

.college-picker-item:hover {
    border-color: var(--palavibe-purple, #68246D);
    background: rgba(104, 36, 109, 0.03);
    transform: translateY(-1px);
}

.college-picker-item.selected {
    border-color: var(--palavibe-purple, #68246D);
    background: rgba(104, 36, 109, 0.08);
}

.college-picker-item-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: rgba(104, 36, 109, 0.1);
    color: var(--palavibe-purple, #68246D);
    display: flex;
    align-items: center;
    justify-content: center;
}

.college-picker-item-icon .material-symbols-rounded {
    font-size: 20px;
}

.college-picker-item-info {
    flex: 1;
    min-width: 0;
}

.college-picker-item-top {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 2px;
}

.college-picker-item-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--md-sys-color-on-surface, #1C1B1F);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.college-picker-item-motto {
    font-size: 12px;
    color: var(--md-sys-color-outline, #79747E);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.college-picker-item-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--md-sys-color-outline, #79747E);
}

.college-picker-item.selected .college-picker-item-indicator {
    color: var(--palavibe-purple, #68246D);
}

.college-picker-empty {
    padding: 36px 16px;
    text-align: center;
    color: var(--md-sys-color-outline, #79747E);
}

.college-picker-empty .material-symbols-rounded {
    font-size: 40px;
    opacity: 0.5;
    margin-bottom: 8px;
}

/* Dark Mode Overrides for Settings & College Picker */
[data-theme="dark"] .settings-tabs-bar {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.08);
}

[data-theme="dark"] .settings-tab-btn {
    color: #CAC4D0;
}

[data-theme="dark"] .settings-tab-btn:hover:not(.active) {
    background: rgba(208, 188, 255, 0.1);
    color: #D0BCFF;
}

[data-theme="dark"] .settings-tab-btn.active,
[data-theme="dark"] .settings-tab-btn.active:hover,
[data-theme="dark"] .settings-tab-btn.active:focus {
    background: #D0BCFF !important;
    color: #381E72 !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .settings-tab-btn.active .material-symbols-rounded,
[data-theme="dark"] .settings-tab-btn.active:hover .material-symbols-rounded,
[data-theme="dark"] .settings-tab-btn.active:focus .material-symbols-rounded {
    color: #381E72 !important;
}

[data-theme="dark"] .settings-status-pill {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.1);
    color: #E6E1E5;
}

[data-theme="dark"] .settings-status-pill:hover {
    background: rgba(208, 188, 255, 0.15);
    border-color: #D0BCFF;
}

[data-theme="dark"] .college-picker-sheet {
    background: #1E1A22;
}

[data-theme="dark"] .college-picker-header {
    border-bottom-color: rgba(255, 255, 255, 0.08);
}

[data-theme="dark"] .college-picker-icon-badge {
    background: rgba(208, 188, 255, 0.14);
    color: #D0BCFF;
}

[data-theme="dark"] .college-picker-header h3 {
    color: #F4EFF4;
}

[data-theme="dark"] .college-picker-search-bar {
    background: #2B2730;
}

[data-theme="dark"] .college-picker-search-bar:focus-within {
    border-color: #D0BCFF;
    background: #2B2730;
}

[data-theme="dark"] .college-picker-search-bar input {
    color: #F4EFF4;
}

[data-theme="dark"] .college-cluster-chip {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.1);
    color: #CAC4D0;
}

[data-theme="dark"] .college-cluster-chip.active {
    background: #D0BCFF;
    color: #381E72;
    border-color: #D0BCFF;
}

[data-theme="dark"] .college-picker-item {
    background: #25202B;
    border-color: rgba(255, 255, 255, 0.08);
}

[data-theme="dark"] .college-picker-item:hover {
    border-color: #D0BCFF;
    background: rgba(208, 188, 255, 0.08);
}

[data-theme="dark"] .college-picker-item.selected {
    border-color: #D0BCFF;
    background: rgba(208, 188, 255, 0.16);
}

[data-theme="dark"] .college-picker-item-icon {
    background: rgba(208, 188, 255, 0.14);
    color: #D0BCFF;
}

[data-theme="dark"] .college-picker-item-name {
    color: #F4EFF4;
}

[data-theme="dark"] .college-picker-item-motto {
    color: #938F99;
}

[data-theme="dark"] .college-picker-item.selected .college-picker-item-indicator {
    color: #D0BCFF;
}

/* Mobile Adjustments for College Picker */
@media (max-width: 600px) {
    #college-picker-modal {
        align-items: flex-end;
        padding: 0;
    }

    .college-picker-sheet {
        border-radius: 24px 24px 0 0;
        max-height: 85vh;
        max-height: 85dvh;
        animation: collegePickerSlideUp 0.25s cubic-bezier(0.2, 0, 0, 1);
    }

    @keyframes collegePickerSlideUp {
        from {
            transform: translateY(100%);
        }
        to {
            transform: translateY(0);
        }
    }
}