/* ================================================
   Your Study Partner — Modern Light Mode UI
   ================================================ */

/* ---- Google Fonts ---- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=Outfit:wght@400;500;600;700;800&display=swap');

:root {
    --bg: #F8FAFC;
    --bg-alt: #FFFFFF;
    --bg-muted: #F1F5F9;
    --bg-card: #FFFFFF;
    --bg-glass: rgba(255, 255, 255, 0.82);
    --text: #0F172A;
    --text-muted: #64748B;
    --text-light: #94A3B8;
    --border: #E2E8F0;
    --border-strong: #CBD5E1;
    --border-focus: #6366F1;
    --primary-50: #EEF2FF;
    --primary-100: #E0E7FF;
    --primary-200: #C7D2FE;
    --primary-400: #818CF8;
    --primary-500: #4F46E5;
    --primary-600: #4338CA;
    --primary-700: #3730A3;
    --accent-400: #FBBF24;
    --accent-500: #F59E0B;
    --accent-600: #D97706;
    --success-50: #ECFDF5;
    --success-500: #10B981;
    --danger-50: #FEF2F2;
    --danger-500: #EF4444;
    --warning-50: #FFFBEB;
    --warning-500: #F59E0B;
    --shadow-sm: 0 10px 20px rgba(15, 23, 42, 0.06);
    --shadow: 0 20px 40px rgba(15, 23, 42, 0.08);
    --shadow-md: 0 24px 45px rgba(15, 23, 42, 0.08);
    --shadow-lg: 0 30px 60px rgba(15, 23, 42, 0.1);
    --shadow-xl: 0 30px 70px rgba(15, 23, 42, 0.12);
    --radius-sm: 8px;
    --radius: 14px;
    --radius-md: 18px;
    --radius-lg: 28px;
    --radius-full: 9999px;
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-heading: 'Outfit', 'Inter', sans-serif;
    --ease: cubic-bezier(0.4, 0, 0.2, 1);
    --duration: 0.2s;
    --duration-md: 0.35s;
    --nav-height: 72px;
}

/* ================================================
   Reset & Base
   ================================================ */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-body);
    font-size: 1rem;
    line-height: 1.75;
    color: var(--text);
    background: radial-gradient(circle at top, rgba(79, 70, 229, 0.12), transparent 30%), linear-gradient(180deg, #F8FAFC 0%, #F1F5F9 100%);
    min-height: 100vh;
    padding-top: 0;
}

::selection {
    background: rgba(79, 70, 229, 0.16);
    color: var(--text);
}

a {
    color: var(--primary-600);
    text-decoration: none;
    transition: color var(--duration) var(--ease);
}
a:hover { color: var(--primary-700); }

img { max-width: 100%; display: block; }

button, input, textarea, select { font: inherit; }

@media (min-width: 861px) {
    body > main {
        padding-top: var(--nav-height);
    }
}

/* ================================================
   Typography
   ================================================ */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    font-weight: 700;
    line-height: 1.15;
    color: var(--text);
}
h1 { font-size: clamp(2.3rem, 4vw, 3.8rem); }
h2 { font-size: clamp(1.75rem, 3vw, 2.75rem); }
h3 { font-size: clamp(1.35rem, 2.5vw, 1.9rem); }
h4 { font-size: 1.1rem; }

p { margin-bottom: 1.15rem; color: var(--text-muted); }

.lead { font-size: 1.05rem; color: var(--text); }

.text-muted { color: var(--text-muted); }
.text-light { color: var(--text-light); }
.text-primary { color: var(--primary-600); }
.text-success { color: var(--success-500); }
.text-danger { color: var(--danger-500); }
.text-center { text-align: center; }
.text-sm { font-size: 0.9rem; }
.text-xs { font-size: 0.78rem; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }

/* ================================================
   Layout Utilities
   ================================================ */
.container {
    width: min(100%, 1280px);
    margin: 0 auto;
    padding: 0 1.5rem;
}

.container-sm { max-width: 640px; }
.container-md { max-width: 960px; }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.gap-3 { gap: 1.5rem; }
.gap-4 { gap: 2rem; }

.grid { display: grid; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

@media (max-width: 1024px) {
    .grid-4,
    .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
    .grid-4,
    .grid-3,
    .grid-2 { grid-template-columns: 1fr; }
}

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }
.mt-6 { margin-top: 3rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }
.mb-6 { margin-bottom: 3rem; }
.py-4 { padding: 2rem 0; }
.py-6 { padding: 3rem 0; }
.py-8 { padding: 4rem 0; }

.hidden { display: none !important; }
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border: 0;
}

/* ================================================
   Navbar
   ================================================ */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    height: var(--nav-height);
    width: 100%;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(18px);
    border-bottom: 1px solid rgba(148, 163, 184, 0.16);
}

.navbar .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-family: var(--font-heading);
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: -0.04em;
    color: var(--text);
}

.navbar-brand:hover { color: var(--text); }

.navbar-brand .brand-icon {
    width: 40px;
    height: 40px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, var(--primary-500), var(--primary-700));
    color: #fff;
    font-size: 1.1rem;
}

.navbar-brand .brand-logo {
    width: 38px;
    height: 38px;
    object-fit: cover;
    border-radius: 50%;
}

.navbar-links {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    list-style: none;
}

.navbar-links li { list-style: none; }

.navbar-links a {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-muted);
    transition: all var(--duration) var(--ease);
}

.navbar-links a:hover,
.navbar-links a.active {
    background: var(--primary-50);
    color: var(--primary-600);
}


.navbar-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* theme toggle removed — styles intentionally left blank */

.user-menu { position: relative; }

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, var(--primary-400), var(--primary-600));
    color: #fff;
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    transition: transform var(--duration) var(--ease), border-color var(--duration) var(--ease);
    border: 2px solid transparent;
}

.user-avatar:hover {
    transform: scale(1.05);
    border-color: rgba(79, 70, 229, 0.2);
}

.user-avatar img {
    width: 100%;
    height: 100%;
    border-radius: var(--radius-full);
    object-fit: cover;
}

.user-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: min(260px, 100vw - 2rem);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: 0.5rem;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px) scale(0.97);
    transition: all var(--duration) var(--ease);
    z-index: 100;
}

.admin-actions-dropdown {
    min-height: 240px;
}

.user-dropdown.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.user-dropdown a,
.user-dropdown button {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    width: 100%;
    padding: 0.75rem 0.85rem;
    border-radius: var(--radius-sm);
    background: none;
    border: none;
    color: var(--text);
    text-align: left;
    cursor: pointer;
    transition: background var(--duration) var(--ease);
}

.user-dropdown a:hover,
.user-dropdown button:hover {
    background: var(--bg-muted);
}

.user-dropdown .divider {
    height: 1px;
    background: var(--border);
    margin: 0.35rem 0;
}

.mobile-menu-btn {
    display: none;
    width: 42px;
    height: 42px;
    border: none;
    background: none;
    cursor: pointer;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

.mobile-menu-btn span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--text);
    border-radius: 999px;
    transition: all var(--duration) var(--ease);
}

.mobile-menu-btn.active span:nth-child(1) { transform: rotate(45deg) translate(5px, 5px); }
.mobile-menu-btn.active span:nth-child(2) { opacity: 0; }
.mobile-menu-btn.active span:nth-child(3) { transform: rotate(-45deg) translate(5px, -5px); }

