/* =========================================================================
   SB Admin 2 Design System — Adapted for Bootstrap 5
   Extracted from SB Admin 2 theme by Start Bootstrap
   Modified for HabiCode Classroom (BS5 + Bootstrap Icons)
   ========================================================================= */

/* ── Base Typography ── */
/* Family and ink come from the tokens in main.css */
body {
    font-size: var(--hc-fs-base);
}

a:focus-visible {
    outline: 2px solid var(--primary-color, #2B3A8C);
    outline-offset: 2px;
}

/* ── Wrapper Layout ── */
#wrapper {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

#wrapper #content-wrapper {
    background-color: var(--hc-canvas);
    flex: 1;
    min-width: 0;
    overflow-x: hidden;
    overflow-y: auto;
}

#wrapper #content-wrapper #content {
    flex: 1 0 auto;
}

/* ── Container Padding ── */
.container,
.container-fluid,
.container-sm,
.container-md,
.container-lg,
.container-xl,
.container-xxl {
    padding-left: 1rem; 
    padding-right: 1rem;
}

/* ── Scroll to Top Button ── */
.scroll-to-top {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    display: none;
    width: 2.75rem;
    height: 2.75rem;
    text-align: center;
    color: #fff;
    background: rgba(90, 92, 105, 0.5);
    line-height: 46px;
    border-radius: 0.35rem;
    z-index: 1000;
}

.scroll-to-top:focus,
.scroll-to-top:hover {
    color: white;
    background: #5a5c69;
}

