/* =========================================================================
   HabiCode Classroom — Global Styles & Design System
   ========================================================================= */

/* ── HabiCode Design Tokens ──
   Palette: design_assets/habicode-logo-kit/README.md.
   Fills take --bs-primary (white text stays readable in both themes);
   text and lines take --primary-color (a lighter teal in dark mode). */
:root,
[data-bs-theme="light"] {
    --primary-color: #2B3A8C;      /* Navy */
    --secondary-color: #1F2B6E;    /* Deep Navy */
    --tertiary-color: #F0604D;     /* Coral */
    --hb-indigo-dark: #1F2B6E;     /* Deep Navy Background */
    --hb-indigo-card: #1e293b;     /* Indigo Card Surface */
    --hb-teal-primary: #3CCFBF;    /* Teal on dark surfaces (sidebar, dark badges) */
    --hb-teal-hover: #0B7D72;      /* Teal Text */
    --hb-coral-accent: #F0604D;    /* Coral Highlight Accent */
    --hb-primary-hover: #1F2B6E;   /* Fill hover and active */

    /* Bootstrap's own primary, which links, badges, and utilities read */
    --bs-primary: #2B3A8C;
    --bs-primary-rgb: 43, 58, 140;
    --bs-primary-text-emphasis: #1F2B6E;
    --bs-primary-bg-subtle: #E6E9F6;
    --bs-primary-border-subtle: #B9C0E4;
    --bs-link-color: #0B7D72;
    --bs-link-color-rgb: 11, 125, 114;
    --bs-link-hover-color: #2B3A8C;
    --bs-link-hover-color-rgb: 43, 58, 140;
    --bs-focus-ring-color: rgba(43, 58, 140, 0.25);

    /* ── Foundation tokens ──
       One family, one ink, flat surfaces. Page stylesheets should read these
       instead of hard-coding sizes, greys, radii and shadows. */

    /* Ink: navy-based text, so copy sits in the brand instead of SB Admin grey */
    --hc-ink: #1B2150;             /* headings, body copy (15.6:1 on white) */
    --hc-ink-soft: #4B5173;        /* secondary copy, captions (8.1:1) */
    --hc-ink-faint: #6B7091;       /* placeholders, disabled, meta (5.0:1) */

    /* Surfaces */
    --hc-canvas: #F3F4F8;          /* page behind the cards */
    --hc-surface: #FFFFFF;         /* cards, panels, top bar */
    --hc-surface-sunk: #F7F8FB;    /* card headers, table heads, wells */
    --hc-line: #DCDFEA;            /* borders and dividers */
    --hc-line-strong: #C3C8DB;     /* input borders, hover outlines */

    /* Habi threads: decoration only, never text */
    --hc-thread-navy: #2B3A8C;
    --hc-thread-teal: #0F9A8D;
    --hc-thread-coral: #F0604D;
    --hc-thread-gold: #E3A21A;

    /* Type: Lexend is the brand face and was drawn for reading fluency */
    --hc-font-sans: Lexend, "Segoe UI", Roboto, Arial, sans-serif;
    --hc-font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    --hc-fs-2xs: 0.6875rem;        /* 11 sidebar captions, micro labels */
    --hc-fs-xs: 0.75rem;           /* 12 meta, counts */
    --hc-fs-sm: 0.875rem;          /* 14 secondary copy, table cells */
    --hc-fs-base: 1rem;            /* 16 body */
    --hc-fs-md: 1.125rem;          /* 18 card titles */
    --hc-fs-lg: 1.3125rem;         /* 21 section headings */
    --hc-fs-xl: 1.5rem;            /* 24 page titles */
    --hc-fs-2xl: 1.75rem;          /* 28 */
    --hc-fs-3xl: 2.25rem;          /* 36 public pages, big numbers */
    --hc-fs-4xl: 3rem;             /* 48 display numbers */

    /* Shape: controls < surfaces < overlays; chips are pills */
    --hc-r-control: 6px;
    --hc-r-surface: 10px;
    --hc-r-overlay: 14px;

    /* Elevation: surfaces are flat; only things that float get a shadow */
    --hc-shadow-overlay: 0 12px 32px -8px rgba(27, 33, 80, 0.28), 0 2px 6px rgba(27, 33, 80, 0.08);

    /* Progress as thread: light stitches over, dark stitches under, offset by half
       a repeat, so any bar colour reads as woven weft. Flat SVG, no gradients. */
    --hc-weave: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 2' preserveAspectRatio='none'%3E%3Crect width='6' height='1' fill='white' fill-opacity='.32'/%3E%3Crect x='6' y='1' width='6' height='1' fill='black' fill-opacity='.16'/%3E%3C/svg%3E");

    /* Bootstrap reads these. --bs-heading-color stays Bootstrap's 'inherit': body
       is already ink, and headings inside coloured headers must stay white. */
    --bs-body-font-family: var(--hc-font-sans);
    --bs-body-color: var(--hc-ink);
    --bs-body-color-rgb: 27, 33, 80;
    --bs-body-bg: var(--hc-surface);
    --bs-secondary-color: var(--hc-ink-soft);
    --bs-secondary-color-rgb: 75, 81, 115;
    --bs-tertiary-color: var(--hc-ink-faint);
    --bs-secondary-bg: #E9EBF3;
    --bs-tertiary-bg: var(--hc-surface-sunk);
    --bs-border-color: var(--hc-line);
    --bs-border-color-translucent: rgba(27, 33, 80, 0.12);
    --bs-border-radius: var(--hc-r-control);
    --bs-border-radius-sm: 4px;
    --bs-border-radius-lg: var(--hc-r-surface);
    --bs-border-radius-xl: var(--hc-r-overlay);
    --bs-box-shadow: var(--hc-shadow-overlay);
    --bs-box-shadow-sm: none;
    --bs-font-monospace: var(--hc-font-mono);

    /* Info: a woven indigo-blue between the navy and the teal, replacing
       Bootstrap cyan (#0dcaf0, 1.95:1 under white text). 5.4:1 under white,
       4.9:1 as text on the canvas. */
    --hc-info: #2E6BB8;
    --hc-info-hover: #255A9C;
    --hc-info-text: #2E6BB8;
    --bs-info: #2E6BB8;
    --bs-info-rgb: 46, 107, 184;
    --bs-info-text-emphasis: #1D4E89;
    --bs-info-bg-subtle: #E7EFFA;
    --bs-info-border-subtle: #B5CCEB;
}

/* ── Base type ── */
body {
    font-family: var(--hc-font-sans);
    color: var(--hc-ink);
    line-height: 1.55;
    font-feature-settings: "tnum" 0;
}

h1, .h1, h2, .h2, h3, .h3, h4, .h4, h5, .h5, h6, .h6 {
    font-family: var(--hc-font-sans);
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: -0.012em;
}

h1, .h1 { font-size: var(--hc-fs-3xl); }
h2, .h2 { font-size: var(--hc-fs-2xl); }
h3, .h3 { font-size: var(--hc-fs-xl); }
h4, .h4 { font-size: var(--hc-fs-lg); }
h5, .h5 { font-size: var(--hc-fs-md); }
h6, .h6 { font-size: var(--hc-fs-base); }

/* Signed-in pages are working screens: titles stay at page-title size */
#content h1, #content .h1 { font-size: var(--hc-fs-2xl); }
#content h2, #content .h2 { font-size: var(--hc-fs-xl); }

small, .small { font-size: var(--hc-fs-sm); }

/* Text-size utilities on the same scale; templates use these instead of
   style="font-size: ...". !important like Bootstrap's own .fs-* utilities. */
.hc-fs-2xs { font-size: var(--hc-fs-2xs) !important; }
.hc-fs-xs { font-size: var(--hc-fs-xs) !important; }
.hc-fs-sm { font-size: var(--hc-fs-sm) !important; }
.hc-fs-base { font-size: var(--hc-fs-base) !important; }
.hc-fs-md { font-size: var(--hc-fs-md) !important; }
.hc-fs-lg { font-size: var(--hc-fs-lg) !important; }
.hc-fs-xl { font-size: var(--hc-fs-xl) !important; }
.hc-fs-2xl { font-size: var(--hc-fs-2xl) !important; }
.hc-fs-3xl { font-size: var(--hc-fs-3xl) !important; }
.hc-fs-4xl { font-size: var(--hc-fs-4xl) !important; }

/* Small layout utilities that used to be repeated inline styles */
.hc-prewrap { white-space: pre-wrap; }
.hc-minw-0 { min-width: 0; }
.hc-lh-snug { line-height: 1.35; }
.hc-tracked { letter-spacing: 0.04em; }

/* Lexend runs heavier than Nunito did: every bold step drops one notch */
.fw-bold, .fw-bolder { font-weight: 600 !important; }
.fw-semibold { font-weight: 500 !important; }
b, strong { font-weight: 600; }

/* Light text on dark reads bolder than it is; the variable axis takes it back */
[data-bs-theme="dark"] body { font-weight: 350; }
code, kbd, pre, samp { font-family: var(--hc-font-mono); }

/* Overlays float; everything else lies flat */
.dropdown-menu {
    --bs-dropdown-border-color: var(--hc-line);
    --bs-dropdown-border-radius: var(--hc-r-surface);
    --bs-dropdown-box-shadow: var(--hc-shadow-overlay);
    box-shadow: var(--bs-dropdown-box-shadow);
}

.modal {
    --bs-modal-border-radius: var(--hc-r-overlay);
    --bs-modal-inner-border-radius: calc(var(--hc-r-overlay) - 1px);
    --bs-modal-box-shadow: var(--hc-shadow-overlay);
    --bs-modal-border-color: var(--hc-line);
}

.toast { --bs-toast-border-radius: var(--hc-r-surface); }

.btn { --bs-btn-font-weight: 500; }

/* Button tiers: one solid primary per header (the main action), everything
   else is the quiet secondary below. Colour is reserved for status. */
.btn-outline-secondary {
    --bs-btn-color: var(--hc-ink);
    --bs-btn-bg: var(--hc-surface);
    --bs-btn-border-color: var(--hc-line-strong);
    --bs-btn-hover-color: var(--hc-ink);
    --bs-btn-hover-bg: var(--bs-secondary-bg);
    --bs-btn-hover-border-color: var(--hc-line-strong);
    --bs-btn-active-color: var(--hc-ink);
    --bs-btn-active-bg: var(--bs-secondary-bg);
    --bs-btn-active-border-color: var(--hc-ink-faint);
    --bs-btn-disabled-color: var(--hc-ink-faint);
    --bs-btn-disabled-bg: transparent;
    --bs-btn-disabled-border-color: var(--hc-line);
    --bs-btn-focus-shadow-rgb: var(--bs-primary-rgb);
}
.btn-outline-secondary > .bi { color: var(--hc-ink-soft); }

/* Counts are data, not status: one neutral chip everywhere. */
.badge.hc-count {
    --bs-badge-color: var(--hc-ink-soft);
    background-color: var(--bs-secondary-bg);
    border: 1px solid var(--hc-line);
    border-radius: 999px;
    font-variant-numeric: tabular-nums;
}

/* Jump bars: the labels already say the type, so the icons stay neutral. */
.section-jump-bar .btn .bi { color: var(--hc-ink-soft) !important; }

.badge { --bs-badge-font-weight: 600; letter-spacing: 0.01em; }

.form-control,
.form-select { border-color: var(--hc-line-strong); }

/* ── Callouts ──
   Bootstrap 5.3's own alert variables (tinted surface, text emphasis, subtle
   border) on our tokens. A full hairline border, never a coloured left stripe:
   edge colour is reserved for "you are here" markers in navigation. */
.alert {
    --bs-alert-border-radius: var(--hc-r-surface);
    --bs-alert-padding-y: 0.75rem;
    --bs-alert-padding-x: 1rem;
    border: 1px solid var(--bs-alert-border-color);
    box-shadow: none;
    font-size: var(--hc-fs-sm);
    line-height: 1.5;
}
.alert.shadow, .alert.shadow-sm { box-shadow: none !important; }
/* Neutral callouts sit on the sunk surface */
.alert-secondary, .alert-light {
    --bs-alert-color: var(--hc-ink);
    --bs-alert-bg: var(--hc-surface-sunk);
    --bs-alert-border-color: var(--hc-line);
}
/* Headings and links inside a callout take its colour */
.alert :is(h1, h2, h3, h4, h5, h6, .alert-heading) { color: inherit; }

.table {
    --bs-table-color: var(--hc-ink);
    --bs-table-border-color: var(--hc-line);
}
.table > thead th {
    color: var(--hc-ink-soft);
    font-weight: 600;
    font-size: var(--hc-fs-sm);
}

/* ── Selvedge: the woven edge under the top bar ──
   The one decorative move in the signed-in app. Two offset rows of thread
   in the kit colours read as weave; flat fills, no gradients. */
.topbar {
    border-bottom: 1px solid var(--hc-line);
}
.topbar::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: -1px;
    height: 4px;
    pointer-events: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='4' shape-rendering='crispEdges'%3E%3Cpath fill='%232B3A8C' d='M0 0h120v4H0z'/%3E%3Cpath fill='%230F9A8D' d='M8 0h32v2H8zM16 2h32v2H16z'/%3E%3Cpath fill='%23F0604D' d='M72 0h8v2h-8z'/%3E%3Cpath fill='%23E3A21A' d='M92 2h8v2h-8z'/%3E%3C/svg%3E");
    background-size: 120px 4px;
    background-repeat: repeat-x;
}

@media print {
    .topbar::after { display: none; }
}

/* ── Bootstrap Components on the Brand Palette ──
   Bootstrap compiles #0d6efd into these, so --bs-primary alone doesn't reach them. */
.btn-primary {
    --bs-btn-color: #fff;
    --bs-btn-bg: var(--bs-primary);
    --bs-btn-border-color: var(--bs-primary);
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: var(--hb-primary-hover);
    --bs-btn-hover-border-color: var(--hb-primary-hover);
    --bs-btn-active-color: #fff;
    --bs-btn-active-bg: var(--hb-primary-hover);
    --bs-btn-active-border-color: var(--hb-primary-hover);
    --bs-btn-disabled-color: #fff;
    --bs-btn-disabled-bg: var(--bs-primary);
    --bs-btn-disabled-border-color: var(--bs-primary);
    --bs-btn-focus-shadow-rgb: var(--bs-primary-rgb);
}

.btn-outline-primary {
    --bs-btn-color: var(--bs-primary);
    --bs-btn-border-color: var(--bs-primary);
    --bs-btn-hover-bg: var(--bs-primary);
    --bs-btn-hover-border-color: var(--bs-primary);
    --bs-btn-active-bg: var(--bs-primary);
    --bs-btn-active-border-color: var(--bs-primary);
    --bs-btn-disabled-color: var(--bs-primary);
    --bs-btn-disabled-border-color: var(--bs-primary);
    --bs-btn-focus-shadow-rgb: var(--bs-primary-rgb);
}