@media (max-width: 860px) {
    :root {
        --nav-height: 64px;
        --mobile-gutter: 16px;
        --mobile-gap: 16px;
        --mobile-section: 24px;
    }

    html {
        overflow-x: hidden;
    }

    body {
        padding-top: calc(var(--nav-height) + env(safe-area-inset-top, 0px));
        overflow-x: hidden;
    }

    body.nav-open {
        overflow: hidden;
        touch-action: none;
    }

    body.nav-open::before {
        content: '';
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, 0.45);
        z-index: 998;
        pointer-events: none;
    }

    main {
        width: 100%;
        max-width: 100vw;
        overflow-x: clip;
        padding-top: 0;
    }

    .container {
        width: 100%;
        max-width: 100%;
        margin-inline: auto;
        padding-inline: max(var(--mobile-gutter), env(safe-area-inset-left, 0px)) max(var(--mobile-gutter), env(safe-area-inset-right, 0px));
        box-sizing: border-box;
    }

    .py-4 { padding-block: var(--mobile-section); }
    .py-6 { padding-block: calc(var(--mobile-section) + 8px); }
    .py-8 { padding-block: calc(var(--mobile-section) + 16px); }
    .mb-6 { margin-bottom: var(--mobile-section); }
    .mb-4 { margin-bottom: var(--mobile-gap); }

    .card {
        padding: 1.25rem;
        border-radius: var(--radius);
    }

    .page-header {
        padding-block: 0.5rem 0.25rem;
    }

    .page-header h1 {
        font-size: clamp(1.65rem, 6vw, 2rem);
    }

    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
        margin-bottom: 1rem;
    }

    .section-header h2 {
        font-size: 1.25rem;
    }
  /* —— Navbar (single-row app bar) —— */
    .navbar {
        background: #FFFFFF;
        border-bottom: 1px solid var(--border);
        backdrop-filter: none;
    }

    .navbar .container {
        flex-wrap: nowrap;
        align-items: center;
        gap: 0.5rem;
        height: var(--nav-height);
        padding-inline: max(var(--mobile-gutter), env(safe-area-inset-left, 0px)) max(var(--mobile-gutter), env(safe-area-inset-right, 0px));
    }

    .navbar-brand {
        flex: 1;
        min-width: 0;
        gap: 0.5rem;
        font-size: 1.1rem;
    }

    .navbar-brand .brand-name {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .navbar-brand .brand-logo {
        width: 34px;
        height: 34px;
        flex-shrink: 0;
    }

    .navbar-actions {
        width: auto;
        flex-shrink: 0;
        justify-content: flex-end;
        align-items: center;
        gap: 0.5rem;
    }

    .navbar-actions .btn-sm {
        padding: 0.45rem 0.95rem;
        font-size: 0.85rem;
        font-weight: 600;
        border-radius: 9999px;
    }

    .mobile-menu-btn {
        display: flex;
        background: transparent;
        border: none;
        padding: 0.4rem;
        min-width: 36px;
        min-height: 36px;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 5px;
    }

    .mobile-menu-btn span {
        background: var(--text);
        width: 22px;
        height: 2px;
        border-radius: 999px;
    }

    .mobile-menu-btn:hover {
        background: transparent;
    }
    .navbar-links {
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        left: auto;
        width: min(320px, 88vw);
        flex-direction: column;
        justify-content: flex-start;
        align-items: stretch;
        background: var(--bg-card);
        padding: calc(var(--nav-height) + 1rem) 1rem 1.5rem;
        gap: 0.5rem;
        transform: translateX(105%);
        transition: transform var(--duration-md) var(--ease);
        z-index: 999;
        box-shadow: -12px 0 40px rgba(15, 23, 42, 0.12);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        border-radius: 0;
    }

    .navbar-links::before {
        content: 'Menu';
        position: absolute;
        top: 1.25rem;
        left: 1rem;
        font-size: 1.1rem;
        font-weight: 700;
        color: var(--text);
    }

    .navbar-links::after {
        display: none;
    }

    .navbar-links.show {
        transform: translateX(0);
    }

    .navbar-links li {
        width: 100%;
    }

    .navbar-links a {
        display: flex;
        align-items: center;
        gap: 0.75rem;
        width: 100%;
        min-height: 48px;
        padding: 0.85rem 1rem;
        color: var(--text);
        background: var(--bg-muted);
        border-radius: 12px;
        font-size: 0.95rem;
        font-weight: 600;
        box-shadow: none;
        transition: background var(--duration) var(--ease);
    }

    .navbar-links a i {
        width: 22px;
        text-align: center;
        color: var(--primary-600);
    }

    .navbar-links a:hover {
        background: var(--primary-50);
        transform: none;
    }

    .navbar-links a.active {
        background: var(--primary-50);
        color: var(--primary-700);
    }

    .user-dropdown {
        right: 0;
        left: auto;
        width: min(280px, calc(100vw - 2 * var(--mobile-gutter)));
    }

  /* —— Hero & home —— */
    .hero-new {
        padding: 1.5rem 0 1rem;
        margin-top: calc(-1 * var(--nav-height) - env(safe-area-inset-top, 0px));
        padding-top: calc(1.5rem + var(--nav-height) + env(safe-area-inset-top, 0px));
    }

    .hero-new::before {
        display: none;
    }

    .hero-grid {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
        min-height: 0;
    }

    .hero-illustration {
        order: 1;
    }

    .hero-content {
        order: 2;
        align-items: center;
        text-align: center;
        gap: 0.75rem;
    }

    .hero-title {
        font-size: clamp(1.6rem, 7vw, 2.2rem);
        text-align: center;
    }

    .hero-description {
        text-align: center;
        max-width: 100%;
        font-size: 0.9rem;
        line-height: 1.55;
    }

    .hero-cta {
        display: grid;
        grid-template-columns: 1fr;
        gap: 0.65rem;
        width: 100%;
        max-width: 100%;
        margin: 0 auto;
    }

    .hero-btn-primary,
    .hero-btn-secondary {
        padding: 0.8rem 0.5rem;
        font-size: 0.9rem;
        width: 100%;
        text-align: center;
        justify-content: center;
        border-radius: 12px;
    }

    .hero-btn-primary {
        box-shadow: 0 4px 12px rgba(79, 70, 229, 0.2);
    }

    .hero-btn-primary:hover {
        transform: none;
    }

    .hero-btn-secondary:hover {
        transform: none;
    }

    .hero-illustration-wrapper {
        max-width: 240px;
        margin: 0 auto;
    }

    .features-section {
        padding: 0.5rem 0 0.25rem;
    }

    .features-grid {
        grid-template-columns: 1fr 1fr;
        gap: 0.75rem;
    }

    .feature-card {
        padding: 1rem 0.75rem;
        border-radius: 14px;
    }

    .feature-card-icon {
        width: 40px;
        height: 40px;
        border-radius: 10px;
        font-size: 0.95rem;
        margin-bottom: 0.5rem;
    }

    .feature-card h3 {
        font-size: 0.88rem;
        margin-bottom: 0.25rem;
    }

    .feature-card p {
        font-size: 0.75rem;
        line-height: 1.4;
    }

    .hero-cta-short { display: inline; }
    .hero-cta-full { display: none; }

    .stats-bar {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.65rem;
        padding: 1rem 0;
    }

    .stat-item {
        padding: 0.85rem 0.5rem;
    }

    .stat-number {
        font-size: 1.5rem;
    }

    .stat-label {
        font-size: 0.78rem;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 0.15rem;
    }

    .stat-label i {
        font-size: 0.9rem;
    }

  /* —— Subject & resource cards —— */
    .subject-grid {
        grid-template-columns: 1fr;
        gap: var(--mobile-gap);
    }

    .subject-card {
        flex-direction: row;
        align-items: center;
        gap: 0.75rem;
        padding: 0.85rem 0.75rem;
        min-height: 0;
        text-align: left;
    }

    .subject-card .subject-info {
        flex: 1;
        min-width: 0;
    }

    .subject-card .subject-info h4 {
        font-size: 0.95rem;
        white-space: normal;
        word-break: break-word;
    }

    .subject-icon {
        width: 52px;
        height: 52px;
        border-radius: 12px;
        font-size: 1.05rem;
    }

    .resource-list {
        gap: var(--mobile-gap);
    }

    .resource-card {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
        padding: 1rem;
    }

    .resource-actions {
        width: 100%;
    }

    .resource-actions .btn {
        width: 100%;
        justify-content: center;
    }

  /* —— Accordion (chapters on mobile) —— */
    .accordion-header {
        padding: 0.85rem 1rem;
        min-height: 52px;
        font-size: 0.9rem;
    }

    .accordion-body-inner {
        padding: 0 1rem 0.85rem;
    }

  /* —— Subject detail header (icon shrinks on mobile) —— */
    .subject-detail-icon {
        width: 56px;
        height: 56px;
        font-size: 1.5rem;
    }

  /* —— Chapter page header —— */
    .chapter-title {
        font-size: 1.35rem;
    }

    .chapter-badges .badge {
        font-size: 0.68rem;
        padding: 0.2rem 0.6rem;
    }

    .chapter-header-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

  /* —— Tabs, forms, filters —— */
    .tabs {
        margin-bottom: 1rem;
        gap: 0;
        padding-bottom: 2px;
        -webkit-overflow-scrolling: touch;
    }

    .tab-btn {
        padding: 0.75rem 1rem;
        min-width: auto;
        flex-shrink: 0;
        font-size: 0.88rem;
    }

    .class-tabs {
        width: 100%;
        max-width: 100%;
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        border-radius: var(--radius);
        padding: 0.25rem;
    }

    .class-tab {
        padding: 0.75rem 0.5rem;
        font-size: 0.88rem;
        text-align: center;
        justify-content: center;
        min-height: 44px;
        display: flex;
        align-items: center;
    }

    .form-input,
    .form-select,
    .form-textarea {
        font-size: 16px;
        min-height: 48px;
    }

    .search-panel {
        padding: 1rem;
        margin-bottom: 1rem;
        border-radius: var(--radius);
    }

    .search-bar {
        gap: 0.5rem;
        margin-bottom: 1rem;
    }

    .search-field .form-input {
        min-height: 42px;
        padding: 0.65rem 0.75rem 0.65rem 2.35rem;
        font-size: 16px;
        border-radius: 10px;
    }

    .search-field i {
        left: 0.75rem;
        font-size: 0.9rem;
    }

    .search-submit {
        min-height: 42px;
        padding: 0 0.75rem;
        font-size: 0.8rem;
        border-radius: 10px;
    }

    .search-filter-row {
        width: 100%;
    }

    .search-filter-chips {
        gap: 0.4rem;
    }

    .filter-chip {
        padding: 0.35rem 0.7rem;
        font-size: 0.78rem;
    }

    .empty-state {
        padding: 2rem 1rem;
    }

    .empty-state .empty-icon {
        font-size: 2.2rem;
        margin-bottom: 0.75rem;
    }

    .empty-state h3 {
        font-size: 1.1rem;
    }

    .empty-state p {
        font-size: 0.88rem;
    }

    .search-page .empty-state {
        padding: 2rem 0.5rem;
    }

    .upload-card {
        margin: 0;
        padding: 1.25rem;
    }

    .upload-form .field-grid,
    .upload-form .upload-meta {
        grid-template-columns: 1fr;
    }

    .upload-form .upload-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .upload-form .upload-actions .btn {
        width: 100%;
    }

  /* —— Profile & community —— */
    .profile-header {
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: 1rem;
        margin-bottom: 1.5rem;
    }

    .profile-header > div[style*="text-align: right"] {
        text-align: center !important;
        width: 100%;
    }

    .community-feed {
        max-width: 100%;
    }

    .community-toolbar {
        padding: 1rem !important;
    }

    .community-post-creator,
    .community-post-meta,
    .community-toolbar-inner {
        grid-template-columns: 1fr;
    }

    .community-post-actions {
        flex-direction: column;
        gap: 0.5rem;
    }

    .community-post-actions .btn {
        width: 100%;
        justify-content: center;
    }

    .community-post-header {
        flex-direction: column;
        align-items: stretch;
    }

    .community-post-body {
        padding: 0 1rem 1rem;
    }

  /* —— Admin —— */
    .admin-layout {
        display: block;
        width: 100%;
        max-width: 100%;
        margin-inline: auto;
        overflow-x: hidden;
        box-sizing: border-box;
    }

    .admin-content {
        width: 100%;
        max-width: 100%;
        margin-inline: auto;
        padding: var(--mobile-gutter);
        box-sizing: border-box;
        overflow-x: hidden;
    }

    .admin-content .section-header,
    .admin-content .grid-4,
    .admin-content .grid-3,
    .admin-content .grid-2,
    .admin-content .card {
        width: 100%;
        max-width: 100%;
        margin-inline: auto;
        box-sizing: border-box;
    }

    .admin-stat-card {
        width: 100%;
        max-width: 100%;
        padding: 1rem;
    }

    .admin-toolbar {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
        width: 100%;
    }

    .admin-toolbar-field,
    .admin-toolbar-field--grow,
    .admin-toolbar-actions {
        width: 100%;
        min-width: 0;
    }

    .admin-toolbar .form-input,
    .admin-toolbar .form-select,
    .admin-toolbar .btn {
        width: 100%;
        min-width: 0;
        box-sizing: border-box;
    }

    .admin-toolbar-actions {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
    }

    .admin-users-desktop {
        display: none !important;
    }

    .admin-users-mobile {
        display: flex;
        flex-direction: column;
        gap: 0.65rem;
        width: 100%;
    }

    .admin-user-card__menu .user-dropdown {
        right: 0;
        left: auto;
        width: min(260px, calc(100vw - 2 * var(--mobile-gutter) - 1.5rem));
    }

    .admin-table-card {
        padding: 0.75rem !important;
        overflow: visible !important;
    }

    .admin-table-wrap {
        width: 100%;
        max-width: 100%;
        overflow: visible;
    }

    .data-table--mobile-stack {
        display: block;
        width: 100%;
        min-width: 0;
    }

    .data-table--mobile-stack thead {
        display: none;
    }

    .data-table--mobile-stack tbody {
        display: block;
        width: 100%;
    }

    .data-table--mobile-stack tbody tr {
        display: block;
        width: 100%;
        background: var(--bg-alt);
        border: 1px solid var(--border);
        border-radius: var(--radius);
        margin-bottom: 0.75rem;
        padding: 0.85rem;
        box-sizing: border-box;
    }

    .data-table--mobile-stack tbody tr:hover {
        background: var(--bg-alt);
    }

    .data-table--mobile-stack tbody td {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 0.75rem;
        width: 100%;
        min-width: 0;
        padding: 0.45rem 0;
        border: none;
        border-bottom: 1px solid var(--border);
        text-align: right;
        box-sizing: border-box;
        font-size: 0.85rem;
    }

    .data-table--mobile-stack tbody td:last-child {
        border-bottom: none;
        padding-top: 0.5rem;
        justify-content: flex-end;
    }

    .data-table--mobile-stack tbody td::before {
        content: attr(data-label);
        font-size: 0.7rem;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        color: var(--text-muted);
        text-align: left;
        flex-shrink: 0;
    }

    .data-table--mobile-stack tbody td.admin-user-cell,
    .data-table--mobile-stack tbody td.admin-primary-cell {
        display: block;
        border-bottom: 1px solid var(--border);
        padding-bottom: 0.65rem;
        margin-bottom: 0.15rem;
        text-align: left;
    }

    .data-table--mobile-stack tbody td.admin-user-cell::before,
    .data-table--mobile-stack tbody td.admin-primary-cell::before {
        display: none;
    }

    .data-table--mobile-stack .admin-user-cell .font-medium,
    .data-table--mobile-stack .admin-user-cell .text-xs,
    .data-table--mobile-stack .admin-primary-cell .font-medium,
    .data-table--mobile-stack .admin-primary-cell .text-xs {
        white-space: normal;
        word-break: break-word;
        overflow: visible;
        text-overflow: unset;
    }

    .data-table--mobile-stack .admin-user-cell > div,
    .data-table--mobile-stack .admin-primary-cell > div {
        width: 100%;
        min-width: 0;
    }

    .data-table--mobile-stack .admin-table-actions > div {
        flex-wrap: wrap;
        justify-content: flex-end;
    }

    .data-table--mobile-stack tbody td[colspan] {
        display: block;
        text-align: center;
    }

    .data-table--mobile-stack tbody td[colspan]::before {
        display: none;
    }

  /* —— Admin subjects mobile fixes —— */
    .admin-subject-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
        padding: 0.75rem;
    }

    .admin-subject-badges {
        width: 100%;
        justify-content: flex-start;
    }

    .admin-edit-form {
        flex-direction: row;
        flex-wrap: nowrap;
        width: 100%;
    }

    .admin-edit-form .form-input {
        font-size: 0.88rem;
        padding: 0.5rem 0.65rem;
        min-height: 40px;
    }

    .admin-edit-form .btn {
        min-width: 40px;
        min-height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .admin-order-group .btn {
        min-width: 40px;
        min-height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .admin-add-chapter-form {
        flex-wrap: nowrap;
    }

    .admin-add-chapter-form .form-input {
        font-size: 0.88rem;
        padding: 0.5rem 0.65rem;
        min-height: 40px;
    }

    .admin-add-chapter-form .btn {
        min-height: 40px;
    }

    .admin-actions-cell {
        justify-content: space-between !important;
    }

    .admin-actions-cell .btn {
        min-height: 40px;
        display: inline-flex;
        align-items: center;
        gap: 0.4rem;
    }

    .delete-text {
        display: inline;
    }

  /* —— Footer & misc —— */
    .site-footer {
        padding-block: 2rem 1.5rem;
    }

    .site-footer .container {
        padding-inline: var(--mobile-gutter);
    }

    .footer-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .footer-bottom {
        flex-direction: column;
        align-items: center;
        justify-content: center;
        text-align: center;
        gap: 0.5rem;
        width: 100%;
    }

    .footer-bottom span {
        width: 100%;
    }

    .toast-container {
        left: var(--mobile-gutter);
        right: var(--mobile-gutter);
        top: calc(var(--nav-height) + 0.75rem);
    }

    .toast {
        min-width: 0;
        max-width: 100%;
        width: 100%;
    }

    .auth-page {
        padding: var(--mobile-gutter);
        min-height: calc(100dvh - var(--nav-height));
    }

    .auth-card {
        padding: 1.5rem;
        max-width: 100%;
        border-radius: var(--radius-md);
    }

    .modal {
        max-width: calc(100vw - 2 * var(--mobile-gutter));
        margin: 0 auto;
    }

    .modal-footer {
        flex-direction: column;
        align-items: stretch;
    }

    .modal-footer .btn {
        width: 100%;
    }

    .pagination {
        flex-wrap: wrap;
    }

    .breadcrumb {
        font-size: 0.85rem;
        margin-bottom: 0.75rem;
    }
}

/* ================================================
   Mobile: < 768px — Landing page redesign
   ================================================ */
@media (max-width: 767px) {
    :root {
        --nav-height: 56px;
    }

  /* —— Navbar —— */
    .navbar {
        background: #fff;
        border-bottom: 1px solid #e2e8f0;
    }

    .navbar .container {
        height: 56px;
        gap: 0.5rem;
        padding-inline: 16px;
    }

    .navbar-brand {
        gap: 0.4rem;
        font-size: 0.95rem;
    }

    .navbar-brand .brand-logo {
        width: 32px;
        height: 32px;
    }

    .navbar-brand .brand-name {
        font-size: 1rem;
        font-weight: 800;
        line-height: 1.1;
    }

    .navbar-actions {
        gap: 0.4rem;
        align-items: center;
    }

    /* Log In button — outlined pill */
    .navbar-actions .btn-secondary.btn-sm {
        padding: 0.4rem 0.9rem;
        font-size: 0.82rem;
        font-weight: 600;
        border-radius: 9999px !important;
        border: 1.5px solid var(--border-strong);
        background: transparent;
        color: var(--text);
    }

    /* Sign Up button — filled purple pill */
    .navbar-actions .btn-primary.btn-sm {
        padding: 0.4rem 0.9rem;
        font-size: 0.82rem;
        font-weight: 600;
        border-radius: 9999px !important;
        background: var(--primary-500);
        color: #fff;
    }

    /* Hamburger — plain lines */
    .mobile-menu-btn {
        display: flex;
        background: transparent;
        border: none;
        padding: 0.4rem;
        min-width: 36px;
        min-height: 36px;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 5px;
    }

    .mobile-menu-btn span {
        background: var(--text);
        width: 20px;
        height: 2px;
        border-radius: 999px;
        display: block;
    }

  /* —— Hero —— */
    .hero-new {
        background: #eef2ff;
        padding: 1.5rem 0 2rem;
        margin-bottom: 0;
    }

    .hero-new::before {
        display: none;
    }

    /* Stack: illustration → text → buttons */
    .hero-grid {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 0;
        width: 100%;
    }

    /* Illustration on top */
    .hero-illustration {
        order: 1;
        width: 100%;
        display: flex;
        justify-content: center;
        align-items: center;
        margin-bottom: 0.5rem;
    }

    .hero-illustration-wrapper {
        max-width: 260px;
        width: 100%;
        margin: 0 auto;
        animation: heroFloat 3s ease-in-out infinite;
    }

    /* Text block below illustration */
    .hero-content {
        order: 2;
        display: flex;
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: 0.75rem;
        width: 100%;
        padding: 0 4px;
    }

    .hero-title {
        font-size: clamp(1.9rem, 8vw, 2.4rem);
        line-height: 1.15;
        font-weight: 800;
        text-align: center;
        letter-spacing: -0.025em;
        color: #0f172a;
    }

    .hero-description {
        font-size: 0.93rem;
        line-height: 1.7;
        text-align: center;
        color: var(--text-muted);
        max-width: 100%;
        margin: 0;
    }

    /* CTA buttons below text */
    .hero-cta {
        order: 3;
        display: flex;
        flex-direction: column;
        gap: 0.7rem;
        width: 100%;
        margin-top: 1rem;
        align-items: stretch;
    }

    .hero-btn-primary,
    .hero-btn-secondary {
        width: 100%;
        height: 52px;
        padding: 0 1.25rem;
        font-size: 0.97rem;
        font-weight: 600;
        border-radius: 14px !important;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 0.6rem;
    }

    .hero-btn-primary {
        background: var(--primary-500);
        color: #fff;
        box-shadow: 0 6px 20px rgba(79, 70, 229, 0.28);
    }

    .hero-btn-secondary {
        background: #fff;
        color: var(--text);
        border: 1.5px solid var(--border-strong);
        box-shadow: none;
    }

    .hero-btn-primary:hover,
    .hero-btn-secondary:hover {
        transform: none;
    }

  /* —— Feature Cards (2×2 grid) —— */
    .features-section {
        background: #eef2ff;
        padding: 0 0 1.5rem;
    }

    .features-grid {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.75rem;
    }

    .feature-card {
        background: #fff;
        border: 1px solid #e2e8f0;
        box-shadow: 0 2px 12px rgba(79, 70, 229, 0.05);
        padding: 1rem 0.85rem;
        border-radius: 16px;
        display: flex;
        flex-direction: column;
        align-items: center;
        text-align: center;
        transition: none;
    }

    .feature-card:hover {
        transform: none;
        box-shadow: 0 2px 12px rgba(79, 70, 229, 0.05);
    }

    .feature-card-icon {
        width: 42px;
        height: 42px;
        border-radius: 12px;
        font-size: 1rem;
        margin-bottom: 0.6rem;
        display: grid;
        place-items: center;
        background: rgba(79, 70, 229, 0.1) !important;
        color: #4f46e5 !important;
    }

    .feature-card h3 {
        font-size: 0.92rem;
        font-weight: 700;
        color: var(--text);
        margin-bottom: 0.2rem;
        line-height: 1.2;
    }

    .feature-card p {
        font-size: 0.78rem;
        line-height: 1.45;
        color: var(--text-muted);
        margin: 0;
    }

  /* —— Stats Bar (single row, 4 cols, flat) —— */
    .stats-bar {
        display: grid !important;
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 0 !important;
        padding: 1.25rem 0 !important;
        margin: 0;
        background: transparent !important;
        border-top: 1.5px solid #e2e8f0;
        border-bottom: none;
        border-radius: 0 !important;
        box-shadow: none !important;
    }

    .stat-item {
        background: transparent !important;
        border: none !important;
        box-shadow: none !important;
        padding: 0.4rem 0.15rem !important;
        text-align: center !important;
        position: relative;
        border-radius: 0 !important;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        transition: none;
    }

    .stat-item:hover {
        transform: none;
        box-shadow: none;
    }

    /* Vertical divider between stat items */
    .stat-item:not(:last-child)::after {
        content: '';
        position: absolute;
        right: 0;
        top: 15%;
        height: 70%;
        width: 1px;
        background: #e2e8f0;
    }

    .stat-number {
        font-size: 1.6rem !important;
        font-weight: 800 !important;
        color: var(--primary-500) !important;
        margin-bottom: 0.15rem;
        line-height: 1;
        font-family: var(--font-heading);
    }

    .stat-label {
        font-size: 0.68rem !important;
        color: var(--text-muted) !important;
        font-weight: 500;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 0.15rem !important;
        line-height: 1.3;
        text-align: center;
        white-space: normal;
    }

    .stat-label i {
        font-size: 0.72rem !important;
        color: var(--text-muted);
        display: block;
    }

  /* —— Subject grid —— */
    .subject-grid {
        gap: 0.75rem;
    }

    .subject-card {
        gap: 0.75rem;
        padding: 0.75rem;
        border-radius: 12px;
    }

    .subject-icon {
        width: 44px;
        height: 44px;
        font-size: 0.95rem;
    }

    .subject-card .subject-info h4 {
        font-size: 0.9rem;
    }

  /* —— Resource cards —— */
    .resource-card {
        padding: 0.85rem;
        border-radius: 12px;
        gap: 0.6rem;
    }

    .resource-title {
        font-size: 0.9rem;
    }

    .resource-meta {
        font-size: 0.75rem;
        gap: 0.4rem;
        flex-wrap: wrap;
    }

  /* —— Section headers —— */
    .section-header {
        margin-bottom: 0.75rem;
    }

    .section-header h2 {
        font-size: 1.15rem;
    }

  /* —— Bottom CTA —— */
    .hero-cta-landing {
        padding: 2rem 0 1.5rem;
        margin-top: 1rem;
    }

    .hero-cta-landing__copy {
        padding: 1.25rem 1rem;
    }

    .hero-cta-landing h2 {
        font-size: clamp(1.5rem, 6vw, 2rem);
        margin-bottom: 0.5rem;
    }

    .hero-cta-landing p {
        font-size: 0.9rem;
        line-height: 1.6;
        margin-bottom: 1.25rem;
    }

    .hero-cta-landing-actions {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }

    .hero-cta-landing__button-primary,
    .hero-cta-landing__button-secondary {
        width: 100%;
        padding: 0.85rem;
        font-size: 0.95rem;
    }

  /* —— Utility spacing overrides —— */
    .py-4 { padding-block: 1rem; }
    .py-6 { padding-block: 1.5rem; }
    .mb-6 { margin-bottom: 1rem; }
}

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

/* ================================================
   Buttons
   ================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.8rem 1.45rem;
    font-family: var(--font-body);
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.3;
    border-radius: var(--radius);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all var(--duration) var(--ease);
    text-decoration: none;
    position: relative;
    overflow: hidden;
}

.btn:hover { transform: translateY(-1px); }

.btn-primary {
    background: linear-gradient(135deg, var(--primary-500), var(--primary-600));
    color: #fff;
    box-shadow: 0 14px 30px rgba(79, 70, 229, 0.18);
}

.btn-primary:hover { box-shadow: 0 18px 34px rgba(79, 70, 229, 0.22); }

.btn-secondary {
    background: var(--bg-alt);
    color: var(--text);
    border-color: var(--border);
}

.btn-secondary:hover {
    border-color: var(--primary-400);
    color: var(--primary-600);
    background: var(--primary-50);
}

.btn-accent {
    background: linear-gradient(135deg, var(--accent-400), var(--accent-600));
    color: #111827;
}

.btn-danger {
    background: var(--danger-500);
    color: #fff;
}

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
}

.btn-ghost:hover {
    background: var(--bg-muted);
    color: var(--text);
}

.btn-sm { padding: 0.55rem 1rem; font-size: 0.85rem; }
.btn-lg { padding: 1rem 1.8rem; font-size: 1rem; }
.btn-icon { width: 42px; height: 42px; padding: 0; border-radius: var(--radius-full); }
.btn-icon.btn-sm { width: 34px; height: 34px; }

/* ================================================
   Landing CTA Section (bottom hero)
   ================================================ */
.hero-cta-landing {
    background: linear-gradient(135deg, #312E81, #4338CA);
    color: #fff;
    padding: 4rem 0 3rem;
    margin-top: 2rem;
}

.hero-cta-landing__inner {
    display: grid;
    place-items: center;
    text-align: center;
    min-height: 320px;
}

@media (max-width: 860px) {
    .hero-cta-landing__inner {
        min-height: 0;
    }
}

.hero-cta-landing__copy {
    max-width: 760px;
    padding: 1rem 1.25rem;
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: var(--radius-lg);
    background: rgba(255,255,255,0.08);
    box-shadow: 0 32px 80px rgba(15, 23, 42, 0.24);
}

.hero-cta-landing h2 {
    font-size: clamp(2.5rem, 3.8vw, 3.8rem);
    margin-bottom: 1rem;
    letter-spacing: -0.03em;
    color: #ffffff;
}

.hero-cta-landing p {
    color: rgba(255,255,255,0.88);
    font-size: 1.05rem;
    line-height: 1.8;
    margin: 0 auto 1.75rem;
    max-width: 680px;
}

.hero-cta-landing-actions {
    display: inline-flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1rem;
    width: 100%;
}

.hero-cta-landing__button-primary {
    background: linear-gradient(135deg, #F59E0B, #D97706);
    color: #111827;
    box-shadow: 0 22px 42px rgba(20, 20, 70, 0.18);
}

.hero-cta-landing__button-primary:hover {
    background: linear-gradient(135deg, #FBBF24, #EA580C);
}

/* ================================================
   Mock Test UI
   ================================================ */
.test-list {
    display: grid;
    gap: 1.5rem;
}
.test-card {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--bg-card);
    box-shadow: var(--shadow-sm);
    padding: 1.5rem;
}
.test-card:hover {
    transform: translateY(-2px);
}
.test-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    flex-wrap: wrap;
}
.test-card-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}
.test-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    color: var(--text-muted);
    font-size: 0.92rem;
}
.timer-panel {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 1rem;
    align-items: center;
    margin-bottom: 1.5rem;
    padding: 1.1rem 1.25rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-muted);
}
.timer-box {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    border-radius: var(--radius-md);
    background: rgba(79, 70, 229, 0.1);
    color: var(--primary-700);
    font-weight: 700;
    min-width: 180px;
    justify-content: center;
}
.test-questions {
    display: grid;
    gap: 1.5rem;
}
.question-card {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.2rem 1.25rem;
    background: var(--bg-card);
}
.question-card h3 {
    margin-bottom: 1rem;
    font-size: 1rem;
}
.community-list {
    display: grid;
    gap: 1.5rem;
}
.community-card {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.4rem;
    background: var(--bg-card);
    transition: transform var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
}
.community-card:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}
.post-meta {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 1rem;
    color: var(--text-muted);
    font-size: 0.95rem;
}
.comment-card {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1.2rem 1.25rem;
    background: var(--bg-alt);
    margin-bottom: 1rem;
}
.option-group {
    display: grid;
    gap: 0.9rem;
    margin-top: 1rem;
}
.option-item {
    padding: 0.95rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    cursor: pointer;
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.9rem;
    align-items: center;
    transition: background var(--duration) var(--ease), border-color var(--duration) var(--ease);
}
.option-item:hover {
    background: var(--bg-muted);
    border-color: var(--primary-200);
}
.option-item input {
    accent-color: var(--primary-600);
}
.option-label {
    display: block;
    width: 100%;
    font-weight: 500;
}
.result-summary {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    background: var(--bg-card);
}
.result-summary h2 {
    margin-bottom: 0.75rem;
}
.result-score {
    font-size: 2.4rem;
    margin: 0.35rem 0;
    color: var(--primary-700);
}
.result-breakdown {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-top: 1rem;
}
.result-chip {
    background: var(--bg-muted);
    border-radius: var(--radius-full);
    padding: 0.75rem 1rem;
    font-weight: 600;
}
.test-notice {
    margin: 1.5rem 0;
    padding: 1.15rem 1.25rem;
    background: rgba(79, 70, 229, 0.08);
    border: 1px solid rgba(79, 70, 229, 0.15);
    border-radius: var(--radius-md);
    color: var(--text);
}
.test-management {
    display: grid;
    gap: 1.5rem;
}
.mock-form-card {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    background: var(--bg-card);
}
.mock-form-card label {
    display: block;
    margin-bottom: 0.65rem;
    font-weight: 600;
    color: var(--text);
}
.mock-form-card input,
.mock-form-card select,
.mock-form-card textarea {
    width: 100%;
    padding: 0.9rem 1rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: var(--bg-alt);
    margin-bottom: 1rem;
    color: var(--text);
}
.mock-form-card textarea { min-height: 140px; resize: vertical; }
.mock-flag {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}
.mock-test-tabs {
    display: grid;
    gap: 1rem;
}
.mock-test-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}
.mock-test-row .btn {
    flex-shrink: 0;
}
@media (max-width: 768px) {
    .timer-panel { grid-template-columns: 1fr; }
}

