/* ─── BASE  RESET & VARIABLES ─── */
:root {
    --text-main: #1a1a1a;
    --bg-main: #fbf9f1;
    --glass-bg: rgba(255, 255, 255, 0.95);
    --input-bg: #ffffff;
    --border-color: rgba(0, 0, 0, 0.1);
    --card-radius: 12px;
    --brand-blue: #004a80;
    --brand-orange: #f7941d;
    --nav-height: 64px;
    --bottom-nav-height: 60px;
}

.dark {
    --text-main: #fdfbf7;
    --bg-main: #050505;
    --glass-bg: rgba(20, 20, 20, 0.95);
    --input-bg: #111;
    --border-color: rgba(255, 255, 255, 0.1);
}

html,
body,
.glass,
.input-field,
div,
section,
main,
nav,
article,
button,
span,
p,
h1,
h2,
h3,
h4,
h5,
h6 {
    transition: background-color 0.55s ease, color 0.55s ease, border-color 0.55s ease, box-shadow 0.55s ease !important;
}

html {
    height: -webkit-fill-available;
}
/* change for signin page */
#auth-screen:not(.hidden) ~ #floating-bottom-nav-bar {
    display: none;
}

body {
    font-family: 'Plus Jakarta Sans', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    overflow-x: hidden;
    padding-bottom: calc(var(--bottom-nav-height) + 24px + env(safe-area-inset-bottom));
    overscroll-behavior-y: none;
    -webkit-tap-highlight-color: transparent;
    min-height: 100vh;
    min-height: -webkit-fill-available;
}

::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(128, 128, 128, 0.3);
    border-radius: 6px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--brand-orange);
}
.light ::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
}
.light ::-webkit-scrollbar-thumb:hover {
    background: var(--brand-blue);
}

.glass {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
}

/* ─── BUTTONS & INPUTS ─── */
.btn-brand {
    background: linear-gradient(135deg, var(--brand-blue) 0%, var(--brand-orange) 100%);
    background-size: 200% auto;
    transition: transform 0.3s ease, box-shadow 0.3s ease, background-position 0.5s;
    color: white !important;
    font-weight: 800;
    text-transform: uppercase;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.btn-brand:hover,
#ai-floating-btn:hover {
    background-position: right center;
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 74, 128, 0.2);
}

.input-field {
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    outline: none;
    padding: 0.85rem 1rem;
    border-radius: 8px;
    width: 100%;
    transition: border-color 0.3s, box-shadow 0.3s;
}
.input-field:focus {
    border-color: var(--brand-orange);
    box-shadow: 0 0 0 3px rgba(247, 148, 29, 0.15);
}
.input-field::placeholder {
    color: rgba(128, 128, 128, 0.6);
}

/* ─── TOAST NOTIFICATIONS ─── */
#toast-box {
    position: fixed;
    bottom: 5rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 99999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    pointer-events: none;
}
.toast-pill {
    background: rgba(15, 15, 15, 0.95);
    backdrop-filter: blur(10px);
    color: #fff;
    padding: 0.8rem 1.5rem;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    animation: popUp 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}
.custom-toast {
    background: var(--glass-bg);
    backdrop-filter: blur(30px);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.8rem 1.5rem;
    font-size: 12px;
    font-weight: 700;
    color: var(--text-main);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

/* ─── ANIMATIONS ─── */
@keyframes popUp {
    from { opacity: 0; transform: translateY(20px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: none; }
}
@keyframes spin {
    to { transform: rotate(360deg); }
}
@keyframes pulse {
    0%, 100% { opacity: 0.55; }
    50% { opacity: 1; }
}
@keyframes pulse-dot {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.3); opacity: 0.7; }
}
.fade-in {
    animation: fadeIn 0.3s ease-out forwards;
}
.skeleton-pulse {
    animation: pulse 1.4s ease-in-out infinite;
}