.nav-pills { --bs-nav-pills-link-active-bg: var(--bs-primary); }
.dropdown-menu { --bs-dropdown-link-active-bg: var(--bs-primary); }
.progress,
.progress-stacked { --bs-progress-bar-bg: var(--bs-primary); }

/* Progress bars are threads: the fill is woven, the track is the bare loom.
   Striped bars keep their stripes, which mean "working on it". */
.progress-bar:not(.progress-bar-striped),
.hc-thread-fill {
    background-image: var(--hc-weave);
    background-size: 12px 100%;
    background-repeat: repeat-x;
}
.progress { --bs-progress-bg: var(--bs-secondary-bg); }

.pagination {
    --bs-pagination-active-bg: var(--bs-primary);
    --bs-pagination-active-border-color: var(--bs-primary);
    --bs-pagination-focus-box-shadow: 0 0 0 0.25rem var(--bs-focus-ring-color);
}

.list-group {
    --bs-list-group-active-bg: var(--bs-primary);
    --bs-list-group-active-border-color: var(--bs-primary);
}

.accordion {
    --bs-accordion-btn-focus-border-color: var(--primary-color);
    --bs-accordion-btn-focus-box-shadow: 0 0 0 0.25rem var(--bs-focus-ring-color);
}

.form-control:focus,
.form-select:focus,
.form-check-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.25rem var(--bs-focus-ring-color);
}

.form-check-input:checked,
.form-check-input[type="checkbox"]:indeterminate {
    background-color: var(--bs-primary);
    border-color: var(--bs-primary);
}

.form-range::-webkit-slider-thumb { background-color: var(--bs-primary); }
.form-range::-moz-range-thumb { background-color: var(--bs-primary); }

/* ── HabiCode Language & Brand Badges ── */
.badge-habicode {
    background-color: var(--hb-indigo-dark);
    color: var(--hb-teal-primary);
    border: 1px solid var(--hb-teal-primary);
    font-weight: 600;
}

.badge-lang-python {
    background-color: #0369a1; /* #0284c7 was 4.09:1 with white text */
    color: #ffffff;
}

.badge-lang-cpp {
    background-color: #4f46e5;
    color: #ffffff;
}

.badge-lang-java {
    background-color: #ea580c;
    color: #ffffff;
}

.badge-lang-sql {
    background-color: #be185d;
    color: #ffffff;
}

.badge-lang-any {
    background-color: #0d9488;
    color: #ffffff;
}

/* ── Base Layout ── */
body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ── Skip-to-Content Link ── */
.skip-to-content {
    position: absolute;
    left: -9999px;
    top: 0;
    z-index: 100000;
    padding: 0.5rem 1rem;
    background: var(--bs-primary);
    color: #fff;
    text-decoration: none;
    border-radius: 0 0 0.375rem 0.375rem;
    font-weight: 600;
}
.skip-to-content:focus {
    left: 0;
}

/* ── Public Navbar Brand ── */
.navbar-brand {
    font-weight: 700;
    color: var(--primary-color) !important;
    align-items: center;
    gap: 0.5rem;
}

/* ── Cards ── flat: a line, not a cloud */
.card {
    --bs-card-border-color: var(--hc-line);
    --bs-card-border-radius: var(--hc-r-surface);
    --bs-card-inner-border-radius: calc(var(--hc-r-surface) - 1px);
    --bs-card-cap-bg: var(--hc-surface-sunk);
    --bs-card-bg: var(--hc-surface);
    border: 1px solid var(--hc-line);
    box-shadow: none;
    margin-bottom: 1.5rem;
}

/* .shadow / .shadow-sm on surfaces predate the flat system */
.card.shadow,
.card.shadow-sm,
.card.shadow-lg { box-shadow: none !important; }

/* Shadow utilities only take effect on things that float. Everything else
   (buttons, badges, list groups, panels) lies flat on its surface. */
:is(.shadow, .shadow-lg):not(.modal-content, .modal-dialog, .dropdown-menu, .toast, .popover,
    .offcanvas, .position-fixed, .position-absolute, .sticky-top, .fixed-top, .fixed-bottom, :focus-visible) {
    box-shadow: none !important;
}

/* Keyboard focus is an outline, so no shadow utility (shadow-sm is !important)
   can erase it. Two colours: visible on light, dark and coloured fills. */
.btn:focus-visible,
.nav-link:focus-visible,
.dropdown-item:focus-visible,
.list-group-item-action:focus-visible,
.page-link:focus-visible,
.panel-control-btn:focus-visible,
summary:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
    box-shadow: 0 0 0 4px var(--hc-surface) !important;
}

/* ── Status Badges ── */
.status-badge {
    display: inline-block;
    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;
    box-sizing: border-box;
    flex-shrink: 0;
}

/* ── Code Editor ── */
.code-editor {
    height: 400px;
    border: 1px solid #ddd;
    border-radius: 0.375rem;
}

.CodeMirror {
    height: 100%;
    font-size: 14px;
}

.CodeMirror-lines {
    padding-bottom: 10px !important;
}
.CodeMirror-scroll {
    padding-bottom: 10px;
}

/* ── Output Panel ── */
.output-panel {
    background-color: #1e1e1e;
    color: #d4d4d4;
    font-family: 'Consolas', 'Monaco', monospace;
    padding: 1rem;
    border-radius: 0.375rem;
    min-height: 150px;
    max-height: 300px;
    overflow-y: auto;
}

/* ── Test Case Cards: status shows in the card's badge and icon, not an edge ── */
.test-case-card.passed { border-color: var(--bs-success-border-subtle); }
.test-case-card.failed { border-color: var(--bs-danger-border-subtle); }

/* ── Enhanced Breadcrumb Styles ── */
.breadcrumb-wrapper {
    background: var(--hc-surface);
    border: 1px solid var(--hc-line);
    border-radius: var(--hc-r-surface);
    padding: 0.625rem 1rem;
    margin-bottom: 1.5rem;
}

.breadcrumb-wrapper .breadcrumb {
    margin-bottom: 0;
    background: transparent;
    padding: 0;
}

.breadcrumb-wrapper .breadcrumb-item {
    font-size: var(--hc-fs-sm);
}

.breadcrumb-wrapper .breadcrumb-item a {
    color: var(--bs-link-color);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
}

.breadcrumb-wrapper .breadcrumb-item a:hover {
    color: var(--bs-link-hover-color);
    text-decoration: underline;
}

.breadcrumb-wrapper .breadcrumb-item.active {
    color: #495057;
    font-weight: 600;
}

.breadcrumb-wrapper .breadcrumb-item + .breadcrumb-item::before {
    content: "/";
    color: #6c757d;
    font-weight: 400;
    padding-right: 0.5rem;
}

.breadcrumb-wrapper .breadcrumb-icon {
    margin-right: 0.35rem;
    opacity: 0.7;
}

/* ── Rich Text Content Styles ── */
.problem-description, .rich-text-content {
    line-height: 1.7;
}

/* ── Assessment Question Text (plain text + detected code snippets) ── */
.question-text {
    line-height: 1.7;
    overflow-wrap: anywhere;
}

.question-text .question-prose {
    white-space: pre-wrap;
}

.question-text .question-prose + .question-prose,
.question-text .question-code + .question-prose {
    margin-top: 0.75rem;
}

.question-text .question-code {
    margin: 0.75rem 0;
    padding: 0.75rem 1rem;
    background-color: #f6f8fa;
    border: 1px solid var(--bs-border-color);
    border: 1px solid var(--hc-line);
    border-radius: 0.375rem;
    font-size: 0.875rem;
    line-height: 1.5;
    overflow-x: auto;
    overflow-wrap: normal;
    white-space: pre;
    tab-size: 4;
}

.question-text .question-code:last-child {
    margin-bottom: 0;
}

.question-text .question-code code {
    padding: 0;
    background-color: transparent;
    color: inherit;
    font-size: inherit;
    white-space: inherit;
}

[data-bs-theme="dark"] .question-text .question-code {
    background-color: #2b3035;
}

/* ── Student Copy Guard ── */
.copy-guard-active [data-copy-protected="true"],
.copy-guard-active [data-copy-protected="true"] * {
    -webkit-user-select: none !important;
    user-select: none !important;
    -webkit-touch-callout: none;
    -webkit-user-drag: none;
}

.copy-guard-active [data-copy-protected="true"] input,
.copy-guard-active [data-copy-protected="true"] textarea,
.copy-guard-active [data-copy-protected="true"] [contenteditable=""],
.copy-guard-active [data-copy-protected="true"] [contenteditable="true"],
.copy-guard-active [data-copy-protected="true"] [contenteditable="plaintext-only"] {
    -webkit-user-select: text !important;
    user-select: text !important;
}

/* ── DevTools Security Lock Overlay ── */
.habicode-devtools-lock-overlay {
    position: fixed !important;
    inset: 0 !important;
    z-index: 2147483647 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 1.5rem !important;
    background: rgba(15, 23, 42, 0.96) !important;
    backdrop-filter: blur(16px) !important;
    -webkit-backdrop-filter: blur(16px) !important;
    animation: habicode-lock-fadein 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes habicode-lock-fadein {
    from { opacity: 0; transform: scale(0.98); }
    to { opacity: 1; transform: scale(1); }
}

.habicode-lock-card {
    background: #1e293b;
    border: 1px solid rgba(239, 68, 68, 0.4);
    border-radius: 1rem;
    padding: 2.25rem 2rem;
    max-width: 32rem;
    width: 100%;
    text-align: center;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7), 0 0 30px rgba(239, 68, 68, 0.2);
    color: #f8fafc;
}

.habicode-lock-icon-wrapper {
    width: 64px;
    height: 64px;
    margin: 0 auto 1.25rem auto;
    background: rgba(239, 68, 68, 0.15);
    border: 2px solid #ef4444;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ef4444;
    font-size: var(--hc-fs-3xl);
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.4);
    animation: habicode-lock-pulse 2s infinite ease-in-out;
}

@keyframes habicode-lock-pulse {
    0%, 100% { transform: scale(1); box-shadow: 0 0 20px rgba(239, 68, 68, 0.4); }
    50% { transform: scale(1.06); box-shadow: 0 0 30px rgba(239, 68, 68, 0.7); }
}

.habicode-lock-title {
    font-size: var(--hc-fs-xl);
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: #ffffff;
    letter-spacing: -0.02em;
}

.habicode-lock-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    font-size: var(--hc-fs-xs);
    font-weight: 700;
    letter-spacing: 0.01em;
    background: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.4);
    border-radius: 9999px;
    margin-bottom: 1rem;
}

.habicode-lock-desc {
    font-size: var(--hc-fs-sm);
    color: #94a3b8;
    line-height: 1.6;
    margin-bottom: 1.25rem;
}

.habicode-lock-alert {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.25);
    border-radius: 0.5rem;
    padding: 0.75rem 1rem;
    font-size: var(--hc-fs-sm);
    color: #fca5a5;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.habicode-lock-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.habicode-lock-btn {
    padding: 0.75rem 1.25rem;
    font-weight: 600;
    border-radius: 0.5rem;
    font-size: var(--hc-fs-base);
}

.habicode-lock-btn-secondary {
    padding: 0.6rem 1.25rem;
    font-weight: 500;
    border-radius: 0.5rem;
    font-size: var(--hc-fs-sm);
    color: #94a3b8;
    border-color: #334155;
}
.habicode-lock-btn-secondary:hover {
    color: #ffffff;
    background: #334155;
}

.problem-description h1,
.problem-description h2,
.problem-description h3,
.problem-description h4,
.problem-description h5,
.problem-description h6 {
    margin-top: 1rem;
    margin-bottom: 0.5rem;
}

.editorial-text {
    line-height: 1.6;
}

.editorial-text img {
    max-width: 100%;
    height: auto;
}

/* The editorial can sit on a light card, so code blocks need their own edge. */
.editorial-text pre:not(.mermaid) {
    background-color: var(--bs-body-bg);
    border: 1px solid var(--bs-border-color);
}

.card-body .editorial-text pre code,
.modal-body .editorial-text pre code {
    color: var(--bs-body-color);
}

.problem-description pre {
    background-color: #f8f9fa;
    padding: 1rem;
    border-radius: 0.375rem;
    overflow-x: auto;
}

.problem-description code {
    background-color: #f8f9fa;
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
    font-size: 0.875em;
}

.problem-description pre code {
    background-color: transparent;
    padding: 0;
}

.lesson-content pre:not([class*="CodeMirror"]):not(.output-content),
.problem-description .lesson-content pre:not([class*="CodeMirror"]):not(.output-content),
.lesson-content.problem-description pre:not([class*="CodeMirror"]):not(.output-content),
#livePreviewContent pre:not([class*="CodeMirror"]):not(.output-content),
.code-playground-preview pre {
    background-color: #282a36 !important;
    background: #282a36 !important;
    color: #f8f8f2 !important;
    padding: 1rem !important;
    border-radius: 0.5rem !important;
    overflow-x: auto !important;
    font-family: Consolas, Monaco, 'Courier New', monospace !important;
}

.lesson-content pre:not([class*="CodeMirror"]):not(.output-content) code,
.problem-description .lesson-content pre:not([class*="CodeMirror"]):not(.output-content) code,
.lesson-content.problem-description pre:not([class*="CodeMirror"]):not(.output-content) code,
#livePreviewContent pre:not([class*="CodeMirror"]):not(.output-content) code,
.code-playground-preview pre code,
.code-playground-preview code {
    background-color: transparent !important;
    background: transparent !important;
    color: #f8f8f2 !important;
    padding: 0 !important;
    border: none !important;
    font-family: inherit !important;
    font-size: inherit !important;
}

/* Ensure CodeMirror editor lines and IDE elements are NEVER affected by pre rules */
.code-playground .CodeMirror pre.CodeMirror-line,
.code-playground .CodeMirror pre.CodeMirror-line-like,
.CodeMirror pre.CodeMirror-line,
.CodeMirror pre.CodeMirror-line-like {
    background-color: transparent !important;
    background: transparent !important;
    padding: 0 4px !important;
    border-radius: 0 !important;
    border: none !important;
    overflow-x: visible !important;
    font-family: inherit !important;
    font-size: inherit !important;
    line-height: inherit !important;
    color: inherit !important;
    box-shadow: none !important;
    margin: 0 !important;
}

.lesson-content :not(pre) > code {
    background-color: #f1f3f5;
    color: #d63384;
    padding: 0.15rem 0.4rem;
    border-radius: 0.25rem;
    font-size: 0.9em;
}

[data-bs-theme="dark"] .lesson-content :not(pre) > code {
    background-color: var(--bs-tertiary-bg);
    color: #e685b5;
}