.hero-cta-landing__button-secondary {
    background: rgba(255,255,255,0.14);
    color: #ffffff;
    border: 1px solid rgba(255,255,255,0.22);
    backdrop-filter: blur(14px);
}

.hero-cta-landing__button-secondary:hover {
    background: rgba(255,255,255,0.22);
}

@media (max-width: 900px) {
    .hero-cta-landing {
        padding: 2.5rem 0 1.5rem;
        margin-top: 1rem;
    }
    .hero-cta-landing__copy {
        padding: 1rem 1.25rem;
        border-radius: var(--radius);
    }
    .hero-cta-landing h2 {
        font-size: clamp(1.6rem, 5vw, 2.2rem);
        margin-bottom: 0.5rem;
    }
    .hero-cta-landing p {
        font-size: 0.92rem;
        line-height: 1.6;
        margin-bottom: 1.25rem;
    }
    .hero-cta-landing-actions {
        flex-direction: column;
        align-items: stretch;
        gap: 0.65rem;
    }
    .hero-cta-landing__button-primary,
    .hero-cta-landing__button-secondary {
        width: 100%;
        padding: 0.8rem;
        font-size: 0.9rem;
    }
}

@media (max-width: 560px) {
    .hero-cta-landing {
        padding: 2.5rem 0 1.5rem;
    }
    .hero-cta-landing__copy {
        border-radius: 22px;
    }
    .hero-cta-landing p {
        font-size: 1rem;
    }
}