/* ─── STRICT YOUTUBE-STYLE BOTTOM NAV BAR ─── */
#floating-bottom-nav-bar {
    position: fixed !important;
    z-index: 99999 !important;
    display: flex;
    align-items: center;
    justify-content: space-around;
    background: var(--glass-bg);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    transition: transform 0.3s ease-in-out, opacity 0.3s ease;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    height: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom, 0);
    border-top: 1px solid var(--border-color);
    border-radius: 0 !important;
    box-shadow: 0 -2px 15px rgba(0, 0, 0, 0.05);
}

#floating-bottom-nav-bar.nav-hidden {
    transform: translateY(100%) !important;
    pointer-events: none;
}

.nav-island-btn {
    flex: 1;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: var(--text-main);
    opacity: 0.5;
    background: none;
    border: none;
    cursor: pointer;
    transition: 0.2s ease;
    font-family: inherit;
    gap: 4px;
    padding: 6px 0;
}

.nav-island-btn:hover {
    background: rgba(128, 128, 128, 0.05);
}

.nav-island-btn.active { 
    opacity: 1; 
    color: var(--brand-blue);
}
.dark .nav-island-btn.active { 
    color: var(--brand-orange);
}

.nav-island-btn .icon-box {
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav-island-btn i { font-size: 20px; }
.nav-island-btn span { font-size: 10px; font-weight: 600; }

/* ─── DASHBOARD CARDS (updated for Resize & Drag) ─── */
.dash-card-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    transition: all 0.3s ease;
}
@media (max-width: 768px) {
    .dash-card-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 480px) {
    .dash-card-grid { grid-template-columns: 1fr; }
}

.dash-card {
    background: var(--glass-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--card-radius);
    padding: 1.25rem 1rem;
    transition: all 0.3s ease;
    cursor: pointer;
    min-height: 120px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    position: relative;
    overflow: hidden;
    gap: 0.5rem;
}

.dash-card:active {
    cursor: pointer;
}

.dash-card:hover {
    transform: translateY(-4px);
    border-color: rgba(247, 148, 29, 0.4);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

.dash-card .card-icon {
    font-size: 28px;
    color: var(--brand-orange);
    transition: transform 0.3s ease;
}
.dash-card:hover .card-icon {
    transform: scale(1.1);
}
.dash-card .card-title {
    font-weight: 800;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-main);
}
.dash-card .card-action {
    margin-top: 0.25rem;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--brand-orange);
    border: 1px solid rgba(247, 148, 29, 0.25);
    padding: 0.4rem 0.8rem;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
    background: rgba(247, 148, 29, 0.05);
}
.dash-card:hover .card-action {
    background: var(--brand-orange);
    color: #fff;
    border-color: var(--brand-orange);
}

/* Size spanning logic */
.dash-card[data-size="1"] { grid-column: span 1; }
.dash-card[data-size="2"] { grid-column: span 2; }
.dash-card[data-size="3"] { grid-column: span 3; }

@media (max-width: 768px) {
    .dash-card[data-size="2"], .dash-card[data-size="3"] { grid-column: span 2; }
}
@media (max-width: 480px) {
    .dash-card[data-size="2"], .dash-card[data-size="3"] { grid-column: span 1; }
}

/* Resize Handle */
.resize-handle {
    display: none !important;
}

/* ─── PROFILE MINI ─── */
.profile-mini {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    background: var(--glass-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    flex-wrap: wrap;
}
.profile-mini .avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%; 
    object-fit: cover;
    border: 2px solid var(--brand-orange);
    flex-shrink: 0;
    background: #111;
}
.profile-mini .info {
    flex: 1;
    min-width: 0;
}
.profile-mini .info .name {
    font-weight: 800;
    font-size: 15px;
    line-height: 1.2;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.profile-mini .info .id {
    font-size: 10px;
    font-weight: 600;
    opacity: 0.5;
    font-family: monospace;
    letter-spacing: 0.05em;
}
.quick-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}
.quick-actions .qa-btn {
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.5rem 0.75rem;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-main);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    white-space: nowrap;
}
.quick-actions .qa-btn:hover {
    border-color: var(--brand-orange);
    background: rgba(247, 148, 29, 0.08);
}
.quick-actions .qa-btn i {
    font-size: 14px;
    color: var(--brand-orange);
}