.problem-description table {
    width: 100%;
    margin-bottom: 1rem;
    border-collapse: collapse;
}

.problem-description table th,
.problem-description table td {
    padding: 0.5rem;
    border: 1px solid #dee2e6;
}

.problem-description table th {
    background-color: #f8f9fa;
}

.problem-description img {
    max-width: 100%;
    height: auto;
}

.problem-description blockquote {
    border-left: 3px solid var(--hc-line-strong);
    padding-left: 1rem;
    margin-left: 0;
    color: #6c757d;
}

/* ── Theme Toggle Button ── */
.theme-toggle-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.375rem;
    border-radius: 0.375rem;
    color: #858796;
    transition: color 0.2s;
}

.theme-toggle-btn:hover {
    color: var(--primary-color);
}

[data-bs-theme="light"] .theme-toggle-btn .bi-sun-fill { display: none; }
[data-bs-theme="dark"] .theme-toggle-btn .bi-moon-fill { display: none; }

/* ── Sidebar Badge ── */
.sidebar .nav-item .nav-link .badge {
    font-size: var(--hc-fs-2xs);
    vertical-align: middle;
}

/* ===== Mobile Responsive Enhancements ===== */

@media (max-width: 767.98px) {
    /* Headings scale down */
    h2 { font-size: var(--hc-fs-lg); }
    h3 { font-size: var(--hc-fs-md); }
    h4 { font-size: var(--hc-fs-md); }
    h5 { font-size: var(--hc-fs-base); }

    /* Button groups wrap instead of overflow */
    .btn-group {
        flex-wrap: wrap;
        gap: 0.25rem;
    }

    .btn-group > .btn,
    .btn-group > form > .btn {
        border-radius: 0.375rem !important;
    }

    /* d-flex rows wrap on mobile */
    .d-flex.justify-content-between {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    /* List rows that end in an action group (e.g. Active Students) get a "⋯"
       toggle from app.js: the wrap above used to drop the buttons under long
       names, so rows in one list disagreed. Now every row keeps its text full
       width with the toggle on the right; the actions open as a row below. */
    .list-group-item.has-list-actions {
        flex-wrap: wrap !important;
        column-gap: 0.5rem;
    }
    .list-group-item.has-list-actions > :first-child {
        flex: 1 1 0;
        min-width: 0;
    }
    .list-group-item.has-list-actions > .list-actions-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
        width: 2.25rem;
        height: 2.25rem;
        padding: 0;
    }
    .list-group-item.has-list-actions.list-actions-open > .list-actions-toggle {
        background: var(--bs-secondary-bg);
    }
    .list-group-item.has-list-actions:not(.list-actions-open) > .list-actions-group {
        display: none !important;
    }
    .list-group-item.has-list-actions.list-actions-open > .list-actions-group {
        display: flex;
        width: 100%;
        justify-content: flex-end;
        flex-wrap: nowrap;
        gap: 0.35rem;
        padding-top: 0.4rem;
    }
    .list-group-item.has-list-actions > .list-actions-group .btn {
        flex: 0 0 auto;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 2.5rem;
        height: 2.5rem;
        padding: 0;
    }

    /* Cards get less padding on mobile */
    .card-body {
        padding: 0.75rem;
    }

    .card-header {
        padding: 0.5rem 0.75rem;
    }

    /* Footer smaller text */
    footer small {
        font-size: var(--hc-fs-xs);
    }

    /* Breadcrumb compact styling */
    .breadcrumb-wrapper {
        padding: 0.5rem 0.75rem;
        margin-bottom: 1rem;
    }

    .breadcrumb-wrapper .breadcrumb-item {
        font-size: var(--hc-fs-xs);
    }

    /* Tables always scrollable on mobile */
    .table {
        font-size: var(--hc-fs-sm);
    }

    /* Input groups don't overflow */
    .input-group {
        max-width: 100% !important;
    }

    /* Selects with inline min-width don't overflow */
    select.form-select {
        max-width: 100% !important;
    }

    /* Stack form rows on mobile */
    .row > [class*="col-md-"],
    .row > [class*="col-lg-"] {
        margin-bottom: 0.5rem;
    }

    /* Make code blocks scrollable */
    pre, .output-panel {
        font-size: 12px;
        max-width: 100vw;
    }

    /* Code editor: auto height on mobile */
    .code-editor {
        height: auto;
        min-height: 200px;
        max-height: 350px;
    }

    .CodeMirror {
        border-radius: 0.25rem;
    }

    /* Navbar brand smaller */
    .navbar-brand {
        font-size: var(--hc-fs-base);
    }

    /* Badge sizing */
    .badge {
        font-size: var(--hc-fs-2xs);
    }

    .form-text {
        font-size: var(--hc-fs-xs);
    }
}

/* The "⋯" list-row toggle (added by app.js) is only for phones. */
@media (min-width: 768px) {
    .list-actions-toggle { display: none !important; }
}

/* Tablet tweaks */
@media (min-width: 768px) and (max-width: 991.98px) {
    h2 { font-size: var(--hc-fs-xl); }

    .btn-group {
        flex-wrap: wrap;
        gap: 0.25rem;
    }
}

/* Utility: force wrap on mobile */
.mobile-stack {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

/* ── Dark Mode Overrides ── */
[data-bs-theme="dark"] .breadcrumb-wrapper .breadcrumb-item.active {
    color: #d1d3e2;
}

[data-bs-theme="dark"] .output-panel {
    background-color: #0d1117;
}

[data-bs-theme="dark"] .problem-description pre {
    background-color: #2b3035;
}

[data-bs-theme="dark"] .problem-description code {
    background-color: #2b3035;
}

@media (max-width: 767.98px) {
    .mobile-stack {
        flex-direction: column;
        align-items: stretch;
    }

    .mobile-stack > * {
        width: 100%;
    }
}

/* Make all table containers responsive by default */
.table-responsive {
    -webkit-overflow-scrolling: touch;
}

/* ===== What's New Modal Styles ===== */
.whats-new-modal .modal-content {
    box-shadow: 0 1rem 3rem rgba(0,0,0,0.25), 0 0 0 1px rgba(0,0,0,0.05);
    border: none;
}
.whats-new-modal #whatsNewVersionSelect {
    font-size: var(--hc-fs-xs);
    padding: 0.2rem 0.5rem;
    border-radius: 0.375rem;
    border-color: rgba(255,255,255,0.3);
    background-color: rgba(255,255,255,0.15);
    color: white;
}
.whats-new-modal #whatsNewVersionSelect option { color: #333; background: white; }
.whats-new-modal .modal-header {
    background: var(--bs-primary);
    color: white;
    border-bottom: none;
}
.whats-new-modal .modal-header .btn-close {
    filter: brightness(0) invert(1);
}
.whats-new-modal .modal-title {
    font-weight: 700;
}
.whats-new-release-card {
    border: none;
    border-radius: 0.75rem;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    cursor: pointer;
}
.whats-new-release-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 0.5rem 1rem rgba(0,0,0,0.1) !important;
}
.whats-new-release-card .card-body { padding: 0; }
.whats-new-release-card .card-collapse-trigger {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem;
}
.whats-new-release-card .card-collapse-trigger .collapse-chevron {
    transition: transform 0.2s ease;
    color: #adb5bd;
    flex-shrink: 0;
}
.whats-new-release-card:not(.collapsed) .card-collapse-trigger .collapse-chevron {
    transform: rotate(180deg);
}
.whats-new-release-card .card-collapse-body {
    padding: 0 0.75rem 0.75rem 0.75rem;
}
.whats-new-release-header {
    cursor: pointer;
    transition: background-color 0.15s ease;
}
.whats-new-release-header:hover {
    background-color: rgba(0,0,0,0.02);
}
.whats-new-release-header .collapse-chevron {
    transition: transform 0.2s ease;
    color: #adb5bd;
}
.whats-new-release-header:not(.collapsed) .collapse-chevron {
    transform: rotate(180deg);
}
.whats-new-feature-icon {
    width: 44px;
    height: 44px;
    border-radius: 0.625rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--hc-fs-lg);
    flex-shrink: 0;
}
.whats-new-feature-icon.icon-danger { background-color: #fde8e8; color: #dc3545; }
.whats-new-feature-icon.icon-primary { background-color: #e7f1ff; color: var(--primary-color, #2B3A8C); }
.whats-new-feature-icon.icon-success { background-color: #e6f9ee; color: #198754; }
.whats-new-feature-icon.icon-info { background-color: var(--bs-info-bg-subtle); color: var(--hc-info-text); }
.whats-new-feature-icon.icon-warning { background-color: #fff8e1; color: #ffc107; }
.whats-new-nav-btn {
    position: relative;
}
.whats-new-dot {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 8px;
    height: 8px;
    background-color: #dc3545;
    border-radius: 50%;
    border: 1.5px solid white;
}
.whats-new-scroll {
    max-height: 420px;
    overflow-y: auto;
}
@media (max-width: 767.98px) {
    .whats-new-scroll { max-height: 55vh; }
    .whats-new-feature-icon { width: 36px; height: 36px; font-size: var(--hc-fs-base); }
}

/* =========================================================================
   Dark Mode Overrides (Bootstrap 5.3 native via data-bs-theme="dark")
   ========================================================================= */

[data-bs-theme="dark"] {
    /* Override app-specific custom properties for dark mode */
    --primary-color: #3CCFBF;
    --secondary-color: #7FE3D8;
    --tertiary-color: #FF7A66;
    --hb-primary-hover: #096A61;

    --bs-primary: #0B7D72;
    --bs-primary-rgb: 11, 125, 114;
    --bs-primary-text-emphasis: #3CCFBF;
    --bs-primary-bg-subtle: #0B2F2C;
    --bs-primary-border-subtle: #0B7D72;
    --bs-link-color: #3CCFBF;
    --bs-link-color-rgb: 60, 207, 191;
    --bs-link-hover-color: #7FE3D8;
    --bs-link-hover-color-rgb: 127, 227, 216;
    --bs-focus-ring-color: rgba(60, 207, 191, 0.25);

    /* Foundation tokens on deep navy instead of Bootstrap's neutral greys */
    --hc-ink: #E7E9F4;
    --hc-ink-soft: #A9AFCE;
    --hc-ink-faint: #8C92B4;
    --hc-canvas: #10142B;
    --hc-surface: #181D3A;
    --hc-surface-sunk: #141833;
    --hc-line: #2C335E;
    --hc-line-strong: #4A548E;     /* also the secondary-button outline */
    --hc-thread-navy: #5566C8;
    --hc-thread-teal: #3CCFBF;
    --hc-thread-coral: #FF7A66;
    --hc-thread-gold: #F0B53A;
    --hc-shadow-overlay: 0 14px 36px -8px rgba(0, 0, 0, 0.6), 0 2px 6px rgba(0, 0, 0, 0.3);

    --bs-body-color: var(--hc-ink);
    --bs-body-color-rgb: 231, 233, 244;
    --bs-body-bg: var(--hc-surface);
    --bs-body-bg-rgb: 24, 29, 58;
    --bs-emphasis-color: #FFFFFF;
    --bs-secondary-color: var(--hc-ink-soft);
    --bs-secondary-color-rgb: 169, 175, 206;
    --bs-tertiary-color: var(--hc-ink-faint);
    --bs-secondary-bg: #222849;
    --bs-secondary-bg-rgb: 34, 40, 73;
    --bs-tertiary-bg: var(--hc-surface-sunk);
    --bs-tertiary-bg-rgb: 20, 24, 51;
    --bs-border-color: var(--hc-line);
    --bs-border-color-translucent: rgba(169, 175, 206, 0.16);

    --hc-info-text: #8DB8F0;       /* 8:1 on the dark surface */
    --bs-info-text-emphasis: #9CC2F2;
    --bs-info-bg-subtle: #16264A;
    --bs-info-border-subtle: #2E4F85;
}

/* ── Info blue on compiled Bootstrap components (they bake in Bootstrap's cyan) ── */
.btn-info {
    --bs-btn-color: #fff;
    --bs-btn-bg: var(--hc-info);
    --bs-btn-border-color: var(--hc-info);
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: var(--hc-info-hover);
    --bs-btn-hover-border-color: var(--hc-info-hover);
    --bs-btn-active-color: #fff;
    --bs-btn-active-bg: var(--hc-info-hover);
    --bs-btn-active-border-color: var(--hc-info-hover);
    --bs-btn-disabled-color: #fff;
    --bs-btn-disabled-bg: var(--hc-info);
    --bs-btn-disabled-border-color: var(--hc-info);
    --bs-btn-focus-shadow-rgb: var(--bs-info-rgb);
}
.btn-outline-info {
    --bs-btn-color: var(--hc-info-text);
    --bs-btn-border-color: var(--hc-info);
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: var(--hc-info);
    --bs-btn-hover-border-color: var(--hc-info);
    --bs-btn-active-color: #fff;
    --bs-btn-active-bg: var(--hc-info-hover);
    --bs-btn-active-border-color: var(--hc-info-hover);
    --bs-btn-disabled-color: var(--hc-info-text);
    --bs-btn-disabled-border-color: var(--hc-info);
    --bs-btn-focus-shadow-rgb: var(--bs-info-rgb);
}
.text-bg-info { color: #fff !important; background-color: RGBA(var(--bs-info-rgb), var(--bs-bg-opacity, 1)) !important; }
/* Old markup paired cyan with dark text; on the blue, text is white. */
.bg-info.text-dark, .bg-info.text-body, .badge.bg-info { color: #fff !important; --bs-badge-color: #fff; }
.text-info { color: var(--hc-info-text) !important; }
.link-info { color: var(--hc-info-text) !important; text-decoration-color: rgba(var(--bs-info-rgb), 0.5) !important; }
.table-info {
    --bs-table-color: var(--bs-info-text-emphasis);
    --bs-table-bg: var(--bs-info-bg-subtle);
    --bs-table-border-color: var(--bs-info-border-subtle);
    --bs-table-striped-bg: var(--bs-info-bg-subtle);
    --bs-table-hover-bg: var(--bs-info-border-subtle);
    color: var(--bs-table-color);
}

[data-bs-theme="dark"] .topbar::after {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='4' shape-rendering='crispEdges'%3E%3Cpath fill='%233A4AA8' d='M0 0h120v4H0z'/%3E%3Cpath fill='%233CCFBF' d='M8 0h32v2H8zM16 2h32v2H16z'/%3E%3Cpath fill='%23FF7A66' d='M72 0h8v2h-8z'/%3E%3Cpath fill='%23F0B53A' d='M92 2h8v2h-8z'/%3E%3C/svg%3E");
    background-size: 120px 4px;
}

/* --bs-primary is a fill here, too dark to read as text on dark surfaces */
[data-bs-theme="dark"] .text-primary { color: var(--primary-color) !important; }

/* ── Navbar Dark Mode ── */
[data-bs-theme="dark"] .navbar {
    background-color: var(--bs-body-bg) !important;
}

/* ── Hero Section Dark Mode ── */
[data-bs-theme="dark"] .hero-section::before {
    background: rgba(33, 37, 41, 0.88);
}

/* ── Sidebar Dark Mode ── */
[data-bs-theme="dark"] .sidebar {
    background-color: var(--bs-tertiary-bg);
    border-right-color: var(--bs-border-color);
}

[data-bs-theme="dark"] .sidebar .nav-link {
    color: var(--bs-body-color);
}

[data-bs-theme="dark"] .sidebar .nav-link:hover {
    background-color: var(--bs-secondary-bg);
}

[data-bs-theme="dark"] .sidebar .nav-link.active {
    background-color: var(--bs-primary);
    color: #fff;
}


/* ── Footer Dark Mode ── */
[data-bs-theme="dark"] footer {
    background-color: var(--bs-tertiary-bg);
    border-top-color: var(--bs-border-color);
}

/* ── Breadcrumb Dark Mode ── */

[data-bs-theme="dark"] .breadcrumb-wrapper .breadcrumb-item.active {
    color: var(--bs-secondary-color);
}

[data-bs-theme="dark"] .breadcrumb-wrapper .breadcrumb-item + .breadcrumb-item::before {
    color: var(--bs-secondary-color);
}

/* ── Code Editor Dark Mode ── */
[data-bs-theme="dark"] .code-editor {
    border-color: var(--bs-border-color);
}


/* ── Rich Text Content Dark Mode ── */
[data-bs-theme="dark"] .problem-description pre {
    background-color: var(--bs-secondary-bg);
}

[data-bs-theme="dark"] .problem-description code {
    background-color: var(--bs-secondary-bg);
}

[data-bs-theme="dark"] .problem-description table th,
[data-bs-theme="dark"] .problem-description table td {
    border-color: var(--bs-border-color);
}

[data-bs-theme="dark"] .problem-description table th {
    background-color: var(--bs-secondary-bg);
}

[data-bs-theme="dark"] .problem-description blockquote {
    color: var(--bs-secondary-color);
}

/* ── What's New Modal Dark Mode ── */
[data-bs-theme="dark"] .whats-new-modal #whatsNewVersionSelect option {
    color: var(--bs-body-color);
    background: var(--bs-body-bg);
}

[data-bs-theme="dark"] .whats-new-release-card {
    background-color: var(--bs-secondary-bg) !important;
}

[data-bs-theme="dark"] .whats-new-release-card:hover {
    box-shadow: 0 0.5rem 1rem rgba(0,0,0,0.3) !important;
}

[data-bs-theme="dark"] .whats-new-release-header:hover {
    background-color: rgba(255,255,255,0.05);
}

[data-bs-theme="dark"] .whats-new-feature-icon.icon-danger { background-color: rgba(220, 53, 69, 0.2); }
[data-bs-theme="dark"] .whats-new-feature-icon.icon-primary { background-color: rgba(var(--bs-primary-rgb), 0.2); }
[data-bs-theme="dark"] .whats-new-feature-icon.icon-success { background-color: rgba(25, 135, 84, 0.2); }
[data-bs-theme="dark"] .whats-new-feature-icon.icon-info { background-color: var(--bs-info-bg-subtle); }
[data-bs-theme="dark"] .whats-new-feature-icon.icon-warning { background-color: rgba(255, 193, 7, 0.2); }

[data-bs-theme="dark"] .whats-new-dot {
    border-color: var(--bs-body-bg);
}

/* ── Dark Mode Toggle Button ── */
.theme-toggle-btn {
    background: none;
    border: none;
    padding: 0.375rem 0.5rem;
    font-size: var(--hc-fs-md);
    color: var(--bs-body-color);
    cursor: pointer;
    border-radius: 0.375rem;
    transition: background-color 0.15s ease;
    line-height: 1;
}

.theme-toggle-btn:hover {
    background-color: var(--bs-secondary-bg);
}

.theme-toggle-btn:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.theme-toggle-btn .bi-sun-fill { display: none; }
.theme-toggle-btn .bi-moon-fill { display: inline; }

[data-bs-theme="dark"] .theme-toggle-btn .bi-sun-fill { display: inline; }
[data-bs-theme="dark"] .theme-toggle-btn .bi-moon-fill { display: none; }

/* Respect system preference when no manual selection */
@media (prefers-color-scheme: dark) {
    :root:not([data-bs-theme]) .theme-toggle-btn .bi-sun-fill { display: inline; }
    :root:not([data-bs-theme]) .theme-toggle-btn .bi-moon-fill { display: none; }
}

/* ── Dark Mode: bg-light Override ── */
/* Bootstrap's bg-light doesn't adapt to dark mode. This override maps it to bg-body-tertiary. */
[data-bs-theme="dark"] .bg-light {
    background-color: var(--bs-tertiary-bg) !important;
}

/* Also fix bg-light badges */
[data-bs-theme="dark"] .badge.bg-light {
    background-color: var(--bs-secondary-bg) !important;
    color: var(--bs-body-color) !important;
}

/* ── Dark Mode: table-light Override ── */
/* Bootstrap's table-light doesn't adapt to dark mode (used in leaderboard for empty cells). */
[data-bs-theme="dark"] .table-light,
[data-bs-theme="dark"] .table > tbody > tr > .table-light,
[data-bs-theme="dark"] .table-striped > tbody > tr:nth-of-type(odd) > .table-light {
    background-color: var(--bs-secondary-bg) !important;
    color: var(--bs-secondary-color);
}

/* ── Dark Mode: table-dark header contrast fix ── */
/* In dark mode, table-dark blends with the background, so we add contrast */
[data-bs-theme="dark"] .table-dark,
[data-bs-theme="dark"] .table-dark > th,
[data-bs-theme="dark"] .table-dark > td {
    --bs-table-bg: #1a1d20;
    --bs-table-striped-bg: #1a1d20;
    --bs-table-hover-bg: #1a1d20;
    --bs-table-border-color: #343a40;
    background-color: #1a1d20 !important;
    border-bottom: 2px solid #495057;
}

/* Ensure dynamically generated header content also inherits styling */
[data-bs-theme="dark"] thead.table-dark th {
    background-color: #1a1d20 !important;
    border-bottom-color: #495057;
}

/* ── Dark Mode: table-striped contrast fix ── */
/* Ensure striped rows have visible contrast in dark mode */
[data-bs-theme="dark"] .table-striped > tbody > tr:nth-of-type(odd) > *,
[data-bs-theme="dark"] .table-striped-columns > tbody > tr > :nth-child(even) {
    --bs-table-striped-bg: rgba(255, 255, 255, 0.03);
}

/* ── Dark Mode: Leaderboard "your row" highlight ── */
/* Tint the cells only: clear the light-mode row fill (#fff3cd) so it doesn't
   show through, and don't tint the <tr> too, which stacks the yellow. */
[data-bs-theme="dark"] .you-row {
    background-color: transparent !important;
}
[data-bs-theme="dark"] .you-row td {
    background-color: rgba(255, 193, 7, 0.15) !important;
}
[data-bs-theme="dark"] .you-row .text-danger {
    color: var(--bs-danger-text-emphasis) !important;
}

/* ── Leaderboard Result Cells ── */
/* Bootstrap's table rule outranks a plain class color, and .you-row td outranks a
   plain class fill, so both are set on the cell here. Keep each --lb-*-bg / -fg pair
   at 4.5:1 or better in both themes (tests/test_leaderboard_readability.py). */
#leaderboardTable {
    --lb-solved-bg: #d1e7dd;
    --lb-solved-fg: #0f5132;
    --lb-first-bg: #157347;
    --lb-first-fg: #ffffff;
    --lb-rejected-bg: #f8d7da;
    --lb-rejected-fg: #842029;
    --lb-partial-bg: #ffe69c;
    --lb-partial-fg: #664d03;
    --lb-frozen-bg: #e7effa;
    --lb-frozen-fg: #1d4e89;
    --lb-good: #146c43;
    --lb-bad: #b02a37;
    --lb-warn: #664d03;
}

[data-bs-theme="dark"] #leaderboardTable {
    --lb-solved-bg: #0f5132;
    --lb-solved-fg: #d1e7dd;
    --lb-first-bg: #157347;
    --lb-first-fg: #ffffff;
    --lb-rejected-bg: #58151c;
    --lb-rejected-fg: #f8d7da;
    --lb-partial-bg: #664d03;
    --lb-partial-fg: #fff3cd;
    --lb-frozen-bg: #16264a;
    --lb-frozen-fg: #9cc2f2;
    --lb-good: #75b798;
    --lb-bad: #ea868f;
    --lb-warn: #ffda6a;
}

#leaderboardTable > tbody > tr > td.pc2-solved,
#leaderboardTable > tbody > tr > td.table-success {
    background-color: var(--lb-solved-bg) !important;
    color: var(--lb-solved-fg) !important;
}

#leaderboardTable > tbody > tr > td.pc2-first-ac {
    background-color: var(--lb-first-bg) !important;
    color: var(--lb-first-fg) !important;
    font-weight: bold;
}

#leaderboardTable > tbody > tr > td.pc2-rejected,
#leaderboardTable > tbody > tr > td.table-danger {
    background-color: var(--lb-rejected-bg) !important;
    color: var(--lb-rejected-fg) !important;
}