/* ================================================
   Cards
   ================================================ */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1.75rem;
    transition: all var(--duration-md) var(--ease);
}

.card:hover { box-shadow: var(--shadow); }

.card-glass {
    background: var(--bg-glass);
    backdrop-filter: blur(18px);
    border: 1px solid rgba(226, 232, 240, 0.55);
}

.card-hover:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.card-gradient {
    position: relative;
    overflow: hidden;
}
.card-gradient::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary-500), var(--accent-500));
}

/* ================================================
   Forms
   ================================================ */
.form-group { margin-bottom: 1.35rem; }

.form-label {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.45rem;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 0.95rem 1rem;
    font-family: var(--font-body);
    font-size: 0.95rem;
    color: var(--text);
    background: var(--bg-alt);
    border: 1.3px solid var(--border);
    border-radius: var(--radius);
    transition: all var(--duration) var(--ease);
    outline: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.12);
}

.form-input::placeholder { color: var(--text-light); }

.form-textarea { resize: vertical; min-height: 120px; }

.form-error { font-size: 0.82rem; color: var(--danger-500); margin-top: 0.35rem; }
.form-hint { font-size: 0.82rem; color: var(--text-muted); margin-top: 0.35rem; }

.form-floating { position: relative; }
.form-floating .form-input { padding-top: 1.5rem; padding-bottom: 0.5rem; }

.form-floating .form-label {
    position: absolute;
    top: 50%;
    left: 1rem;
    transform: translateY(-50%);
    font-weight: 400;
    color: var(--text-light);
    pointer-events: none;
    transition: all var(--duration) var(--ease);
    margin: 0;
}

.form-floating .form-input:focus ~ .form-label,
.form-floating .form-input:not(:placeholder-shown) ~ .form-label {
    top: 0.65rem;
    transform: translateY(0);
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--primary-600);
}

.password-strength {
    height: 4px;
    border-radius: 999px;
    background: var(--border);
    margin-top: 0.5rem;
    overflow: hidden;
}
.password-strength-bar {
    height: 100%;
    width: 0;
    border-radius: 999px;
    transition: width 0.3s ease;
}
.password-strength-bar.weak { width: 33%; background: var(--danger-500); }
.password-strength-bar.medium { width: 66%; background: var(--warning-500); }
.password-strength-bar.strong { width: 100%; background: var(--success-500); }

/* ================================================
   Badges
   ================================================ */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.3rem 0.75rem;
    font-size: 0.72rem;
    font-weight: 700;
    border-radius: var(--radius-full);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.badge-primary { background: var(--primary-100); color: var(--primary-700); }
.badge-success { background: var(--success-50); color: var(--success-500); }
.badge-warning { background: var(--warning-50); color: var(--accent-600); }
.badge-danger { background: var(--danger-50); color: var(--danger-500); }
.badge-neutral { background: var(--bg-muted); color: var(--text-muted); }

