/* Thai Food Quiz & e-Learning - Ref Alignment & Master Design System
   Modern e-Learning System Style */

:root {
    --navy: #5c2415;
    --navy-dark: #3d140a;
    --navy-light: #7b3622;
    --navy-tint: #fbf5f2;

    --gold: #f1a92e;              /* สีส้มทองปุ่มเข้าเรียนตาม Ref */
    --gold-hover: #e0971d;
    --gold-bright: #ffd166;
    --gold-deep: #8f6500;
    --gold-light: #fef8e7;
    --accent-gold: #c69214;

    --grey-action: #5c6773;       /* สีเทาปุ่มผลการเรียนตาม Ref */
    --grey-hover: #4b545f;
    --grey-exam: #5c6773;         /* แถบหัวข้อแบบทดสอบตาม Ref ให้คอนทราสต์ชัด */

    --bg-page: #ffffff;           /* พื้นหลังหน้าเว็บสีขาวสะอาดตาม Ref */
    --bg-body: #ffffff;
    --bg-surface: #ffffff;
    --bg-light: #f8f9fa;
    --bg-subtle: #f0f2f5;
    --bg-white: #ffffff;

    --text-primary: #1e242b;
    --text-dark: #1e242b;
    --text-secondary: #596573;
    --text-muted: #6b7280;
    --text-light: #6b7280;

    --border-light: #e5e7eb;
    --border-subtle: rgba(90, 35, 19, 0.08);

    --success: #15803d;
    --success-bg: #ecfdf5;
    --success-border: #a7f3d0;
    --warning: #b45309;
    --warning-bg: #fffbeb;
    --warning-border: #fde68a;
    --danger: #b91c1c;
    --danger-bg: #fef2f2;
    --danger-border: #fecaca;
    --info: #0284c7;
    --info-bg: #f0f9ff;
    --info-border: #bae6fd;

    --shadow-xs: 0 1px 2px rgba(45, 23, 15, 0.03);
    --shadow: 0 2px 4px rgba(45, 23, 15, 0.04), 0 1px 2px rgba(45, 23, 15, 0.02);
    --shadow-md: 0 4px 14px -2px rgba(45, 23, 15, 0.06), 0 2px 6px -1px rgba(45, 23, 15, 0.03);
    --shadow-lg: 0 12px 30px -4px rgba(45, 23, 15, 0.08), 0 4px 10px -2px rgba(45, 23, 15, 0.04);
    --radius: 8px;
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-pill: 9999px;
}

/* Browser Surfaces (Impeccable Quality Standards) */
::selection {
    background: var(--navy);
    color: var(--gold-bright);
}

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-subtle);
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

:focus-visible {
    outline: 2px solid var(--accent-gold);
    outline-offset: 2px;
}

*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    overflow-x: hidden;
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: 'Prompt', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #ffffff;
    color: #1f2429;
    font-size: 15px;
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    overflow-x: hidden;
    max-width: 100vw;
    -webkit-font-smoothing: antialiased;
}

img, video, iframe {
    max-width: 100%;
}

/* TOP NAVBAR (ตรงตาม Ref PDF ทุกหน้า) */
.ref-navbar {
    background: #ffffff;
    height: 64px;
    border-bottom: 1px solid #e5e7eb;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.ref-nav-inner {
    max-width: 1180px;
    height: 100%;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.ref-nav-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    flex: 1 1 auto;
}

.ref-hamburger-btn {
    background: none;
    border: none;
    font-size: 26px;
    color: #2b2b2b;
    cursor: pointer;
    padding: 4px 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background .15s;
    flex-shrink: 0;
}

.ref-hamburger-btn:hover {
    background: #f3f4f6;
}

.ref-brand-wrap {
    display: flex;
    align-items: center;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    text-decoration: none;
    flex: 1 1 auto;
}

.ref-brand-logo {
    height: 38px;
    width: auto;
    object-fit: contain;
    margin: 0 6px 0 0;
    flex-shrink: 0;
}

.ref-brand-title {
    font-size: 15px;
    font-weight: 500;
    color: #1f2429;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    min-width: 0;
    flex-shrink: 1;
}

.ref-nav-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
    margin-left: auto;
}

/* Navbar Auth Buttons (เข้าสู่ระบบ / สมัครสมาชิก) */
.ref-auth-btns {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.auth-btn-full {
    display: inline;
}

.auth-btn-short {
    display: none;
}

.ref-auth-btns .btn,
.ref-btn-login,
.ref-btn-register {
    height: 36px;
    padding: 0 16px;
    font-size: 13.5px;
    white-space: nowrap !important;
    word-break: keep-all !important;
    border-radius: var(--radius-pill) !important;
    font-weight: 500 !important;
    transition: all 0.2s ease;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    text-decoration: none !important;
    line-height: 1 !important;
    flex-shrink: 0 !important;
    box-sizing: border-box !important;
    align-self: center !important;
}

.ref-btn-login {
    background: #ffffff !important;
    border: 1.5px solid var(--navy) !important;
    color: var(--navy) !important;
}

.ref-btn-login:hover {
    background: var(--navy-50) !important;
    color: var(--navy) !important;
}

.ref-btn-register {
    background: var(--navy) !important;
    border: 1.5px solid var(--navy) !important;
    color: #ffffff !important;
    box-shadow: 0 2px 6px rgba(92, 36, 21, 0.15) !important;
}

.ref-btn-register:hover {
    background: var(--navy-dark) !important;
    border-color: var(--navy-dark) !important;
    color: #ffffff !important;
}


.ref-user-dropdown {
    position: relative;
}

.ref-user-btn {
    background: none;
    border: none;
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: inherit;
    font-size: 14.5px;
    font-weight: 500;
    color: var(--text-primary);
    cursor: pointer;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    transition: background .15s;
}

.ref-user-btn:hover {
    background: var(--bg-subtle);
}

.ref-user-btn i {
    font-size: 18px;
    color: var(--text-secondary);
}

.ref-user-menu {
    position: absolute;
    right: 0;
    top: 100%;
    margin-top: 6px;
    background: #ffffff;
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 210px;
    padding: 6px 0;
    display: none;
    z-index: 1001;
    animation: dropdownFade .15s ease-out;
}

.ref-user-menu.show {
    display: block;
}

.ref-user-menu a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    font-size: 14px;
    color: var(--text-secondary);
    text-decoration: none;
    transition: background .15s;
}

.ref-user-menu a:hover {
    background: var(--navy-tint);
    color: var(--navy);
}

/* OFFCANVAS DRAWER MENU */
.ref-drawer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 1999;
    display: none;
    opacity: 0;
    transition: opacity .25s ease;
}

.ref-drawer-overlay.show {
    display: block;
    opacity: 1;
}

.ref-nav-drawer {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: 290px;
    background: #ffffff;
    z-index: 2000;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15);
    transform: translateX(-100%);
    transition: transform .25s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.ref-nav-drawer.open {
    transform: translateX(0);
}

.ref-drawer-header {
    padding: 18px 20px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.ref-drawer-close-btn {
    background: none;
    border: none;
    font-size: 20px;
    color: #6b7280;
    cursor: pointer;
    padding: 4px;
}

.ref-drawer-body {
    flex: 1;
    padding: 14px 0;
}

.drawer-item a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 22px;
    color: #374151;
    text-decoration: none;
    font-size: 14.5px;
    font-weight: 400;
    transition: background .15s;
}