@media (max-width: 640px) {
    .profile-mini .avatar { width: 40px; height: 40px; }
    .profile-mini .info .name { font-size: 14px; }
    .quick-actions .qa-btn { font-size: 9px; padding: 0.4rem 0.6rem; }
    .quick-actions .qa-btn i { font-size: 12px; }
}

.profile-ring-stacked { border-radius: 50%; padding: 2px; }

/* ─── UNIFIED GRID ─── */
.unified-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    width: 100%;
    padding: 4px 0;
}
@media (min-width: 640px) {
    .unified-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 1024px) {
    .unified-grid { grid-template-columns: repeat(3, 1fr); }
}

.unified-card {
    background: var(--glass-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--card-radius);
    overflow: hidden;
    transition: all 0.3s ease;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 220px;
}
.unified-card:hover {
    transform: translateY(-3px);
    border-color: rgba(247, 148, 29, 0.3);
    box-shadow: 0 12px 25px rgba(0, 0, 0, 0.1);
}
.unified-card .thumb-wrap {
    position: relative;
    width: 100%;
    aspect-ratio: 16/9;
    overflow: hidden;
    background: #0a0a0a;
    flex-shrink: 0;
}
.unified-card .thumb-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease;
}
.unified-card:hover .thumb-wrap img {
    transform: scale(1.03);
}
.unified-card .card-body {
    padding: 12px 16px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.unified-card .card-body .title {
    font-weight: 700;
    font-size: 14px;
    line-height: 1.4;
    color: var(--text-main);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.unified-card .card-body .meta {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 11px;
    color: rgba(128, 128, 128, 0.8);
    margin-top: 2px;
    flex-wrap: wrap;
}
.unified-card .card-body .meta .teacher {
    font-weight: 600;
    color: var(--text-main);
    opacity: 0.8;
}
.unified-card .card-body .badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
}

/* ─── MEDIA VAULT & ANTI-THEFT ─── */
#vault-wrapper {
    width: 100%;
    height: 100%;
    max-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
    position: relative;
    overflow: hidden;
    border-radius: 0;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}
.plyr {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #000;
}
.plyr video {
    max-height: 100vh;
    object-fit: contain;
}
#media-vault .plyr__video-embed iframe {
    transform: scale(1.12);
    pointer-events: none;
    top: -8%;
    height: 116%;
}
.plyr--full-ui.plyr--video .plyr__control--overlaid {
    background: var(--brand-orange);
}
.plyr--video .plyr__controls {
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.9));
    padding-bottom: max(10px, env(safe-area-inset-bottom));
}
#anti-theft-blank {
    display: none;
    position: absolute;
    inset: 0;
    background: #000 !important;
    z-index: 2147483647 !important;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #fff !important;
    font-weight: 800;
    text-transform: uppercase;
    font-size: 14px;
    letter-spacing: 0.1em;
    pointer-events: auto !important;
}
#anti-theft-blank.show { display: flex !important; }

#secure-watermark {
    position: absolute;
    z-index: 2147483646 !important;
    pointer-events: none !important;
    font-weight: 800;
    font-size: 18px;
    color: rgba(255, 255, 255, 0.15) !important;
    mix-blend-mode: difference !important;
    white-space: nowrap;
    user-select: none;
    transition: all 1.2s ease-in-out;
}

#screenshot-warning {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(10px);
    z-index: 999999;
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    color: #fff;
    font-weight: 800;
    font-size: 20px;
    padding: 2rem;
    text-align: center;
}
#screenshot-warning.active { display: flex; }
#screenshot-warning .sub { font-size: 12px; opacity: 0.6; margin-top: 1rem; }