/* ================================================
   Hero
   ================================================ */
/* ================================================
   Hero Section — New Design
   ================================================ */
.hero-new {
    position: relative;
    padding: 5rem 0 3rem;
    margin-top: calc(-1 * var(--nav-height));
    background: linear-gradient(135deg, #f8fafc 0%, #eef2ff 50%, #f8fafc 100%);
    overflow: hidden;
}

.hero-new::before {
    content: '';
    position: absolute;
    top: -200px;
    right: -200px;
    width: 500px;
    height: 500px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(79, 70, 229, 0.08), transparent 70%);
    pointer-events: none;
}
.hero-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 3rem;
    align-items: center;
}

.hero-content {
    flex: 1;
    min-width: 300px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 1.5rem;
    order: 1;
}

.hero-cta {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 0.5rem;
    order: 3;
    max-width: 360px;
}

.hero-title {
    font-family: var(--font-heading);
    font-size: clamp(2.2rem, 4.5vw, 3.4rem);
    font-weight: 800;
    line-height: 1.15;
    letter-spacing: -0.03em;
    color: var(--text);
}

.hero-title-accent {
    color: var(--primary-500);
}

.hero-description {
    font-size: clamp(1rem, 1.3vw, 1.15rem);
    color: var(--text-muted);
    line-height: 1.7;
    max-width: 520px;
    margin: 0;
}

.hero-cta {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 0.5rem;
    max-width: 360px;
}

.hero-btn-primary {
    padding: 0.85rem 2rem;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(79, 70, 229, 0.25);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.hero-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 32px rgba(79, 70, 229, 0.35);
}

.hero-btn-secondary {
    padding: 0.85rem 2rem;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 12px;
    background: var(--bg-card);
    border: 2px solid var(--border);
    color: var(--text);
    transition: transform 0.25s ease, border-color 0.25s ease;
}

.hero-btn-secondary:hover {
    transform: translateY(-2px);
    border-color: var(--primary-400);
    background: var(--bg-card);
    color: var(--text);
}

/* Hero Illustration */
.hero-illustration {
    display: flex;
    justify-content: center;
    align-items: center;
    flex: 1;
    min-width: 300px;
    order: 2;
}

.hero-illustration-wrapper {
    max-width: 420px;
    width: 100%;
}

.hero-svg {
    width: 100%;
    height: auto;
}

.float-icon {
    animation: float 3s ease-in-out infinite;
}

.float-1 { animation-delay: 0s; }
.float-2 { animation-delay: 0.8s; }
.float-3 { animation-delay: 1.6s; }
.float-4 { animation-delay: 2.4s; }

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

.hero-cta-short { display: none; }
.hero-cta-full { display: inline; }

/* ================================================
   Features Section
   ================================================ */
.features-section {
    padding: 3rem 0 2rem;
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
}

.feature-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 2rem 1.5rem;
    text-align: center;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.feature-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 20px 40px rgba(79, 70, 229, 0.08);
}

.feature-card-icon {
    width: 56px;
    height: 56px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
    margin: 0 auto 1.25rem;
    transition: transform 0.3s ease;
}

.feature-card:hover .feature-card-icon {
    transform: scale(1.1);
}

.feature-card h3 {
    font-family: var(--font-heading);
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 0.5rem;
}

.feature-card p {
    font-size: 0.88rem;
    color: var(--text-muted);
    line-height: 1.55;
    margin: 0;
}

/* ================================================
   Stats Bar
   ================================================ */
.stats-bar {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1.5rem;
    padding: 3rem 0;
}
@media (max-width: 768px) { .stats-bar { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 540px) { .stats-bar { grid-template-columns: 1fr; } }

.stat-item {
    text-align: center;
    padding: 1.75rem 1.25rem;
    border-radius: var(--radius-md);
    background: var(--bg-card);
    border: 1px solid var(--border);
    transition: transform var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
}
.stat-item:hover { transform: translateY(-3px); box-shadow: var(--shadow-sm); }

.stat-number {
    font-family: var(--font-heading);
    font-size: 2.25rem;
    font-weight: 800;
    color: var(--primary-600);
    margin-bottom: 0.35rem;
}
.stat-label { font-size: 0.9rem; color: var(--text-muted); font-weight: 500; }

/* ================================================
   Subject Cards
   ================================================ */
.subject-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1.25rem;
}

.subject-card {
    position: relative;
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.35rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    transition: transform var(--duration) var(--ease), box-shadow var(--duration) var(--ease), border-color var(--duration) var(--ease);
    text-decoration: none;
    color: var(--text);
}
.subject-card:hover {
    transform: translateY(-6px) scale(1.01);
    box-shadow: 0 22px 50px rgba(79, 70, 229, 0.12);
    border-color: rgba(79, 70, 229, 0.18);
}
.subject-card {
    /* subtle left accent using subject color instead of full-width top stripe */
    border-left: 4px solid var(--card-color, var(--primary-500));
    padding-left: 1rem;
}
.subject-icon {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    font-size: 1.15rem;
    color: #fff;
    background: linear-gradient(180deg, var(--card-color, var(--primary-500)), rgba(0,0,0,0.06));
    box-shadow: 0 8px 18px rgba(16, 24, 40, 0.06);
    flex-shrink: 0;
}
.subject-icon {
    transition: box-shadow var(--duration-md) var(--ease), transform var(--duration) var(--ease);
}

.subject-card:hover .subject-icon {
    transform: translateY(-4px) scale(1.03);
    box-shadow: 0 26px 60px rgba(79, 70, 229, 0.12);
}

.subject-info { min-width: 0; overflow: hidden; }
.subject-info h4 { margin-bottom: 0; font-size: 1rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.subject-meta { font-size: 0.85rem; color: var(--text-muted); }

.subject-detail-icon {
    width: 80px;
    height: 80px;
    font-size: 2.5rem;
    border-radius: var(--radius-lg);
    display: grid;
    place-items: center;
    color: #fff;
    flex-shrink: 0;
}

/* Hide subject descriptions on homepage */
.home-subject-grid .subject-meta { display: none; }

.accordion-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.chapter-counts {
    font-weight: normal;
    font-family: var(--font-body);
    white-space: nowrap;
}

.chapter-context-badge {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.chapter-header-row {
    display: flex;
    gap: 1.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.chapter-badges {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.35rem;
    flex-wrap: wrap;
}

.chapter-title {
    margin-bottom: 0.25rem;
    font-size: 1.8rem;
}

/* ================================================
   Tabs
   ================================================ */
.tabs {
    display: flex;
    gap: 0.25rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1.5rem;
    overflow-x: auto;
}
.tabs::-webkit-scrollbar { display: none; }
.tab-btn {
    padding: 0.85rem 1.15rem;
    font-family: var(--font-body);
    font-size: 0.92rem;
    font-weight: 500;
    color: var(--text-muted);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    white-space: nowrap;
    transition: color var(--duration) var(--ease), border-color var(--duration) var(--ease);
}
.tab-btn:hover { color: var(--primary-600); }
.tab-btn.active { color: var(--primary-600); border-bottom-color: var(--primary-600); font-weight: 600; }
.tab-content { display: none; animation: fadeIn 0.35s var(--ease); }
.tab-content.active { display: block; }

/* ================================================
   Resource Cards
   ================================================ */
.resource-list { display: flex; flex-direction: column; gap: 0.85rem; }

.resource-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.2rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: transform var(--duration) var(--ease), border-color var(--duration) var(--ease);
}
.resource-card { cursor: pointer; }
.resource-card:hover { border-color: rgba(79, 70, 229, 0.2); transform: translateY(-2px); box-shadow: 0 14px 36px rgba(15,23,42,0.06); }

/* Ensure anchor resource-cards inherit text styles and hide default link decoration */
.resource-card { color: inherit; text-decoration: none; }
.resource-card:focus { outline: 3px solid rgba(79,70,229,0.08); outline-offset: 2px; }

.resource-icon {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}
.resource-icon.pdf { background: #FEE2E2; color: #B91C1C; }
.resource-icon.doc { background: #DBEAFE; color: #1D4ED8; }
.resource-icon.ppt { background: #FEF3C7; color: #B45309; }
.resource-icon.img { background: #D1FAE5; color: #047857; }

.resource-info { flex: 1; min-width: 0; }
.resource-title {
    font-weight: 600;
    font-size: 0.97rem;
    margin-bottom: 0.2rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.resource-meta { display: flex; flex-wrap: wrap; gap: 0.75rem; color: var(--text-muted); font-size: 0.82rem; }
.resource-actions { display: flex; gap: 0.35rem; flex-shrink: 0; }

/* ================================================
   Breadcrumb
   ================================================ */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
    font-size: 0.88rem;
    color: var(--text-muted);
    margin-bottom: 1.35rem;
}
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--primary-600); }
.breadcrumb .sep { color: var(--text-light); }
.breadcrumb .current { color: var(--text); font-weight: 600; }

/* ================================================
   File Viewer
   ================================================ */
.viewer-container { display: flex; flex-direction: column; min-height: calc(100vh - var(--nav-height)); }
.viewer-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.5rem;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
}
.viewer-title { font-weight: 600; font-size: 0.95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.viewer-controls { display: flex; align-items: center; gap: 0.65rem; }
.viewer-frame { flex: 1; min-height: 420px; background: var(--bg-muted); overflow: auto; }
.viewer-frame iframe, .viewer-frame embed, .viewer-frame canvas { width: 100%; height: 100%; border: none; }

/* ================================================
   Search Results
   ================================================ */
.search-page {
    min-height: 60vh;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.search-panel {
    width: 100%;
    max-width: 100%;
    margin: 0 auto 1.5rem;
    padding: 1.5rem;
    box-sizing: border-box;
}

.search-form {
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    box-sizing: border-box;
}

.search-bar {
    display: flex;
    align-items: stretch;
    gap: 0.65rem;
    margin-bottom: 1.25rem;
    width: 100%;
}

.search-field {
    position: relative;
    flex: 1;
    min-width: 0;
    display: block;
}

.search-field i {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-light);
    font-size: 1rem;
    pointer-events: none;
    z-index: 1;
}

.search-field .form-input {
    width: 100%;
    padding: 0.85rem 1rem 0.85rem 2.65rem;
    font-size: 1rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    box-sizing: border-box;
}

.search-submit {
    flex-shrink: 0;
    align-self: stretch;
    padding: 0 1.15rem;
    white-space: nowrap;
    min-height: 44px;
}

.search-filters-panel {
    border: none;
    margin: 0;
    padding: 0;
    min-width: 0;
}

.search-filters-title {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
    padding: 0;
    width: 100%;
}

.search-filter-row {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
    margin-bottom: 0.85rem;
}

.search-filter-row:last-child {
    margin-bottom: 0;
}

.search-filter-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text);
    flex-shrink: 0;
}

.search-filter-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    width: 100%;
}

.filter-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.4rem 0.85rem;
    font-size: 0.82rem;
    font-weight: 500;
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    background: var(--bg-alt);
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--duration) var(--ease);
    white-space: nowrap;
}

.filter-chip:hover,
.filter-chip.active {
    border-color: var(--primary-500);
    color: var(--primary-600);
    background: var(--primary-50);
}

.search-result-count {
    margin-bottom: 1.25rem;
    color: var(--text-muted);
    font-size: 0.92rem;
    text-align: center;
}