.drawer-item a:hover {
    background: #f3f4f6;
    color: var(--navy);
}

.drawer-item a i {
    width: 20px;
    font-size: 17px;
    color: #6b7280;
}

.drawer-divider {
    border-top: 1px solid #e5e7eb;
    margin: 10px 0;
}

/* PAGE LAYOUT & CENTERED TITLE */
.ref-main-container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px 60px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* ปลดล็อกคอนเทนเนอร์สำหรับหน้าที่มีตารางข้อมูลกว้างบนหน้าจอคอมพิวเตอร์ */
.ref-main-container:has(.admin-wide),
.ref-main-container:has(.main-content-wide),
.ref-main-container.wide-mode {
    max-width: 1440px;
}

@media (min-width: 1600px) {
    .ref-main-container:has(.admin-wide),
    .ref-main-container:has(.main-content-wide),
    .ref-main-container.wide-mode {
        max-width: 1560px;
    }
}

.main-wrapper,
.main-content {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px 60px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.ref-main-container > .main-content {
    padding-left: 0;
    padding-right: 0;
}

.main-content.admin-wide,
.main-content-wide {
    max-width: 1440px !important;
    width: 100% !important;
}

@media (min-width: 1600px) {
    .main-content.admin-wide,
    .main-content-wide {
        max-width: 1560px !important;
    }
}

/* สไตล์ตารางจัดการสมาชิกโดยเฉพาะ ให้พอดีหน้าจอคอมพิวเตอร์ */
.admin-members-table {
    width: 100%;
    min-width: 1020px;
    table-layout: auto;
}

.admin-members-table th,
.admin-members-table td {
    padding: 13px 14px;
    font-size: 13.5px;
}

.admin-members-table .table-action-cell {
    width: 85px !important;
    min-width: 85px !important;
    text-align: center !important;
}

.page-top-title {
    text-align: center;
    font-size: 20px;
    font-weight: 500;
    color: #1f2429;
    margin: 26px 0 20px;
    letter-spacing: -0.01em;
}

/* PAGE 1: หน้าแรก - HERO COVER BANNER (16:9 อิงตาม Ref Page 1) */
.ref-hero-wrapper {
    width: 100%;
    margin-bottom: 24px;
}

.ref-cover-box {
    width: 100%;
    aspect-ratio: 16 / 9;
    max-height: 460px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
    background: var(--navy-dark);
    position: relative;
    display: block;
    overflow: hidden;
    text-decoration: none;
    box-shadow: var(--shadow-lg);
    transition: transform .25s ease, box-shadow .25s ease, border-color .25s ease;
}

.ref-cover-box:hover {
    transform: translateY(-2px);
    box-shadow: 0 16px 36px -4px rgba(45, 23, 15, 0.14);
    border-color: var(--gold);
}

.ref-cover-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform .4s ease;
}

.ref-cover-box:hover .ref-cover-img {
    transform: scale(1.02);
}

.ref-cover-scrim {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(20, 8, 4, 0.25) 0%, rgba(20, 8, 4, 0.4) 40%, rgba(20, 8, 4, 0.92) 100%);
    pointer-events: none;
}

.ref-cover-fallback {
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at 50% 30%, #5c2415 0%, #3d140a 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gold-bright);
    font-size: 64px;
}

.ref-cover-content {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 24px 28px;
    z-index: 2;
    color: #ffffff;
}

.ref-cover-top-badges {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.ref-badge-gold {
    background: rgba(241, 169, 46, 0.95);
    color: #2b1800;
    font-size: 12.5px;
    font-weight: 700;
    padding: 5px 14px;
    border-radius: var(--radius-pill);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.ref-badge-glass {
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: #ffffff;
    font-size: 12.5px;
    font-weight: 500;
    padding: 5px 12px;
    border-radius: var(--radius-pill);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid rgba(255, 255, 255, 0.25);
}

.ref-cover-bottom {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
}

.ref-cover-heading {
    font-size: 24px;
    font-weight: 700;
    color: #ffffff;
    line-height: 1.3;
    margin-bottom: 6px;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

.ref-cover-subheading {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.85);
    line-height: 1.4;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}

.ref-cover-action {
    flex-shrink: 0;
}

.ref-cover-cta-btn {
    background: var(--gold);
    color: #2b1800;
    font-size: 14.5px;
    font-weight: 700;
    padding: 12px 24px;
    border-radius: var(--radius-pill);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.28);
    transition: all .2s ease;
}

.ref-cover-box:hover .ref-cover-cta-btn {
    background: var(--gold-hover);
    transform: translateX(4px);
}

/* PAGE 2: สื่อการเรียนรู้ - VIDEO PLAYER & INFO */
.ref-video-screen {
    width: 100%;
    aspect-ratio: 16 / 9;
    max-height: 480px;
    background: #000000;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
}

.ref-video-backdrop {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: brightness(0.4) blur(2px);
    transform: scale(1.05);
}

.ref-video-locked-overlay {
    position: absolute;
    inset: 0;
    background: rgba(20, 8, 4, 0.65);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    z-index: 3;
    text-align: center;
}

.ref-locked-card {
    background: rgba(255, 255, 255, 0.96);
    border-radius: var(--radius-md);
    padding: 28px 32px;
    max-width: 460px;
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.6);
}

.ref-locked-icon {
    font-size: 36px;
    color: var(--navy);
    margin-bottom: 12px;
}

.ref-locked-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.ref-locked-desc {
    font-size: 13.5px;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 20px;
}

.ref-locked-btn {
    background: var(--gold);
    color: #2b1800;
    font-weight: 700;
    font-size: 14.5px;
    padding: 11px 26px;
    border-radius: var(--radius-pill);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all .15s ease;
    box-shadow: 0 2px 8px rgba(241, 169, 46, 0.3);
}

.ref-locked-btn:hover {
    background: var(--gold-hover);
    transform: translateY(-1px);
}


.ref-video-empty {
    color: #ffffff;
    text-align: center;
    padding: 40px;
}

.ref-video-empty i {
    font-size: 36px;
    color: var(--gold);
    display: block;
    margin-bottom: 12px;
}

.ref-video-empty .empty-title {
    font-size: 15px;
    font-weight: 600;
}

.ref-course-headline {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 24px 0 16px;
}

.ref-course-info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    padding-bottom: 24px;
    border-bottom: 1px solid #e5e7eb;
    margin-bottom: 28px;
}

.ref-info-col-left .info-heading,
.ref-info-col-right .info-heading {
    font-size: 13.5px;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.ref-info-col-left .info-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 14px;
    color: var(--text-primary);
}

.ref-info-col-left .info-list span {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.ref-info-col-right .info-fee {
    font-size: 19px;
    font-weight: 700;
    color: var(--success);
}

.ref-course-action-btns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    margin-top: auto;
}