/* ── Animations ── */
@keyframes growIn {
    0% {
        transform: scale(0.9);
        opacity: 0;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.animated--grow-in {
    animation-name: growIn;
    animation-duration: 200ms;
    animation-timing-function: cubic-bezier(0.18, 1.25, 0.4, 1);
}

@keyframes fadeIn {
    0% { opacity: 0; }
    100% { opacity: 1; }
}

.animated--fade-in {
    animation-name: fadeIn;
    animation-duration: 200ms;
    animation-timing-function: cubic-bezier(0, 1, 0.4, 1);
}

/* ── Brand Backgrounds (solid fills; class names kept from SB Admin 2) ── */
.bg-gradient-primary {
    background-color: #1F2B6E;
    background-image: none;
}

.bg-gradient-secondary {
    background-color: #858796;
    background-image: none;
}

.bg-gradient-success {
    background-color: #1cc88a;
    background-image: none;
}

.bg-gradient-info {
    background-color: var(--hc-info);
    background-image: none;
}

.bg-gradient-warning {
    background-color: #ffbe1f;
    background-image: none;
}

.bg-gradient-danger {
    background-color: #e74a3b;
    background-image: none;
}

/* ── Gray Scale Backgrounds ── */
.bg-gray-100 { background-color: #f8f9fc !important; }
.bg-gray-200 { background-color: #eaecf4 !important; }
.bg-gray-300 { background-color: #dddfeb !important; }
.bg-gray-400 { background-color: #d1d3e2 !important; }
.bg-gray-500 { background-color: #b7b9cc !important; }
.bg-gray-600 { background-color: #858796 !important; }
.bg-gray-700 { background-color: #6e707e !important; }
.bg-gray-800 { background-color: #5a5c69 !important; }
.bg-gray-900 { background-color: #3a3b45 !important; }

/* ── Gray Scale Text ── */
.text-gray-100 { color: #f8f9fc !important; }
.text-gray-200 { color: #eaecf4 !important; }
.text-gray-300 { color: #dddfeb !important; }
.text-gray-400 { color: #d1d3e2 !important; }
.text-gray-500 { color: #b7b9cc !important; }
.text-gray-600 { color: var(--hc-ink-faint) !important; }
.text-gray-700 { color: var(--hc-ink-soft) !important; }
.text-gray-800 { color: var(--hc-ink) !important; }
.text-gray-900 { color: var(--hc-ink) !important; }

/* ── Utility: Overflow Hidden ── */
.o-hidden {
    overflow: hidden !important;
}

/* ── Text Size Utilities ── */
.text-xs { font-size: var(--hc-fs-2xs); }
.text-lg { font-size: var(--hc-fs-md); }
.font-weight-bold { font-weight: 700 !important; }

/* ── Icon Circle ── */
.icon-circle {
    height: 2.5rem;
    width: 2.5rem;
    border-radius: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ── Border-Left Accent Cards ── */
.border-bottom-primary { border-bottom: 0.25rem solid var(--bs-primary) !important; }

.border-bottom-secondary { border-bottom: 0.25rem solid #858796 !important; }

.border-bottom-success { border-bottom: 0.25rem solid #1cc88a !important; }

.border-bottom-info { border-bottom: 0.25rem solid var(--hc-info) !important; }

.border-bottom-warning { border-bottom: 0.25rem solid #ffbe1f !important; }

.border-bottom-danger { border-bottom: 0.25rem solid #e74a3b !important; }

/* ── Progress Bar Small ── */
.progress-sm { height: .5rem; }

/* ── Rotate Utilities ── */
.rotate-15  { transform: rotate(15deg); }
.rotate-n-15 { transform: rotate(-15deg); }

/* ── Dropdown Styles ── */
.dropdown .dropdown-menu {
    font-size: var(--hc-fs-sm);
}

.dropdown .dropdown-menu .dropdown-header {
    font-weight: 800;
    font-size: var(--hc-fs-2xs);
    color: #b7b9cc;
}

.dropdown.no-arrow .dropdown-toggle::after {
    display: none;
}

/* Sidebar transition — only after first user interaction to prevent flash on load */
.sidebar.sidebar-animate {
    transition: width 0.25s ease-in-out;
}

/* Early sidebar collapse — applied via <html> class before body paints */
html.sidebar-toggled-early .sidebar {
    width: 0 !important;
    overflow: hidden !important;
}

html.sidebar-toggled-early .sidebar .collapse,
html.sidebar-toggled-early .sidebar .collapsing {
    display: none !important;
}

@media (min-width: 768px) {
    html.sidebar-toggled-early .sidebar {
        overflow-y: auto !important;
        overflow-x: hidden !important;
        width: 6.5rem !important;
    }
    html.sidebar-toggled-early .sidebar .nav-item .nav-link {
        text-align: center;
        padding: 0.75rem 0.5rem;
        width: 100%;
        display: block;
        min-height: unset;
    }
    html.sidebar-toggled-early .sidebar .nav-item .nav-link span {
        font-size: var(--hc-fs-2xs);
        display: block;
    }
    html.sidebar-toggled-early .sidebar .nav-item .nav-link i {
        margin-right: 0;
        font-size: var(--hc-fs-base);
        width: auto;
    }
    html.sidebar-toggled-early .sidebar .sidebar-brand .sidebar-brand-text {
        display: none;
    }
    html.sidebar-toggled-early .sidebar .sidebar-heading {
        text-align: center;
        font-size: var(--hc-fs-2xs);
        padding: 0 0.5rem;
    }
    html.sidebar-toggled-early .sidebar .collapse,
    html.sidebar-toggled-early .sidebar .collapsing {
        display: none !important;
    }
}

/* ── Topbar ── */
.topbar {
    height: 4.375rem;
    z-index: 1030;
}

/* Prevent topbar items from causing horizontal overflow on mobile */
@media (max-width: 767.98px) {
    .topbar {
        padding-left: 0.25rem;
        padding-right: 0.25rem;
    }

    .topbar .navbar-nav .nav-item {
        margin-left: 0 !important;
        margin-right: 0 !important;
    }

    .topbar .topbar-divider {
        display: none !important;
    }

    .topbar .nav-link {
        padding-left: 0.4rem;
        padding-right: 0.4rem;
    }

    .topbar .topbar-brand-text {
        font-size: var(--hc-fs-sm);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 40vw;
    }
}

.topbar #sidebarToggleTop {
    height: 2.5rem;
    width: 2.5rem;
    color: #858796;
    font-size: var(--hc-fs-md);
    display: flex;
    align-items: center;
    justify-content: center;
}

.topbar #sidebarToggleTop:hover {
    background-color: #eaecf4;
}

.topbar #sidebarToggleTop:active {
    background-color: #dddfeb;
}

.topbar #sidebarToggleTop:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.topbar .topbar-brand-text {
    font-size: var(--hc-fs-base);
    text-decoration: none;
}

.topbar .topbar-brand-text .hc-logo__word { font-size: inherit; }

.topbar .navbar-search {
    width: 25rem;
}

.topbar .navbar-search input {
    font-size: var(--hc-fs-sm);
    height: auto;
}

.topbar .topbar-divider {
    width: 0;
    border-right: 1px solid #e3e6f0;
    height: calc(4.375rem - 2rem);
    margin: auto 1rem;
}

.topbar .nav-item .nav-link {
    height: 4.375rem;
    display: flex;
    align-items: center;
    padding: 0 0.75rem;
}

.topbar .nav-item .nav-link:focus-visible {
    outline: 2px solid var(--primary-color, #2B3A8C);
    outline-offset: -2px;
    border-radius: 0.25rem;
}

.topbar .dropdown {
    position: static;
}

.topbar .dropdown .dropdown-menu {
    width: calc(100% - 1.5rem);
    right: 0.75rem;
}

.topbar .dropdown-list {
    padding: 0;
    border: none;
    overflow: hidden;
}

.topbar .dropdown-list .dropdown-header {
    background-color: var(--bs-primary);
    border: 1px solid var(--bs-primary);
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
    color: #fff;
}

.topbar .dropdown-list .dropdown-item {
    white-space: normal;
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
    border-left: 1px solid #e3e6f0;
    border-right: 1px solid #e3e6f0;
    border-bottom: 1px solid #e3e6f0;
    line-height: 1.3rem;
}

.topbar .dropdown-list .dropdown-item .dropdown-list-image {
    position: relative;
    height: 2.5rem;
    width: 2.5rem;
}

.topbar .dropdown-list .dropdown-item .dropdown-list-image img {
    height: 2.5rem;
    width: 2.5rem;
}

.topbar .dropdown-list .dropdown-item .text-truncate {
    max-width: 10rem;
}

.topbar .dropdown-list .dropdown-item:active {
    background-color: #eaecf4;
    color: #3a3b45;
}

@media (min-width: 576px) {
    .topbar .dropdown {
        position: relative;
    }
    .topbar .dropdown .dropdown-menu {
        width: auto;
        right: 0;
    }
    .topbar .dropdown-list {
        width: 20rem !important;
    }
    .topbar .dropdown-list .dropdown-item .text-truncate {
        max-width: 13.375rem;
    }
}

/* ── Topbar Badge Counter ── */
.topbar .nav-item .nav-link .badge-counter,
.sidebar .nav-item .nav-link .badge-counter {
    position: absolute;
    transform: scale(0.7);
    transform-origin: top right;
    right: .25rem;
    margin-top: -.25rem;
}

.topbar .nav-item .nav-link .img-profile,
.sidebar .nav-item .nav-link .img-profile {
    height: 2rem;
    width: 2rem;
}

/* ── Sidebar ── */
.sidebar {
    width: 6.5rem;
    z-index: 100;
    position: sticky;
    top: 0;
    height: 100vh;
    max-height: 100vh;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
    flex-shrink: 0;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.25) rgba(0, 0, 0, 0.15);
}

/* Custom Webkit scrollbar for sidebar */
.sidebar::-webkit-scrollbar {
    width: 5px;
}

.sidebar::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.12);
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.25);
    border-radius: 4px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.45);
}

.sidebar .nav-item {
    position: relative;
}

.sidebar .nav-item:last-child {
    margin-bottom: 1rem;
}

.sidebar .nav-item .nav-link {
    text-align: center;
    padding: 0.75rem 1rem;
    width: 100%;
    color: rgba(255, 255, 255, 0.8);
    font-weight: 500;
}

.sidebar .nav-item .nav-link span {
    font-size: var(--hc-fs-2xs);
    display: block;
}

.sidebar .nav-item .nav-link i {
    color: rgba(255, 255, 255, 0.7);
    font-size: var(--hc-fs-sm);
}

.sidebar .nav-item .nav-link:hover {
    color: #fff;
}

.sidebar .nav-item .nav-link:hover i {
    color: #fff;
}

.sidebar .nav-item.active .nav-link {
    font-weight: 600;
    color: #fff;
    border-left: 3.5px solid var(--hb-teal-primary, #3CCFBF) !important;
    background: rgba(60, 207, 191, 0.16) !important;
}

.sidebar .nav-item.active .nav-link i {
    color: var(--hb-teal-primary, #3CCFBF) !important;
}

/* Mobile sidebar: full slide-out drawer navigation on handhelds (<768px) */
@media (max-width: 767.98px) {
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 17rem !important;
        max-width: 85vw;
        z-index: 1050;
        box-shadow: 4px 0 28px rgba(0, 0, 0, 0.6);
        overscroll-behavior-y: contain;
        padding-bottom: 2rem;
    }

    .sidebar.toggled,
    html.sidebar-toggled-early .sidebar {
        width: 0 !important;
        overflow: hidden !important;
        box-shadow: none !important;
    }

    .sidebar .sidebar-brand {
        height: 4.25rem;
        justify-content: flex-start;
        padding: 0.75rem 1.25rem;
    }

    .sidebar .sidebar-brand .sidebar-brand-icon svg {
        height: 2.25rem;
        width: auto;
    }

    .sidebar .sidebar-brand .sidebar-brand-text {
        display: inline !important;
        font-size: var(--hc-fs-md);
        font-weight: 800;
        letter-spacing: 0.5px;
        margin-left: 0.4rem;
    }

    .sidebar hr.sidebar-divider {
        margin: 0.4rem 1rem 0.65rem;
    }

    .sidebar .sidebar-heading {
        text-align: left !important;
        padding: 0.35rem 1.25rem !important;
        font-size: var(--hc-fs-xs) !important;
        font-weight: 700 !important;
        letter-spacing: 0.06em;
        color: rgba(255, 255, 255, 0.85) !important;
    }

    .sidebar .nav-item .nav-link {
        display: flex !important;
        align-items: center !important;
        text-align: left !important;
        padding: 0.75rem 1.25rem !important;
        min-height: 44px;
        width: 100%;
        color: rgba(255, 255, 255, 0.85);
    }

    .sidebar .nav-item .nav-link i {
        font-size: var(--hc-fs-md) !important;
        margin-right: 0.75rem !important;
        color: rgba(255, 255, 255, 0.7);
        width: 1.25rem;
        text-align: center;
        flex-shrink: 0;
    }

    .sidebar .nav-item .nav-link span {
        font-size: var(--hc-fs-sm) !important;
        display: inline !important;
        font-weight: 500;
        white-space: nowrap;
        color: #f8fafc;
    }

    .sidebar .nav-item.active .nav-link {
        color: #fff !important;
        border-left: 3.5px solid var(--hb-teal-primary, #3CCFBF) !important;
        background: rgba(60, 207, 191, 0.18) !important;
    }

    .sidebar .nav-item.active .nav-link i {
        color: var(--hb-teal-primary, #3CCFBF) !important;
    }

    .sidebar .nav-item.active .nav-link span {
        font-weight: 600;
        color: #fff !important;
    }

    .sidebar .sidebar-submenu-inner {
        margin-left: 0.75rem !important;
        margin-right: 0.75rem !important;
        padding: 0.65rem 0.65rem !important;
    }

    .sidebar .sidebar-class-link {
        min-height: 42px;
        padding: 0.55rem 0.75rem;
    }

    .sidebar .sidebar-join-btn {
        min-height: 42px;
        font-size: var(--hc-fs-sm);
    }
}

/* Mobile sidebar backdrop */
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 1045;
    transition: opacity 0.25s ease;
}

/* Show backdrop when sidebar is open on mobile */
@media (max-width: 767.98px) {
    body:not(.sidebar-toggled) .sidebar-backdrop {
        display: block;
    }
    body.sidebar-toggled .sidebar-backdrop,
    html.sidebar-toggled-early .sidebar-backdrop {
        display: none !important;
    }
}

/* Mobile Close Button */
.sidebar-close-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #ffffff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.15s ease;
    font-size: var(--hc-fs-base);
    padding: 0;
}

.sidebar-close-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: scale(1.05);
    color: #ffffff;
}

.sidebar-close-btn:active {
    transform: scale(0.95);
}

/* Sidebar Toggled (collapsed) */
.sidebar.toggled {
    width: 0 !important;
    overflow: hidden;
}

/* Sidebar Brand */
.sidebar .sidebar-brand {
    --hc-h: 1.75rem;
    height: 4.375rem;
    text-decoration: none;
    font-size: var(--hc-fs-base);
    font-weight: 800;
    padding: 1.5rem 1rem;
    text-align: center;
    z-index: 1;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar .sidebar-brand .sidebar-brand-icon {
    font-size: var(--hc-fs-4xl);
}

.sidebar .sidebar-brand .sidebar-brand-icon svg {
    height: 3rem;
    width: auto;
}

.sidebar .sidebar-brand .sidebar-brand-text {
    display: none;
}

/* Sidebar Divider & Heading */
.sidebar hr.sidebar-divider {
    margin: 0 1rem 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.15);
}

.sidebar .sidebar-heading {
    text-align: center;
    padding: 0 1rem;
    font-weight: 800;
    font-size: var(--hc-fs-2xs);
    /* 0.85 keeps ≥4.5:1 (WCAG AA) against the sidebar fill (#1F2B6E) */
    color: rgba(255, 255, 255, 0.85);
    text-transform: uppercase;
}

/* ── Desktop Sidebar (768px+) ── */
@media (min-width: 768px) {
    .sidebar {
        width: 15rem !important;
    }

    .sidebar .nav-item .nav-link {
        display: flex;
        align-items: center;
        width: 100%;
        text-align: left;
        padding: 0.8rem 1.25rem;
        min-height: 40px;
    }

    .sidebar .nav-item .nav-link i {
        font-size: var(--hc-fs-base);
        margin-right: 0.65rem;
        width: 1.2rem;
        text-align: center;
        flex-shrink: 0;
    }

    .sidebar .nav-item .nav-link span {
        font-size: var(--hc-fs-sm);
        display: inline;
        font-weight: 500;
    }

    .sidebar .sidebar-brand {
        height: 4.375rem;
        justify-content: center;
        padding: 1.25rem 1rem;
    }

    .sidebar .sidebar-brand .sidebar-brand-text {
        display: inline;
        font-size: var(--hc-fs-md);
        font-weight: 800;
    }

    .sidebar .sidebar-heading {
        text-align: left;
        padding: 0.35rem 1.25rem;
        font-size: var(--hc-fs-2xs);
        font-weight: 700;
        letter-spacing: 0.05em;
    }

    /* Toggled (mini sidebar on desktop) */
    .sidebar.toggled {
        overflow-y: auto;
        overflow-x: hidden;
        width: 6.5rem !important;
    }

    .sidebar.toggled .nav-item:last-child {
        margin-bottom: 1rem;
    }

    .sidebar.toggled .nav-item .nav-link {
        text-align: center;
        display: block;
        padding: 0.75rem 0.5rem;
        min-height: unset;
    }

    .sidebar.toggled .nav-item .nav-link span {
        font-size: var(--hc-fs-2xs);
        display: block;
    }

    /* Count badges stay compact pills on the rail instead of stretching full width */
    .sidebar.toggled .nav-item .nav-link .badge {
        display: inline-block;
        margin: 0.2rem 0 0 !important;
    }

    .sidebar.toggled .nav-item .nav-link i {
        margin-right: 0;
        font-size: var(--hc-fs-base);
        width: auto;
    }

    .sidebar.toggled .sidebar-brand .sidebar-brand-text {
        display: none;
    }

    .sidebar.toggled .sidebar-heading {
        text-align: center;
        font-size: var(--hc-fs-2xs);
        padding: 0 0.5rem;
    }

    .sidebar.toggled .collapse,
    .sidebar.toggled .collapsing {
        display: none !important;
    }

    /* Collapsed mode: class list opens as a flyout beside the rail instead of expanding the sidebar.
       Positioned fixed (top set by JS) so the rail's overflow doesn't clip it. */
    .sidebar.toggled .nav-item.sidebar-flyout-open > .collapse {
        display: block !important;
        position: fixed;
        left: 6.5rem;
        width: 17rem;
        max-height: calc(100vh - var(--sidebar-flyout-top, 0px) - 1rem);
        overflow-y: auto;
        z-index: 1040;
        text-align: left;
    }

    .sidebar.toggled .nav-item.sidebar-flyout-open > .collapse .sidebar-submenu-inner {
        margin: 0 !important;
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
    }

    /* The flyout replaces the hover label while it's open */
    .sidebar.toggled .nav-item.sidebar-flyout-open > .nav-link[data-tooltip]::after,
    .sidebar.toggled .nav-item.sidebar-flyout-open > .nav-link[data-tooltip]::before {
        display: none;
    }

    /* Collapsed mode desktop tooltips */
    .sidebar.toggled .nav-item .nav-link[data-tooltip] {
        position: relative;
    }
    .sidebar.toggled .nav-item .nav-link[data-tooltip]:hover::after,
    .sidebar.toggled .nav-item .nav-link[data-tooltip]:focus-visible::after {
        content: attr(data-tooltip);
        position: absolute;
        left: 100%;
        top: 50%;
        transform: translateY(-50%);
        background-color: #0f172a;
        color: #f8fafc;
        padding: 0.35rem 0.65rem;
        border-radius: 0.375rem;
        font-size: var(--hc-fs-xs);
        font-weight: 500;
        white-space: nowrap;
        z-index: 1035;
        pointer-events: none;
        box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
        border: 1px solid rgba(255, 255, 255, 0.15);
        margin-left: 0.6rem;
    }
    .sidebar.toggled .nav-item .nav-link[data-tooltip]:hover::before,
    .sidebar.toggled .nav-item .nav-link[data-tooltip]:focus-visible::before {
        content: '';
        position: absolute;
        left: 100%;
        top: 50%;
        transform: translateY(-50%);
        border-width: 5px;
        border-style: solid;
        border-color: transparent #0f172a transparent transparent;
        z-index: 1035;
        pointer-events: none;
        margin-left: 0.1rem;
    }
}

/* ── Section Switcher (teacher & student) ──
   The mobile drawer and mini rail style every `.nav-link span` with !important, so the switcher's own
   text rules use !important at higher specificity to keep their layout. */
.sidebar .nav-item .nav-link.sidebar-switcher {
    background: transparent;
    border: 0;
    cursor: pointer;
}

.sidebar .nav-item .nav-link.sidebar-switcher:focus-visible {
    outline: 2px solid #3CCFBF;
    outline-offset: 2px;
}

.sidebar .nav-item .nav-link .sidebar-switcher-text {
    display: flex !important;
    flex-direction: column;
    flex: 1 1 auto;
    min-width: 0;
    line-height: 1.25;
}

.sidebar .nav-item .nav-link .sidebar-switcher-caption {
    font-size: var(--hc-fs-2xs) !important;
    font-weight: 700 !important;
    letter-spacing: 0.01em;
    color: rgba(255, 255, 255, 0.85) !important;
}

.sidebar .nav-item .nav-link .sidebar-switcher-name {
    font-size: var(--hc-fs-sm) !important;
    font-weight: 700 !important;
    color: #fff !important;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar .sidebar-switcher .sidebar-count-badge,
.sidebar .sidebar-switcher-chevron {
    margin-left: 0.5rem;
    flex-shrink: 0;
}

.sidebar .sidebar-switcher-chevron {
    font-size: var(--hc-fs-xs);
    opacity: 0.8;
}

/* Expanded sidebar (desktop and open mobile drawer): a boxed control naming the current class */
.sidebar:not(.toggled) .nav-item .nav-link.sidebar-switcher {
    margin: 0 0.75rem 0.25rem;
    width: calc(100% - 1.5rem) !important;
    padding: 0.55rem 0.75rem !important;
    border-radius: 0.5rem;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.16);
}

.sidebar:not(.toggled) .nav-item .nav-link.sidebar-switcher:hover,
.sidebar:not(.toggled) .nav-item .nav-link.sidebar-switcher[aria-expanded="true"] {
    background: rgba(255, 255, 255, 0.14);
}

/* The current class's own links sit indented under the switcher */
.sidebar:not(.toggled) .nav-item .nav-link.sidebar-section-link {
    padding-left: 2rem !important;
}

/* Mini rail: icon plus a one-line class name, like the other rail items */
@media (min-width: 768px) {
    .sidebar.toggled .nav-item .nav-link .sidebar-switcher-caption,
    .sidebar.toggled .nav-item .nav-link .sidebar-switcher-chevron,
    .sidebar.toggled .nav-item .nav-link.sidebar-switcher .sidebar-count-badge {
        display: none !important;
    }

    .sidebar.toggled .nav-item .nav-link .sidebar-switcher-text {
        display: block !important;
    }

    .sidebar.toggled .nav-item .nav-link .sidebar-switcher-name {
        display: block !important;
        font-size: var(--hc-fs-2xs) !important;
        font-weight: 500 !important;
    }
}

/* ── Sidebar Submenu & Section Cards ── */
.sidebar .nav-item .nav-link[data-bs-toggle="collapse"] {
    position: relative;
}

/* Student "due soon" marker: on class cards, and on the My Classes icon so it shows in the mini sidebar */
.sidebar-due-dot {
    display: inline-block;
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
    background: #fbbf24;
    box-shadow: 0 0 0 2px rgba(251, 191, 36, 0.3);
    flex-shrink: 0;
}

.sidebar-warn-dot {
    background: #f87171;
    box-shadow: 0 0 0 2px rgba(248, 113, 113, 0.3);
}

.sidebar-due-dot-icon {
    position: absolute;
    top: -0.1rem;
    right: -0.3rem;
}

/* Per-class "to grade" count on the teacher's class cards */
.sidebar-class-pending {
    font-size: var(--hc-fs-2xs);
    font-weight: 700;
    padding: 0.2em 0.5em;
    flex-shrink: 0;
}

.sidebar-count-badge {
    background: rgba(60, 207, 191, 0.22);
    color: #3CCFBF !important;
    font-size: var(--hc-fs-2xs);
    font-weight: 700;
    padding: 0.2em 0.55em;
    border: 1px solid rgba(60, 207, 191, 0.35);
}

.sidebar-submenu-inner {
    background: #0f172a;
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}

[data-bs-theme="dark"] .sidebar-submenu-inner {
    background: #0b1120;
    border-color: rgba(255, 255, 255, 0.08);
}

.sidebar-submenu-header {
    font-size: var(--hc-fs-xs);
    font-weight: 700;
    color: #94a3b8;
    letter-spacing: 0.01em;
    padding: 0.35rem 0.4rem 0.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    margin-bottom: 0.5rem;
}

.sidebar-badge-muted {
    background: rgba(255, 255, 255, 0.14);
    color: #f1f5f9;
    font-size: var(--hc-fs-2xs);
    font-weight: 600;
    padding: 0.2em 0.55em;
}

.sidebar-submenu-list {
    max-height: 260px;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    padding-right: 2px;
    contain: content;
}

.sidebar-class-card {
    transition: background-color 0.12s ease, border-color 0.12s ease;
    border: 1px solid transparent;
    content-visibility: auto;
    contain-intrinsic-size: 0 38px;
}

.sidebar-class-card:hover {
    background-color: rgba(255, 255, 255, 0.08);
}

.sidebar-class-card.active {
    background-color: rgba(60, 207, 191, 0.16);
    border-left: 3.5px solid var(--hb-teal-primary, #3CCFBF);
    border-top: 1px solid rgba(60, 207, 191, 0.25);
    border-right: 1px solid rgba(60, 207, 191, 0.25);
    border-bottom: 1px solid rgba(60, 207, 191, 0.25);
}

.sidebar-class-link {
    color: #e2e8f0;
    font-size: var(--hc-fs-sm);
    font-weight: 500;
    min-height: 38px;
    padding: 0.45rem 0.65rem;
    transition: color 0.12s ease;
    min-width: 0; /* let long class names truncate instead of pushing the copy-code button out */
}

.sidebar-token-copy-btn {
    flex-shrink: 0;
}

.sidebar-class-icon {
    font-size: var(--hc-fs-base);
    color: #94a3b8;
    flex-shrink: 0;
    transition: color 0.12s ease;
}

.sidebar-class-link.active-link .sidebar-class-icon {
    color: var(--hb-teal-primary, #3CCFBF);
}

.sidebar-class-name {
    font-weight: 600;
    color: #f8fafc;
    letter-spacing: -0.01em;
}

.sidebar-class-link:hover,
.sidebar-class-link.active-link {
    color: #ffffff !important;
}

.active-dot {
    width: 7px;
    height: 7px;
    background-color: var(--hb-teal-primary, #3CCFBF);
    border-radius: 50%;
    display: inline-block;
    box-shadow: 0 0 8px var(--hb-teal-primary, #3CCFBF);
    flex-shrink: 0;
}

.sidebar-empty-classes {
    background: rgba(255, 255, 255, 0.03);
    border: 1px dashed rgba(255, 255, 255, 0.12);
}

.sidebar-empty-classes i {
    font-size: var(--hc-fs-xl);
    color: var(--hb-teal-primary, #3CCFBF);
    opacity: 0.7;
}

.sidebar-empty-title {
    font-size: var(--hc-fs-sm);
    font-weight: 600;
    color: #f1f5f9;
}

.sidebar-empty-desc {
    font-size: var(--hc-fs-xs);
    color: #94a3b8;
}

.sidebar-submenu-divider {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    margin: 0.5rem 0;
}

.sidebar-join-btn {
    background: rgba(60, 207, 191, 0.12);
    color: #3CCFBF !important;
    border: 1px dashed rgba(60, 207, 191, 0.5);
    font-size: var(--hc-fs-sm);
    font-weight: 600;
    padding: 0.45rem 0.75rem;
    min-height: 38px;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.sidebar-join-btn:hover {
    background: rgba(60, 207, 191, 0.24);
    border-color: rgba(60, 207, 191, 0.85);
    color: #ffffff !important;
    box-shadow: 0 2px 8px rgba(60, 207, 191, 0.25);
}

.sidebar-submenu-list::-webkit-scrollbar {
    width: 4px;
}

.sidebar-submenu-list::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-submenu-list::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, 0.25);
    border-radius: 4px;
}

.sidebar-submenu-list::-webkit-scrollbar-thumb:hover {
    background-color: rgba(255, 255, 255, 0.45);
}

.sidebar-token-copy-btn {
    color: rgba(255, 255, 255, 0.45);
    background: transparent;
    border: none;
    border-radius: 4px;
    padding: 0.2rem 0.35rem;
    font-size: var(--hc-fs-xs);
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: color 0.12s ease, background-color 0.12s ease;
    opacity: 0.55;
    flex-shrink: 0;
}

.sidebar-class-card:hover .sidebar-token-copy-btn,
.sidebar-token-copy-btn:focus-visible {
    opacity: 1;
}

.sidebar-token-copy-btn:hover {
    color: #3CCFBF !important;
    background-color: rgba(60, 207, 191, 0.2);
}

.sidebar-filter-wrapper {
    position: relative;
}

.sidebar-filter-wrapper .form-control {
    font-size: var(--hc-fs-xs);
    border-color: rgba(255, 255, 255, 0.15) !important;
    background-color: rgba(15, 23, 42, 0.6) !important;
    color: #f8fafc !important;
    border-radius: 0.375rem;
    height: 30px;
}

.sidebar-filter-wrapper .form-control:focus {
    border-color: var(--hb-teal-primary, #3CCFBF) !important;
    box-shadow: 0 0 0 0.15rem rgba(60, 207, 191, 0.25) !important;
}

.sidebar-filter-wrapper .form-control::placeholder {
    color: #94a3b8 !important;
    font-size: var(--hc-fs-xs);
}

.sidebar-filter-wrapper .input-group-text {
    border-color: rgba(255, 255, 255, 0.15) !important;
    background-color: rgba(15, 23, 42, 0.6) !important;
    color: #94a3b8;
    font-size: var(--hc-fs-xs);
    height: 30px;
}

.text-cyan {
    color: var(--hb-teal-primary, #3CCFBF) !important;
}

.command-palette-content {
    background-color: var(--bs-body-bg, #ffffff);
    backdrop-filter: blur(12px);
}
[data-bs-theme="dark"] .command-palette-content {
    background-color: #1a2230;
    border: 1px solid rgba(255, 255, 255, 0.12) !important;
}
.command-palette-content .cmd-item.active {
    background-color: rgba(60, 207, 191, 0.12);
    border-left: 3px solid var(--hb-teal-primary, #3CCFBF) !important;
}

/* ── Login Page Styles ── */
.bg-login-image {
    background-color: #f8f9fc;
    min-height: 100%;
}

form.user .form-control-user {
    font-size: var(--hc-fs-sm);
    border-radius: var(--hc-r-control);
    padding: 0.75rem 1.25rem;
}

form.user .form-select {
    font-size: var(--hc-fs-sm);
    border-radius: var(--hc-r-control);
    padding: 0.75rem 1.25rem;
}

form.user .btn-user {
    font-size: var(--hc-fs-sm);
    border-radius: var(--hc-r-control);
    padding: 0.75rem 1rem;
}

/* ── Sticky Footer ── */
footer.sticky-footer {
    padding: 2rem 0;
    flex-shrink: 0;
    background-color: var(--hc-canvas);
}

footer.sticky-footer .copyright {
    line-height: 1;
    font-size: var(--hc-fs-xs);
}

body.sidebar-toggled footer.sticky-footer {
    width: 100%;
}

/* ── Card Header Styles ── */
.card .card-header {
    background-color: var(--hc-surface-sunk);
    border-bottom: 1px solid var(--hc-line);
}

/* ── Dark Mode Overrides ── */
[data-bs-theme="dark"] #wrapper #content-wrapper {
    background-color: var(--hc-canvas);
}

[data-bs-theme="dark"] .sidebar {
    background-color: #0C1024 !important;
    background-image: none !important;
}

[data-bs-theme="dark"] .topbar {
    background-color: var(--hc-surface) !important;
    box-shadow: none !important;
}

[data-bs-theme="dark"] .topbar #sidebarToggleTop {
    color: #d1d3e2;
}

[data-bs-theme="dark"] .topbar #sidebarToggleTop:hover {
    background-color: #343a40;
}

[data-bs-theme="dark"] .topbar #sidebarToggleTop:active {
    background-color: #495057;
}

[data-bs-theme="dark"] .card .card-header {
    background-color: var(--hc-surface-sunk);
    border-bottom-color: var(--hc-line);
}

[data-bs-theme="dark"] footer.sticky-footer {
    background-color: var(--hc-canvas) !important;
    border-top-color: var(--hc-line);
}

[data-bs-theme="dark"] .bg-gradient-primary {
    background-color: #1F2B6E;
    background-image: none;
}


[data-bs-theme="dark"] .bg-login-image { background-color: #1a1d21; }

/* Alerts: see "Callouts" in main.css (tinted surface, hairline border, no stripe). */

/* ══════════════════════════════════════════════════════════════════════
   Notice cards — solid toasts (flash messages included)
   (round icon, bold title, message, close button, bottom progress strip)
   Markup: templates/_flash_messages.html and buildNoticeToast() in app.js
   ══════════════════════════════════════════════════════════════════════ */
/* Solid fills from the kit palette; each pair passes AA (white 5.0:1+, ink on gold 8:1). */
.hb-notice-success { --hb-notice-bg: #0B7D72; --hb-notice-fg: #fff; }
.hb-notice-danger  { --hb-notice-bg: #C6432F; --hb-notice-fg: #fff; }
.hb-notice-info    { --hb-notice-bg: #2E6BB8; --hb-notice-fg: #fff; }
.hb-notice-warning { --hb-notice-bg: #E3A21A; --hb-notice-fg: #1B2150; }

.alert.hb-notice,
.toast.hb-notice {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.9rem;
    padding: 0.9rem 2.75rem 1.2rem 1rem;
    overflow: hidden;
    border: 0 !important;
    border-radius: var(--hc-r-surface);
    background-color: var(--hb-notice-bg, #2E6BB8) !important;
    color: var(--hb-notice-fg, #fff) !important;
    box-shadow: var(--hc-shadow-overlay);
    font-size: var(--hc-fs-sm);
    line-height: 1.4;
}

/* Bootstrap hides .toast until .show/.showing; keep that while using flex. */
.toast.hb-notice:not(.show):not(.showing) {
    display: none;
}

/* Server-rendered flash toasts, until app.js moves them into #globalToastContainer. */
.hb-flash-stack {
    z-index: 2100;
}

.toast.hb-notice {
    width: 24rem;
    max-width: calc(100vw - 2rem);
}

.hb-notice-icon {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    background-color: var(--hb-notice-fg, #fff);
    color: var(--hb-notice-bg, #2E6BB8);
    font-size: var(--hc-fs-lg);
}

/* The -lg glyphs are hairline; thicken them to read at a glance. */
.hb-notice-icon .bi,
.hb-notice-close .bi {
    -webkit-text-stroke: 1px currentColor;
}

.hb-notice-content {
    flex: 1 1 auto;
    min-width: 0;
    overflow-wrap: anywhere;
}

.hb-notice-title {
    font-size: var(--hc-fs-base);
    font-weight: 700;
    line-height: 1.25;
}

.hb-notice a:not(.btn) {
    color: inherit;
    text-decoration: underline;
}

.hb-notice-action {
    margin-top: 0.5rem;
}

.hb-notice-close {
    position: absolute;
    top: 0.35rem;
    right: 0.35rem;
    padding: 0.35rem 0.5rem;
    border: 0;
    border-radius: 0.25rem;
    background: transparent;
    color: inherit;
    font-size: var(--hc-fs-xs);
    line-height: 1;
    opacity: 0.9;
}

.hb-notice-close:hover {
    opacity: 1;
    background-color: color-mix(in srgb, currentColor 18%, transparent);
}

.hb-notice-close:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 1px;
}

.hb-notice-progress {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 0.3rem;
    background-color: color-mix(in srgb, var(--hb-notice-fg, #fff) 45%, transparent);
    transform-origin: left center;
}

/* Toasts: the strip drains over the auto-hide delay and restarts with
   Bootstrap's timer when the pointer or focus leaves the toast. */
.toast.hb-notice.show .hb-notice-progress {
    animation: hb-notice-drain var(--hb-notice-duration, 5000ms) linear forwards;
}

.toast.hb-notice:hover .hb-notice-progress,
.toast.hb-notice:focus-within .hb-notice-progress {
    animation: none;
}

@keyframes hb-notice-drain {
    from { transform: scaleX(1); }
    to   { transform: scaleX(0); }
}

@media (prefers-reduced-motion: reduce) {
    .toast.hb-notice.show .hb-notice-progress {
        animation: none;
    }
}

/* ══════════════════════════════════════════════════════════════════════
   Editor Locked / Solved Message Cards (Dark Mode support)
   ══════════════════════════════════════════════════════════════════════ */
[data-bs-theme="dark"] .editor-locked-overlay,
[data-bs-theme="dark"] .past-deadline-overlay {
    background: rgba(0, 0, 0, 0.7) !important;
    backdrop-filter: blur(4px);
}

[data-bs-theme="dark"] .editor-locked-message {
    background-color: #2b3035 !important;
    color: #f8f9fa !important;
    border: 1px solid #495057 !important;
    box-shadow: 0 0.75rem 2rem rgba(0, 0, 0, 0.6) !important;
}

[data-bs-theme="dark"] .editor-locked-message h4,
[data-bs-theme="dark"] .editor-locked-message .h4 {
    color: #ffffff !important;
}

[data-bs-theme="dark"] .editor-locked-message p {
    color: #e2e8f0 !important;
}

[data-bs-theme="dark"] .editor-locked-message .text-muted {
    color: #adb5bd !important;
}

[data-bs-theme="dark"] .editor-locked-message strong {
    color: #ffffff !important;
}

[data-bs-theme="dark"] .editor-locked-message .text-success {
    color: #34d399 !important;
}

[data-bs-theme="dark"] .editor-locked-message .text-warning {
    color: #fbbf24 !important;
}

[data-bs-theme="dark"] .editor-locked-message .text-danger {
    color: #f87171 !important;
}

/* ── Output Panel & Custom Input (Light & Dark Theme Contrast) ── */
.output-panel {
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    background-color: #f8fafc !important;
    border: 1px solid #cbd5e1 !important;
    color: #0f172a !important;
}

.output-panel .text-muted {
    color: #64748b !important;
}

.output-panel .text-danger {
    color: #dc2626 !important;
}

.output-panel .text-warning {
    color: #b45309 !important;
}

.output-panel .text-success {
    color: #16a34a !important;
}

.output-panel .text-info {
    color: #0284c7 !important;
}

#customInput {
    background-color: #ffffff !important;
    border: 1px solid #cbd5e1 !important;
    color: #0f172a !important;
}

#customInput::placeholder {
    color: #94a3b8 !important;
}

[data-bs-theme="dark"] .editor-io-section {
    background-color: #212529 !important;
    border-color: #373b3e !important;
}

[data-bs-theme="dark"] .output-panel {
    background-color: #0f172a !important;
    border: 1px solid #334155 !important;
    color: #f8fafc !important;
}

[data-bs-theme="dark"] .output-panel .text-muted {
    color: #94a3b8 !important;
}

[data-bs-theme="dark"] .output-panel .text-danger {
    color: #f87171 !important;
}

[data-bs-theme="dark"] .output-panel .text-warning {
    color: #fbbf24 !important;
}

[data-bs-theme="dark"] .output-panel .text-success {
    color: #34d399 !important;
}

[data-bs-theme="dark"] .output-panel .text-info {
    color: #38bdf8 !important;
}

[data-bs-theme="dark"] #customInput {
    background-color: #0f172a !important;
    border: 1px solid #334155 !important;
    color: #f8fafc !important;
}

[data-bs-theme="dark"] #customInput::placeholder {
    color: #64748b !important;
}

/* ══════════════════════════════════════════════════════════════════════
   CodeMirror Theme Enhancements (Light & Dark Mode)
   ══════════════════════════════════════════════════════════════════════ */
.cm-s-default.CodeMirror {
    background-color: #ffffff !important;
    color: #0f172a !important;
    border: 1px solid #cbd5e1;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
}

.cm-s-default .CodeMirror-gutters {
    background-color: #f8fafc !important;
    border-right: 1px solid #e2e8f0 !important;
    color: #94a3b8 !important;
}

.cm-s-default .CodeMirror-linenumber {
    color: #64748b !important;
}

.cm-s-default .CodeMirror-cursor {
    border-left: 2px solid #0f172a !important;
}

.cm-s-default .CodeMirror-selected {
    background: #dbeafe !important;
}

.cm-s-default .CodeMirror-focused .CodeMirror-selected {
    background: #bfdbfe !important;
}

.cm-s-default .CodeMirror-line::selection,
.cm-s-default .CodeMirror-line > span::selection,
.cm-s-default .CodeMirror-line > span > span::selection {
    background: #bfdbfe !important;
}

.cm-s-default .CodeMirror-activeline-background {
    background: #f1f5f9 !important;
}

.cm-s-default span.cm-keyword {
    color: #7c3aed !important;
    font-weight: 600;
}

.cm-s-default span.cm-def {
    color: #0284c7 !important;
    font-weight: 600;
}

.cm-s-default span.cm-variable {
    color: #0f172a !important;
}

.cm-s-default span.cm-variable-2 {
    color: #0369a1 !important;
}

.cm-s-default span.cm-variable-3 {
    color: #0d9488 !important;
}

.cm-s-default span.cm-property {
    color: #0284c7 !important;
}

.cm-s-default span.cm-operator {
    color: #d97706 !important;
}

.cm-s-default span.cm-comment {
    color: #64748b !important;
    font-style: italic;
}

.cm-s-default span.cm-string,
.cm-s-default span.cm-string-2 {
    color: #16a34a !important;
}

.cm-s-default span.cm-number {
    color: #ea580c !important;
}

.cm-s-default span.cm-atom {
    color: #7c3aed !important;
}

.cm-s-default span.cm-builtin {
    color: #0284c7 !important;
}

.cm-s-default span.cm-tag {
    color: #dc2626 !important;
}

.cm-s-default span.cm-attribute {
    color: #0284c7 !important;
}

.cm-s-default .CodeMirror-matchingbracket {
    border-bottom: 2px solid #0284c7 !important;
    color: #0f172a !important;
    background-color: #e0f2fe !important;
}

.cm-s-dracula.CodeMirror {
    border: 1px solid #334155;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
}

/* ══════════════════════════════════════════════════════════════════════
   Mobile-First: Maximize screen real-estate on small devices
   ══════════════════════════════════════════════════════════════════════ */
:root {
    --safe-pad-left: max(12px, env(safe-area-inset-left, 0px));
    --safe-pad-right: max(12px, env(safe-area-inset-right, 0px));
    --safe-pad-bottom: max(12px, env(safe-area-inset-bottom, 0px));
}

@media (max-width: 767.98px) {
    /* Responsive container horizontal padding respecting safe-area cutouts */
    .container,
    .container-fluid,
    .container-sm,
    .container-md,
    .container-lg,
    .container-xl,
    .container-xxl {
        padding-left: var(--safe-pad-left) !important;
        padding-right: var(--safe-pad-right) !important;
    }

    /* Reduce topbar bottom margin */
    .topbar.mb-4 {
        margin-bottom: 0.5rem !important;
    }

    /* Tighten main content area */
    #content {
        padding-left: 0 !important;
        padding-right: 0 !important;
    }

    /* Reduce vertical padding on page-level wrappers (container py-4, py-3, etc.) */
    .container.py-4,
    .container-fluid.py-4 {
        padding-top: 0.5rem !important;
        padding-bottom: 0.5rem !important;
    }

    .container.py-3,
    .container-fluid.py-3 {
        padding-top: 0.35rem !important;
        padding-bottom: 0.35rem !important;
    }

    /* Tighter card bodies */
    .card-body {
        padding: 0.5rem !important;
    }

    .card-header {
        padding: 0.35rem 0.5rem !important;
    }

    /* Tighter card margins */
    .card.mb-4 {
        margin-bottom: 0.75rem !important;
    }

    /* Remove excess row gutters */
    .row {
        --bs-gutter-x: 0.5rem;
    }

    /* Tighter alert padding */
    .alert {
        padding: 0.5rem 0.65rem;
    }

    /* Reduce breadcrumb spacing */
    .breadcrumb {
        padding: 0.25rem 0;
        margin-bottom: 0.25rem;
        font-size: var(--hc-fs-xs);
    }

    /* Compact footer */
    footer.sticky-footer {
        padding: 0.5rem 0 !important;
    }

    /* Tighter global announcement wrappers */
    .global-announcements-wrapper {
        margin-bottom: 0.5rem !important;
    }

    /* Compact flash messages */
    .mb-3 > .alert {
        margin-bottom: 0.35rem !important;
    }

    /* Smaller page headings */
    h1.h3, .h3 {
        font-size: var(--hc-fs-md);
    }
}

/* ═══════════════════════════════════════════════════════════════════
   Classmate Presence & Online Indicator Styles
   ═══════════════════════════════════════════════════════════════════ */
.presence-pulse-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    background-color: #10b981;
    border-radius: 50%;
    position: relative;
    flex-shrink: 0;
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    animation: presence-pulse 2s infinite cubic-bezier(0.66, 0, 0, 1);
}

.presence-pulse-dot.offline {
    background-color: #94a3b8;
    box-shadow: none;
    animation: none;
}

.presence-pulse-dot.idle {
    background-color: #f59e0b;
    box-shadow: none;
    animation: none;
}

@keyframes presence-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    }
    70% {
        box-shadow: 0 0 0 7px rgba(16, 185, 129, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
    }
}

/* Classmate Avatar Stack */
.avatar-stack {
    display: inline-flex;
    align-items: center;
}

.avatar-stack .avatar-item {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 2px solid var(--bs-card-bg, #ffffff);
    margin-left: -8px;
    object-fit: cover;
    background: #e2e8f0;
    transition: transform 0.15s ease;
}

.avatar-stack .avatar-item:first-child {
    margin-left: 0;
}

.avatar-stack .avatar-item:hover {
    transform: translateY(-2px) scale(1.1);
    z-index: 2;
}

.avatar-stack .avatar-more {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: #475569;
    color: #ffffff;
    font-size: var(--hc-fs-2xs);
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--bs-card-bg, #ffffff);
    margin-left: -8px;
}

/* Classmates Presence Trigger Pill */
.classmates-presence-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.75rem;
    background: var(--bs-card-bg, #ffffff);
    border: 1px solid var(--bs-border-color, #e2e8f0);
    border-radius: 2rem;
    font-size: var(--hc-fs-sm);
    color: var(--bs-body-color, #1e293b);
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.classmates-presence-pill:hover {
    border-color: #10b981;
    background: rgba(16, 185, 129, 0.05);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(16, 185, 129, 0.1);
}

[data-bs-theme="dark"] .classmates-presence-pill {
    background: #1e293b;
    border-color: #334155;
    color: #f8fafc;
}

[data-bs-theme="dark"] .classmates-presence-pill:hover {
    border-color: #10b981;
    background: rgba(16, 185, 129, 0.12);
}

/* Classmate List Item */
.classmate-list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.65rem 0.85rem;
    border-radius: 0.5rem;
    transition: background 0.15s ease;
    border: 1px solid transparent;
}

.classmate-list-item:hover {
    background: var(--bs-tertiary-bg, #f8fafc);
    border-color: var(--bs-border-color-translucent, rgba(0,0,0,0.05));
}

.classmate-list-item .avatar-wrapper {
    position: relative;
    flex-shrink: 0;
}

.avatar-wrapper .status-badge,
.classmate-list-item .avatar-wrapper .status-badge {
    position: absolute;
    bottom: -1px;
    right: -1px;
    width: 10px;
    height: 10px;
    min-width: 10px;
    min-height: 10px;
    max-width: 10px;
    max-height: 10px;
    padding: 0 !important;
    margin: 0;
    border-radius: 50% !important;
    aspect-ratio: 1 / 1;
    border: 2px solid var(--bs-card-bg, #ffffff);
    box-sizing: border-box;
    display: inline-block;
    flex-shrink: 0;
}

.classmate-list-item .avatar-wrapper .status-badge.online,
.avatar-wrapper .status-badge.online {
    background: #10b981;
}

.classmate-list-item .avatar-wrapper .status-badge.idle,
.avatar-wrapper .status-badge.idle {
    background: #f59e0b;
}

.classmate-list-item .avatar-wrapper .status-badge.offline,
.avatar-wrapper .status-badge.offline {
    background: #94a3b8;
}

[data-bs-theme="dark"] .classmate-list-item .avatar-wrapper .status-badge,
[data-bs-theme="dark"] .avatar-wrapper .status-badge {
    border-color: #1e293b;
}

/* ── Profile Picture & Avatar Hover Expand Effect ── */
.img-profile,
.avatar-item,
.avatar-wrapper img,
.profile-pic-expand,
img[src*="/uploads/profile_pics/"],
img[src*="api.dicebear.com"],
img[src*="default_avatar.svg"],
img[onclick*="openPhotoModal"] {
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.25s ease, filter 0.25s ease;
    transform-origin: center center;
    will-change: transform;
}

.img-profile:hover,
.avatar-item:hover,
.avatar-wrapper img:hover,
.profile-pic-expand:hover,
img[src*="/uploads/profile_pics/"]:hover,
img[src*="api.dicebear.com"]:hover,
img[src*="default_avatar.svg"]:hover,
img[onclick*="openPhotoModal"]:hover {
    transform: scale(1.18);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2), 0 0 0 2px rgba(var(--bs-primary-rgb), 0.4);
    z-index: 10;
    position: relative;
    cursor: pointer;
}

/* Subtle adjustment for dark mode */
[data-bs-theme="dark"] .img-profile:hover,
[data-bs-theme="dark"] .avatar-item:hover,
[data-bs-theme="dark"] .avatar-wrapper img:hover,
[data-bs-theme="dark"] .profile-pic-expand:hover,
[data-bs-theme="dark"] img[src*="/uploads/profile_pics/"]:hover,
[data-bs-theme="dark"] img[src*="api.dicebear.com"]:hover,
[data-bs-theme="dark"] img[src*="default_avatar.svg"]:hover,
[data-bs-theme="dark"] img[onclick*="openPhotoModal"]:hover {
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45), 0 0 0 2px rgba(59, 130, 246, 0.6);
}

/* Exempt modal dialog preview images from hover enlargement */
#photoExpandModal img,
#photoExpandImage,
#removePhotoModal img,
.modal-body #photoExpandImage {
    transform: none !important;
    box-shadow: none !important;
    cursor: default !important;
}

/* ── View-transition names ──
   Cross-document transitions (@view-transition { navigation: auto }) are deliberately NOT
   enabled: cross-fading two mostly-white pages reads as a blink on every sidebar click.
   Navigation is an instant swap instead. The names below are kept because they create
   stacking contexts the layout relies on (see html.lesson-fullscreen #content). */
#accordionSidebar {
    view-transition-name: sidebar-nav;
}

nav.topbar {
    view-transition-name: topbar-nav;
}

#content {
    view-transition-name: main-content-view;
}

/* ── Real-Time Platform Maintenance Overlay ── */
#platformMaintenanceOverlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 105000 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 1.5rem !important;
    background: #1b2556 !important;
    backdrop-filter: blur(14px) !important;
    -webkit-backdrop-filter: blur(14px) !important;
    opacity: 0;
    transition: opacity 0.35s ease-in-out;
    box-sizing: border-box !important;
    pointer-events: auto !important;
}

#platformMaintenanceOverlay.active {
    opacity: 1;
}

.maintenance-overlay-card {
    max-width: 580px;
    width: 100%;
    border-radius: 1.25rem;
    background: #ffffff;
    position: relative;
    overflow: hidden;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.45) !important;
    border: 1px solid rgba(255, 255, 255, 0.2);
    transform: scale(0.96);
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

#platformMaintenanceOverlay.active .maintenance-overlay-card {
    transform: scale(1);
}

.maintenance-card-strip {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 6px;
    background: #ffc107;
}

.maintenance-gear-badge {
    width: 86px;
    height: 86px;
    margin: 0 auto;
    border-radius: 50%;
    background: rgba(255, 193, 7, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
}

.maintenance-gear-spin {
    font-size: var(--hc-fs-4xl);
    color: #d97706;
    display: inline-block;
    animation: ptyMaintSpin 8s linear infinite;
}

@keyframes ptyMaintSpin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes maintGlow {
    0%, 100% { text-shadow: 0 0 0 transparent; }
    50% { text-shadow: 0 0 10px rgba(255, 193, 7, 0.7); }
}

.maintenance-pulse-text {
    animation: maintGlow 1s ease-in-out;
}