.search-result-count strong { color: var(--text); }

.search-highlight {
    background: rgba(245, 158, 11, 0.18);
    padding: 0.1rem 0.2rem;
    border-radius: 3px;
}

@media (min-width: 861px) {
    .search-filter-row {
        flex-direction: row;
        align-items: center;
        gap: 1rem;
    }

    .search-filter-label {
        min-width: 3.25rem;
    }

    .search-result-count {
        text-align: left;
    }
}

/* ================================================
   Upload Material
   ================================================ */
.upload-page {
    padding: 2.5rem 0;
}

.upload-card {
    max-width: 980px;
    margin: 0 auto;
    padding: 2.25rem;
    background: var(--bg-alt);
    border: 1px solid rgba(148, 163, 184, 0.18);
    border-radius: calc(var(--radius) * 1.25);
    box-shadow: 0 28px 80px rgba(15, 23, 42, 0.09);
}

.upload-card .section-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.75rem;
    flex-wrap: wrap;
}

.upload-card .section-title {
    margin: 0;
    font-size: clamp(1.65rem, 2.4vw, 2.1rem);
    line-height: 1.05;
}

.upload-card .section-description {
    margin: 0;
    max-width: 720px;
    color: var(--text-muted);
    line-height: 1.75;
}

.upload-form {
    display: grid;
    gap: 1.5rem;
}

.upload-form .form-group {
    margin-bottom: 0;
}

.upload-form .form-label {
    display: block;
    margin-bottom: 0.65rem;
    color: var(--text);
    font-weight: 600;
    letter-spacing: -0.01em;
}

.upload-form .form-input,
.upload-form .form-select,
.upload-form .form-textarea {
    width: 100%;
    padding: 1rem 1.15rem;
    font-size: 0.95rem;
    line-height: 1.65;
    color: var(--text);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: border-color 0.24s ease, box-shadow 0.24s ease, transform 0.24s ease;
    box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.04);
}

.upload-form .form-input:focus,
.upload-form .form-select:focus,
.upload-form .form-textarea:focus {
    border-color: var(--primary-500);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.14);
    outline: none;
    transform: translateY(-1px);
}

.upload-form .form-textarea {
    min-height: 180px;
    resize: vertical;
}

.upload-form .form-input[type="file"] {
    padding: 0.95rem 1rem;
    height: auto;
}

.upload-form .file-note {
    display: block;
    margin-top: 0.55rem;
    color: var(--text-muted);
    font-size: 0.92rem;
}

.upload-form .field-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.25rem;
}

.upload-form .field-grid .form-group {
    margin-bottom: 0;
}

.upload-form .upload-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    margin-top: 0.5rem;
}

.upload-form .btn-primary {
    min-width: 160px;
    padding: 1rem 1.6rem;
    font-weight: 700;
    border-radius: calc(var(--radius) * 1.1);
    box-shadow: 0 16px 34px rgba(59, 130, 246, 0.18);
    transition: transform 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.upload-form .btn-primary:hover {
    background: var(--primary-600);
    box-shadow: 0 20px 42px rgba(59, 130, 246, 0.24);
    transform: translateY(-1px);
}

.upload-form .btn-secondary {
    min-width: 140px;
    padding: 0.98rem 1.35rem;
    border-radius: calc(var(--radius) * 1.1);
}

.upload-form .upload-meta {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.25rem;
}

.upload-dropzone {
    display: grid;
    place-items: center;
    gap: 1rem;
    padding: 2.25rem 1.75rem;
    border: 2px dashed rgba(59, 130, 246, 0.38);
    border-radius: calc(var(--radius) * 1.2);
    background: rgba(59, 130, 246, 0.08);
    color: var(--primary-700);
    text-align: center;
    transition: all 0.24s ease;
}

.upload-dropzone:hover,
.upload-dropzone.dragover {
    background: rgba(59, 130, 246, 0.16);
    border-color: var(--primary-500);
    box-shadow: 0 0 0 6px rgba(59, 130, 246, 0.08);
    cursor: pointer;
}

.upload-dropzone .upload-icon {
    font-size: 2.6rem;
}

.upload-dropzone p {
    margin: 0;
    color: var(--text);
    font-size: 0.97rem;
    line-height: 1.75;
}

.upload-dropzone .upload-note {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: 0.5rem;
}

.upload-dropzone input[type="file"] {
    display: none;
}

@media (max-width: 860px) {
    .upload-card {
        padding: 1.6rem;
    }

    .upload-form .field-grid {
        grid-template-columns: 1fr;
    }

    .upload-form .upload-actions {
        justify-content: stretch;
    }
}

@media (max-width: 560px) {
    .upload-card {
        padding: 1.25rem;
    }

    .upload-card .section-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .upload-form .upload-actions {
        flex-direction: column;
        align-items: stretch;
    }
}

/* ================================================
   Admin
   ================================================ */
.admin-layout { display: grid; grid-template-columns: 260px 1fr; min-height: calc(100vh - var(--nav-height)); }
@media (max-width: 1024px) { .admin-layout { grid-template-columns: 1fr; } }
.admin-sidebar {
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    padding: 1.5rem 0;
}
@media (max-width: 1024px) {
    .admin-sidebar {
        position: fixed;
        top: var(--nav-height);
        left: 0;
        bottom: 0;
        width: 260px;
        z-index: 900;
        display: block;
        transform: translateX(-100%);
        transition: transform var(--duration-md) var(--ease);
        border-right: 1px solid var(--border);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    .admin-sidebar.show {
        transform: translateX(0);
    }
    .admin-sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, 0.45);
        z-index: 899;
    }
    .admin-sidebar-overlay.show {
        display: block;
    }
}
.admin-sidebar-nav { list-style: none; padding: 0 0.75rem; }
.admin-sidebar-nav li { margin-bottom: 0.25rem; }
.admin-sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-muted);
    border-radius: var(--radius);
    transition: all var(--duration) var(--ease);
}
.admin-sidebar-nav a:hover,
.admin-sidebar-nav a.active {
    background: var(--primary-50);
    color: var(--primary-600);
}
.admin-content { padding: 2rem; background: transparent; }

@media (max-width: 1024px) {
    .admin-sidebar-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 0.5rem;
        padding: 0.5rem 0.85rem;
        background: var(--bg-muted);
        border: 1px solid var(--border);
        border-radius: var(--radius);
        color: var(--text-muted);
        font-size: 0.85rem;
        font-weight: 500;
        cursor: pointer;
        transition: all var(--duration) var(--ease);
        margin-bottom: 1rem;
    }
    .admin-sidebar-toggle:hover {
        background: var(--primary-50);
        color: var(--primary-600);
        border-color: var(--primary-200);
    }
    .admin-sidebar-toggle i {
        font-size: 1rem;
    }
}
@media (min-width: 1025px) {
    .admin-sidebar-toggle { display: none; }
}

.admin-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.75rem;
    width: 100%;
}

.admin-toolbar-field--grow {
    flex: 1 1 220px;
    min-width: 0;
}

.admin-toolbar-field {
    flex: 0 1 auto;
    min-width: 0;
}

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

.admin-table-card {
    padding: 0;
    overflow-x: auto;
}

.admin-table-wrap {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Subject header row above chapter table */
.admin-subject-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-muted);
}

.admin-subject-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
}

.admin-subject-info .subject-icon {
    border-radius: 8px;
}

.admin-subject-badges {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

/* Inline edit form for chapter title */
.admin-edit-form {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    width: 100%;
}

.admin-edit-form .form-input {
    flex: 1;
    min-width: 0;
    padding: 0.4rem 0.6rem;
    font-size: 0.85rem;
}

/* Order buttons group */
.admin-order-group {
    display: flex;
    gap: 0.25rem;
    align-items: center;
}

/* Actions cell delete text */
.delete-text {
    display: inline;
}

/* Add chapter form row */
.admin-add-chapter-form {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    width: 100%;
}

.admin-add-chapter-form .form-input {
    flex: 1;
    min-width: 0;
    padding: 0.4rem 0.6rem;
    font-size: 0.85rem;
}

.admin-users-mobile {
    display: none;
    width: 100%;
}

/* Admin users: card list on tablet & mobile (sidebar is hidden ≤1024px) */
@media (max-width: 1024px) {
    .admin-users-desktop {
        display: none !important;
    }

    .admin-users-mobile {
        display: flex !important;
        flex-direction: column;
        gap: 0.65rem;
        width: 100%;
        max-width: 100%;
    }

    .admin-user-card {
        overflow: visible;
    }

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

    .admin-user-card__meta {
        display: flex !important;
    }
}

.admin-user-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.9rem 1rem;
    box-shadow: var(--shadow-sm);
    width: 100%;
    box-sizing: border-box;
}

.admin-user-card__top {
    display: flex;
    align-items: flex-start;
    gap: 0.65rem;
}

.admin-user-card__avatar {
    width: 40px;
    height: 40px;
    font-size: 0.8rem;
    flex-shrink: 0;
}

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

.admin-user-card__name {
    display: block;
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.35;
    color: var(--text);
    word-break: break-word;
}

.admin-user-card__email {
    display: block;
    margin-top: 0.2rem;
    font-size: 0.78rem;
    color: var(--text-muted);
    word-break: break-all;
    line-height: 1.4;
}

.admin-user-card__menu {
    flex-shrink: 0;
    margin-left: 0.15rem;
}

.admin-user-card__meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
}

.admin-user-card__date {
    margin-left: auto;
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.admin-user-card__date i {
    margin-right: 0.25rem;
    opacity: 0.75;
}

.dropdown-section-label {
    padding: 0.5rem 0.85rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
}

.admin-table-actions .user-menu {
    display: inline-block;
    vertical-align: middle;
}

.admin-stat-card {
    padding: 1.5rem;
    border-radius: var(--radius-md);
    background: var(--bg-card);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 1rem;
}
.admin-stat-icon { width: 52px; height: 52px; border-radius: var(--radius); display: grid; place-items: center; font-size: 1.35rem; }

/* ================================================
   Table
   ================================================ */
.data-table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.data-table thead { background: var(--bg-alt); }
.data-table th, .data-table td { padding: 0.9rem 1rem; text-align: left; border-bottom: 1px solid var(--border); }
.data-table th { font-weight: 700; font-size: 0.8rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.data-table tbody tr:hover { background: var(--bg-muted); }

/* ================================================
   Pagination
   ================================================ */
.pagination { display: flex; align-items: center; justify-content: center; gap: 0.5rem; margin-top: 2rem; }
.page-btn {
    min-width: 38px;
    height: 38px;
    padding: 0 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-alt);
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--duration) var(--ease);
}
.page-btn:hover { border-color: var(--primary-400); color: var(--primary-600); }
.page-btn.active { background: var(--primary-600); border-color: var(--primary-600); color: #fff; }

/* ================================================
   Toast Notifications
   ================================================ */
.toast-container { position: fixed; top: calc(var(--nav-height) + 1rem); right: 1rem; z-index: 9999; display: flex; flex-direction: column; gap: 0.75rem; }
.toast {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    border-radius: var(--radius);
    background: var(--bg-card);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    min-width: 300px;
    max-width: 440px;
    animation: slideInRight 0.35s var(--ease);
    font-size: 0.92rem;
}
.toast.success { border-left: 3px solid var(--success-500); }
.toast.error { border-left: 3px solid var(--danger-500); }
.toast.warning { border-left: 3px solid var(--warning-500); }
.toast.info { border-left: 3px solid var(--primary-500); }
.toast-close { margin-left: auto; background: none; border: none; color: var(--text-light); cursor: pointer; font-size: 1.1rem; }

/* ================================================
   Empty State
   ================================================ */
.empty-state { text-align: center; padding: 3rem 1.5rem; color: var(--text-muted); }
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 1rem; opacity: 0.55; }
.empty-state h3 { margin-bottom: 0.5rem; color: var(--text); }
.empty-state p { max-width: 420px; margin: 0 auto 1.5rem; }