.btn-enter-course {
    background: var(--gold);
    color: #2b1800;
    padding: 14px 20px;
    font-size: 15px;
    font-weight: 700;
    text-align: center;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: background .15s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-enter-course:hover {
    background: var(--gold-hover);
    color: #1a0f00;
}

.btn-enter-course.locked {
    background: #e2e8f0;
    color: #64748b;
    border: 1px solid #cbd5e1;
    cursor: not-allowed;
    opacity: 0.9;
}

.btn-enter-course.locked:hover {
    background: #cbd5e1;
    color: #475569;
}

.btn-score-course {
    background: var(--grey-action);
    color: #ffffff;
    padding: 14px 20px;
    font-size: 15px;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: background .15s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-score-course:hover {
    background: var(--grey-hover);
    color: #ffffff;
}

/* PAGE 3: แบบทดสอบ - EXAMINATION UI */
.ref-exam-bar {
    background: var(--grey-exam);
    color: #ffffff;
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 14px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-xs);
}

.ref-exam-exit-btn {
    color: #ffffff;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 500;
    transition: opacity .15s;
    font-size: 13.5px;
}

.ref-exam-exit-btn:hover {
    opacity: .85;
}

.ref-exam-title {
    font-weight: 600;
    letter-spacing: 0.01em;
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    color: #ffffff;
}

.ref-exam-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    font-weight: 500;
    color: #ffffff;
    background: rgba(0, 0, 0, 0.22);
    border: 1px solid rgba(255, 255, 255, 0.22);
    padding: 3px 10px;
    border-radius: var(--radius-pill);
    vertical-align: middle;
}

.ref-exam-status-badge #answeredCountNum {
    color: var(--gold-bright);
    font-weight: 700;
}

.ref-exam-status-badge.all-answered {
    background: rgba(22, 163, 74, 0.3);
    border-color: rgba(74, 222, 128, 0.45);
    color: #bbf7d0;
}

.ref-exam-timer-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ref-exam-timer-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 500;
    color: #ffffff;
    background: rgba(0, 0, 0, 0.22);
    border: 1px solid rgba(255, 255, 255, 0.22);
    padding: 4px 12px;
    border-radius: var(--radius-pill);
}

.ref-exam-timer-badge i {
    color: var(--gold-bright);
    font-size: 14px;
}

.ref-exam-timer-digit {
    color: var(--gold-bright);
    font-family: monospace;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.ref-exam-card {
    background: #ffffff;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    padding: 36px 32px 30px;
    margin-bottom: 24px;
    min-height: 320px;
    display: flex;
    flex-direction: column;
}

.ref-q-header {
    font-size: 17px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 24px;
    display: flex;
    gap: 10px;
    line-height: 1.5;
}

.ref-q-num {
    font-weight: 700;
    color: var(--navy);
}

.ref-opt-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 20px;
    margin-bottom: 12px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 15px;
    color: var(--text-primary);
    transition: all .15s ease;
    background: #ffffff;
}

.ref-opt-item:hover {
    background: var(--bg-subtle);
    border-color: #cbd5e1;
}

.ref-opt-item.selected {
    background: var(--navy-tint);
    border-color: var(--accent-gold);
    color: var(--navy-dark);
    box-shadow: 0 0 0 1px var(--accent-gold);
}

.ref-opt-badge {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--bg-subtle);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
    flex-shrink: 0;
    transition: all .15s ease;
}

.ref-opt-item.selected .ref-opt-badge {
    background: var(--accent-gold);
    color: #ffffff;
}

.ref-opt-radio {
    width: 18px;
    height: 18px;
    accent-color: var(--accent-gold);
    margin: 0;
}

.ref-exam-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: auto;
    padding-top: 20px;
}

.ref-prev-btn {
    background: var(--bg-subtle);
    color: var(--text-secondary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    padding: 10px 22px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all .15s ease;
}

.ref-prev-btn:hover:not(:disabled) {
    background: #e2e8f0;
    color: var(--text-primary);
}

.ref-prev-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.ref-next-btn {
    background: var(--gold);
    color: #2b1800;
    border: none;
    border-radius: var(--radius-sm);
    padding: 10px 28px;
    font-family: inherit;
    font-size: 14.5px;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: background .15s, transform .15s;
    box-shadow: 0 2px 6px rgba(241, 169, 46, 0.3);
}

.ref-next-btn:hover {
    background: var(--gold-hover);
    transform: translateY(-1px);
}

.ref-submit-exam-btn {
    background: var(--success);
    color: #ffffff;
    border: none;
    border-radius: var(--radius-sm);
    padding: 10px 28px;
    font-family: inherit;
    font-size: 14.5px;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: background .15s, transform .15s;
    box-shadow: 0 2px 6px rgba(21, 128, 61, 0.3);
}

.ref-submit-exam-btn:hover {
    background: #166534;
    transform: translateY(-1px);
}

.ref-shortcut-hint {
    font-size: 12px;
    color: var(--text-muted);
    text-align: center;
    margin-top: 14px;
}

.ref-exam-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 10px;
}

.ref-page-btn {
    width: 38px;
    height: 38px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    background: #ffffff;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .15s;
}

.ref-page-btn:hover {
    background: var(--bg-subtle);
    border-color: #cbd5e1;
}

.ref-page-btn.active {
    background: var(--navy);
    color: #ffffff;
    border-color: var(--navy);
    box-shadow: 0 2px 6px rgba(92, 36, 21, 0.25);
}

.ref-page-btn.answered {
    background: var(--success-bg);
    color: var(--success);
    border-color: var(--success-border);
    font-weight: 700;
}

.ref-page-btn.unanswered-warn {
    background: #fef2f2 !important;
    color: #dc2626 !important;
    border-color: #ef4444 !important;
    font-weight: 700;
}

/* PAGE 4: ผลคะแนน - ACCORDION CARDS & SUMMARY */
.ref-summary-card {
    background: linear-gradient(135deg, var(--navy-dark) 0%, var(--navy) 100%);
    color: #ffffff;
    border-radius: var(--radius-md);
    padding: 24px 28px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-md);
}

.ref-summary-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--gold-bright);
}

.ref-summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
}