/* MOVABLE VAULT CLOSE BUTTON */
#vault-close-btn {
    touch-action: none;
    cursor: grab;
}
#vault-close-btn:active { cursor: grabbing; }

/* ─── LIVE STREAM CHAT ─── */
#live-classroom-chat-container {
    height: 100%;
    max-height: 100vh;
    display: flex;
    flex-direction: column;
    background: #0b0b0b;
    border-left: 1px solid rgba(255, 255, 255, 0.05);
}
#live-classroom-chat-container.hidden { display: none !important; }

#end-live-btn {
    position: absolute;
    bottom: 80px;
    right: 20px;
    z-index: 50;
    padding: 10px 20px;
    border-radius: 8px;
    background: #ef4444;
    color: #fff;
    font-weight: 800;
    font-size: 12px;
    text-transform: uppercase;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.3);
    transition: all 0.2s;
    display: none;
}
#end-live-btn:hover {
    background: #dc2626;
}
#end-live-btn.visible { display: block; }

/* ─── MODALS & OVERLAYS ─── */
#custom-modal .custom-scrollbar::-webkit-scrollbar { width: 4px; }
#custom-modal .custom-scrollbar::-webkit-scrollbar-thumb {
    background: var(--brand-orange);
    border-radius: 4px;
}

#payment-overlay {
    position: fixed;
    inset: 0;
    z-index: 99998;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(20px);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}
#payment-overlay.active { display: flex; }
#payment-overlay .payment-card {
    background: var(--glass-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--card-radius);
    padding: 2.5rem 2rem;
    max-width: 400px;
    width: 100%;
    text-align: center;
    animation: fadeIn 0.3s ease forwards;
}

#app-install-loading {
    position: fixed;
    inset: 0;
    z-index: 999999;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(20px);
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 800;
    text-transform: uppercase;
    font-size: 16px;
    gap: 1.5rem;
    animation: fadeIn 0.3s ease;
}
#app-install-loading.active { display: flex; }
#app-install-loading .spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--brand-orange);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* ─── AI CHAT ─── */
#ai-chat-window {
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    transform-origin: bottom right;
}
.ai-drawer-hidden {
    opacity: 0 !important;
    transform: scale(0.95) translateY(20px) !important;
    pointer-events: none !important;
}

/* ─── SEARCH & TOP NAV ─── */
#nav-profile-pic {
    aspect-ratio: 1;
    overflow: hidden;
}
#nav-profile-pic img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    display: block;
}

.search-container {
    width: 40px;
    transition: width 0.3s ease;
    flex-shrink: 0;
}
.search-container.expanded { width: min(240px, 45vw); }

#nav-branding-block .inst-brand-logo {
    border-radius: 8px;
    object-fit: cover;
    background: #111;
    border: 1px solid var(--border-color);
}
#nav-branding-block .inst-brand-name {
    font-weight: 800;
    font-style: italic;
    letter-spacing: -0.02em;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 160px;
}

@media (max-width: 480px) {
    .search-container.expanded { width: 120px; }
    #nav-branding-block .inst-brand-name { font-size: 13px; max-width: 100px; }
}
@media (min-width: 768px) {
    #nav-branding-block .inst-brand-name { max-width: 280px; }
}

/* ─── AD BANNER & POPUP ─── */
.ad-banner-container {
    position: relative;
    overflow: hidden;
    border-radius: 12px;
    background: var(--glass-bg);
    border: 1px solid var(--border-color);
    display: flex;
    gap: 0.5rem;
    padding: 0.5rem;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    height: auto;
    min-height: 80px;
}
.ad-banner-container a {
    scroll-snap-align: start;
    flex-shrink: 0;
    display: block;
}
.ad-banner-container img {
    height: 100px;
    max-height: 120px;
    object-fit: cover;
    border-radius: 8px;
    min-width: 180px;
    width: auto;
}
@media (min-width: 768px) {
    .ad-banner-container img {
        height: 140px;
        max-height: 160px;
        min-width: 260px;
    }
}