#leaderboardTable > tbody > tr > td.table-warning {
    background-color: var(--lb-partial-bg) !important;
    color: var(--lb-partial-fg) !important;
}

#leaderboardTable > tbody > tr > td.table-info {
    background-color: var(--lb-frozen-bg) !important;
    color: var(--lb-frozen-fg) !important;
}

/* Muted labels inside a filled cell take the cell's color, or they vanish into the fill */
#leaderboardTable > tbody > tr > td.table-success .text-muted,
#leaderboardTable > tbody > tr > td.table-danger .text-muted,
#leaderboardTable > tbody > tr > td.table-warning .text-muted,
#leaderboardTable > tbody > tr > td.table-info .text-muted {
    color: inherit !important;
}

#leaderboardTable > tbody > tr > td.text-success {
    color: var(--lb-good) !important;
}

#leaderboardTable > tbody > tr > td.text-danger {
    color: var(--lb-bad) !important;
}

#leaderboardTable > tbody > tr > td.text-warning {
    color: var(--lb-warn) !important;
}

/* ── Dark Mode: Text Contrast Overrides for .text-dark and links ── */
[data-bs-theme="dark"] .text-dark:not(.badge):not(.btn):not([class*="bg-warning"]):not([class*="bg-info"]):not([class*="bg-light"]) {
    color: var(--bs-body-color, #e9ecef) !important;
}

[data-bs-theme="dark"] .table .text-dark:not(.badge):not(.btn):not([class*="bg-warning"]):not([class*="bg-info"]):not([class*="bg-light"]) {
    color: var(--bs-body-color, #e9ecef) !important;
}

[data-bs-theme="dark"] a.text-dark {
    color: var(--bs-body-color, #e9ecef) !important;
}

[data-bs-theme="dark"] a.text-dark:hover {
    color: var(--bs-link-hover-color) !important;
}

/* Bootstrap keeps .bg-white white in dark mode, under light text. Panels take
   the card surface; badges keep their white chip (their .text-dark is not flipped). */
[data-bs-theme="dark"] .bg-white:not(.badge) {
    background-color: var(--bs-card-bg, #2b3035) !important;
}

[data-bs-theme="dark"] .card-header.bg-white,
[data-bs-theme="dark"] .modal-header.bg-white,
[data-bs-theme="dark"] .modal-content.bg-white,
[data-bs-theme="dark"] .modal-footer.bg-white {
    background-color: var(--bs-card-cap-bg, #252a30) !important;
    border-color: var(--bs-card-border-color, #2d3238) !important;
}

/* ── Dark Mode: Submission Audit Modal & Timeline Stream ── */
[data-bs-theme="dark"] #submissionAuditModal .modal-content {
    background-color: var(--bs-body-bg, #212529) !important;
    color: var(--bs-body-color, #dee2e6);
}

[data-bs-theme="dark"] #submissionAuditModal .pinned-tabs-bar {
    background-color: var(--bs-tertiary-bg, #2b3035) !important;
    border-color: var(--bs-border-color, #373b3e) !important;
}

[data-bs-theme="dark"] #submissionAuditModal .timeline-stream .timeline-item,
[data-bs-theme="dark"] #submissionAuditModal .timeline-stream .bg-white,
[data-bs-theme="dark"] #submissionAuditModal .timeline-card {
    background-color: var(--bs-tertiary-bg, #2b3035) !important;
    border-color: var(--bs-border-color, #373b3e) !important;
    color: var(--bs-body-color, #dee2e6) !important;
}

[data-bs-theme="dark"] #submissionAuditModal .card-footer.bg-white {
    background-color: var(--bs-tertiary-bg, #2b3035) !important;
    border-color: var(--bs-border-color, #373b3e) !important;
}

[data-bs-theme="dark"] #submissionAuditModal .modal-footer {
    background-color: var(--bs-tertiary-bg, #2b3035) !important;
    border-color: var(--bs-border-color, #373b3e) !important;
}

[data-bs-theme="dark"] .file-item-card,
[data-bs-theme="dark"] .file-item-card.bg-white {
    background-color: #1e2227 !important;
    border-color: #2e343d !important;
}

[data-bs-theme="dark"] .file-item-card .text-dark {
    color: var(--bs-body-color, #f8f9fa) !important;
}

/* ── Dark Mode: Rubric Builder & Assignment Forms ── */
[data-bs-theme="dark"] #rubricBuilderContainer {
    background-color: var(--bs-tertiary-bg) !important;
    border-color: var(--bs-border-color) !important;
}

[data-bs-theme="dark"] #rubricCriteriaList .card,
[data-bs-theme="dark"] #rubricCriteriaList .card.bg-white {
    background-color: var(--bs-body-bg) !important;
    border-color: var(--bs-border-color) !important;
}

[data-bs-theme="dark"] #rubricCriteriaList .card-header,
[data-bs-theme="dark"] #rubricCriteriaList .card-header.bg-white {
    background-color: var(--bs-tertiary-bg) !important;
    border-color: var(--bs-border-color) !important;
}

[data-bs-theme="dark"] .level-card-inner {
    background-color: var(--bs-tertiary-bg) !important;
    border-color: var(--bs-border-color) !important;
}

[data-bs-theme="dark"] .level-card-inner textarea,
[data-bs-theme="dark"] .level-card-inner input {
    color: var(--bs-body-color) !important;
}

[data-bs-theme="dark"] .level-card-inner textarea.bg-white,
[data-bs-theme="dark"] .level-card-inner textarea.bg-body {
    background-color: var(--bs-secondary-bg) !important;
    color: var(--bs-body-color) !important;
}

[data-bs-theme="dark"] #rubricCriteriaList input.bg-light,
[data-bs-theme="dark"] #rubricCriteriaList input.bg-body {
    background-color: var(--bs-secondary-bg) !important;
    color: var(--bs-body-color) !important;
}

/* ── Dark Mode: Rubric Matrix Table & Modal ── */
[data-bs-theme="dark"] .rubric-matrix-table {
    border-color: var(--bs-border-color) !important;
}

[data-bs-theme="dark"] .rubric-matrix-table td {
    border-color: var(--bs-border-color) !important;
    background-color: var(--bs-body-bg);
}

[data-bs-theme="dark"] .rubric-matrix-table td.bg-light {
    background-color: var(--bs-tertiary-bg) !important;
}

[data-bs-theme="dark"] .rubric-matrix-table .bg-white {
    background-color: var(--bs-secondary-bg) !important;
    border-color: var(--bs-border-color) !important;
}

[data-bs-theme="dark"] #matrixPreviewContainer {
    background-color: var(--bs-tertiary-bg) !important;
}

[data-bs-theme="dark"] #solutionInlinePreview.bg-white,
[data-bs-theme="dark"] #solutionInlinePreview {
    background-color: var(--bs-body-bg) !important;
    border-color: var(--bs-border-color) !important;
}

/* ── Dark Mode: Task Card Styles ── */
/* These are defined inline in student/view_section.html but need dark mode overrides */

/* Problem item hover */
[data-bs-theme="dark"] .problem-item:hover {
    background-color: var(--hb-hover-bg) !important;
}

/* Problem item states */
[data-bs-theme="dark"] .problem-item.passed,
[data-bs-theme="dark"] .problem-item.solved {
    background-color: rgba(25, 135, 84, 0.1) !important;
}

[data-bs-theme="dark"] .problem-item.failed {
    background-color: rgba(220, 53, 69, 0.1) !important;
}

/* Task card states */
[data-bs-theme="dark"] .task-scheduled {
    background-color: var(--bs-tertiary-bg) !important;
    border-color: var(--bs-secondary-color) !important;
}

[data-bs-theme="dark"] .task-scheduled .card-header {
    background-color: var(--bs-secondary-bg) !important;
}

[data-bs-theme="dark"] .task-scheduled .progress-circle {
    background-color: var(--bs-tertiary-bg) !important;
    color: var(--bs-secondary-color) !important;
}

/* Progress circle - default 0% state */
[data-bs-theme="dark"] .progress-circle.bg-light {
    background-color: var(--bs-secondary-bg) !important;
    color: var(--bs-body-color) !important;
}

/* ── Dark Mode: Button Overrides ── */
/* btn-light is nearly white and looks jarring in dark mode */
[data-bs-theme="dark"] .btn-light {
    background-color: var(--bs-secondary-bg);
    border-color: var(--bs-border-color);
    color: var(--bs-body-color);
}
[data-bs-theme="dark"] .btn-light:hover {
    background-color: var(--bs-tertiary-bg);
    border-color: var(--bs-border-color);
    color: var(--bs-body-color);
}

/* btn-warning solid is too bright in dark mode — tone it down */
[data-bs-theme="dark"] .btn-warning {
    background-color: #997404;
    border-color: #8a6803;
    color: #fff;
}
[data-bs-theme="dark"] .btn-warning:hover {
    background-color: #8a6803;
    border-color: #7a5c02;
    color: #fff;
}

/* btn-outline-warning contrast fix */
[data-bs-theme="dark"] .btn-outline-warning {
    --bs-btn-color: #cca020;
    --bs-btn-border-color: #cca020;
    --bs-btn-hover-bg: #cca020;
    --bs-btn-hover-border-color: #cca020;
    --bs-btn-hover-color: #000;
    --bs-btn-active-bg: #cca020;
    --bs-btn-active-border-color: #cca020;
    --bs-btn-active-color: #000;
}


/* btn-outline-success contrast fix */
[data-bs-theme="dark"] .btn-outline-success {
    --bs-btn-color: #28a745;
    --bs-btn-border-color: #28a745;
    --bs-btn-hover-bg: #28a745;
    --bs-btn-hover-border-color: #28a745;
    --bs-btn-hover-color: #fff;
    --bs-btn-active-bg: #28a745;
    --bs-btn-active-border-color: #28a745;
    --bs-btn-active-color: #fff;
}

/* btn-outline-danger contrast fix */
[data-bs-theme="dark"] .btn-outline-danger {
    --bs-btn-color: #dc3545;
    --bs-btn-border-color: #dc3545;
    --bs-btn-hover-bg: #dc3545;
    --bs-btn-hover-border-color: #dc3545;
    --bs-btn-hover-color: #fff;
    --bs-btn-active-bg: #dc3545;
    --bs-btn-active-border-color: #dc3545;
    --bs-btn-active-color: #fff;
}

/* Blue icons and grey hints inside a selected (filled) button vanish into it. */
.btn-check:checked + .btn :is(.text-primary, .text-muted, .text-body-secondary):not(.badge),
.btn.active :is(.text-primary, .text-muted, .text-body-secondary):not(.badge) {
    color: inherit !important;
}

/* Outline buttons set Bootstrap's button variables, not `color`, so the
   active/checked state (.btn-check, .active) gets its own readable text. */
/* btn-outline-primary contrast fix */
[data-bs-theme="dark"] .btn-outline-primary {
    --bs-btn-color: #3CCFBF;
    --bs-btn-border-color: #3CCFBF;
    --bs-btn-hover-bg: #3CCFBF;
    --bs-btn-hover-border-color: #3CCFBF;
    --bs-btn-hover-color: #1F2B6E;
    --bs-btn-active-bg: #3CCFBF;
    --bs-btn-active-border-color: #3CCFBF;
    --bs-btn-active-color: #1F2B6E;
}

/* btn-outline-dark is dark-on-dark in dark mode */
[data-bs-theme="dark"] .btn-outline-dark {
    --bs-btn-color: #dee2e6;
    --bs-btn-border-color: #dee2e6;
    --bs-btn-hover-bg: #dee2e6;
    --bs-btn-hover-border-color: #dee2e6;
    --bs-btn-hover-color: #212529;
    --bs-btn-active-bg: #dee2e6;
    --bs-btn-active-border-color: #dee2e6;
    --bs-btn-active-color: #212529;
}

/* btn-success solid — slightly muted for dark mode */
[data-bs-theme="dark"] .btn-success {
    background-color: #1e7e3e;
    border-color: #1c7439;
}
[data-bs-theme="dark"] .btn-success:hover {
    background-color: #1c7439;
    border-color: #1a6c34;
}

/* btn-danger solid — slightly muted for dark mode */
[data-bs-theme="dark"] .btn-danger {
    background-color: #c82333;
    border-color: #bd2130;
}
[data-bs-theme="dark"] .btn-danger:hover {
    background-color: #bd2130;
    border-color: #b21f2d;
}

/* btn-secondary solid — adjusted for dark mode */
[data-bs-theme="dark"] .btn-secondary {
    background-color: #5a6268;
    border-color: #545b62;
}
[data-bs-theme="dark"] .btn-secondary:hover {
    background-color: #545b62;
    border-color: #4e555b;
}

/* btn-dark — ensure it stays readable */
[data-bs-theme="dark"] .btn-dark {
    background-color: #212529;
    border-color: #1d2124;
    color: #fff;
}
[data-bs-theme="dark"] .btn-dark:hover {
    background-color: #1d2124;
    border-color: #1a1d20;
}

/* ── Dark Mode: Navbar ── */
[data-bs-theme="dark"] .navbar-light.bg-white {
    background-color: var(--bs-body-bg) !important;
    border-bottom-color: var(--bs-border-color);
}

/* ── Dark Mode: Inline hardcoded green backgrounds ── */
[data-bs-theme="dark"] [style*="background:#198754"],
[data-bs-theme="dark"] [style*="background: #198754"] {
    background-color: #146c43 !important;
}

/* ── Dark Mode: Modal headers with bg-warning ── */
[data-bs-theme="dark"] .modal-header.bg-warning {
    background-color: #997404 !important;
    color: #fff !important;
}

/* ── Stacking Order & Overlay Hierarchy ── */
.topbar {
    z-index: 1030 !important;
}
.dropdown-menu {
    z-index: 1045 !important;
}
.topbar .dropdown-menu {
    z-index: 1050 !important;
}
.modal-backdrop {
    --bs-backdrop-zindex: 1060;
    z-index: 1060 !important;
    transition: opacity 0.15s linear;
}
.modal {
    --bs-modal-zindex: 1065;
    z-index: 1065 !important;
}
.modal.show {
    pointer-events: auto;
}
/* Stacking Guard: An orphaned backdrop without modal-open on body must never trap clicks or cover page */
body:not(.modal-open) .modal-backdrop {
    display: none !important;
    pointer-events: none !important;
    opacity: 0 !important;
}
.modal-backdrop.fade:not(.show) {
    pointer-events: none !important;
}
/* Phones: every modal behaves like .modal-dialog-scrollable so the header and the
   footer actions (Save / Create / Submit) stay on screen while only the body scrolls.
   Short modals are unaffected: the content only grows up to the viewport height. */
@media (max-width: 575.98px) {
    .modal-dialog:not([class*="modal-fullscreen"]) {
        height: calc(100% - var(--bs-modal-margin) * 2);
    }
    .modal-dialog:not([class*="modal-fullscreen"]) .modal-content {
        max-height: 100%;
        overflow: hidden;
    }
    .modal-dialog:not([class*="modal-fullscreen"]) .modal-body {
        overflow-y: auto;
        overscroll-behavior: contain;
    }
    /* Forms that wrap .modal-body + .modal-footer must pass the flex layout through. */
    .modal-dialog:not([class*="modal-fullscreen"]) .modal-content > form {
        display: flex;
        flex-direction: column;
        flex: 1 1 auto;
        min-height: 0;
    }
}
/* iOS zooms the page when a focused field's font is under 16px. CodeMirror's hidden
   input textarea is invisible, so enlarging it only prevents that zoom. */
.CodeMirror textarea {
    font-size: 16px !important;
}
/* Leaderboard: keep the rank badge (trophy + "T-1" + info icon) and the time/solved
   summary on one line; the table scrolls inside .table-responsive instead of stacking. */
#leaderboardTable td:first-child,
#leaderboardTable th:first-child,
#leaderboardTable td:last-child {
    white-space: nowrap;
}
/* ── Accessibility: WCAG AA text contrast (light theme; found by scripts/a11y_audit.py) ──
   Same hues, darker shades where text sat below 4.5:1. Backgrounds and dark mode unchanged. */
html:not([data-bs-theme="dark"]) .text-primary { color: var(--bs-primary) !important; }
html:not([data-bs-theme="dark"]) .text-success { color: #146c43 !important; }
html:not([data-bs-theme="dark"]) .text-danger { color: #b02a37 !important; }
html:not([data-bs-theme="dark"]) .text-warning { color: #8a6503 !important; }
/* The darker shades above are for light surfaces; on dark surfaces (consoles, code chips,
   dark card headers) they drop to ~2:1, so use bright shades there (all >= 5.5:1 on #212529). */
html:not([data-bs-theme="dark"]) :is(.bg-dark, .bg-black) .text-primary,
html:not([data-bs-theme="dark"]) :is(.bg-dark, .bg-black).text-primary { color: #3CCFBF !important; }
html:not([data-bs-theme="dark"]) :is(.bg-dark, .bg-black) .text-success,
html:not([data-bs-theme="dark"]) :is(.bg-dark, .bg-black).text-success { color: #4ade80 !important; }
html:not([data-bs-theme="dark"]) :is(.bg-dark, .bg-black) .text-info,
html:not([data-bs-theme="dark"]) :is(.bg-dark, .bg-black).text-info { color: #8DB8F0 !important; }
html:not([data-bs-theme="dark"]) :is(.bg-dark, .bg-black) .text-danger,
html:not([data-bs-theme="dark"]) :is(.bg-dark, .bg-black).text-danger { color: #f87171 !important; }
html:not([data-bs-theme="dark"]) :is(.bg-dark, .bg-black) .text-warning,
html:not([data-bs-theme="dark"]) :is(.bg-dark, .bg-black).text-warning { color: #fbbf24 !important; }
html:not([data-bs-theme="dark"]) .text-gray-600 { color: #6b6d7c !important; }
html:not([data-bs-theme="dark"]) .bg-primary-subtle.text-primary { color: var(--bs-primary-text-emphasis) !important; }
html:not([data-bs-theme="dark"]) .bg-success-subtle.text-success { color: #0a3622 !important; }
html:not([data-bs-theme="dark"]) .bg-info-subtle.text-info { color: var(--bs-info-text-emphasis) !important; }
html:not([data-bs-theme="dark"]) .bg-warning-subtle.text-warning { color: #664d03 !important; }
html:not([data-bs-theme="dark"]) .bg-danger-subtle.text-danger { color: #58151c !important; }
html:not([data-bs-theme="dark"]) .btn-outline-danger { --bs-btn-color: #b02a37; }
html:not([data-bs-theme="dark"]) .btn-outline-success { --bs-btn-color: #146c43; }
/* Tabs/pills only: topbar and sidebar (.navbar-nav) keep their own icon colors. */
html:not([data-bs-theme="dark"]) .nav:not(.navbar-nav) { --bs-nav-link-color: var(--bs-primary); }
html:not([data-bs-theme="dark"]) .btn-outline-warning { --bs-btn-color: #8a6503; }
html:not([data-bs-theme="dark"]) .bg-secondary-subtle.text-secondary { color: #41464b !important; }
html:not([data-bs-theme="dark"]) code { color: #b02a6e; }
/* Badges default to white text, which is 1.6:1 on warning yellow. */
.badge.bg-warning { --bs-badge-color: #212529; color: #212529; }
/* Sidebar/topbar dividers and headings are wrapped in <li> so the menus are valid lists. */
.sidebar-meta { list-style: none; }
/* Show/hide password icons: at least a 24x24px target (WCAG 2.2 target size). */
.pw-toggle { min-width: 24px; min-height: 24px; display: inline-flex; align-items: center; justify-content: center; }

/* ── Large screens ──
   .container-wide: data-heavy management pages (section, task, submissions, question bank)
   match .container up to 1600px, then grow instead of stopping at 1320px. Forms and
   reading pages keep plain .container for comfortable line lengths. */
@media (min-width: 1600px) {
    .container.container-wide { max-width: 1520px; }
}
@media (min-width: 1920px) {
    .container.container-wide { max-width: 1720px; }
}
@media (min-width: 2400px) {
    .container.container-wide { max-width: 2080px; }
}
/* Touch screens: IDE pane collapse/expand icons are ~18px; give them a usable hit area. */
@media (pointer: coarse) {
    .panel-control-btn {
        min-width: 32px;
        min-height: 32px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
}
.editor-locked-overlay {
    z-index: 20 !important;
}

/* ── Notifications Modal Styles ── */
#notificationsModal .modal-body {
    min-height: 200px;
    max-height: 60vh;
    overflow-y: auto;
}

#notificationsModal .list-group-item {
    transition: background-color 0.15s ease;
}

#notificationsModal .list-group-item:hover {
    background-color: var(--bs-tertiary-bg);
}

[data-bs-theme="dark"] #notificationsModal .list-group-item.bg-light {
    background-color: rgba(var(--bs-primary-rgb), 0.12) !important;
}

@media (max-width: 575.98px) {
    #notificationsModal .list-group-item {
        padding: 0.75rem 0.75rem !important;
        gap: 0.5rem !important;
    }
    #notificationsModal .list-group-item .badge.rounded-circle {
        padding: 0.35rem !important;
    }
    #notificationsModal .list-group-item .badge.rounded-circle i {
        font-size: var(--hc-fs-base) !important;
    }
    #notificationsModal .list-group-item h6 {
        font-size: var(--hc-fs-sm) !important;
    }
}

/* ── Real-time Notification Pulse Highlight ── */
@keyframes notificationPulse {
    0% { background-color: rgba(var(--bs-primary-rgb), 0.25); }
    100% { background-color: transparent; }
}

.notification-new-highlight {
    animation: notificationPulse 2.5s ease-out !important;
}

/* ── 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;
}

/* ── Declarative AJAX Loading Transitions ── */
.ajax-updating {
    opacity: 0.65;
    pointer-events: none;
    transition: opacity 0.15s ease;
}

/* ── Mermaid Diagram Styles ── */
.mermaid-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 1.5rem 0;
    padding: 1.25rem;
    background: #ffffff;
    border: 1px solid #e3e6f0;
    border-radius: 0.5rem;
    overflow-x: auto;
    box-shadow: 0 0.15rem 0.5rem rgba(0, 0, 0, 0.04);
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

.mermaid-wrapper .mermaid {
    width: 100%;
    display: flex;
    justify-content: center;
    text-align: center;
}

.mermaid-wrapper .mermaid svg,
.mermaid-wrapper svg,
.mermaid-wrapper img,
.mermaid-diagram-svg {
    max-width: 100%;
    height: auto;
    min-height: 40px;
    display: block;
    margin: 0 auto;
}

.mermaid-error {
    background-color: rgba(220, 53, 69, 0.05);
    border: 1px solid rgba(220, 53, 69, 0.3);
    border-radius: 0.375rem;
    padding: 0.75rem 1rem;
    margin: 1rem 0;
    color: #dc3545;
    font-size: var(--hc-fs-sm);
    font-family: monospace;
}

/* Dark Mode Overrides for Mermaid */
[data-bs-theme="dark"] .mermaid-wrapper {
    background-color: #1e2227;
    border-color: #2e343d;
    box-shadow: 0 0.15rem 0.5rem rgba(0, 0, 0, 0.25);
}

[data-bs-theme="dark"] .mermaid-error {
    background-color: rgba(220, 53, 69, 0.15);
    border-color: rgba(220, 53, 69, 0.4);
    color: #ea868f;
}

.mermaid-diagram-block {
    margin: 1.25rem auto;
    padding: 0.75rem;
    text-align: center;
    border-radius: 0.5rem;
    background: #ffffff;
    border: 1px solid #e3e6f0;
    box-shadow: 0 0.15rem 0.5rem rgba(0, 0, 0, 0.04);
}
.mermaid-diagram-block .mermaid-svg-holder,
.mermaid-diagram-block svg,
.mermaid-diagram-block img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 0 auto;
}
[data-bs-theme="dark"] .mermaid-diagram-block {
    background-color: #1e2227;
    border-color: #2e343d;
    box-shadow: 0 0.15rem 0.5rem rgba(0, 0, 0, 0.25);
}
.mermaid-diagram-block pre,
pre.mermaid.d-none {
    display: none !important;
}

/* ── Mermaid Interactive Zoom & Pan Affordance ── */
.mermaid-wrapper,
.mermaid-diagram-block {
    position: relative;
}

.mermaid-zoomable {
    cursor: zoom-in;
    position: relative;
    border-radius: 0.5rem;
    transition: transform 0.18s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.18s ease, border-color 0.18s ease;
}

.mermaid-zoomable:hover {
    border-color: rgba(59, 130, 246, 0.5) !important;
    box-shadow: 0 0.35rem 1rem rgba(59, 130, 246, 0.12) !important;
}

.mermaid-zoomable:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 3px;
}

/* ── Mermaid Diagram Zoom Modal / Lightbox ── */
.mermaid-zoom-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(10, 15, 30, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 99999;
    display: none;
    flex-direction: column;
    box-sizing: border-box;
    overflow: hidden;
}

.mermaid-zoom-backdrop.active {
    display: flex;
}

.mermaid-zoom-topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1.25rem;
    background: rgba(15, 23, 42, 0.75);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    color: #f8fafc;
    z-index: 2052;
    flex-shrink: 0;
    gap: 1rem;
}

.mermaid-zoom-header-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
}

.mermaid-zoom-title {
    font-size: var(--hc-fs-sm);
    font-weight: 600;
    color: #f1f5f9;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.mermaid-zoom-title i {
    color: #60a5fa;
}

.mermaid-zoom-badge {
    font-size: var(--hc-fs-xs);
    font-weight: 500;
    padding: 0.2rem 0.55rem;
    border-radius: 9999px;
    background: rgba(99, 102, 241, 0.2);
    color: #a5b4fc;
    border: 1px solid rgba(99, 102, 241, 0.35);
}

.mermaid-zoom-toolbar {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.mermaid-zoom-btn {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #e2e8f0;
    border-radius: 0.375rem;
    padding: 0.35rem 0.65rem;
    font-size: var(--hc-fs-sm);
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease, color 0.15s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    user-select: none;
}

.mermaid-zoom-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
    color: #ffffff;
}

.mermaid-zoom-btn:active {
    transform: scale(0.95);
}

.mermaid-zoom-btn.active {
    background: rgba(59, 130, 246, 0.35);
    border-color: rgba(59, 130, 246, 0.6);
    color: #93c5fd;
}

.mermaid-zoom-level {
    font-size: var(--hc-fs-xs);
    font-weight: 600;
    font-family: SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    min-width: 3.5rem;
    text-align: center;
    padding: 0.35rem 0.5rem;
    background: rgba(0, 0, 0, 0.35);
    border-radius: 0.375rem;
    color: #38bdf8;
    border: 1px solid rgba(56, 189, 248, 0.25);
    user-select: none;
    cursor: pointer;
}

.mermaid-zoom-level:hover {
    background: rgba(56, 189, 248, 0.15);
    border-color: rgba(56, 189, 248, 0.45);
}

.mermaid-zoom-btn-close {
    background: rgba(239, 68, 68, 0.18);
    border-color: rgba(239, 68, 68, 0.35);
    color: #fca5a5;
    margin-left: 0.3rem;
}

.mermaid-zoom-btn-close:hover {
    background: rgba(239, 68, 68, 0.4);
    border-color: rgba(239, 68, 68, 0.6);
    color: #ffffff;
}

.mermaid-zoom-viewport {
    flex: 1;
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #0b1120;
    background-image: radial-gradient(rgba(255, 255, 255, 0.12) 1.5px, transparent 1.5px);
    background-size: 26px 26px;
    touch-action: none;
}

.mermaid-zoom-canvas {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    transform-origin: center center;
    will-change: transform;
    user-select: none;
    cursor: grab;
    transition: transform 0.05s ease-out;
}

.mermaid-zoom-canvas.dragging {
    cursor: grabbing !important;
    transition: none !important;
}

.mermaid-zoom-svg-card {
    background: #ffffff;
    padding: 2rem;
    border-radius: 0.75rem;
    box-shadow: 0 20px 45px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    max-width: none;
}

[data-bs-theme="dark"] .mermaid-zoom-svg-card {
    background: #1e2227;
    box-shadow: 0 20px 45px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.12);
}

.mermaid-zoom-svg-card svg {
    max-width: none !important;
    height: auto !important;
    display: block;
    margin: 0 auto;
}

.mermaid-zoom-bottombar {
    position: absolute;
    bottom: 1.25rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 9999px;
    padding: 0.35rem 0.9rem;
    color: #94a3b8;
    font-size: var(--hc-fs-xs);
    z-index: 2052;
    pointer-events: none;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    white-space: nowrap;
}

.mermaid-zoom-toast {
    position: absolute;
    top: 4.5rem;
    left: 50%;
    transform: translateX(-50%) translateY(-10px);
    background: rgba(16, 185, 129, 0.92);
    color: #ffffff;
    padding: 0.45rem 1rem;
    border-radius: 9999px;
    font-size: var(--hc-fs-sm);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 2055;
}

.mermaid-zoom-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

@media (max-width: 768px) {
    .mermaid-zoom-topbar {
        padding: 0.5rem 0.75rem;
        gap: 0.5rem;
    }
    .mermaid-zoom-badge,
    .mermaid-zoom-bottombar {
        display: none !important;
    }
    .mermaid-zoom-btn {
        padding: 0.3rem 0.45rem;
        font-size: var(--hc-fs-xs);
    }
    .mermaid-zoom-level {
        min-width: 2.75rem;
        font-size: var(--hc-fs-xs);
    }
}

/* ── Markdown Content Styling (Assignments, Prompts, & Documentation) ── */
.markdown-content {
    line-height: 1.7;
    color: var(--bs-body-color, #2d3748);
}

.markdown-content h1,
.markdown-content h2,
.markdown-content h3,
.markdown-content h4,
.markdown-content h5,
.markdown-content h6 {
    margin-top: 1.4rem;
    margin-bottom: 0.65rem;
    font-weight: 700;
    line-height: 1.3;
    color: var(--bs-heading-color, inherit);
}

.markdown-content h1:first-child,
.markdown-content h2:first-child,
.markdown-content h3:first-child,
.markdown-content h4:first-child {
    margin-top: 0;
}

.markdown-content h1 { font-size: var(--hc-fs-2xl); border-bottom: 1px solid var(--bs-border-color, #e2e8f0); padding-bottom: 0.4rem; }
.markdown-content h2 { font-size: var(--hc-fs-lg); border-bottom: 1px solid var(--bs-border-color, #e2e8f0); padding-bottom: 0.3rem; }
.markdown-content h3 { font-size: var(--hc-fs-md); }
.markdown-content h4 { font-size: var(--hc-fs-base); }
.markdown-content h5 { font-size: var(--hc-fs-base); }
.markdown-content h6 { font-size: var(--hc-fs-sm); text-transform: uppercase; letter-spacing: 0.05em; }

.markdown-content p {
    margin-bottom: 1rem;
}

.markdown-content ul,
.markdown-content ol {
    margin-bottom: 1rem;
    padding-left: 1.6rem;
}

.markdown-content li {
    margin-bottom: 0.25rem;
}

.markdown-content blockquote {
    border-left: 3px solid var(--hc-line-strong);
    margin: 1.25rem 0;
    padding: 0.6rem 1rem 0.6rem 1.25rem;
    background: rgba(59, 130, 246, 0.05);
    border-radius: 0 0.375rem 0.375rem 0;
    color: var(--bs-secondary-color, #4b5563);
}

.markdown-content blockquote p:last-child {
    margin-bottom: 0;
}

.markdown-content code {
    font-family: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 0.875em;
    color: #e11d48;
    background-color: rgba(225, 29, 72, 0.08);
    padding: 0.15rem 0.35rem;
    border-radius: 0.25rem;
}

.markdown-content pre {
    background-color: #1e1e2e !important;
    color: #f8f8f2 !important;
    border: 1px solid #313244 !important;
    border-radius: 0.5rem !important;
    padding: 1rem !important;
    margin: 1rem 0 !important;
    overflow-x: auto !important;
}

.markdown-content pre code,
.markdown-content pre code.language-text,
.markdown-content pre code[class*="language-"] {
    color: #f8f8f2 !important;
    background-color: transparent !important;
    padding: 0 !important;
    font-size: 0.9em !important;
    font-family: Consolas, Monaco, SFMono-Regular, Menlo, 'Courier New', monospace !important;
}

/* Question explanations (Markdown) shown inside feedback alerts */
.explanation-content > :last-child {
    margin-bottom: 0;
}

.explanation-content pre {
    margin: 0.5rem 0 !important;
}

.markdown-content table {
    width: 100%;
    margin-bottom: 1.25rem;
    border-collapse: collapse;
    border: 1px solid var(--bs-border-color, #dee2e6);
    border-radius: 0.375rem;
    overflow: hidden;
}

.markdown-content th,
.markdown-content td {
    padding: 0.6rem 0.85rem;
    border: 1px solid var(--bs-border-color, #dee2e6);
}

.markdown-content th {
    background-color: var(--bs-tertiary-bg, #f8f9fa);
    font-weight: 600;
}

.markdown-content tbody tr:nth-child(even) {
    background-color: var(--bs-secondary-bg, rgba(0, 0, 0, 0.02));
}

.markdown-content hr {
    margin: 1.5rem 0;
    border: 0;
    border-top: 1px solid var(--bs-border-color, #e2e8f0);
}

/* Responsive, Adaptive Images for Markdown, Assignment, and Worksheet Content */
.markdown-content img,
.rich-worksheet-content img,
.rich-worksheet-sheet img {
    display: block;
    width: auto;
    max-width: 100%;
    height: auto;
    max-height: 48vh;
    object-fit: contain;
    margin: 1.25rem auto;
    border-radius: 0.5rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
    border: 1px solid var(--bs-border-color, rgba(0, 0, 0, 0.1));
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    cursor: zoom-in;
}

.markdown-content img:hover,
.rich-worksheet-content img:hover,
.rich-worksheet-sheet img:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.14);
    border-color: var(--bs-primary, #2B3A8C);
}

/* Inline badges / emojis exception */
.markdown-content img.inline-img,
.markdown-content img.badge-img,
.rich-worksheet-content img.inline-img,
.rich-worksheet-content img.badge-img,
.rich-worksheet-sheet img.inline-img,
.rich-worksheet-sheet img.badge-img {
    display: inline-block;
    max-height: 1.5em;
    width: auto;
    margin: 0 0.25rem;
    box-shadow: none;
    border: none;
    cursor: default;
    transform: none;
}

/* Table cell images exception */
.markdown-content td img,
.markdown-content th img,
.rich-worksheet-content td img,
.rich-worksheet-content th img,
.rich-worksheet-sheet td img,
.rich-worksheet-sheet th img {
    max-height: 180px;
    max-width: 100%;
    margin: 0.25rem auto;
}

/* Screen size adaptive scaling */
@media (min-width: 1400px) {
    .markdown-content img:not(.inline-img):not(.badge-img),
    .rich-worksheet-content img:not(.inline-img):not(.badge-img),
    .rich-worksheet-sheet img:not(.inline-img):not(.badge-img) {
        max-height: 52vh;
        max-width: min(100%, 780px);
    }
}

@media (min-width: 992px) and (max-width: 1399.98px) {
    .markdown-content img:not(.inline-img):not(.badge-img),
    .rich-worksheet-content img:not(.inline-img):not(.badge-img),
    .rich-worksheet-sheet img:not(.inline-img):not(.badge-img) {
        max-height: 48vh;
        max-width: min(100%, 680px);
    }
}

@media (min-width: 768px) and (max-width: 991.98px) {
    .markdown-content img:not(.inline-img):not(.badge-img),
    .rich-worksheet-content img:not(.inline-img):not(.badge-img),
    .rich-worksheet-sheet img:not(.inline-img):not(.badge-img) {
        max-height: 42vh;
        max-width: min(100%, 540px);
        margin: 1rem auto;
    }
}

@media (max-width: 767.98px) {
    .markdown-content img:not(.inline-img):not(.badge-img),
    .rich-worksheet-content img:not(.inline-img):not(.badge-img),
    .rich-worksheet-sheet img:not(.inline-img):not(.badge-img) {
        max-height: 38vh;
        max-width: 100%;
        margin: 0.75rem auto;
        border-radius: 0.375rem;
    }
}

@media (max-height: 600px) {
    .markdown-content img:not(.inline-img):not(.badge-img),
    .rich-worksheet-content img:not(.inline-img):not(.badge-img),
    .rich-worksheet-sheet img:not(.inline-img):not(.badge-img) {
        max-height: 40vh;
    }
}

/* ── Content Image Lightbox Modal ── */
.image-lightbox-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.88);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 1090;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s ease-in-out;
    padding: 1.5rem;
    box-sizing: border-box;
}

.image-lightbox-backdrop.active {
    opacity: 1;
    pointer-events: auto;
}

.image-lightbox-topbar {
    position: absolute;
    top: 1rem;
    left: 1.5rem;
    right: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #f8fafc;
    z-index: 1092;
    pointer-events: auto;
}

.image-lightbox-title {
    font-size: var(--hc-fs-sm);
    font-weight: 500;
    color: #e2e8f0;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
    max-width: 65vw;
}

.image-lightbox-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.image-lightbox-btn {
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #ffffff;
    border-radius: 0.375rem;
    padding: 0.35rem 0.75rem;
    font-size: var(--hc-fs-sm);
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    text-decoration: none;
}

.image-lightbox-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.35);
    color: #ffffff;
}

.image-lightbox-btn:active {
    transform: scale(0.96);
}

.image-lightbox-content {
    max-width: 94vw;
    max-height: 84vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    user-select: none;
}

.image-lightbox-img {
    max-width: 92vw;
    max-height: 80vh;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 0.5rem;
    box-shadow: 0 10px 35px rgba(0, 0, 0, 0.6);
    transform: scale(0.96);
    transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1);
    cursor: zoom-out;
}

.image-lightbox-backdrop.active .image-lightbox-img {
    transform: scale(1);
}

.image-lightbox-caption {
    margin-top: 0.75rem;
    color: #94a3b8;
    font-size: var(--hc-fs-sm);
    text-align: center;
    max-width: 80vw;
    line-height: 1.4;
}

/* Dark Mode Overrides for Markdown Content */
[data-bs-theme="dark"] .markdown-content code {
    color: #f43f5e;
    background-color: rgba(244, 63, 94, 0.15);
}

[data-bs-theme="dark"] .markdown-content blockquote {
    border-left-color: #60a5fa;
    background: rgba(96, 165, 250, 0.08);
    color: #94a3b8;
}

[data-bs-theme="dark"] .markdown-content table {
    border-color: #374151;
}

[data-bs-theme="dark"] .markdown-content th,
[data-bs-theme="dark"] .markdown-content td {
    border-color: #374151;
}

[data-bs-theme="dark"] .markdown-content th {
    background-color: #1f2937;
}

[data-bs-theme="dark"] .markdown-content tbody tr:nth-child(even) {
    background-color: rgba(255, 255, 255, 0.03);
}

/* ── Rich Worksheet Content Styling (Student Submitted & SpeedGrader Views) ── */
.rich-worksheet-content {
    font-size: var(--hc-fs-base);
    line-height: 1.65;
    color: var(--bs-body-color, #212529);
}

.rich-worksheet-content .contains-task-list {
    list-style-type: none !important;
    padding-left: 0.25rem !important;
    margin-bottom: 1rem;
}

.rich-worksheet-content .task-list-item {
    list-style-type: none !important;
    display: flex !important;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.4rem;
}

.rich-worksheet-content .worksheet-checkbox,
.rich-worksheet-content input[type="checkbox"] {
    width: 1.2em;
    height: 1.2em;
    accent-color: var(--bs-primary, #2B3A8C);
    margin: 0;
    vertical-align: middle;
    cursor: default;
}

.rich-worksheet-content table {
    width: 100%;
    margin-bottom: 1.25rem;
    border-collapse: collapse !important;
    border: 1px solid var(--bs-border-color, #dee2e6);
}

.rich-worksheet-content th,
.rich-worksheet-content td {
    border: 1px solid var(--bs-border-color, #dee2e6);
    padding: 10px 12px;
    vertical-align: top;
    min-height: 36px;
}

.rich-worksheet-content th {
    background-color: var(--bs-tertiary-bg, #f8f9fa);
    font-weight: 600;
}

.rich-worksheet-content tbody tr:nth-child(even) {
    background-color: var(--bs-secondary-bg, rgba(0, 0, 0, 0.02));
}

.rich-worksheet-content .katex-math-inline {
    display: inline-block;
    vertical-align: middle;
    margin: 0 2px;
}

.rich-worksheet-content .katex-math-display {
    display: block;
    text-align: center;
    margin: 0.85rem auto;
    padding: 0.5rem;
}

.rich-worksheet-content pre {
    background-color: var(--bs-tertiary-bg, #f1f3f5);
    border: 1px solid var(--bs-border-color, #dee2e6);
    border-radius: 0.5rem;
    padding: 12px 16px;
    overflow-x: auto;
    margin: 1rem 0;
}

.rich-worksheet-content code {
    font-family: SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.9em;
    padding: 0.15rem 0.35rem;
    border-radius: 0.25rem;
    color: var(--bs-code-color, #d63384);
}

.rich-worksheet-content pre code {
    background-color: transparent;
    padding: 0;
    color: inherit;
}

.rich-worksheet-content blockquote {
    border-left: 3px solid var(--hc-line-strong);
    margin: 1.25rem 0;
    padding: 0.6rem 1rem 0.6rem 1.25rem;
    background: rgba(var(--bs-primary-rgb), 0.05);
    border-radius: 0 0.375rem 0.375rem 0;
    color: var(--bs-secondary-color, #6c757d);
}

/* Dark Mode Overrides for Rich Worksheet Content */
[data-bs-theme="dark"] .rich-worksheet-content table,
[data-bs-theme="dark"] .rich-worksheet-content th,
[data-bs-theme="dark"] .rich-worksheet-content td {
    border-color: #374151;
}

[data-bs-theme="dark"] .rich-worksheet-content th {
    background-color: #1f2937;
    color: #e5e7eb;
}

[data-bs-theme="dark"] .rich-worksheet-content tbody tr:nth-child(even) {
    background-color: rgba(255, 255, 255, 0.03);
}

[data-bs-theme="dark"] .rich-worksheet-content pre {
    background-color: #1e2227;
    border-color: #2e343d;
    color: #cdd6f4;
}

[data-bs-theme="dark"] .rich-worksheet-content code {
    color: #f43f5e;
    background-color: rgba(244, 63, 94, 0.15);
}

[data-bs-theme="dark"] .rich-worksheet-content blockquote {
    border-left-color: #60a5fa;
    background: rgba(96, 165, 250, 0.08);
    color: #94a3b8;
}

[data-bs-theme="dark"] .markdown-content img,
[data-bs-theme="dark"] .rich-worksheet-content img,
[data-bs-theme="dark"] .rich-worksheet-sheet img {
    border-color: rgba(255, 255, 255, 0.12);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
}

[data-bs-theme="dark"] .markdown-content img:hover,
[data-bs-theme="dark"] .rich-worksheet-content img:hover,
[data-bs-theme="dark"] .rich-worksheet-sheet img:hover {
    border-color: #60a5fa;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.55);
}

/* ── Worksheet Normal Editor Toolbar ── */
.worksheet-editor-toolbar {
    min-height: 38px;
    background-color: var(--bs-tertiary-bg, #f8f9fa);
    border: 1px solid var(--bs-border-color, #dee2e6);
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

[data-bs-theme="dark"] .worksheet-editor-toolbar {
    background-color: #1e2227;
    border-color: #2e343d;
}

/* ==========================================================================
   Mobile-First IDE & Responsive Workspace Enhancements
   ========================================================================== */

/* Back and reload for installed windows, which have no browser controls */
.pwa-nav {
    display: none;
    align-items: center;
}

.pwa-nav .btn {
    height: 2.5rem;
    width: 2.5rem;
    padding: 0;
    color: #858796;
}

@media (display-mode: standalone) {
    .pwa-nav {
        display: inline-flex;
    }
}

/* Back and reload need the brand's space on phones; the app icon already names it */
@media (display-mode: standalone) and (max-width: 430px) {
    .topbar .topbar-brand-text {
        display: none;
    }
}

/* Mobile Bottom Navigation Bar (Handhelds only) */
.mobile-bottom-nav {
    --mobile-nav-bg: var(--bs-body-bg, #ffffff);
    --mobile-nav-accent: #2b3a8c;
    --mobile-nav-accent-bg: rgba(43, 58, 140, 0.12);
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(56px + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: var(--mobile-nav-bg);
    border-top: 1px solid var(--bs-border-color, #dee2e6);
    display: flex;
    align-items: center;
    justify-content: space-around;
    z-index: 1040;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
}

[data-bs-theme="dark"] .mobile-bottom-nav {
    --mobile-nav-bg: #181825;
    --mobile-nav-accent: #8fa2f0;
    --mobile-nav-accent-bg: rgba(143, 162, 240, 0.18);
    border-top-color: #313244;
}

/* Links and buttons (Classes, Messages) share one look. */
.mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    min-width: 0;
    height: 100%;
    padding: 0;
    border: 0;
    background: none;
    color: var(--bs-secondary-color, #6c757d);
    text-decoration: none;
    font-size: var(--hc-fs-2xs);
    font-weight: 500;
    gap: 2px;
    -webkit-tap-highlight-color: transparent;
}

/* The icon sits in a pill that fills in for the current page. */
.mobile-nav-icon {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 3.25rem;
    height: 1.75rem;
    border-radius: 1rem;
    transition: background-color 0.15s ease;
}

.mobile-nav-icon .bi {
    font-size: var(--hc-fs-md);
    line-height: 1;
}

.mobile-nav-item.active {
    color: var(--mobile-nav-accent);
}

.mobile-nav-item.active .mobile-nav-icon {
    background: var(--mobile-nav-accent-bg);
}

.mobile-nav-item.active .mobile-nav-label {
    font-weight: 700;
}

/* Touch: brief feedback while pressed. Hover color only for real pointers,
   because :hover sticks after a tap and would light up two items. */
.mobile-nav-item:active .mobile-nav-icon {
    background: var(--bs-tertiary-bg, #f1f3f5);
}

@media (hover: hover) and (pointer: fine) {
    .mobile-nav-item:hover {
        color: var(--mobile-nav-accent);
    }
}

.mobile-nav-item:focus-visible {
    outline: 2px solid var(--mobile-nav-accent);
    outline-offset: -4px;
    border-radius: 0.5rem;
}

/* Counts and the due-soon dot, outlined in the bar color so they read on any icon. */
.mobile-nav-badge {
    position: absolute;
    top: -5px;
    left: calc(50% + 3px);
    min-width: 1.15rem;
    height: 1.15rem;
    padding: 0 0.3rem;
    border: 2px solid var(--mobile-nav-bg);
    border-radius: 1rem;
    background: var(--bs-danger, #dc3545);
    color: #fff;
    font-size: var(--hc-fs-2xs);
    font-weight: 700;
    line-height: calc(1.15rem - 4px);
    text-align: center;
    box-sizing: border-box;
}

.mobile-nav-dot {
    position: absolute;
    top: 0;
    left: calc(50% + 6px);
    width: 0.65rem;
    height: 0.65rem;
    border: 2px solid var(--mobile-nav-bg);
    border-radius: 50%;
    background: var(--bs-danger, #dc3545);
}

/* Class switcher sheet (bottom bar → Classes / Sections). */
.mobile-class-switcher.offcanvas-bottom {
    height: auto;
    max-height: 75vh;
    border-top-left-radius: 1rem;
    border-top-right-radius: 1rem;
}

.mobile-class-switcher .offcanvas-body {
    padding-top: 0;
    padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
}

.switcher-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.switcher-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    min-height: 48px;
    padding: 0.6rem 0.5rem;
    border-radius: 0.6rem;
    color: var(--bs-body-color);
    text-decoration: none;
}

.switcher-item:active,
.switcher-item.is-current {
    background: rgba(43, 58, 140, 0.08);
}

[data-bs-theme="dark"] .switcher-item:active,
[data-bs-theme="dark"] .switcher-item.is-current {
    background: rgba(143, 162, 240, 0.14);
}

.switcher-icon {
    color: #2b3a8c;
}

[data-bs-theme="dark"] .switcher-icon {
    color: #8fa2f0;
}

.switcher-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 600;
}

.switcher-current {
    font-size: var(--hc-fs-xs);
    color: var(--bs-secondary-color);
}

.switcher-empty {
    margin: 0.5rem 0;
    color: var(--bs-secondary-color);
}

@media (prefers-reduced-motion: reduce) {
    .mobile-nav-icon {
        transition: none;
    }
}

/* Compensate page wrapper padding for bottom nav */
@media (max-width: 767.98px) {
    #content-wrapper {
        padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px)) !important;
    }
    body.no-mobile-bottom-nav #content-wrapper {
        padding-bottom: 0 !important;
    }
}

/* iOS Safari Automatic Viewport Zoom Fix */
@media (max-width: 767.98px) {
    input[type="text"],
    input[type="password"],
    input[type="email"],
    input[type="number"],
    input[type="tel"],
    input[type="search"],
    select.form-select,
    select.form-control,
    textarea.form-control,
    .form-control,
    .form-control-sm {
        font-size: var(--hc-fs-base) !important; /* Prevents auto-zoom on iOS Safari */
    }
}

/* Mobile IDE Tab Navigation */
.mobile-ide-tabs {
    display: none;
}

@media (max-width: 991.98px) {
    .mobile-ide-tabs {
        display: flex;
        background: var(--bs-tertiary-bg, #f8f9fa);
        border: 1px solid var(--bs-border-color, #dee2e6);
        border-radius: 0.5rem;
        padding: 4px;
        margin-bottom: 0.75rem;
        gap: 4px;
    }

    [data-bs-theme="dark"] .mobile-ide-tabs {
        background: #1e1e2e;
        border-color: #313244;
    }

    .mobile-ide-tab-btn {
        flex: 1;
        padding: 10px 12px;
        min-height: 44px;
        font-size: var(--hc-fs-sm);
        font-weight: 600;
        text-align: center;
        border: none;
        background: transparent;
        color: var(--bs-secondary-color, #adb5bd);
        border-radius: 0.375rem;
        transition: all 0.2s ease;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 6px;
    }

    .mobile-ide-tab-btn.active {
        background: var(--bs-card-bg, #ffffff);
        color: var(--bs-primary);
        box-shadow: 0 1px 4px rgba(0,0,0,0.12);
    }

    [data-bs-theme="dark"] .mobile-ide-tab-btn.active {
        background: #282a36;
        color: #38bdf8;
    }

    /* Split-pane mobile segmented active visibility */
    .split-pane-container {
        flex-direction: column !important;
        height: auto !important;
    }

    .split-pane {
        display: none !important;
        width: 100% !important;
        min-width: 100% !important;
        flex: none !important;
    }

    .split-pane.mobile-active-pane {
        display: flex !important;
        min-height: calc(100dvh - 280px);
        animation: fadeSlideIn 0.15s ease;
    }

    @keyframes fadeSlideIn {
        from { opacity: 0; transform: translateX(10px); }
        to   { opacity: 1; transform: translateX(0); }
    }

    /* Hide desktop resize handles on mobile */
    .split-handle,
    .ide-vertical-expander,
    .ide-vertical-resize-handle {
        display: none !important;
    }

    /* Sticky Bottom Mobile Execution Bar */
    .mobile-ide-bottom-bar {
        position: sticky;
        bottom: 0;
        left: 0;
        right: 0;
        background: var(--bs-card-bg, #ffffff);
        border-top: 1px solid var(--bs-border-color, #dee2e6);
        padding: 8px 12px calc(8px + env(safe-area-inset-bottom, 0px));
        z-index: 1020;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 8px;
        box-shadow: 0 -2px 10px rgba(0,0,0,0.06);
    }

    [data-bs-theme="dark"] .mobile-ide-bottom-bar {
        background: #1e1e2e;
        border-top-color: #313244;
    }

    .mobile-ide-bottom-bar .btn {
        min-height: 46px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        font-weight: 600;
        border-radius: 0.5rem;
        flex: 1;
    }

    /* Mobile Programming Keyboard Accessory Bar */
    .mobile-code-accessory-bar {
        display: flex;
        overflow-x: auto;
        white-space: nowrap;
        background: #1e1e2e;
        border-top: 1px solid #313244;
        padding: 6px 8px;
        gap: 6px;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .mobile-code-accessory-bar::-webkit-scrollbar {
        display: none;
    }

    .code-symbol-btn {
        min-width: 40px;
        height: 38px;
        background: #313244;
        color: #cdd6f4;
        border: 1px solid #45475a;
        border-radius: 6px;
        font-family: 'Consolas', 'Monaco', monospace;
        font-size: 14px;
        font-weight: 600;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0 10px;
        user-select: none;
        touch-action: manipulation;
    }

    .code-symbol-btn:active {
        background: var(--bs-primary);
        color: #ffffff;
    }
}

/* Assessment Touch Hitbox Active State */
.mcq-option-card:active,
.question-nav-btn:active {
    transform: scale(0.98);
    transition: transform 0.05s ease;
}

/* ==========================================================================
   Phase 2 Responsive & Accessibility Additions
   ========================================================================== */

/* R11: Skeleton Loading Placeholders (solid fill, opacity pulse) */
.skeleton {
    background: var(--bs-tertiary-bg, #e9ecef);
    animation: skeleton-pulse 1.5s ease-in-out infinite;
    border-radius: 0.375rem;
}

[data-bs-theme="dark"] .skeleton {
    background: #2a2a3a;
}

@keyframes skeleton-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.55; }
}

.skeleton-text {
    height: 1em;
    margin-bottom: 0.5rem;
    width: 100%;
}

.skeleton-text.short { width: 40%; }
.skeleton-text.medium { width: 70%; }
.skeleton-card { min-height: 120px; }
.skeleton-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

/* R13: Landscape Orientation Support for Phones (height <= 500px) */
@media (max-width: 991.98px) and (orientation: landscape) and (max-height: 500px) {
    .mobile-ide-tabs {
        padding: 2px;
        margin-bottom: 0.25rem;
    }

    .mobile-ide-tab-btn {
        min-height: 36px;
        padding: 4px 8px;
        font-size: var(--hc-fs-xs);
    }

    .split-pane.mobile-active-pane {
        min-height: calc(100dvh - 150px);
    }

    .mobile-ide-bottom-bar {
        padding: 4px 8px calc(4px + env(safe-area-inset-bottom, 0px));
    }

    .mobile-ide-bottom-bar .btn {
        min-height: 36px;
        font-size: var(--hc-fs-sm);
    }

    .mobile-code-accessory-bar {
        padding: 3px 6px;
        gap: 4px;
    }

    .code-symbol-btn {
        height: 30px;
        min-width: 32px;
        font-size: 12px;
        padding: 0 6px;
    }

    .topbar {
        height: 3.25rem !important;
        min-height: 3.25rem !important;
    }

    .topbar .navbar-brand {
        display: none !important;
    }
}

/* R16: Print Stylesheet for Grades, Reports & Assessments */
@media print {
    .sidebar,
    .sidebar-backdrop,
    .topbar,
    .mobile-bottom-nav,
    .mobile-ide-tabs,
    .mobile-ide-bottom-bar,
    .mobile-code-accessory-bar,
    .assessment-mobile-nav-pill,
    .offcanvas,
    footer.sticky-footer,
    .btn:not(.btn-print-keep),
    .breadcrumb,
    .dropdown,
    .skip-to-content,
    #sidebarBackdrop {
        display: none !important;
    }

    #wrapper {
        display: block !important;
    }

    #content-wrapper {
        margin-left: 0 !important;
        padding-bottom: 0 !important;
    }

    #content {
        padding: 0 !important;
    }

    body {
        font-size: 11pt;
        color: #000 !important;
        background: #fff !important;
    }

    .card {
        border: 1px solid #ddd !important;
        box-shadow: none !important;
        break-inside: avoid;
    }

    .table-responsive {
        overflow: visible !important;
    }

    .badge {
        border: 1px solid #777 !important;
        color: #000 !important;
        background: #f8f9fa !important;
    }

    /* Print support for Mermaid diagrams, code snippets, and figures */
    .mermaid-wrapper,
    .mermaid-print-wrapper,
    .code-playground,
    .code-print-block,
    .lesson-content img,
    .lesson-content table,
    .lesson-content pre {
        break-inside: avoid !important;
        page-break-inside: avoid !important;
    }

    .mermaid svg {
        max-width: 100% !important;
        height: auto !important;
    }

    .page-notes-section {
        break-inside: avoid !important;
        page-break-inside: avoid !important;
    }

    .book-cover-page {
        break-after: page !important;
        page-break-after: always !important;
    }
}

/* R19: Reduced Motion & Accessibility Preferences
   Animations and transitions finish at once; loading spinners keep turning
   (Bootstrap slows them) because they mean "still working". */
@media (prefers-reduced-motion: reduce) {
    *:not(.spinner-border, .spinner-grow),
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }

    .skeleton {
        animation: none !important;
        background-size: 100% 100% !important;
    }

    .mobile-ide-tab-btn,
    .mobile-nav-item,
    .mcq-option-card,
    .question-nav-btn {
        transition: none !important;
    }

    .split-pane.mobile-active-pane {
        animation: none !important;
    }

    .mcq-option-card:active,
    .question-nav-btn:active {
        transform: none !important;
    }
}






/* Grading queue: participant initials */
.grading-queue-avatar {
    width: 2rem;
    height: 2rem;
    flex-shrink: 0;
    font-size: var(--hc-fs-xs);
}

/* Grading queue on phones: each submission is a compact card instead of a
   five-column table that pushed the Grade button off screen.
   Student + Grade on top; assignment, section and submitted time stack under the name. */
@media (max-width: 767.98px) {
    #gradingQueueTable thead {
        display: none;
    }
    #gradingQueueTable,
    #gradingQueueTable tbody,
    #gradingQueueTable td {
        display: block;
    }
    #gradingQueueTable tr {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        grid-template-areas:
            "student action"
            "assignment assignment"
            "section section"
            "submitted submitted";
        column-gap: 0.75rem;
        row-gap: 0.2rem;
        padding: 0.75rem 1rem;
        border-bottom: 1px solid var(--bs-border-color);
    }
    #gradingQueueTable tr:last-child {
        border-bottom: 0;
    }
    #gradingQueueTable td {
        padding: 0 !important;
        border: 0;
    }
    #gradingQueueTable td:nth-child(1) { grid-area: student; }
    #gradingQueueTable td:nth-child(2) { grid-area: assignment; padding-left: 2.5rem !important; }
    #gradingQueueTable td:nth-child(3),
    #gradingQueueTable td:nth-child(4) {
        font-size: var(--hc-fs-sm);
    }
    #gradingQueueTable td:nth-child(3) {
        grid-area: section;
        min-width: 0;
        padding-left: 2.5rem !important;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    #gradingQueueTable td:nth-child(4) { grid-area: submitted; padding-left: 2.5rem !important; }
    #gradingQueueTable td:nth-child(4) > div { display: inline; }
    #gradingQueueTable td:nth-child(4) small::before { content: " · "; }
    #gradingQueueTable td:nth-child(5) { grid-area: action; align-self: center; }
}

/* ── Sign in with Google (follows Google's branding: white, grey border, G mark) ── */
.btn-google {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    font-size: var(--hc-fs-sm);
    font-weight: 500;
    color: #1f1f1f;
    background-color: #fff;
    border: 1px solid #747775;
    border-radius: var(--hc-r-control);
    padding: 0.75rem 1rem;
}

.btn-google:hover,
.btn-google:focus-visible {
    color: #1f1f1f;
    background-color: #f2f2f2;
    border-color: #747775;
}

.btn-google-logo {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

[data-bs-theme="dark"] .btn-google {
    color: #e3e3e3;
    background-color: #131314;
    border-color: #8e918f;
}

[data-bs-theme="dark"] .btn-google:hover,
[data-bs-theme="dark"] .btn-google:focus-visible {
    color: #e3e3e3;
    background-color: #2a2a2c;
}

.auth-divider {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 1rem 0;
    font-size: var(--hc-fs-xs);
    color: var(--bs-secondary-color);
}

.auth-divider::before,
.auth-divider::after {
    content: "";
    flex: 1;
    border-top: 1px solid var(--bs-border-color);
}

/* "?" help popovers (e.g. Item Analysis metrics on assessment results). */
.metric-help-popover {
    max-width: 22rem;
    font-size: var(--hc-fs-sm);
}
.metric-help-popover .popover-body {
    line-height: 1.45;
}

/* ==========================================================================
   Hover feedback: show what the pointer is on
   - Rows and things you open (list items, table rows, clickable cards,
     dashboard section cards) get a flat indigo tint.
   - Container cards only get an indigo outline, so a whole page section
     doesn't change color while you work inside it; a nested card hands the
     highlight to the innermost one. An inset outline (not border-color)
     also shows on borderless cards and leaves their shadows alone.
   - Pointer devices only: on touch screens :hover sticks after a tap.
   ========================================================================== */
:root {
    --hb-hover-bg: #eef0f6;
    --hb-hover-border: #b4bbd7;
    --hb-hover-row: rgba(43, 58, 140, 0.07);
}

[data-bs-theme="dark"] {
    --hb-hover-bg: #353b48;
    --hb-hover-border: #4e5876;
    --hb-hover-row: rgba(143, 162, 240, 0.08);
}

@media (hover: hover) {
    .card:hover:not(:has(.card:hover)) {
        outline: 1px solid var(--hb-hover-border);
        outline-offset: -1px;
    }

    /* A card is clickable when the stretched link is its own, not a row's inside it. */
    .card:has(.stretched-link):not(:has(.list-group-item .stretched-link, .card .stretched-link, td .stretched-link)):hover,
    .section-card:hover {
        background-color: var(--hb-hover-bg);
    }

    /* Contextual items (list-group-item-warning, ...) keep their own hover color. */
    .list-group {
        --bs-list-group-action-hover-bg: var(--hb-hover-bg);
    }

    .list-group-item:not(.active, .disabled, [class*="list-group-item-"]):hover {
        background-color: var(--hb-hover-bg);
    }

    /* Every table, not just .table-hover; a translucent overlay keeps row tints visible. */
    .table > tbody > tr:hover > * {
        --bs-table-hover-bg: var(--hb-hover-row);
        --bs-table-color-state: var(--bs-table-hover-color);
        --bs-table-bg-state: var(--bs-table-hover-bg);
    }
}

/* Raise hand (problem IDE and assessment page, js/pages/live_monitor_student.js):
   outlined until raised, then solid navy so it reads as "on" at a glance. */
.raise-hand-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-weight: 600;
    white-space: nowrap;
}
.raise-hand-btn[hidden] { display: none; }
.raise-hand-btn.is-raised {
    --bs-btn-color: #FFFFFF;
    --bs-btn-bg: var(--hc-thread-navy);
    --bs-btn-border-color: var(--hc-thread-navy);
    --bs-btn-hover-color: #FFFFFF;
    --bs-btn-hover-bg: var(--hc-thread-navy);
    --bs-btn-hover-border-color: var(--hc-thread-navy);
    --bs-btn-active-color: #FFFFFF;
    --bs-btn-active-bg: var(--hc-thread-navy);
    --bs-btn-active-border-color: var(--hc-thread-navy);
}
.raise-hand-btn.is-raised > .bi { color: inherit; }
/* On the assessment's navy timer bar the raised state flips to white. */
.assessment-timer .raise-hand-btn.is-raised {
    --bs-btn-color: #1F2B6E;
    --bs-btn-bg: #FFFFFF;
    --bs-btn-border-color: #FFFFFF;
    --bs-btn-hover-color: #1F2B6E;
    --bs-btn-hover-bg: #FFFFFF;
    --bs-btn-hover-border-color: #FFFFFF;
    --bs-btn-active-color: #1F2B6E;
    --bs-btn-active-bg: #FFFFFF;
    --bs-btn-active-border-color: #FFFFFF;
}