.ref-summary-item {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    border-radius: var(--radius-sm);
    padding: 14px 18px;
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.ref-summary-lbl {
    font-size: 12.5px;
    color: rgba(255, 255, 255, 0.8);
    margin-bottom: 4px;
}

.ref-summary-val {
    font-size: 22px;
    font-weight: 700;
    color: #ffffff;
}

.ref-summary-val.highlight {
    color: var(--gold-bright);
}

.ref-summary-val.success {
    color: #86efac;
}

.ref-accordion-item {
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    background: #ffffff;
    margin-bottom: 14px;
    overflow: hidden;
    box-shadow: var(--shadow-xs);
    transition: box-shadow .2s ease;
}

.ref-accordion-item:hover {
    box-shadow: var(--shadow);
}

.ref-accordion-header {
    padding: 18px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    user-select: none;
    background: #ffffff;
    transition: background .15s ease;
}

.ref-accordion-header:hover {
    background: var(--bg-subtle);
}

.ref-accordion-left .acc-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.ref-accordion-left .acc-sub {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 3px;
}

.ref-accordion-right {
    display: flex;
    align-items: center;
    gap: 18px;
}

.ref-accordion-right .acc-score {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
}

.acc-badge-pass {
    background: var(--success-bg);
    color: var(--success);
    border: 1px solid var(--success-border);
    font-size: 12.5px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: var(--radius-pill);
}

.acc-badge-wait {
    background: var(--bg-subtle);
    color: var(--text-muted);
    border: 1px solid var(--border-light);
    font-size: 12.5px;
    font-weight: 500;
    padding: 3px 10px;
    border-radius: var(--radius-pill);
}

.ref-accordion-right .acc-chevron {
    font-size: 14px;
    color: var(--text-muted);
    transition: transform .2s ease;
}

.ref-accordion-header.open .acc-chevron {
    transform: rotate(180deg);
}

.ref-accordion-content {
    display: none;
    padding: 0 24px 20px;
    border-top: 1px solid var(--border-light);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.ref-accordion-content.open {
    display: block;
}

.ref-score-table {
    width: 100%;
    min-width: 520px;
    border-collapse: collapse;
    font-size: 13.5px;
    margin-top: 12px;
}

.ref-score-table th,
.ref-score-table td {
    padding: 12px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border-light);
}

.ref-score-table th {
    color: var(--text-muted);
    font-weight: 600;
    font-size: 13px;
    background: var(--bg-subtle);
}

.ref-score-table td {
    color: var(--text-primary);
}

.ref-score-table tr:last-child td {
    border-bottom: none;
}

.ref-score-table td.status-done {
    color: var(--success);
    font-weight: 600;
}

/* RESULT & QUIZ SOLUTIONS (เฉลยข้อสอบตามโจทย์ที่ได้รับ + ปุ่มดำเนินการ 3 ปุ่ม) */
.result-actions-bar {
    display: flex;
    gap: 14px;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    margin: 22px 0 28px;
    padding: 16px 20px;
    background: #ffffff;
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    box-shadow: var(--shadow-xs);
}

.result-actions-bar .btn {
    padding: 11px 22px;
    font-size: 14.5px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    transition: all .2s ease;
}

.sol-section {
    margin-bottom: 34px;
}

.sol-header {
    background: #ffffff;
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 22px 26px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-xs);
}

.sol-header-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--navy);
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
}

.sol-header-desc {
    font-size: 13.5px;
    color: var(--text-secondary);
    margin-bottom: 14px;
}

.sol-stat-pills {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.sol-stat-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: var(--radius-pill);
    font-size: 13px;
    font-weight: 600;
}

.sol-stat-pill.correct {
    background: var(--success-bg);
    color: var(--success);
    border: 1px solid var(--success-border);
}

.sol-stat-pill.wrong {
    background: var(--danger-bg);
    color: var(--danger);
    border: 1px solid var(--danger-border);
}

.sol-stat-pill.percent {
    background: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #bfdbfe;
}

.sol-card {
    background: #ffffff;
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 22px 24px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-xs);
    transition: box-shadow .2s ease, border-color .2s ease;
}

.sol-card.is-correct {
    border-color: var(--success-border);
    background: #fafdfb;
}

.sol-card.is-wrong {
    border-color: var(--alert-error-border);
    background: #fffdfd;
}

.sol-card-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 14px;
}

.sol-q-title {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    font-size: 15.5px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.5;
    flex: 1;
}

.sol-q-no {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    color: #ffffff;
    background: var(--navy);
}

.sol-card.is-correct .sol-q-no {
    background: var(--success);
}

.sol-card.is-wrong .sol-q-no {
    background: var(--danger);
}

.sol-tag-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    font-weight: 600;
    padding: 5px 12px;
    border-radius: var(--radius-pill);
    flex-shrink: 0;
}

.sol-tag-correct {
    background: var(--success-bg);
    color: var(--success);
    border: 1px solid var(--success-border);
}

.sol-tag-wrong {
    background: var(--danger-bg);
    color: var(--danger);
    border: 1px solid var(--danger-border);
}

.sol-tag-unanswered {
    background: var(--bg-subtle);
    color: var(--text-muted);
    border: 1px solid var(--border-light);
}

.sol-options-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-left: 44px;
}

@media (max-width: 640px) {
    .sol-options-list {
        padding-left: 0;
    }
}

.sol-option-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-light);
    font-size: 14px;
    color: var(--text-primary);
    background: #fafafa;
}

.sol-option-item.opt-key {
    background: #ecfdf5;
    border-color: #a7f3d0;
    color: #065f46;
    font-weight: 600;
}

.sol-option-item.opt-wrong-user {
    background: #fef2f2;
    border-color: #fecaca;
    color: #991b1b;
    font-weight: 600;
}

.sol-opt-left {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
}

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

.badge-key {
    background: #15803d;
    color: #ffffff;
    font-size: 11px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.badge-user-ok {
    background: #059669;
    color: #ffffff;
    font-size: 11px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.badge-user-wrong {
    background: #dc2626;
    color: #ffffff;
    font-size: 11px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.sol-explanation-box {
    margin-top: 14px;
    margin-left: 44px;
    padding: 12px 16px;
    background: #fdfbf7;
    border: 1px solid rgba(241, 169, 46, 0.35);
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    color: var(--text-secondary);
    line-height: 1.55;
}

@media (max-width: 640px) {
    .sol-explanation-box {
        margin-left: 0;
    }
}

/* PAGE 5 & 6: โปรไฟล์ & จัดการระบบ */
.ref-profile-box {
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    background: #ffffff;
    box-shadow: var(--shadow-md);
    padding: 40px 36px;
}

.ref-profile-avatar-row {
    display: flex;
    align-items: center;
    gap: 18px;
    margin-bottom: 32px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border-light);
}

.ref-profile-avatar-circle {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--navy) 0%, var(--navy-light) 100%);
    color: var(--gold-bright);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    font-weight: 700;
    box-shadow: 0 4px 10px rgba(92, 36, 21, 0.25);
}

.ref-profile-name-text {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

.ref-profile-email-sub {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 2px;
}

.ref-profile-section-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 24px;
}

.ref-profile-grid {
    display: flex;
    flex-direction: column;
    gap: 14px;
    max-width: 540px;
    margin: 0 auto 32px;
}

.ref-profile-row {
    display: grid;
    grid-template-columns: 150px 1fr;
    font-size: 14.5px;
    align-items: center;
}

.ref-profile-label {
    text-align: right;
    padding-right: 18px;
    color: var(--text-muted);
    font-weight: 500;
}

.ref-profile-val {
    color: var(--text-primary);
    font-weight: 500;
}

.ref-delete-account-btn {
    border: 2px solid var(--danger);
    color: var(--danger);
    background: transparent;
    padding: 10px 24px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 14.5px;
    text-decoration: none;
    display: block;
    width: fit-content;
    margin: 32px auto 0;
    transition: all .15s ease;
}

.ref-delete-account-btn:hover {
    background: var(--danger);
    color: #ffffff;
}

/* MEMBER SEARCH & DIRECTORY (ค้นหาชื่อผู้ใช้รายอื่น) */
.member-search-box {
    background: #ffffff;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 32px 36px;
    box-shadow: var(--shadow-md);
}

.member-search-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 20px;
}

.member-search-bar {
    display: flex;
    gap: 10px;
    width: 100%;
}

.member-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
    margin-top: 16px;
}

.member-card {
    background: #ffffff;
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 16px;
    display: flex;
    align-items: flex-start;
    gap: 14px;
    transition: all .2s ease;
    box-shadow: var(--shadow-xs);
}