.ad-popup {
    position: fixed;
    bottom: 90px;
    left: 16px;
    z-index: 8000;
    max-width: 280px;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1rem;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    display: none;
    animation: fadeIn 0.3s ease forwards;
}
.ad-popup.active { display: block; }
.ad-popup .ad-close {
    position: absolute;
    top: -10px;
    right: -10px;
    background: #ff4444;
    border: 2px solid var(--bg-main);
    color: #fff;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}
.ad-popup a { display: block; }
.ad-popup img {
    width: 100%;
    border-radius: 8px;
    max-height: 140px;
    object-fit: cover;
}

/* ─── NEW ANALYTICS DASHBOARD ─── */
.analytics-value {
    font-size: 38px;
    line-height: 1.1;
    font-weight: 900;
    background: -webkit-linear-gradient(45deg, var(--text-main), var(--brand-orange));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
@media(min-width:768px) {
    .analytics-value { font-size: 46px; }
}
.analytics-label {
    font-size: 11px;
    letter-spacing: 0.1em;
    font-weight: 800;
    text-transform: uppercase;
    color: var(--text-main);
    opacity: 0.7;
    margin-bottom: 6px;
}
.analytics-card {
    min-height: 110px;
    padding: 20px;
    border-radius: 16px;
    transition: 0.3s ease-out;
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: linear-gradient(135deg, var(--glass-bg), rgba(255, 255, 255, 0.5));
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.03);
}
.dark .analytics-card {
    background: linear-gradient(135deg, rgba(30,30,30,0.9), rgba(15,15,15,0.95));
    border-color: rgba(255, 255, 255, 0.05);
}
@media(min-width:768px) {
    .analytics-card {
        min-height: 130px;
        padding: 24px;
    }
}
.analytics-card:hover {
    transform: translateY(-6px);
    border-color: var(--brand-blue);
    box-shadow: 0 12px 30px rgba(0, 74, 128, 0.15);
}
.analytics-icon {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, var(--brand-blue), var(--brand-orange));
    transform: scaleX(0);
    transform-origin: left;
    transition: 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.analytics-card:hover .analytics-icon {
    transform: scaleX(1);
}

/* ─── TOPIC CHIPS (YOUTUBE STYLE) ─── */
.topic-chips-container {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 8px;
    margin-bottom: 12px;
    scrollbar-width: none;
}
.topic-chips-container::-webkit-scrollbar {
    display: none;
}
.topic-chip {
    padding: 6px 14px;
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 11px;
    font-weight: 800;
    color: var(--text-main);
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.2s;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.topic-chip.active, .topic-chip:hover {
    background: var(--text-main);
    color: var(--bg-main);
    border-color: var(--text-main);
}

/* ─── BADGES & MISC ─── */
.demo-badge {
    background: rgba(247, 148, 29, 0.15);
    color: var(--brand-orange);
    font-size: 8px;
    font-weight: 800;
    text-transform: uppercase;
    padding: 4px 8px;
    border-radius: 6px;
    border: 1px solid rgba(247, 148, 29, 0.2);
    letter-spacing: 0.05em;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.teacher-grid-btn {
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    background: var(--input-bg);
    color: var(--text-main);
    font-size: 9px;
    font-weight: 800;
    text-transform: uppercase;
    transition: all 0.2s;
    border: 1px solid var(--border-color);
    cursor: pointer;
}
.teacher-grid-btn.grid-btn-active {
    background: rgba(247, 148, 29, 0.15);
    border-color: rgba(247, 148, 29, 0.3);
    color: var(--brand-orange);
}
.teacher-grid-btn:hover { border-color: var(--brand-orange); }

.group-chat-bubble {
    padding: 0.75rem 1rem !important;
    font-size: 0.9rem !important;
    line-height: 1.5 !important;
    border-radius: 8px !important;
    max-width: 92% !important;
    min-width: 100px !important;
    word-wrap: break-word !important;
}

/* ─── LOADING SENTINEL ─── */
#scroll-sentinel {
    height: 20px;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px 0;
    color: rgba(128, 128, 128, 0.5);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}
#scroll-sentinel .spinner-sm {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--brand-orange);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: 8px;
}
.dark #scroll-sentinel .spinner-sm {
    border-color: rgba(255, 255, 255, 0.1);
    border-top-color: var(--brand-orange);
}
.light #scroll-sentinel .spinner-sm {
    border-color: rgba(0, 0, 0, 0.1);
    border-top-color: var(--brand-orange);
}