/* ================================================
   Accordion
   ================================================ */
.accordion-item { border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 0.75rem; overflow: hidden; }
.accordion-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.95rem 1.15rem;
    font-weight: 600;
    font-size: 0.95rem;
    background: var(--bg-card);
    color: var(--text);
    cursor: pointer;
}
.accordion-header:hover { background: var(--bg-alt); }
.accordion-icon { transition: transform var(--duration) var(--ease); color: var(--text-muted); }
.accordion-item.active .accordion-icon { transform: rotate(180deg); }
.accordion-body { max-height: 0; overflow: hidden; transition: max-height 0.35s var(--ease); }
.accordion-body-inner { padding: 0 1.15rem 1rem; }

/* ================================================
   Footer
   ================================================ */
.site-footer {
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    padding: 3rem 0 1.5rem;
    margin-top: 4rem;
}
.footer-grid {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr;
    gap: 2rem;
    margin-bottom: 2rem;
}
@media (max-width: 768px) { .footer-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 480px) { .footer-grid { grid-template-columns: 1fr; } }
.footer-brand {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    font-family: var(--font-heading);
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--text);
    margin-bottom: 0.65rem;
}
.footer-brand-logo {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 50%;
    flex-shrink: 0;
}
.footer-desc { color: var(--text-muted); font-size: 0.92rem; max-width: 300px; }
.footer-col h4 { font-size: 0.85rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text); margin-bottom: 0.9rem; }
.footer-links { list-style: none; }
.footer-links li { margin-bottom: 0.45rem; }
.footer-links a { color: var(--text-muted); font-size: 0.92rem; }
.footer-links a:hover { color: var(--primary-600); }
.footer-bottom { border-top: 1px solid var(--border); padding-top: 1.25rem; display: flex; justify-content: space-between; flex-wrap: wrap; gap: 0.75rem; font-size: 0.85rem; color: var(--text-muted); }
.footer-social { display: flex; gap: 0.5rem; }
.footer-social a { width: 36px; height: 36px; display: grid; place-items: center; border-radius: var(--radius-full); border: 1px solid var(--border); color: var(--text-muted); transition: all var(--duration) var(--ease); }
.footer-social a:hover { background: var(--primary-50); border-color: rgba(79, 70, 229, 0.2); color: var(--primary-600); transform: translateY(-1px); }

/* ================================================
   Mobile & Compact Overrides (small phones)
   ================================================ */
.hero-search .form-input { width: 100%; }

@media (max-width: 540px) {
    .stats-bar {
        grid-template-columns: repeat(2, 1fr);
    }

    .stat-number {
        font-size: 1.35rem;
    }

    .stat-label {
        font-size: 0.72rem;
    }

    .subject-grid {
        gap: 0.65rem;
    }

    .subject-card {
        padding: 0.7rem 0.65rem;
        gap: 0.6rem;
    }

    .subject-icon {
        width: 44px;
        height: 44px;
        font-size: 0.9rem;
    }

    .subject-card .subject-info h4 {
        font-size: 0.85rem;
    }

    .resource-card {
        padding: 0.85rem;
    }

    .resource-title {
        font-size: 0.9rem;
    }

    .resource-meta {
        font-size: 0.75rem;
        flex-wrap: wrap;
        gap: 0.35rem;
    }

    .footer-links {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.25rem 1rem;
    }
}

@media (max-width: 380px) {
    .footer-links {
        grid-template-columns: 1fr;
    }
}

/* ================================================
   Auth Pages
   ================================================ */
.auth-page {
    min-height: calc(100vh - var(--nav-height));
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2.5rem;
    background: linear-gradient(135deg, rgba(79,70,229,0.08), #F8FAFC 40%, #FFFFFF);
}
.auth-card {
    width: 100%;
    max-width: 500px;
    padding: 2.4rem;
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-xl);
}
.auth-header { text-align: center; margin-bottom: 2rem; }
.auth-header h2 { margin-bottom: 0.4rem; }
.auth-header p { font-size: 0.95rem; color: var(--text-muted); }
.auth-divider { display: flex; align-items: center; gap: 1rem; margin: 1.5rem 0; color: var(--text-light); font-size: 0.82rem; }
.auth-divider::before, .auth-divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.auth-footer { text-align: center; margin-top: 1.5rem; font-size: 0.92rem; color: var(--text-muted); }

/* ================================================
   Community Feed (Facebook-like)
   ================================================ */
.community-feed {
    max-width: 720px;
    margin: 0 auto;
}
.community-post-card {
    background: var(--bg-alt);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}
.community-post-item {
    background: var(--bg-alt);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
}
.community-posts {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}
.community-post-detail {
    background: var(--bg-alt);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}
.comments-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}
.community-post-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}
.community-post-actions .btn.active {
    color: var(--primary-700);
    background: var(--primary-50);
}
.community-toolbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
    padding: 0.65rem 1rem;
}
.community-toolbar-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}
.community-search-form {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    min-width: 0;
}
.community-search-form .form-input {
    min-width: 0;
}
#createPostCard {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-alt);
    padding: 1rem 1.25rem;
}
#createPostCard .community-post-creator {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.75rem;
    align-items: start;
}
#createPostCard .community-post-creator-body {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
#createPostCard .community-post-meta {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}
#createPostCard .community-post-creator-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}
.community-post-creator {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 1rem;
    align-items: start;
}
.community-post-creator-body {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
.community-post-meta {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}
.community-post-creator-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    flex-wrap: wrap;
}
.community-prologue {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 2rem 1rem;
    text-align: center;
}
.community-prologue-actions {
    display: inline-flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    justify-content: center;
}
.community-post-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 1.25rem 1.5rem 0;
}
.community-post-author {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}
.avatar-small {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, var(--primary-500), var(--primary-700));
    color: #fff;
    font-weight: 700;
}
.badge-pill {
    display: inline-flex;
    align-items: center;
    padding: 0.45rem 0.9rem;
    border-radius: 999px;
    font-size: 0.78rem;
    background: var(--bg-muted);
    color: var(--text-muted);
}
.community-post-body {
    padding: 0 1.5rem 1.5rem;
    color: var(--text);
    line-height: 1.75;
}
.community-post-body img {
    width: 100%;
    max-height: 420px;
    object-fit: cover;
    border-radius: var(--radius);
    margin-bottom: 1rem;
}
.community-attachment {
    margin-bottom: 1rem;
}
.comment-thread-item {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.comment-thread-item:hover {
    transform: translateY(-1px);
}
.comment-reply-form {
    margin-top: 1rem;
}
.comment-reply-form .form-input {
    width: 100%;
}
@media (max-width: 720px) {
    .community-post-creator,
    .community-post-meta {
        grid-template-columns: 1fr;
    }
    .community-toolbar-inner {
        flex-direction: column;
        align-items: stretch;
    }
    .community-toolbar-left {
        justify-content: space-between;
    }
    .community-search-form {
        max-width: 100% !important;
    }
    #createPostCard .community-post-meta {
        grid-template-columns: 1fr;
    }
}
@media (max-width: 640px) {
    .community-post-actions {
        flex-direction: column;
    }
    .community-post-header {
        flex-direction: column;
        align-items: stretch;
    }
    .community-post-body {
        padding: 0 1.25rem 1.25rem;
    }
}
.comment-item:last-child {
    border-bottom: none !important;
    margin-bottom: 0 !important;
    padding-bottom: 0 !important;
}
.avatar-circle {
    flex-shrink: 0;
}
.auth-footer a { color: var(--primary-600); font-weight: 600; }

/* ================================================
   Profile
   ================================================ */
.profile-header { display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap; margin-bottom: 2rem; }
.profile-avatar {
    width: 90px;
    height: 90px;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, var(--primary-400), var(--primary-600));
    color: #fff;
    display: grid;
    place-items: center;
    font-weight: 800;
    font-size: 1.5rem;
}
.profile-avatar img { width: 100%; height: 100%; border-radius: var(--radius-full); object-fit: cover; }

/* ================================================
   Section Headers
   ================================================ */
.section-header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 0.75rem; margin-bottom: 1rem; }
.section-header h2 { font-size: 1.45rem; position: relative; padding-bottom: 0.5rem; }
.section-header h2::after { content: ''; display: block; width: 56px; height: 3px; border-radius: 3px; background: linear-gradient(90deg, var(--primary-500), var(--accent-500)); margin-top: 0.4rem; }

/* ================================================
   Chips / Tags
   ================================================ */
.chip-group { display: flex; flex-wrap: wrap; gap: 0.65rem; }
.chip { display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.45rem 0.95rem; font-size: 0.85rem; font-weight: 600; border: 1px solid var(--border); border-radius: var(--radius-full); background: var(--bg-alt); color: var(--text-muted); cursor: pointer; transition: all var(--duration) var(--ease); }
.chip:hover, .chip.active { background: var(--primary-50); border-color: rgba(79, 70, 229, 0.2); color: var(--primary-600); }

/* ================================================
   Modal
   ================================================ */
.modal-overlay { position: fixed; inset: 0; background: rgba(15, 23, 42, 0.45); z-index: 9999; display: flex; align-items: center; justify-content: center; padding: 1rem; opacity: 0; visibility: hidden; transition: opacity var(--duration) var(--ease), visibility var(--duration) var(--ease); }
.modal-overlay.show { opacity: 1; visibility: visible; }
.modal { width: 100%; max-width: 540px; background: var(--bg-card); border-radius: var(--radius-lg); box-shadow: var(--shadow-xl); transform: translateY(10px); transition: transform var(--duration-md) var(--ease); }
.modal-overlay.show .modal { transform: translateY(0); }
.modal-header, .modal-footer { padding: 1.25rem 1.5rem; }
.modal-header { display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border); }
.modal-header h3 { font-size: 1.05rem; }
.modal-body { padding: 1.5rem; }
.modal-footer { display: flex; justify-content: flex-end; gap: 0.75rem; border-top: 1px solid var(--border); }

/* ================================================
   Skeleton Loader
   ================================================ */
.skeleton { background: linear-gradient(90deg, var(--bg-muted) 25%, var(--bg-alt) 50%, var(--bg-muted) 75%); background-size: 200% 100%; animation: shimmer 1.5s infinite; border-radius: var(--radius-sm); }

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

/* ================================================
   Animations
   ================================================ */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeInUp { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideInRight { from { opacity: 0; transform: translateX(90px); } to { opacity: 1; transform: translateX(0); } }
@keyframes slideInDown { from { opacity: 0; transform: translateY(-18px); } to { opacity: 1; transform: translateY(0); } }
@keyframes scaleIn { from { opacity: 0; transform: scale(0.92); } to { opacity: 1; transform: scale(1); } }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.04); } }