.member-card:hover {
    border-color: var(--gold);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.member-avatar {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--navy) 0%, var(--navy-light) 100%);
    color: var(--gold-bright);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 700;
    flex-shrink: 0;
    box-shadow: 0 2px 6px rgba(92, 36, 21, 0.2);
}

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

.member-name {
    font-size: 14.5px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.member-username {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.member-meta {
    font-size: 12px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 6px;
}

/* CLASSIC DESIGN SYSTEM COMPONENTS (Full Compatibility for all pages) */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.card {
    background: #ffffff;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    overflow: hidden;
    transition: all .2s ease;
}

.card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    transform: translateY(-2px);
}

.card .card-img {
    width: 100%;
    height: 160px;
    object-fit: cover;
    background: #f3f4f6;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #9ca3af;
    font-size: 40px;
}

.card .card-body {
    padding: 18px 20px;
}

.card .card-badge {
    display: inline-block;
    background: #fef3c7;
    color: #92400e;
    font-size: 12px;
    font-weight: 600;
    padding: 2px 10px;
    border-radius: 50px;
    margin-bottom: 8px;
}

.card .card-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 6px;
    color: #111827;
}

.card .card-text {
    font-size: 13.5px;
    color: #4b5563;
    line-height: 1.6;
    margin-bottom: 12px;
}

.category-header {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 24px 28px;
    margin-bottom: 24px;
}

.category-header h1 {
    font-size: 22px;
    color: #111827;
}

.category-header p {
    color: #4b5563;
    font-size: 14px;
    margin-top: 4px;
}

.section-title {
    font-size: 18px;
    font-weight: 600;
    color: #111827;
    margin: 24px 0 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.banner {
    background: linear-gradient(135deg, #3d140a, #5c2415);
    border-radius: 8px;
    padding: 36px 32px;
    color: #ffffff;
    margin-bottom: 28px;
}

.admin-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    margin: 20px 0;
}

.admin-card {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 22px;
    text-align: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.admin-card i {
    font-size: 32px;
    color: var(--gold);
    margin-bottom: 8px;
}

.admin-card .stat {
    font-size: 28px;
    font-weight: 700;
    color: var(--navy);
}

.admin-card .label {
    font-size: 13px;
    color: var(--text-muted);
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 50px;
}

.status-pass {
    background: #dcfce7;
    color: #166534;
}

.status-fail {
    background: #fee2e2;
    color: #991b1b;
}

.status-wait {
    background: #fef3c7;
    color: #92400e;
}

.quiz-card {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 24px;
    margin-bottom: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.quiz-card .q-number {
    display: inline-flex;
    width: 30px;
    height: 30px;
    background: var(--navy);
    color: #ffffff;
    border-radius: 50%;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    margin-right: 8px;
}

.quiz-card .q-text {
    font-size: 15px;
    font-weight: 500;
    margin-bottom: 12px;
}

.quiz-card .q-option {
    display: flex;
    align-items: center;
    padding: 10px 14px;
    margin-bottom: 6px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: all .15s;
}

.quiz-card .q-option:hover {
    border-color: var(--gold);
    background: #fffdf5;
}

.quiz-card .q-option input {
    margin-right: 10px;
}

/* BUTTONS, ALERTS, FORMS & TABLES */
.btn {
    padding: 9px 20px;
    border-radius: 4px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all .15s;
    border: 1px solid transparent;
}

.btn-primary {
    background: var(--navy);
    color: #ffffff;
    border-color: var(--navy);
}

.btn-primary:hover {
    background: var(--navy-dark);
    color: #ffffff;
}

.btn-gold {
    background: var(--gold);
    color: #2b1800;
    font-weight: 700;
}

.btn-gold:hover {
    background: var(--gold-hover);
    color: #1a0f00;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--navy);
    color: var(--navy);
}

.btn-outline:hover {
    background: var(--navy);
    color: #ffffff;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

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

.btn-danger:hover {
    background: #b91c1c;
}

.alert {
    padding: 12px 16px;
    border-radius: 4px;
    font-size: 14px;
    margin-bottom: 16px;
}

.alert-success {
    background: #ecfdf5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.alert-error {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.alert-info {
    background: #f0f9ff;
    color: #075985;
    border: 1px solid #bae6fd;
}

.form-card {
    background: #ffffff;
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 30px;
    margin: 20px auto;
}

.form-card h2 {
    font-size: 18px;
    color: var(--text-primary);
    margin-bottom: 20px;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--text-secondary);
}

.form-group input, 
.form-group textarea, 
.form-group select {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 14px;
    outline: none;
}

.form-group input:focus, 
.form-group textarea:focus, 
.form-group select:focus {
    border-color: var(--navy);
    box-shadow: 0 0 0 2px rgba(92, 36, 21, 0.1);
}

.table-wrapper {
    background: #ffffff;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    overflow-x: auto;
    margin: 20px 0;
    width: 100%;
    box-shadow: var(--shadow-xs);
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 720px;
}

th, td {
    padding: 12px 14px;
    text-align: left;
    font-size: 14px;
    vertical-align: middle;
}

.table-action-cell {
    white-space: nowrap;
    text-align: center;
    width: 155px;
    min-width: 155px;
}

.table-action-btns {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    flex-wrap: nowrap;
}

.table-action-btns .btn,
.table-action-btns span {
    white-space: nowrap;
    flex-shrink: 0;
    padding: 5px 10px;
    font-size: 13px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

th {
    background: var(--bg-subtle);
    color: var(--text-secondary);
    font-weight: 600;
    border-bottom: 1px solid var(--border-light);
}

td {
    border-bottom: 1px solid var(--bg-subtle);
    color: var(--text-primary);
}

tr:hover td {
    background: var(--navy-tint);
}

/* Note: Complete Responsive Design System is defined at the bottom of stylesheet for proper cascade */


/* FLOATING CHAT WIDGET & BOTTOM-RIGHT BUTTON (PDF 4.24 Use Case 7.1) */
.floating-chat-btn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(135deg, var(--navy) 0%, var(--navy-dark) 100%);
    color: #ffffff;
    border: 2px solid var(--gold);
    border-radius: 50px;
    padding: 12px 20px;
    font-family: 'Prompt', sans-serif;
    font-size: 14.5px;
    font-weight: 600;
    box-shadow: 0 4px 18px rgba(92, 36, 21, 0.35);
    cursor: pointer;
    transition: all 0.25s ease;
    text-decoration: none;
    outline: none;
}

.floating-chat-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(92, 36, 21, 0.45);
    background: linear-gradient(135deg, var(--navy-dark) 0%, #2b0e07 100%);
    border-color: var(--gold-bright);
}

.floating-chat-btn i {
    font-size: 17px;
    color: var(--gold);
}

.floating-chat-badge {
    position: absolute;
    top: -6px;
    right: -4px;
    background: #ef4444;
    color: #ffffff;
    font-size: 11px;
    font-weight: 700;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    border: 2px solid #ffffff;
    animation: pulseBadge 2s infinite;
}

@keyframes pulseBadge {
    0% { transform: scale(1); }
    50% { transform: scale(1.15); }
    100% { transform: scale(1); }
}

@keyframes chatBtnPulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.08);
        box-shadow: 0 10px 24px rgba(92, 36, 21, 0.4);
    }
}

.floating-chat-btn.has-new-reply {
    animation: chatBtnPulse 1.2s cubic-bezier(0.16, 1, 0.3, 1) 3;
}