/* ─── ADMIN STATUS BADGES ─── */
.status-badge-pending {
    background: rgba(234, 179, 8, 0.15);
    color: #eab308;
    border: 1px solid rgba(234, 179, 8, 0.2);
    padding: 2px 10px;
    border-radius: 6px;
    font-size: 8px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.status-badge-approved {
    background: rgba(34, 197, 94, 0.15);
    color: #22c55e;
    border: 1px solid rgba(34, 197, 94, 0.2);
    padding: 2px 10px;
    border-radius: 6px;
    font-size: 8px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.status-badge-rejected {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.2);
    padding: 2px 10px;
    border-radius: 6px;
    font-size: 8px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.admin-inst-item { transition: all 0.2s ease; }
.admin-inst-item:hover {
    border-color: var(--brand-orange) !important;
    transform: translateY(-2px);
}

.qa-btn.request-btn { position: relative; }
.qa-btn.request-btn .dot {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 8px;
    height: 8px;
    background: #ef4444;
    border-radius: 50%;
    border: 2px solid var(--bg-main);
    display: none;
}
.qa-btn.request-btn .dot.active {
    display: block;
    animation: pulse-dot 1.5s ease-in-out infinite;
}

.social-icon {
    font-size: 18px;
    color: #6b7280;
    transition: all 0.2s ease;
}
.social-icon:hover { transform: scale(1.1); }
.fa-whatsapp:hover { color: #25D366; }
.fa-instagram:hover { color: #E4405F; }
.fa-telegram:hover { color: #229ED9; }

.app-offline-active {
    filter: grayscale(1) contrast(1.1) !important;
    pointer-events: none !important;
}
.app-offline-active #toast-box,
.app-offline-active .toast-pill {
    filter: none !important;
    pointer-events: auto !important;
}

/* ============================================================
   FLEXIBLE DASHBOARD LAYOUTS (Controlled by data-layout)
   ============================================================ */

/* --- Common Base for all layouts --- */
#main-content[data-layout] .unified-grid {
    transition: grid-template-columns 0.3s ease, gap 0.3s ease;
}
#main-content[data-layout] .unified-card {
    transition: min-height 0.3s ease, flex-direction 0.3s ease;
}
#main-content[data-layout] .unified-card .thumb-wrap {
    transition: width 0.3s ease, height 0.3s ease;
}

/* --- Layout: Standard Grid (Default) --- */
#main-content[data-layout="grid"] .unified-grid {
    grid-template-columns: 1fr;
}
@media (min-width: 640px) {
    #main-content[data-layout="grid"] .unified-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 1024px) {
    #main-content[data-layout="grid"] .unified-grid { grid-template-columns: repeat(3, 1fr); }
}

/* --- Layout: List View --- */
#main-content[data-layout="list"] .unified-grid {
    grid-template-columns: 1fr !important;
}
#main-content[data-layout="list"] .unified-card {
    flex-direction: row !important;
    min-height: auto !important;
    padding-right: 1rem;
}
#main-content[data-layout="list"] .unified-card .thumb-wrap {
    width: 160px !important;
    height: 90px !important;
    flex-shrink: 0;
    aspect-ratio: 16/9 !important;
}
#main-content[data-layout="list"] .unified-card .card-body {
    padding: 12px 16px !important;
    flex: 1 !important;
}
#main-content[data-layout="list"] .unified-card .card-body .title {
    font-size: 15px !important;
}
#main-content[data-layout="list"] .unified-card .card-body .meta {
    font-size: 11px !important;
}