.animate-fade-in { animation: fadeIn 0.4s var(--ease) both; }
.animate-fade-in-up { animation: fadeInUp 0.45s var(--ease) both; }
.animate-slide-down { animation: slideInDown 0.35s var(--ease) both; }
.animate-scale-in { animation: scaleIn 0.35s var(--ease) both; }

.stagger > *:nth-child(1) { animation-delay: 0.05s; }
.stagger > *:nth-child(2) { animation-delay: 0.1s; }
.stagger > *:nth-child(3) { animation-delay: 0.15s; }
.stagger > *:nth-child(4) { animation-delay: 0.2s; }
.stagger > *:nth-child(5) { animation-delay: 0.25s; }
.stagger > *:nth-child(6) { animation-delay: 0.3s; }
.stagger > *:nth-child(7) { animation-delay: 0.35s; }
.stagger > *:nth-child(8) { animation-delay: 0.4s; }

.reveal { opacity: 0; transform: translateY(30px); transition: all 0.6s var(--ease); }
.reveal.visible { opacity: 1; transform: translateY(0); }

/* ================================================
   Alerts & Flash Messages
   ================================================ */
.alert {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    border-radius: var(--radius);
    margin-bottom: 1.25rem;
    font-size: 0.92rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
}
.alert-success { border-left: 4px solid var(--success-500); color: var(--success-600); background: var(--success-50); }
.alert-danger { border-left: 4px solid var(--danger-500); color: var(--danger-600); background: var(--danger-50); }
.alert-warning { border-left: 4px solid var(--warning-500); color: var(--accent-600); background: var(--warning-50); }
.alert-info { border-left: 4px solid var(--primary-500); color: var(--primary-700); background: var(--primary-50); }

/* ================================================
   Scrollbar
   ================================================ */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(148, 163, 184, 0.55); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: rgba(148, 163, 184, 0.75); }

/* ================================================
   Misc utilities
   ================================================ */
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.divider { height: 1px; background: var(--border); margin: 1.5rem 0; }
.page-header { padding: 2rem 0 1rem; }
.page-header h1 { margin-bottom: 0.35rem; }
.page-header p { color: var(--text-muted); font-size: 1rem; }
.class-tabs { display: flex; background: var(--bg-muted); border-radius: var(--radius-full); padding: 0.3rem; border: 1px solid var(--border); width: fit-content; }
.class-tab { padding: 0.6rem 1.4rem; font-size: 0.9rem; font-weight: 600; border-radius: var(--radius-full); border: none; background: transparent; color: var(--text-muted); cursor: pointer; transition: all var(--duration) var(--ease); }
.class-tab.active { background: var(--primary-600); color: #fff; box-shadow: 0 10px 24px rgba(79,70,229,0.14); }
.step-progress { display: flex; align-items: center; gap: 0.65rem; margin-bottom: 2rem; }
.step { display: flex; align-items: center; gap: 0.45rem; color: var(--text-light); font-size: 0.85rem; font-weight: 500; }
.step.active { color: var(--primary-600); }
.step.completed { color: var(--success-500); }
.step-number { width: 28px; height: 28px; border-radius: var(--radius-full); border: 2px solid currentColor; display: grid; place-items: center; font-size: 0.78rem; font-weight: 700; }
.step.active .step-number { background: var(--primary-600); color: #fff; }
.step.completed .step-number { background: var(--success-500); color: #fff; }
.step-line { width: 40px; height: 2px; background: var(--border); }
.step-line.completed { background: var(--success-500); }


.messages-sidebar {
    background: var(--bg-alt);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
}
.messages-main {
    background: var(--bg-alt);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.thread-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    cursor: pointer;
    border-radius: var(--radius);
    transition: background 0.15s;
}
.thread-item:hover {
    background: var(--bg-muted);
}
.thread-item.active {
    background: var(--primary-50);
}
.thread-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-500), var(--primary-700));
    color: #fff;
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: 0.85rem;
    flex-shrink: 0;
}
.thread-info {
    flex: 1;
    min-width: 0;
}
.thread-name {
    font-weight: 600;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.thread-preview {
    font-size: 0.8rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.thread-time {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
    flex-shrink: 0;
}


/* ========== Subject grid for teacher registration ========== */
.subject-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin-top: 0.5rem;
}
.subject-column {
    background: var(--bg-muted);
    border-radius: var(--radius);
    padding: 0.6rem 0.75rem;
}
.subject-column-label {
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.4rem;
    padding-bottom: 0.35rem;
    border-bottom: 1px solid var(--border);
}
.subject-check {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.3rem 0;
    cursor: pointer;
    font-size: 0.88rem;
    transition: opacity 0.1s;
}
.subject-check:hover {
    opacity: 0.8;
}
.subject-check input[type="checkbox"] {
    accent-color: var(--primary-500);
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* Sidebar overlay (mobile) */
.sidebar-overlay {
    position: fixed;
    inset: 0;
    z-index: 999;
    background: rgba(0,0,0,0.4);
}



/* Answer highlight for teacher/admin replies */
.answer-teacher {
    border-left: 3px solid var(--warning-500);
}
.answer-admin {
    border-left: 3px solid var(--danger-500);
}

/* Messaging tabs */
.messages-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
}
.messages-tab {
    flex: 1;
    padding: 0.7rem 0.5rem;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
    transition: color 0.15s, border-color 0.15s;
    border-bottom: 2px solid transparent;
}
.messages-tab:hover {
    color: var(--text);
}
.messages-tab.active {
    color: var(--primary-600);
    border-bottom-color: var(--primary-600);
}
.messages-tab i {
    margin-right: 0.35rem;
}
.tab-content {
    display: none;
}
.tab-content.active {
    display: block;
}

/* Teacher directory */
.subject-group {
    margin-bottom: 0.5rem;
}
.subject-group-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
    border-radius: var(--radius);
    background: var(--bg-muted);
    margin-bottom: 0.25rem;
}
.subject-group-icon {
    color: var(--primary-600);
    font-size: 0.8rem;
}
.teacher-item {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.55rem 0.75rem;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.15s;
    margin-left: 0.5rem;
}
.teacher-item:hover {
    background: var(--bg-muted);
}
.teacher-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--warning-500), var(--accent-600));
    color: #fff;
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: 0.75rem;
    flex-shrink: 0;
}
.teacher-info {
    flex: 1;
    min-width: 0;
}
.teacher-name {
    font-weight: 600;
    font-size: 0.88rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.teacher-subject {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Message image attachments */
.message-bubble img {
    cursor: pointer;
    transition: opacity 0.15s;
}
.message-bubble img:hover {
    opacity: 0.9;
}

/* ====== About Page ====== */
.about-hero {
  text-align: center;
  padding: 4rem 1rem 2.5rem;
  position: relative;
  overflow: hidden;
}
.about-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--primary-50) 0%, var(--bg) 50%, var(--primary-50) 100%);
  opacity: 0.7;
  pointer-events: none;
}
.about-hero > * {
  position: relative;
  z-index: 1;
}
.about-hero h1 {
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 0.75rem;
}
.about-hero h1::after {
  content: '';
  display: block;
  width: 60px;
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--primary-500), var(--primary-300));
  margin: 0.75rem auto 0;
}
.about-hero-subtitle {
  font-size: 1.1rem;
  color: var(--text-muted);
  max-width: 600px;
  margin: 0 auto;
  line-height: 1.7;
}
.about-section {
  max-width: 900px;
  margin: 0 auto;
  padding: 2.5rem 1rem;
}
.about-section-content h2 {
  font-size: 1.6rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 1.25rem;
  color: var(--text-primary);
}
.about-section-content p {
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: 1rem;
  text-align: center;
  max-width: 700px;
  margin-left: auto;
  margin-right: auto;
}
.about-features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.5rem;
  margin-top: 1.5rem;
}
.about-feature {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 1.75rem 1.25rem;
  text-align: center;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}
.about-feature:hover {
  transform: translateY(-4px);
  box-shadow: 0 10px 28px rgba(0,0,0,0.08);
}
.about-feature-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--primary-50);
  color: var(--primary-600);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  margin: 0 auto 1rem;
  transition: transform 0.3s ease, background 0.3s ease;
}
.about-feature:hover .about-feature-icon {
  transform: scale(1.1);
  background: var(--primary-100);
}
.about-feature h3 {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}
.about-feature p {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.55;
  text-align: center;
  margin: 0;
}

/* ====== Team Section ====== */
.about-team-section {
  max-width: 1000px;
  margin: 0 auto;
  padding: 2.5rem 1rem 4rem;
}
.about-team-section .about-section-content h2 {
  margin-bottom: 0.5rem;
}
.team-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 2rem;
  margin-top: 2rem;
}
.team-card {
  text-align: center;
  padding: 1.75rem 1rem 1.5rem;
  border-radius: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.team-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 14px 36px rgba(0,0,0,0.08);
}
.team-photo-wrapper {
  position: relative;
  width: 120px;
  height: 120px;
  margin: 0 auto 1.25rem;
}
.team-photo,
.team-photo-fallback {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  object-fit: cover;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.4rem;
  font-weight: 700;
  color: var(--primary-600);
  background: var(--primary-50);
}
.team-photo-ring {
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 3px solid var(--primary-200);
  pointer-events: none;
}
.team-name {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
}
.team-role {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0;
}

@media (max-width: 600px) {
  .about-hero { padding: 2.5rem 1.25rem 2rem; }
  .about-hero h1 { font-size: 1.7rem; }
  .about-hero h1::after { width: 50px; height: 3px; }
  .about-hero-subtitle { font-size: 0.95rem; padding: 0 0.25rem; }
  .about-section { padding: 1.75rem 1.25rem; }
  .about-section-content h2 { font-size: 1.3rem; }
  .about-section-content p { font-size: 0.92rem; }
  .about-features { grid-template-columns: 1fr 1fr; gap: 0.85rem; }
  .about-feature { padding: 1.25rem 0.75rem; border-radius: 12px; }
  .about-feature-icon { width: 44px; height: 44px; font-size: 1.05rem; margin-bottom: 0.65rem; }
  .about-feature h3 { font-size: 0.88rem; }
  .about-feature p { font-size: 0.78rem; }
  .about-team-section { padding: 1.75rem 1.25rem 3rem; }
  .team-grid { grid-template-columns: repeat(2, 1fr); gap: 1rem; margin-top: 1.5rem; }
  .team-card { padding: 1.25rem 0.75rem 1rem; border-radius: 14px; }
  .team-photo-wrapper { width: 80px; height: 80px; margin-bottom: 0.85rem; }
  .team-photo, .team-photo-fallback { width: 80px; height: 80px; font-size: 1.5rem; }
  .team-photo-ring { inset: -3px; border-width: 2px; }
  .team-name { font-size: 0.9rem; }
  .team-role { font-size: 0.75rem; }
}

@media (max-width: 550px) {
  .about-features { grid-template-columns: 1fr; }
  .team-grid { grid-template-columns: 1fr; }
  .features-grid { grid-template-columns: 1fr; }
}

@media (max-width: 400px) {
  .features-grid { grid-template-columns: 1fr; }
  .hero-cta { grid-template-columns: 1fr; }
}

/* ====== Contact Modal ====== */
.contact-modal-links {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.contact-modal-item {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.85rem 1rem;
  border-radius: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  text-decoration: none;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.contact-modal-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0,0,0,0.06);
  text-decoration: none;
}
.contact-modal-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}
.contact-modal-label {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-primary);
}
.contact-modal-value {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-left: auto;
  text-align: right;
}