@keyframes chatMsgFadeIn {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.chat-bubble-admin.new-arrival,
.chat-bubble-user.new-arrival {
    animation: chatMsgFadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.floating-chat-box {
    position: fixed;
    bottom: 84px;
    right: 24px;
    width: 380px;
    max-width: calc(100vw - 32px);
    height: 510px;
    max-height: calc(100vh - 120px);
    background: #ffffff;
    border: 1px solid var(--border-light);
    border-radius: 16px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.22);
    z-index: 10000;
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: chatSlideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.floating-chat-box.open {
    display: flex;
}

@keyframes chatSlideUp {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.chat-box-header {
    background: linear-gradient(135deg, var(--navy) 0%, var(--navy-dark) 100%);
    color: #ffffff;
    padding: 14px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 2px solid var(--gold);
}

.chat-box-header-title {
    display: flex;
    align-items: center;
    gap: 10px;
}

.chat-box-header-icon {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    color: var(--gold);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.chat-box-header-text h3,
.chat-box-header-text h4 {
    margin: 0;
    font-size: 14.5px;
    font-weight: 700;
    color: #ffffff;
}

.chat-box-header-text span {
    font-size: 11.5px;
    color: rgba(255, 255, 255, 0.8);
}

.chat-box-close-btn {
    background: none;
    border: none;
    color: #ffffff;
    font-size: 16px;
    cursor: pointer;
    opacity: 0.8;
    padding: 6px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .2s;
}

.chat-box-close-btn:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.15);
}

.chat-box-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chat-empty-state {
    text-align: center;
    margin: auto;
    padding: 24px 16px;
    color: var(--text-muted);
}

.chat-empty-state i {
    font-size: 38px;
    color: var(--gold);
    margin-bottom: 8px;
    display: block;
}

.chat-empty-state p {
    font-size: 13px;
    line-height: 1.5;
    margin: 0;
}

.chat-bubble-user {
    align-self: flex-end;
    max-width: 82%;
    background: var(--navy);
    color: #ffffff;
    padding: 10px 14px;
    border-radius: 14px 14px 2px 14px;
    font-size: 13.5px;
    line-height: 1.45;
    word-break: break-word;
    box-shadow: 0 2px 6px rgba(92, 36, 21, 0.2);
}

.chat-bubble-admin {
    align-self: flex-start;
    max-width: 82%;
    background: #ffffff;
    color: var(--text-primary);
    border: 1px solid var(--border-light);
    padding: 10px 14px;
    border-radius: 14px 14px 14px 2px;
    font-size: 13.5px;
    line-height: 1.45;
    word-break: break-word;
    box-shadow: var(--shadow-xs);
}

.chat-bubble-meta {
    font-size: 10.5px;
    margin-top: 4px;
    opacity: 0.75;
    display: flex;
    align-items: center;
    gap: 4px;
}

.chat-bubble-user .chat-bubble-meta {
    justify-content: flex-end;
    color: rgba(255, 255, 255, 0.85);
}

.chat-bubble-admin .chat-bubble-meta {
    justify-content: flex-start;
    color: var(--text-muted);
}

.chat-admin-tag {
    font-size: 10.5px;
    font-weight: 600;
    color: var(--navy);
    background: #fef3c7;
    padding: 1px 6px;
    border-radius: 4px;
    margin-bottom: 3px;
    display: inline-block;
}

.chat-box-footer {
    background: #ffffff;
    border-top: 1px solid var(--border-light);
    padding: 12px 14px;
}

.chat-input-row {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.chat-textarea {
    flex: 1;
    resize: none;
    border: 1px solid var(--border-light);
    border-radius: 10px;
    padding: 9px 12px;
    font-size: 13.5px;
    font-family: 'Prompt', sans-serif;
    outline: none;
    line-height: 1.4;
    transition: border-color .2s;
    background: #f9fafb;
}

.chat-textarea:focus {
    border-color: var(--navy);
    background: #ffffff;
}

.chat-send-btn {
    height: 40px;
    width: 44px;
    border-radius: 10px;
    border: none;
    background: var(--navy);
    color: #ffffff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    transition: all .2s;
    flex-shrink: 0;
}

.chat-send-btn:hover:not(:disabled) {
    background: var(--navy-dark);
    transform: scale(1.04);
}

.chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.chat-alert-msg {
    font-size: 12px;
    margin-top: 6px;
    padding: 4px 8px;
    border-radius: 4px;
    display: none;
}

.chat-alert-msg.success {
    display: block;
    background: #ecfdf5;
    color: #065f46;
}

.chat-alert-msg.error {
    display: block;
    background: #fef2f2;
    color: #991b1b;
}

/* MASTER RESPONSIVE DESIGN SYSTEM
   Supports: Desktop / Laptop (>= 1024px), Tablets & iPads (768px - 1023px),
             Smartphones (<= 767px), Compact Phones (<= 480px / 380px) */

/* 1. TABLETS & iPads (Portrait & Landscape: 768px - 1023px)
   e.g. iPad 10.2", iPad Air (820px), iPad Pro 11" (834px), iPad mini (768px) */
@media (max-width: 1024px) {
    .ref-nav-inner {
        padding: 0 16px;
    }

    .ref-brand-title {
        font-size: 14px;
        max-width: 440px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .ref-main-container,
    .main-wrapper,
    .main-content {
        padding: 0 18px 48px;
        max-width: 100%;
    }

    .ref-cover-box {
        aspect-ratio: 16 / 9;
        max-height: 420px;
    }

    .ref-cover-content {
        padding: 22px 24px;
    }

    .ref-cover-heading {
        font-size: 21px;
    }

    .ref-cover-subheading {
        font-size: 13.5px;
    }

    .ref-cover-cta-btn {
        padding: 11px 22px;
        font-size: 14px;
    }

    .card-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
    }

    .ref-course-info-grid {
        gap: 16px;
        padding-bottom: 20px;
        margin-bottom: 24px;
    }

    .ref-summary-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .ref-profile-box {
        padding: 32px 28px;
    }

    .ref-profile-row {
        grid-template-columns: 130px 1fr;
    }

    .admin-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 14px;
    }

    .result-actions-bar {
        padding: 14px 18px;
        gap: 12px;
    }
}

/* 2. MOBILE & PHABLETS (<= 768px)
      Target: Mobile phones, Phablets, Compact tablet views */
@media (max-width: 768px) {
    .ref-navbar {
        height: 58px;
    }

    .ref-nav-inner {
        padding: 0 16px !important;
        gap: 10px;
    }

    .ref-nav-left {
        gap: 8px;
        min-width: 0;
        flex: 1 1 auto;
        overflow: hidden;
    }

    .ref-hamburger-btn {
        font-size: 24px;
        padding: 4px 6px;
        flex-shrink: 0;
    }

    .ref-brand-logo {
        height: 32px;
        margin: 0 4px 0 0;
        flex-shrink: 0;
    }

    .ref-brand-title {
        font-size: 13.5px;
        font-weight: 600;
        max-width: 240px;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }

    .ref-nav-right {
        gap: 8px;
        flex-shrink: 0;
        margin-left: auto;
    }

    .ref-auth-btns {
        gap: 8px;
        flex-shrink: 0;
    }

    .ref-auth-btns .btn-sm {
        height: 34px !important;
        padding: 0 14px !important;
        font-size: 13px !important;
        border-radius: var(--radius-pill) !important;
        white-space: nowrap !important;
    }

    .ref-user-name {
        max-width: 130px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .ref-main-container,
    .main-wrapper,
    .main-content {
        padding: 0 14px 40px;
    }

    .page-top-title {
        font-size: 18px;
        margin: 20px 0 16px;
    }

    /* Hero Banner / Course Cover on Tablets/Phones */
    .ref-cover-box {
        aspect-ratio: 16 / 10;
        min-height: 290px;
    }

    .ref-cover-content {
        padding: 18px 20px;
    }

    .ref-cover-heading {
        font-size: 18.5px;
        line-height: 1.35;
    }

    .ref-cover-subheading {
        font-size: 13px;
        line-height: 1.45;
    }

    .ref-cover-cta-btn {
        padding: 10px 20px;
        font-size: 14px;
    }

    /* Course View */
    .ref-course-headline {
        font-size: 18px;
        margin: 18px 0 14px;
    }

    .ref-course-info-grid {
        grid-template-columns: 1fr;
        gap: 14px;
        padding-bottom: 18px;
        margin-bottom: 22px;
    }

    /* Examination Bar */
    .ref-exam-bar {
        flex-wrap: wrap;
        gap: 10px;
        padding: 11px 16px;
    }

    .ref-exam-title {
        order: 1;
        width: 100%;
        text-align: center;
        justify-content: center;
        font-size: 14.5px;
    }

    .ref-exam-exit-btn {
        order: 2;
        font-size: 13px;
    }

    .ref-exam-bar > div:last-child,
    .ref-exam-timer-wrap {
        order: 3;
        font-size: 13px;
        margin-left: auto;
    }

    /* Examination Card */
    .ref-exam-card {
        padding: 24px 20px 20px;
        min-height: auto;
    }

    .ref-q-header {
        font-size: 15.5px;
        margin-bottom: 18px;
        gap: 8px;
    }

    .ref-opt-item {
        padding: 12px 16px;
        gap: 12px;
        font-size: 14px;
    }

    .ref-opt-badge {
        width: 26px;
        height: 26px;
        font-size: 12px;
    }

    .ref-exam-actions {
        padding-top: 16px;
    }

    /* Result Page */
    .ref-summary-card {
        padding: 20px 18px;
    }

    .ref-summary-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .result-actions-bar {
        padding: 14px 16px;
        gap: 10px;
    }

    .result-actions-bar .btn {
        font-size: 14px;
        padding: 10px 18px;
    }

    .sol-header {
        padding: 18px 20px;
    }

    .sol-header-title {
        font-size: 16.5px;
    }

    .sol-card {
        padding: 18px 20px;
    }

    .ref-accordion-header {
        padding: 15px 18px;
    }

    .ref-accordion-content {
        padding: 0 18px 16px;
    }

    /* Profile */
    .ref-profile-box {
        padding: 28px 20px;
    }

    .ref-profile-row {
        grid-template-columns: 110px 1fr;
        font-size: 14px;
    }

    /* Admin Pages */
    .admin-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .category-header {
        padding: 18px 20px;
    }

    .category-header h1 {
        font-size: 20px;
    }

    .category-header p {
        font-size: 13.5px;
    }
}

/* 3. MOBILE PHONES (<= 576px)
      Target: iPhone (all regular & pro models), Samsung Galaxy, Android phones */
@media (max-width: 576px) {
    /* Safe Mobile Inputs (Prevents iOS Safari auto-zoom) */
    input[type="text"],
    input[type="password"],
    input[type="email"],
    input[type="number"],
    input[type="tel"],
    select,
    textarea {
        font-size: 16px !important;
    }

    /* Top Navbar */
    .ref-navbar {
        height: 56px;
    }

    .ref-nav-inner {
        padding: 0 16px !important;
        gap: 8px;
        box-sizing: border-box;
    }

    .ref-nav-left {
        gap: 6px;
        min-width: 0;
        flex: 1 1 auto;
        overflow: hidden;
    }

    .ref-hamburger-btn {
        font-size: 22px;
        padding: 4px;
        flex-shrink: 0;
    }

    .ref-brand-wrap {
        min-width: 0;
        flex: 1 1 auto;
        overflow: hidden;
    }

    .ref-brand-logo {
        height: 28px;
        margin: 0 3px 0 0;
        flex-shrink: 0;
    }

    .ref-brand-title {
        font-size: 12px;
        max-width: 125px;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        min-width: 0;
    }

    .ref-nav-right {
        gap: 6px;
        flex-shrink: 0;
        margin-left: auto;
    }

    .ref-auth-btns {
        gap: 6px;
        flex-shrink: 0;
        align-items: center;
    }

    .auth-btn-full {
        display: none !important;
    }

    .auth-btn-short {
        display: inline !important;
    }

    .ref-auth-btns .btn,
    .ref-auth-btns .btn-sm,
    .ref-btn-login,
    .ref-btn-register {
        height: 31px !important;
        padding: 0 11px !important;
        font-size: 12px !important;
        line-height: 1 !important;
        border-radius: var(--radius-pill) !important;
        white-space: nowrap !important;
        box-shadow: none !important;
        align-self: center !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    /* Hide text username on small mobile to give room for title; keep person avatar icon */
    .ref-user-name {
        display: none;
    }

    .ref-user-btn {
        padding: 6px 10px;
        font-size: 13px;
        background: #f8fafc;
        border: 1px solid #e2e8f0;
        border-radius: var(--radius-pill);
    }

    .ref-user-btn i {
        font-size: 19px;
    }

    .ref-user-menu {
        width: 200px;
        right: 0;
    }

    /* Drawer offcanvas */
    .ref-nav-drawer {
        width: min(290px, 85vw);
    }

    .drawer-item a {
        padding: 13px 20px;
        font-size: 15px;
    }

    /* Page container */
    .ref-main-container,
    .main-wrapper,
    .main-content {
        padding: 0 12px 36px;
    }

    .page-top-title {
        font-size: 17px;
        margin: 16px 0 14px;
    }

    /* Hero Banner: Stack bottom cleanly so CTA button is full width */
    .ref-cover-box {
        aspect-ratio: auto;
        min-height: 290px;
        border-radius: var(--radius);
    }

    .ref-cover-content {
        padding: 16px 14px;
    }

    .ref-cover-heading {
        font-size: 17px;
        line-height: 1.35;
        margin-bottom: 6px;
    }

    .ref-cover-subheading {
        font-size: 12px;
        line-height: 1.45;
        margin-bottom: 8px;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .ref-cover-bottom {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .ref-cover-cta-btn {
        width: 100%;
        justify-content: center;
        padding: 11px 16px;
        font-size: 14px;
    }

    /* Video Player & Locked Overlay */
    .ref-locked-card {
        padding: 20px 16px;
        width: 92%;
        max-width: 340px;
    }

    .ref-locked-icon {
        font-size: 28px;
        margin-bottom: 8px;
    }

    .ref-locked-title {
        font-size: 16px;
    }

    .ref-locked-desc {
        font-size: 12.5px;
        margin-bottom: 14px;
    }

    .ref-locked-btn {
        width: 100%;
        justify-content: center;
        font-size: 13.5px;
        padding: 10px 14px;
    }

    .ref-course-action-btns {
        grid-template-columns: 1fr;
        gap: 8px;
        border-radius: 8px;
        overflow: hidden;
    }

    .btn-enter-course,
    .btn-score-course {
        border-radius: 6px;
        padding: 12px 16px;
        font-size: 14px;
    }

    /* Examination Form Card */
    .ref-exam-card {
        padding: 18px 14px 16px;
        border-radius: 10px;
    }

    .ref-q-header {
        font-size: 15px;
        margin-bottom: 14px;
    }

    .ref-opt-item {
        padding: 11px 12px;
        gap: 10px;
        font-size: 13.5px;
        min-height: 48px;
        border-radius: 8px;
    }

    .ref-opt-badge {
        width: 26px;
        height: 26px;
        font-size: 12px;
    }

    .ref-exam-actions {
        display: flex;
        gap: 8px;
        width: 100%;
        padding-top: 14px;
    }

    .ref-prev-btn,
    .ref-next-btn,
    .ref-submit-exam-btn {
        flex: 1;
        justify-content: center;
        padding: 10px 12px;
        font-size: 13px;
    }

    .ref-exam-pagination {
        gap: 4px;
        margin-top: 8px;
    }

    .ref-page-btn {
        width: 31px;
        height: 31px;
        font-size: 12px;
    }

    .ref-shortcut-hint {
        display: none;
    }

    /* Result & Solution Page */
    .ref-summary-card {
        padding: 16px 14px;
    }

    .ref-summary-title {
        font-size: 14.5px;
        margin-bottom: 12px;
    }

    .ref-summary-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .ref-summary-item {
        padding: 10px 12px;
    }

    .ref-summary-lbl {
        font-size: 11px;
    }

    .ref-summary-val {
        font-size: 18px;
    }

    /* 3 Main Result Action Buttons: Full width column on mobile */
    .result-actions-bar {
        flex-direction: column;
        width: 100%;
        padding: 12px 14px;
        gap: 10px;
    }

    .result-actions-bar .btn {
        width: 100%;
        justify-content: center;
        font-size: 13.5px;
        padding: 11px 14px;
    }

    .sol-header {
        padding: 16px 14px;
    }

    .sol-header-title {
        font-size: 15px;
    }

    .sol-header-desc {
        font-size: 12.5px;
        margin-bottom: 10px;
    }

    .sol-stat-pills {
        gap: 6px;
    }

    .sol-stat-pill {
        font-size: 11.5px;
        padding: 4px 10px;
    }

    .sol-card {
        padding: 16px 14px;
    }

    .sol-card-top {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .sol-tag-badge {
        align-self: flex-start;
    }

    .sol-options-list {
        padding-left: 0;
        gap: 6px;
    }

    .sol-option-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
        padding: 9px 12px;
    }

    .sol-opt-left {
        width: 100%;
        font-size: 13px;
    }

    .sol-opt-badges {
        margin-left: 24px;
        align-self: flex-start;
    }

    .sol-explanation-box {
        margin-left: 0;
        padding: 10px 12px;
        font-size: 12.5px;
    }

    .ref-accordion-header {
        padding: 14px 14px;
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .ref-accordion-right {
        width: 100%;
        justify-content: space-between;
    }

    .ref-accordion-content {
        padding: 0 12px 14px;
    }

    /* Card Grid (Dishes) */
    .card-grid {
        grid-template-columns: 1fr;
        gap: 14px;
    }

    .card .card-img {
        height: 180px;
    }

    /* Profile Box */
    .ref-profile-box {
        padding: 22px 14px;
    }

    .ref-profile-avatar-row {
        gap: 12px;
        margin-bottom: 20px;
        padding-bottom: 16px;
    }

    .ref-profile-avatar-circle {
        width: 50px;
        height: 50px;
        font-size: 20px;
    }

    .ref-profile-name-text {
        font-size: 16px;
    }

    .ref-profile-row {
        grid-template-columns: 1fr;
        gap: 2px;
        margin-bottom: 12px;
    }

    .ref-profile-label {
        text-align: left;
        padding-right: 0;
        font-size: 12.5px;
    }

    .ref-profile-val {
        font-size: 14px;
    }

    .ref-delete-account-btn {
        width: 100%;
        text-align: center;
        margin-top: 20px;
    }

    .member-search-box {
        padding: 22px 14px;
    }

    .member-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    /* Forms */
    .form-card {
        padding: 20px 16px;
        margin: 14px auto;
    }

    .form-card h2 {
        font-size: 17px;
        margin-bottom: 16px;
    }

    /* Admin */
    .category-header {
        padding: 16px 14px;
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .category-header form {
        width: 100%;
    }

    .category-header input[type="text"] {
        width: 100%;
    }

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

    .admin-card {
        padding: 14px 10px;
    }

    .admin-card .stat {
        font-size: 20px;
    }

    /* Floating Chat Widget on Mobile */
    .floating-chat-btn {
        bottom: 16px;
        right: 16px;
        padding: 12px 14px;
        border-radius: 50px;
    }

    .floating-chat-btn .chat-btn-text {
        display: none;
    }

    .floating-chat-box {
        bottom: 74px;
        right: 12px;
        left: 12px;
        width: auto;
        max-width: none;
        height: calc(100vh - 100px);
        max-height: 520px;
        border-radius: 14px;
    }

    .chat-box-header {
        padding: 12px 14px;
    }

    .chat-bubble-user,
    .chat-bubble-admin {
        max-width: 90%;
        font-size: 13px;
    }
}

/* 4. ULTRA-COMPACT SMARTPHONES (<= 380px)
      Target: iPhone SE, older Android devices (<= 380px) */
@media (max-width: 380px) {
    .ref-nav-inner {
        padding: 0 12px !important;
        gap: 6px;
    }

    .ref-brand-title {
        max-width: 80px;
        font-size: 11px;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }

    .ref-auth-btns {
        gap: 5px;
    }

    .ref-auth-btns .btn,
    .ref-auth-btns .btn-sm,
    .ref-btn-login,
    .ref-btn-register {
        height: 28px !important;
        padding: 0 8px !important;
        font-size: 11px !important;
        line-height: 1 !important;
        border-radius: var(--radius-pill) !important;
        white-space: nowrap !important;
        align-self: center !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    .ref-summary-grid {
        grid-template-columns: 1fr;
    }

    .admin-grid {
        grid-template-columns: 1fr;
    }

    .ref-exam-pagination .ref-page-btn {
        width: 28px;
        height: 28px;
        font-size: 11.5px;
    }

    .ref-prev-btn,
    .ref-next-btn,
    .ref-submit-exam-btn {
        font-size: 12px;
        padding: 9px 8px;
    }
}

@media (max-width: 330px) {
    .ref-brand-title {
        display: none;
    }
}

/* 5. TOUCH & SAFE-AREA ENHANCEMENTS */
@media (hover: none) and (pointer: coarse) {
    .btn,
    .ref-opt-item,
    .ref-page-btn,
    .ref-user-btn,
    .ref-hamburger-btn {
        touch-action: manipulation;
    }

    .ref-cover-box:hover {
        transform: none;
    }

    .card:hover {
        transform: none;
    }
}