/* --- Layout: Expanded Cards --- */
#main-content[data-layout="expanded"] .unified-grid {
    grid-template-columns: 1fr !important;
}
#main-content[data-layout="expanded"] .unified-card {
    min-height: 320px !important;
}
#main-content[data-layout="expanded"] .unified-card .thumb-wrap {
    height: 220px !important;
    aspect-ratio: 16/9 !important;
}
#main-content[data-layout="expanded"] .unified-card .card-body .title {
    font-size: 18px !important;
    -webkit-line-clamp: 3 !important;
}
#main-content[data-layout="expanded"] .unified-card .card-body .meta {
    font-size: 13px !important;
}

/* --- Layout: Compact Grid (4 cols) --- */
#main-content[data-layout="compact"] .unified-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)) !important;
    gap: 10px !important;
}
#main-content[data-layout="compact"] .unified-card .card-body .title {
    font-size: 12px !important;
    -webkit-line-clamp: 1 !important;
}
#main-content[data-layout="compact"] .unified-card .card-body .meta {
    font-size: 9px !important;
    flex-wrap: wrap !important;
}
#main-content[data-layout="compact"] .unified-card .badges span {
    font-size: 7px !important;
}
#main-content[data-layout="compact"] .unified-card .thumb-wrap {
    aspect-ratio: 16/9 !important;
    height: 100px !important;
}

/* --- Dashboard Action Cards (dash-card-grid) --- */
#main-content[data-layout="list"] .dash-card-grid,
#main-content[data-layout="expanded"] .dash-card-grid {
    grid-template-columns: 1fr 1fr !important;
}
@media (max-width: 480px) {
    #main-content[data-layout="list"] .dash-card-grid,
    #main-content[data-layout="expanded"] .dash-card-grid {
        grid-template-columns: 1fr !important;
    }
}
#main-content[data-layout="list"] .dash-card {
    min-height: 70px !important;
    flex-direction: row !important;
    justify-content: space-between !important;
    padding: 0.75rem 1.25rem !important;
    text-align: left !important;
}
#main-content[data-layout="list"] .dash-card .card-icon {
    font-size: 20px !important;
    margin-right: 0.5rem;
}
#main-content[data-layout="expanded"] .dash-card {
    min-height: 150px !important;
}
#main-content[data-layout="compact"] .dash-card-grid {
    grid-template-columns: repeat(3, 1fr) !important;
}
#main-content[data-layout="compact"] .dash-card {
    padding: 0.5rem !important;
    min-height: 80px !important;
}
#main-content[data-layout="compact"] .dash-card .card-icon {
    font-size: 16px !important;
}
#main-content[data-layout="compact"] .dash-card .card-title {
    font-size: 8px !important;
}
#main-content[data-layout="compact"] .dash-card .card-action {
    font-size: 7px !important;
    padding: 0.2rem 0.4rem !important;
}

/* ─── CUSTOM CARD DRAG & DROP ─── */
#card-sortable-list .sortable-ghost {
    opacity: 0.5;
    background: var(--border-color);
    border: 1px dashed var(--brand-orange);
}
#card-sortable-list .sortable-drag {
    opacity: 0.8;
    transform: scale(1.02);
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}
#card-sortable-list .card-item {
    transition: all 0.2s ease;
}
#card-sortable-list .card-item:active {
    cursor: grabbing;
}
.card-item input {
    background: transparent;
}
.card-item input:focus {
    background: var(--input-bg);
}