/* =========================================================================
   ChemX Tutor — design system กลาง (โหลดเป็นไฟล์สุดท้ายใน head_assets ทุกโซน)
   สี/ฟอนต์/มุมโค้ง/เงา กำหนดที่ :root ที่เดียว — ปรับธีมทั้งเว็บได้จากตรงนี้
   ========================================================================= */

:root {
    /* แบรนด์ (ไล่จากสีโลโก้ #0d47a1) */
    --cx-navy: #0d47a1;
    --cx-primary: #1976d2;
    --cx-primary-600: #1565c0;
    --cx-primary-50: #e8f2fd;
    --cx-primary-100: #cfe3fa;
    --cx-accent: #ffb300;
    --cx-accent-50: #fff6e0;

    /* สถานะ */
    --cx-success: #16a34a;
    --cx-success-50: #e8f7ee;
    --cx-warning: #d97706;
    --cx-warning-50: #fff4e0;
    --cx-danger: #dc2626;
    --cx-danger-50: #fdecec;
    --cx-info: #0284c7;
    --cx-info-50: #e6f4fb;

    /* พื้น/ตัวอักษร */
    --cx-bg: #f4f7fb;
    --cx-surface: #ffffff;
    --cx-border: #e2e8f0;
    --cx-text: #1f2937;
    --cx-muted: #6b7280;

    --cx-radius: 14px;
    --cx-radius-sm: 10px;
    --cx-shadow: 0 1px 2px rgba(17, 24, 39, .04), 0 4px 16px rgba(17, 24, 39, .06);
    --cx-shadow-hover: 0 2px 4px rgba(17, 24, 39, .06), 0 10px 28px rgba(13, 71, 161, .12);
    --cx-font: "Noto Sans Thai", "Noto Sans", system-ui, sans-serif;
    --cx-topbar-h: 64px;

    /* ให้ component ของ Bootstrap ใช้สีแบรนด์ */
    --bs-primary: var(--cx-primary);
    --bs-primary-rgb: 25, 118, 210;
    --bs-link-color: var(--cx-primary);
    --bs-link-hover-color: var(--cx-navy);
    --bs-body-font-family: var(--cx-font);
    --bs-body-color: var(--cx-text);
}

body {
    font-family: var(--cx-font);
    color: var(--cx-text);
}

/* ---------- ปุ่ม ---------- */
.btn {
    border-radius: var(--cx-radius-sm);
    font-weight: 600;
    transition: transform .15s ease, box-shadow .15s ease, background-color .15s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
    --bs-btn-bg: var(--cx-primary);
    --bs-btn-border-color: var(--cx-primary);
    --bs-btn-hover-bg: var(--cx-primary-600);
    --bs-btn-hover-border-color: var(--cx-primary-600);
    --bs-btn-active-bg: var(--cx-navy);
    --bs-btn-active-border-color: var(--cx-navy);
    --bs-btn-disabled-bg: var(--cx-primary);
    --bs-btn-disabled-border-color: var(--cx-primary);
}
/* css/style.css (template เดิม) ทำให้ปุ่มหลักกลายเป็นสีดำตอน hover — ในโซน admin/student ให้เป็นน้ำเงินเข้มตามธีม */
.cx-app .btn.btn-primary:hover,
.cx-app .btn.btn-primary:focus-visible { background: var(--cx-primary-600); border-color: var(--cx-primary-600); }
.btn-outline-primary {
    --bs-btn-color: var(--cx-primary);
    --bs-btn-border-color: var(--cx-primary);
    --bs-btn-hover-bg: var(--cx-primary);
    --bs-btn-hover-border-color: var(--cx-primary);
    --bs-btn-active-bg: var(--cx-primary-600);
}
.btn-accent {
    background: var(--cx-accent);
    border-color: var(--cx-accent);
    color: #1f1300;
}
.btn-accent:hover { background: #ffa000; border-color: #ffa000; color: #1f1300; }

/* ---------- การ์ด ---------- */
.cx-card {
    background: var(--cx-surface);
    border: 1px solid var(--cx-border);
    border-radius: var(--cx-radius);
    box-shadow: var(--cx-shadow);
}
.cx-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--cx-border);
}
.cx-card-title {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--cx-navy);
}
.cx-card-body { padding: 1.25rem; }

/* ---------- หัวข้อหน้า ---------- */
.cx-page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.cx-page-title {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--cx-navy);
}
.cx-page-subtitle { margin: .25rem 0 0; color: var(--cx-muted); }
.cx-page-actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }

/* ---------- ปุ่ม "จัดการ" ในแถวตาราง (หลาย action รวมเป็น dropdown เดียว) ---------- */
.cx-actions .dropdown-menu {
    border: 1px solid var(--cx-border);
    border-radius: var(--cx-radius-sm);
    box-shadow: var(--cx-shadow-hover);
    padding: .35rem;
    min-width: 200px;
}
.cx-actions .dropdown-item {
    display: flex;
    align-items: center;
    gap: .55rem;
    border-radius: 8px;
    padding: .45rem .7rem;
    font-size: .9rem;
}
.cx-actions .dropdown-item i { width: 1rem; text-align: center; color: var(--cx-muted); }
.cx-actions .dropdown-item.text-danger i { color: inherit; }
.cx-actions form { margin: 0; }
.cx-actions form .dropdown-item { width: 100%; border: 0; background: none; text-align: left; }
.cx-actions form .dropdown-item:hover { background: var(--cx-danger-50); }

/* ---------- ช่องบังคับกรอก ---------- */
.cx-required::after { content: " *"; color: var(--cx-danger); }

/* ---------- รูปย่อในตาราง (คอร์ส ฯลฯ) ---------- */
.cx-thumb { width: 96px; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 8px; background: var(--cx-primary-50); flex-shrink: 0; }

/* ---------- แถบขั้นตอน (เช่น สั่งซื้อ → ชำระเงิน → ตรวจสอบ → เข้าเรียน) ---------- */
.cx-steps { display: flex; list-style: none; padding: 0; margin: 0 0 1.5rem; counter-reset: none; }
.cx-steps li { flex: 1; display: flex; flex-direction: column; align-items: center; gap: .4rem; position: relative; color: var(--cx-muted); font-size: .85rem; text-align: center; }
.cx-steps li + li::before { content: ""; position: absolute; top: 1rem; right: 50%; width: 100%; height: 2px; background: var(--cx-border); z-index: 0; }
.cx-steps li.is-done + li::before { background: var(--cx-primary); }
.cx-step-dot { position: relative; z-index: 1; width: 2rem; height: 2rem; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; background: var(--cx-surface); border: 2px solid var(--cx-border); color: var(--cx-muted); }
.cx-steps li.is-done .cx-step-dot { background: var(--cx-primary); border-color: var(--cx-primary); color: #fff; }
.cx-steps li.is-current .cx-step-dot { border-color: var(--cx-primary); color: var(--cx-primary); box-shadow: 0 0 0 4px var(--cx-primary-50); }
.cx-steps li.is-done, .cx-steps li.is-current { color: var(--cx-text); font-weight: 600; }

/* ---------- หัวข้อย่อยในการ์ด ---------- */
.cx-section-title { display: flex; align-items: center; gap: .5rem; font-size: 1.1rem; font-weight: 700; color: var(--cx-navy); margin: 0 0 1rem; }
.cx-step-num { width: 1.6rem; height: 1.6rem; border-radius: 50%; background: var(--cx-primary); color: #fff; font-size: .85rem; display: inline-flex; align-items: center; justify-content: center; }
.cx-subtitle { font-size: .95rem; font-weight: 700; color: var(--cx-text); margin-bottom: .5rem; }

/* ---------- ยอดเงิน ---------- */
.cx-amount { display: flex; flex-wrap: wrap; align-items: baseline; gap: .5rem 1rem; padding: 1rem 1.25rem; border-radius: var(--cx-radius-sm); background: var(--cx-primary-50); margin-bottom: 1rem; }
.cx-amount-value { font-size: 1.9rem; font-weight: 800; color: var(--cx-navy); line-height: 1.1; margin-right: auto; }

/* ---------- QR ---------- */
.cx-qr { text-align: center; margin: 0 auto 1rem; }
.cx-qr .cx-qr-svg, .cx-qr img { display: block; width: 100%; max-width: 240px; height: auto; margin: 0 auto .5rem; padding: .75rem; background: #fff; border: 1px solid var(--cx-border); border-radius: var(--cx-radius-sm); }
.cx-qr img { max-width: 260px; padding: 0; }

/* ---------- รายการคู่ ชื่อ: ค่า ---------- */
.cx-dl { display: grid; grid-template-columns: auto 1fr; gap: .35rem 1rem; margin: 0 0 1rem; }
.cx-dl dt { font-weight: 400; color: var(--cx-muted); }
.cx-dl dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }

/* ---------- รายการสินค้า + ยอดรวม ---------- */
.cx-line-items { list-style: none; padding: 0; margin: 0; }
.cx-line-items li { display: flex; justify-content: space-between; gap: 1rem; padding: .5rem 0; border-bottom: 1px dashed var(--cx-border); }
.cx-line-items li > span:last-child { white-space: nowrap; }
.cx-line-items li.is-total { border-bottom: 0; font-weight: 800; font-size: 1.05rem; }

/* ---------- ส่วนพับได้ ---------- */
.cx-details > summary { cursor: pointer; color: var(--cx-primary); font-weight: 600; }

/* ---------- สลิปที่ส่งแล้ว ---------- */
.cx-slip-sent { display: flex; flex-wrap: wrap; gap: 1rem; align-items: flex-start; }
.cx-slip-sent img { width: 140px; max-height: 220px; object-fit: contain; border: 1px solid var(--cx-border); border-radius: var(--cx-radius-sm); background: #fff; }

/* ---------- ช่องวางไฟล์ (ใช้คู่กับ js/app.js: แสดงตัวอย่างรูป + ลากวาง) ---------- */
.cx-dropzone { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .5rem; min-height: 170px; padding: 1.25rem; border: 2px dashed var(--cx-primary-100); border-radius: var(--cx-radius); background: #fafcff; text-align: center; cursor: pointer; transition: border-color .15s ease, background-color .15s ease; }
.cx-dropzone:hover, .cx-dropzone.is-dragover { border-color: var(--cx-primary); background: var(--cx-primary-50); }
.cx-dropzone input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.cx-dropzone img { max-width: 100%; max-height: 220px; border-radius: 8px; }
.cx-dropzone-text { display: flex; flex-direction: column; align-items: center; gap: .2rem; color: var(--cx-muted); }
.cx-dropzone-text i { font-size: 1.8rem; color: var(--cx-primary); }
.cx-dropzone-text strong { color: var(--cx-text); }
.cx-dropzone.has-file .cx-dropzone-text i { display: none; }

/* ---------- ส่วนพับได้บนมือถือ: <details class="cx-fold" data-cx-mobile-collapse open> ----------
   จอใหญ่กางไว้ / จอ < 992px พับอัตโนมัติ (js/app.js) แตะหัวข้อเพื่อดูเพิ่มเติม */
.cx-fold > summary { display: flex; align-items: center; justify-content: space-between; gap: .5rem; cursor: pointer; list-style: none; }
.cx-fold > summary::-webkit-details-marker { display: none; }
.cx-fold > summary::after { content: "ดูเพิ่มเติม \25BE"; font-size: .8rem; font-weight: 600; color: var(--cx-primary); white-space: nowrap; }
.cx-fold[open] > summary::after { content: "ย่อ \25B4"; }
.cx-fold-card > summary { padding: .85rem 1rem; margin: 0; }
.cx-fold-card[open] > summary { border-bottom: 1px solid var(--cx-border); }
@media (min-width: 992px) {
    /* จอใหญ่: แสดงเป็นหัวข้อปกติ ไม่ต้องมีปุ่มย่อ */
    .cx-fold[data-cx-mobile-collapse] > summary { pointer-events: none; }
    .cx-fold[data-cx-mobile-collapse] > summary::after { content: none; }
}

/* ---------- ตารางที่มือถือแสดงเป็นการ์ด: <table class="cx-table cx-table-stack"> (data-label ใส่โดย js/app.js) ---------- */
@media (max-width: 767.98px) {
    .cx-table-stack thead { display: none; }
    .cx-table-stack, .cx-table-stack tbody, .cx-table-stack tr, .cx-table-stack td { display: block; width: 100% !important; }
    .cx-table-stack tr { border: 1px solid var(--cx-border); border-radius: var(--cx-radius-sm); margin-bottom: .75rem; padding: .35rem .75rem; background: var(--cx-surface); }
    .cx-table-stack > tbody > tr > td { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .45rem 0 !important; border: 0; border-bottom: 1px dashed var(--cx-border); text-align: right !important; }
    .cx-table-stack > tbody > tr > td:last-child { border-bottom: 0; }
    .cx-table-stack > tbody > tr > td::before { content: attr(data-label); font-size: .8rem; font-weight: 600; color: var(--cx-muted); text-align: left; flex-shrink: 0; }
    .cx-table-stack > tbody > tr > td.dt-empty { display: block; text-align: center !important; }
    .cx-table-stack > tbody > tr > td.dt-empty::before { content: none; }
    .cx-table-stack .cx-stack-hide { display: none !important; }
}

/* ---------- การ์ดคำสั่งซื้อ (student/my_orders.php) ---------- */
.cx-order-cards { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.cx-order-card { display: flex; flex-direction: column; }
.cx-order-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: .75rem; padding: 1rem 1.25rem .5rem; }
.cx-order-card-body { padding: 0 1.25rem .75rem; flex: 1; }
.cx-order-course-list { margin: 0; padding-left: 1.1rem; }
.cx-order-course-list li { margin-bottom: .2rem; }
.cx-order-card-foot { display: flex; justify-content: space-between; align-items: center; gap: .75rem; padding: .75rem 1.25rem; border-top: 1px solid var(--cx-border); flex-wrap: wrap; }
.cx-order-total { font-size: 1.15rem; font-weight: 800; color: var(--cx-navy); }
.cx-order-card-foot form { margin: 0; }

.cx-order-first-course { font-weight: 600; margin-bottom: .25rem; }
.cx-search { display: flex; gap: .5rem; max-width: 520px; }

/* ---------- คูปองที่ใช้อยู่ (checkout) ---------- */
.cx-coupon-applied { display: flex; justify-content: space-between; align-items: center; gap: .5rem; padding: .6rem .85rem; border: 1px dashed var(--cx-success); border-radius: var(--cx-radius-sm); background: var(--cx-success-50); color: var(--cx-success); }

/* ---------- รายการ checkbox ยาว (เลือกคอร์ส ฯลฯ) ---------- */
.cx-check-list { max-height: 260px; overflow-y: auto; border: 1px solid var(--cx-border); border-radius: var(--cx-radius-sm); padding: .5rem .75rem; }
.cx-check-list.is-invalid { border-color: var(--cx-danger); }
.cx-check-list .form-check { display: block; padding: .3rem 0 .3rem 1.6rem; margin: 0; }

/* ---------- คูปอง (student/my_coupons.php) ---------- */
.cx-coupon-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.cx-coupon { display: flex; flex-direction: column; border-left: 4px solid var(--cx-primary); }
.cx-coupon.is-muted { border-left-color: var(--cx-border); opacity: .75; }
.cx-coupon-main { padding: 1rem 1.25rem; flex: 1; }
.cx-coupon-code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 800; font-size: 1.1rem; letter-spacing: .04em; color: var(--cx-navy); word-break: break-all; }
.cx-coupon-actions { display: flex; justify-content: flex-end; gap: .5rem; padding: .75rem 1.25rem; border-top: 1px dashed var(--cx-border); }

/* ---------- แท็บกรอง (เช่น สถานะคำสั่งซื้อ) ---------- */
.cx-tabs { position: relative; gap: .35rem; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
.cx-tabs .nav-link { white-space: nowrap; border-radius: 999px; padding: .4rem .9rem; color: var(--cx-muted); background: var(--cx-surface); border: 1px solid var(--cx-border); font-weight: 600; font-size: .9rem; }
.cx-tabs .nav-link.active { background: var(--cx-primary); border-color: var(--cx-primary); color: #fff; }
.cx-tab-count { display: inline-block; min-width: 1.4rem; padding: 0 .35rem; margin-left: .25rem; border-radius: 999px; background: rgba(0,0,0,.06); font-size: .75rem; text-align: center; }
.cx-tabs .nav-link.active .cx-tab-count { background: rgba(255,255,255,.25); }
.cx-slip-thumb { display: block; max-width: 100%; max-height: 240px; object-fit: contain; border: 1px solid var(--cx-border); border-radius: var(--cx-radius-sm); background: #fff; }

/* ---------- คิวตรวจสลิป (admin/review_slips.php) ---------- */
.cx-queue { list-style: none; margin: 0; padding: .35rem; }
.cx-queue a { display: flex; flex-direction: column; gap: .2rem; padding: .7rem .85rem; border-radius: var(--cx-radius-sm); color: var(--cx-text); text-decoration: none; }
.cx-queue a:hover { background: var(--cx-primary-50); }
.cx-queue a.is-active { background: var(--cx-primary-50); box-shadow: inset 3px 0 0 var(--cx-primary); }
.cx-slip-box { display: block; border: 1px solid var(--cx-border); border-radius: var(--cx-radius-sm); background: #fff; overflow: hidden; text-align: center; }
.cx-slip-box img { display: block; width: 100%; max-height: 520px; object-fit: contain; }
.cx-reject > summary { list-style: none; display: inline-block; }
.cx-reject > summary::-webkit-details-marker { display: none; }

/* ---------- ตัวแบ่งหน้า (cx_pagination) ---------- */
.cx-pagination { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem 1rem; padding: .75rem 1rem; border-top: 1px solid var(--cx-border); }
.cx-pagination-info { color: var(--cx-muted); font-size: .85rem; }
.cx-pagination .page-link { border-radius: 8px !important; margin: 0 2px; border-color: var(--cx-border); color: var(--cx-primary); }
.cx-pagination .page-item.active .page-link { background: var(--cx-primary); border-color: var(--cx-primary); color: #fff; }

/* ---------- รายการคำสั่งซื้อแบบแถว (หน้าแจ้งชำระเงิน) ---------- */
.cx-order-list { list-style: none; margin: 0; padding: 0; }
.cx-order-list > li { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem 1.5rem; padding: 1rem 1.25rem; border-bottom: 1px solid var(--cx-border); }
.cx-order-list > li:last-child { border-bottom: 0; }
.cx-order-main { min-width: 0; flex: 1 1 260px; }
.cx-order-side { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }

/* ---------- การ์ดตัวเลขสรุป ---------- */
.cx-stat {
    display: flex;
    align-items: center;
    gap: 1rem;
    height: 100%;
    padding: 1.1rem 1.25rem;
    background: var(--cx-surface);
    border: 1px solid var(--cx-border);
    border-radius: var(--cx-radius);
    box-shadow: var(--cx-shadow);
    color: inherit;
    text-decoration: none;
    transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}
a.cx-stat:hover {
    transform: translateY(-3px);
    box-shadow: var(--cx-shadow-hover);
    border-color: var(--cx-primary-100);
    color: inherit;
}
.cx-stat-icon {
    flex: 0 0 48px;
    width: 48px;
    height: 48px;
    display: grid;
    place-items: center;
    border-radius: 12px;
    font-size: 1.25rem;
    background: var(--cx-primary-50);
    color: var(--cx-primary);
}
.cx-stat-icon.is-success { background: var(--cx-success-50); color: var(--cx-success); }
.cx-stat-icon.is-warning { background: var(--cx-warning-50); color: var(--cx-warning); }
.cx-stat-icon.is-danger { background: var(--cx-danger-50); color: var(--cx-danger); }
.cx-stat-icon.is-info { background: var(--cx-info-50); color: var(--cx-info); }
.cx-stat-label { margin: 0; font-size: .875rem; color: var(--cx-muted); }
@media (max-width: 575.98px) {
    /* มือถือ: icon อยู่บน ข้อความเต็มความกว้างการ์ด ไม่ต้องตัดบรรทัด */
    .cx-stat { flex-direction: column; align-items: flex-start; gap: .6rem; padding: .9rem 1rem; }
    .cx-stat-icon { flex-basis: auto; width: 40px; height: 40px; font-size: 1.05rem; }
    .cx-stat-label { font-size: .8rem; }
    .cx-stat-value { font-size: 1.35rem; }
    .cx-page-title { font-size: 1.3rem; }
}
.cx-stat-value { margin: 0; font-size: 1.6rem; font-weight: 800; line-height: 1.2; color: var(--cx-text); }

/* ---------- badge สถานะ (ใช้คู่กับ cx_status_badge() ใน PHP หรือใส่ class เอง) ---------- */
.cx-badge {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .3rem .7rem;
    border-radius: 999px;
    font-size: .8rem;
    font-weight: 600;
    white-space: nowrap;
    background: #eef0f4;
    color: #4b5563;
}
.cx-badge::before {
    content: "";
    width: .45rem;
    height: .45rem;
    border-radius: 50%;
    background: currentColor;
}
.cx-badge.is-success { background: var(--cx-success-50); color: var(--cx-success); }
.cx-badge.is-warning { background: var(--cx-warning-50); color: var(--cx-warning); }
.cx-badge.is-danger { background: var(--cx-danger-50); color: var(--cx-danger); }
.cx-badge.is-info { background: var(--cx-info-50); color: var(--cx-info); }
.cx-badge.is-primary { background: var(--cx-primary-50); color: var(--cx-primary); }

/* ---------- ตาราง ---------- */
.cx-table { margin: 0; }
.cx-table > thead > tr > th {
    background: #f8f9fc;
    color: var(--cx-muted);
    font-size: .8rem;
    font-weight: 700;
    letter-spacing: .02em;
    text-transform: uppercase;
    border-bottom: 1px solid var(--cx-border);
    padding: .8rem 1rem;
    white-space: nowrap;
}
.cx-table > tbody > tr > td {
    padding: .85rem 1rem;
    border-color: var(--cx-border);
    vertical-align: middle;
}
.cx-table > tbody > tr { transition: background-color .15s ease; }
.cx-table > tbody > tr:hover { background: #fafbff; }

/* DataTables 2 ให้เข้าธีม */
div.dt-container { font-size: .925rem; }
div.dt-container .dt-search input,
div.dt-container .dt-length select {
    border: 1px solid var(--cx-border);
    border-radius: var(--cx-radius-sm);
    padding: .4rem .7rem;
    background: var(--cx-surface);
}
div.dt-container .dt-search input:focus,
div.dt-container .dt-length select:focus {
    outline: none;
    border-color: var(--cx-primary);
    box-shadow: 0 0 0 .2rem rgba(25, 118, 210, .15);
}
div.dt-container .dt-paging .dt-paging-button {
    border-radius: 8px !important;
    border: 0 !important;
}
div.dt-container .dt-paging .dt-paging-button.current,
div.dt-container .dt-paging .dt-paging-button.current:hover {
    background: var(--cx-primary) !important;
    color: #fff !important;
}
div.dt-container .dt-paging .dt-paging-button:hover {
    background: var(--cx-primary-50) !important;
    color: var(--cx-primary) !important;
}
div.dt-container .dt-layout-row { padding: .25rem 0; }

/* ---------- empty state ---------- */
.cx-empty {
    padding: 2.5rem 1rem;
    text-align: center;
    color: var(--cx-muted);
}
.cx-empty i { font-size: 2rem; color: var(--cx-primary-100); margin-bottom: .75rem; display: block; }

/* ---------- ฟอร์ม ---------- */
.form-control, .form-select {
    border-radius: var(--cx-radius-sm);
    border-color: var(--cx-border);
}
.form-control:focus, .form-select:focus {
    border-color: var(--cx-primary);
    box-shadow: 0 0 0 .2rem rgba(25, 118, 210, .15);
}

/* ---------- SweetAlert2 ให้เข้าธีม ---------- */
.swal2-popup { border-radius: var(--cx-radius) !important; font-family: var(--cx-font) !important; }
.swal2-styled.swal2-confirm { background: var(--cx-primary) !important; border-radius: var(--cx-radius-sm) !important; }
.swal2-styled.swal2-cancel { border-radius: var(--cx-radius-sm) !important; }

/* =========================================================================
   App shell — topbar + sidebar ของ admin/ และ student/ (inc/app_topbar.php)
   ใช้ layout เดิมของ SB Admin (#layoutSidenav / .sb-sidenav) แต่จัดหน้าตาใหม่
   ========================================================================= */
body.cx-app { background: var(--cx-bg); }

.cx-topbar {
    position: sticky;
    top: 0;
    z-index: 1030;
    height: var(--cx-topbar-h);
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: 0 1rem;
    background: rgba(255, 255, 255, .92);
    backdrop-filter: saturate(180%) blur(10px);
    border-bottom: 1px solid var(--cx-border);
}
.cx-topbar-toggle {
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--cx-navy);
    font-size: 1.1rem;
}
.cx-topbar-toggle:hover { background: var(--cx-primary-50); }
.cx-topbar-brand {
    display: flex;
    align-items: center;
    gap: .6rem;
    text-decoration: none;
    color: var(--cx-navy);
    font-weight: 800;
    white-space: nowrap;
}
.cx-topbar-brand img { height: 36px; width: auto; }
.cx-topbar-brand small {
    display: block;
    font-size: .72rem;
    font-weight: 600;
    color: var(--cx-muted);
    line-height: 1;
}
.cx-topbar-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: .25rem;
}
.cx-topbar-link {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    padding: .5rem .75rem;
    border-radius: 10px;
    color: var(--cx-text);
    text-decoration: none;
    font-weight: 500;
}
.cx-topbar-link:hover { background: var(--cx-primary-50); color: var(--cx-primary); }
.cx-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, var(--cx-primary), var(--cx-navy));
    color: #fff;
    font-weight: 700;
    font-size: .95rem;
}
.cx-user-toggle {
    display: flex;
    align-items: center;
    gap: .55rem;
    padding: .25rem .5rem .25rem .25rem;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--cx-text);
}
.cx-user-toggle:hover { background: var(--cx-primary-50); }
.cx-user-toggle::after { display: none; }
.cx-user-name { font-weight: 600; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cx-user-menu { border: 1px solid var(--cx-border); border-radius: var(--cx-radius); box-shadow: var(--cx-shadow-hover); padding: .4rem; min-width: 220px; }
.cx-user-menu .dropdown-item { border-radius: 8px; padding: .5rem .75rem; display: flex; align-items: center; gap: .6rem; }
.cx-user-menu .dropdown-item i { width: 1rem; text-align: center; color: var(--cx-muted); }
.cx-user-menu .dropdown-item.text-danger i { color: var(--cx-danger); }

/* sidebar — วางใต้ topbar (เดิม SB Admin ใช้ top: 56px สำหรับ navbar ของตัวเอง) */
.cx-app #layoutSidenav #layoutSidenav_nav { width: 248px; }
.cx-app #layoutSidenav_nav .sb-sidenav {
    background: var(--cx-surface);
    border-right: 1px solid var(--cx-border);
}
.cx-app .sb-sidenav .sb-sidenav-menu .nav { padding: .75rem; gap: 2px; }
.cx-app .sb-sidenav .sb-sidenav-menu .nav-link {
    display: flex;
    align-items: center;
    gap: .2rem;
    padding: .6rem .8rem;
    border-radius: 10px;
    color: #4b5563;
    font-weight: 500;
    transition: background-color .15s ease, color .15s ease;
}
.cx-app .sb-sidenav .sb-sidenav-menu .nav-link .sb-nav-link-icon {
    width: 1.6rem;
    margin-right: .35rem;
    font-size: .95rem;
    color: #9ca3af;
    text-align: center;
}
.cx-app .sb-sidenav .sb-sidenav-menu .nav-link .sb-nav-link-icon i { margin: 0 !important; }
.cx-app .sb-sidenav .sb-sidenav-menu .nav-link:hover { background: var(--cx-primary-50); color: var(--cx-primary); }
.cx-app .sb-sidenav .sb-sidenav-menu .nav-link:hover .sb-nav-link-icon { color: var(--cx-primary); }
.cx-app .sb-sidenav .sb-sidenav-menu .nav-link.active {
    background: var(--cx-primary);
    color: #fff;
    box-shadow: 0 4px 12px rgba(25, 118, 210, .25);
}
.cx-app .sb-sidenav .sb-sidenav-menu .nav-link.active .sb-nav-link-icon { color: #fff; }
.cx-app .sb-sidenav .sb-sidenav-menu .nav-link .badge { margin-left: auto !important; }
.cx-app .sb-sidenav .sb-sidenav-menu-heading {
    padding: 1rem .8rem .35rem;
    font-size: .7rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: #9ca3af;
}
.cx-app .sb-sidenav-footer { display: none; } /* ชื่อผู้ใช้แสดงที่ topbar แล้ว */
.cx-app #layoutSidenav_content { background: var(--cx-bg); }
.cx-app #layoutSidenav_content > main { padding: 1.75rem 1.5rem; }
.cx-app #layoutSidenav_content > footer { background: transparent !important; border-top: 1px solid var(--cx-border); }

@media (min-width: 992px) {
    .cx-app #layoutSidenav #layoutSidenav_nav {
        flex-basis: 248px;
        position: sticky;
        top: var(--cx-topbar-h);
        height: calc(100vh - var(--cx-topbar-h));
        overflow-y: auto;
        transform: none;
        transition: margin-left .2s ease;
    }
    .cx-app #layoutSidenav #layoutSidenav_content { margin-left: 0; }
    /* ซ่อน sidebar: เลื่อนออกด้วย margin (ไม่ใช่ transform) เนื้อหาจะขยายเต็มจอ ไม่เหลือช่องว่าง */
    .cx-app.sb-sidenav-toggled #layoutSidenav #layoutSidenav_nav { margin-left: -248px; transform: none; }
}
@media (max-width: 991.98px) {
    .cx-app #layoutSidenav #layoutSidenav_nav {
        position: fixed;
        top: var(--cx-topbar-h);
        bottom: 0;
        left: 0;
        width: 248px;
        height: auto;
        overflow-y: auto;
        z-index: 1040;
        transform: translateX(-248px);
        transition: transform .2s ease;
        box-shadow: none;
    }
    .cx-app.sb-sidenav-toggled #layoutSidenav #layoutSidenav_nav {
        transform: translateX(0);
        box-shadow: 8px 0 32px rgba(17, 24, 39, .18);
    }
    .cx-app.sb-sidenav-toggled::before { top: var(--cx-topbar-h); height: calc(100vh - var(--cx-topbar-h)); background: rgba(17, 24, 39, .35); }
    .cx-app #layoutSidenav #layoutSidenav_content { margin-left: 0 !important; }
    .cx-app #layoutSidenav_content > main { padding: 1.25rem 1rem; }
    .cx-app .cx-user-name { display: none; }
}
.cx-app .btn-close-sidenav { display: none !important; } /* ปิดด้วยปุ่มเดิมที่ topbar */

/* ---------- animation (ปิดเองถ้าผู้ใช้ตั้งค่าลดการเคลื่อนไหว) ---------- */
@keyframes cx-fade-up {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: none; }
}
.cx-animate > * { animation: cx-fade-up .35s ease both; }
.cx-animate > *:nth-child(2) { animation-delay: .05s; }
.cx-animate > *:nth-child(3) { animation-delay: .1s; }
.cx-animate > *:nth-child(4) { animation-delay: .15s; }
.cx-animate > *:nth-child(n+5) { animation-delay: .2s; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}

/* =========================================================================
   เว็บไซต์สาธารณะ — header (nav.php) + footer (footer.php)
   ========================================================================= */
.cx-nav.navbar {
    padding: .6rem 0;
    background: rgba(255, 255, 255, .95);
    backdrop-filter: saturate(180%) blur(10px);
    border-bottom: 1px solid var(--cx-border);
    z-index: 1030;
}
.cx-nav .cx-nav-brand {
    display: flex;
    align-items: center;
    gap: .6rem;
    margin: 0;
    padding: 0;
    color: var(--cx-navy);
    font-weight: 800;
    font-size: 1.3rem;
}
.cx-nav .cx-nav-brand img { height: 44px; max-height: 44px; width: auto; }
.cx-nav .cx-nav-toggler {
    border: 0;
    width: 42px;
    height: 42px;
    border-radius: 10px;
    color: var(--cx-navy);
    font-size: 1.2rem;
    box-shadow: none !important;
}
.cx-nav .cx-nav-toggler:hover { background: var(--cx-primary-50); }
.cx-nav .navbar-nav .nav-link {
    white-space: nowrap;
    margin: 0 .2rem;
    padding: .5rem .8rem;
    border-radius: 10px;
    color: var(--cx-text);
    font-size: 1rem;
    font-weight: 500;
    transition: background-color .15s ease, color .15s ease;
}
.cx-nav .navbar-nav .nav-link:hover { color: var(--cx-primary); background: var(--cx-primary-50); }
.cx-nav .navbar-nav .nav-link.active { color: var(--cx-primary); font-weight: 700; }
.cx-nav .dropdown-toggle::after { font-size: .8em; margin-left: .35rem; }
.cx-nav button.nav-link { font-family: inherit; line-height: inherit; text-align: left; width: 100%; }
@media (min-width: 992px) { .cx-nav button.nav-link { width: auto; } }
.cx-nav .cx-nav-dropdown {
    border: 1px solid var(--cx-border);
    border-radius: var(--cx-radius);
    box-shadow: var(--cx-shadow-hover);
    padding: .4rem;
    margin-top: .4rem !important;
}
.cx-nav .navbar-nav .cx-nav-dropdown .dropdown-item { border-radius: 8px; padding: .5rem .8rem; }
.cx-nav .navbar-nav .cx-nav-dropdown .dropdown-item:hover,
.cx-nav .navbar-nav .cx-nav-dropdown .dropdown-item:focus { background: var(--cx-primary-50); color: var(--cx-primary); }
.cx-nav .cx-nav-actions { display: flex; align-items: center; gap: .5rem; }
/* ปุ่มใน header ใช้ class ของตัวเอง — บางหน้า (เช่น index.php) เขียน CSS ทับ .btn-primary ทั้งหน้า */
.cx-nav .cx-nav-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .35rem;
    height: 38px;
    padding: 0 1rem;
    border: 1px solid transparent;
    border-radius: 10px;
    font-size: .9rem;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
    text-decoration: none;
    transition: background-color .15s ease, border-color .15s ease, color .15s ease, transform .15s ease;
}
.cx-nav .cx-nav-btn:active { transform: translateY(1px); }
.cx-nav .cx-nav-btn.is-primary { background: var(--cx-primary); color: #fff; }
.cx-nav .cx-nav-btn.is-primary:hover { background: var(--cx-navy); color: #fff; }
.cx-nav .cx-nav-btn.is-outline { border-color: var(--cx-primary); color: var(--cx-primary); background: #fff; }
.cx-nav .cx-nav-btn.is-outline:hover { background: var(--cx-primary-50); }
.cx-nav .cx-nav-btn.is-accent { background: var(--cx-accent); color: #1f1300; }
.cx-nav .cx-nav-btn.is-accent:hover { background: #ffa000; color: #1f1300; }
.cx-nav .cx-nav-btn.is-ghost { color: var(--cx-muted); background: transparent; }
.cx-nav .cx-nav-btn.is-ghost:hover { color: var(--cx-danger); background: var(--cx-danger-50); }
.cx-nav .cx-nav-socials { gap: .25rem; margin-right: .5rem; }
.cx-nav .cx-nav-socials a,
.cx-nav .cx-nav-cart {
    position: relative;
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    color: var(--cx-muted);
    text-decoration: none;
    transition: background-color .15s ease, color .15s ease;
}
.cx-nav .cx-nav-socials a:hover,
.cx-nav .cx-nav-cart:hover { background: var(--cx-primary-50); color: var(--cx-primary); }
.cx-nav .cx-nav-cart { color: var(--cx-navy); font-size: 1.05rem; }
.cx-nav .cx-nav-cart-badge {
    position: absolute;
    top: 2px;
    right: 0;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: var(--cx-danger);
    color: #fff;
    font-size: .7rem;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
}
@media (max-width: 991.98px) {
    .cx-nav .cx-nav-brand { font-size: 1.15rem; }
    .cx-nav .cx-nav-brand img { height: 38px; }
    .cx-nav .navbar-collapse { padding: .75rem 0 .5rem; }
    .cx-nav .navbar-nav { margin: 0 0 .75rem; }
    .cx-nav .navbar-nav .nav-link { margin: 0; }
    .cx-nav .cx-nav-dropdown { box-shadow: none; border: 0; padding: 0 0 0 1rem; }
    .cx-nav .cx-nav-actions { flex-wrap: wrap; padding-top: .75rem; border-top: 1px solid var(--cx-border); }
    .cx-nav .cx-nav-actions .cx-nav-btn { flex: 1 1 auto; }
}

.cx-footer {
    margin-top: 3rem;
    padding: 3rem 0 1.5rem;
    background: var(--cx-navy);
    color: rgba(255, 255, 255, .78);
    text-align: left;
}
.cx-footer a { color: rgba(255, 255, 255, .85); text-decoration: none; font-weight: 400; }
.cx-footer a:hover { color: #fff; }
.cx-footer .cx-footer-brand { display: inline-flex; align-items: center; gap: .6rem; font-size: 1.25rem; font-weight: 800; color: #fff !important; }
.cx-footer-brand img { height: 40px; background: #fff; border-radius: 10px; padding: 3px 6px; }
.cx-footer-text { margin: .9rem 0 0; max-width: 420px; line-height: 1.7; }
.cx-footer-title { font-size: .95rem; font-weight: 700; color: #fff; margin-bottom: .9rem; }
.cx-footer-links { list-style: none; padding: 0; margin: 0; display: grid; gap: .55rem; overflow-wrap: anywhere; }
.cx-footer-links i { width: 1.1rem; margin-right: .35rem; opacity: .8; }
.cx-footer-socials { display: flex; gap: .5rem; margin-top: 1rem; }
.cx-footer-socials a {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: rgba(255, 255, 255, .1);
    transition: background-color .15s ease;
}
.cx-footer-socials a:hover { background: var(--cx-accent); color: #1f1300; }
.cx-footer-bottom {
    margin-top: 2.25rem;
    padding-top: 1.25rem;
    border-top: 1px solid rgba(255, 255, 255, .12);
    font-size: .875rem;
    color: rgba(255, 255, 255, .6);
}

/* =========================================================================
   ปรับหน้าตา component เดิมของแต่ละหน้าในโซน admin/ และ student/ ให้เป็นชุดเดียวกัน
   (เฉพาะการแสดงผล — ไม่แตะ markup/ฟังก์ชันของหน้า) ใช้ selector .cx-app เพื่อไม่กระทบหน้าเว็บสาธารณะ
   ========================================================================= */

/* การ์ด */
.cx-app main .card {
    border: 1px solid var(--cx-border);
    border-radius: var(--cx-radius);
    box-shadow: var(--cx-shadow);
    overflow: hidden;
}
/* หัวการ์ด: เดิมเป็นแถบสีทึบหลายสี (bg-primary / bg-success / bg-info ...) → หัวขาว ตัวอักษรสีแบรนด์แบบเดียวกันทุกหน้า */
.cx-app main .card > .card-header,
.cx-app main .card > .card-header[class*="bg-"] {
    background: var(--cx-surface) !important;
    color: var(--cx-navy) !important;
    border-bottom: 1px solid var(--cx-border);
    padding: .9rem 1.25rem;
    font-weight: 700;
}
.cx-app main .card > .card-header * { color: inherit; }
.cx-app main .card > .card-header .btn { color: revert; }

/* ตาราง: หัวตารางสีฟ้า (table-primary / table-dark / bg-*) → เทาอ่อนแบบเดียวกัน */
.cx-app main .table { --bs-table-hover-bg: #fafbff; }
.cx-app main .table > thead > tr > th,
.cx-app main .table > thead.table-primary > tr > th,
.cx-app main .table > thead.table-dark > tr > th,
.cx-app main .table > thead[class*="bg-"] > tr > th {
    background: #f8f9fc !important;
    color: var(--cx-muted) !important;
    font-size: .82rem;
    font-weight: 700;
    border-bottom: 1px solid var(--cx-border);
    vertical-align: middle;
}
.cx-app main .table > tbody > tr > td { border-color: var(--cx-border); vertical-align: middle; }

/* badge ของ Bootstrap: ทรง pill อ่านง่าย */
.cx-app main .badge { border-radius: 999px; padding: .4em .75em; font-weight: 600; }

/* กล่องแจ้งเตือน: สีอ่อนลง มีแถบสีด้านซ้ายบอกประเภท */
.cx-app main .alert,
.cx-auth .alert {
    border: 1px solid var(--cx-border);
    border-left-width: 4px;
    border-radius: var(--cx-radius-sm);
    background: var(--cx-surface);
    color: var(--cx-text);
}
.cx-app main .alert-info, .cx-auth .alert-info { border-left-color: var(--cx-info); background: var(--cx-info-50); }
.cx-app main .alert-success, .cx-auth .alert-success { border-left-color: var(--cx-success); background: var(--cx-success-50); }
.cx-app main .alert-warning, .cx-auth .alert-warning { border-left-color: var(--cx-warning); background: var(--cx-warning-50); }
.cx-app main .alert-danger, .cx-auth .alert-danger { border-left-color: var(--cx-danger); background: var(--cx-danger-50); }
.cx-app main .alert-secondary, .cx-app main .alert-light { border-left-color: #9ca3af; background: #f8f9fc; }

/* หัวข้อหน้า: ทุกหน้าใช้ .cx-page-title รูปแบบเดียวกัน (ชิดซ้าย + icon สีแบรนด์)
   !important เพราะบางหน้ามี CSS ของตัวเองใส่ gradient ตัวอักษร / จัดกลาง / เส้นใต้ ไว้กับหัวข้อ */
.cx-app main .cx-page-title {
    display: flex !important;
    align-items: center;
    justify-content: flex-start !important;
    gap: .6rem;
    margin-top: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    background: none !important;
    text-align: left !important;
    font-size: 1.5rem !important;
    font-weight: 800 !important;
    color: var(--cx-navy) !important;
    -webkit-text-fill-color: currentColor !important;
    letter-spacing: normal !important;
}
.cx-app main .cx-page-title::before,
.cx-app main .cx-page-title::after { display: none !important; }
.cx-app main .cx-page-title i,
.cx-app main .cx-page-title svg {
    margin: 0 !important;
    font-size: 1.2rem;
    color: var(--cx-primary) !important;
    -webkit-text-fill-color: currentColor !important;
}
@media (max-width: 575.98px) { .cx-app main .cx-page-title { font-size: 1.3rem !important; } }

/* หัวข้ออื่นๆ ในเนื้อหา: สีแบรนด์ */
.cx-app main h1, .cx-app main h2, .cx-app main h3, .cx-app main h4 { color: var(--cx-navy); }
.cx-app main h3.fw-bold, .cx-app main h2.fw-bold { font-weight: 800 !important; }

/* label/ช่องกรอกในฟอร์มหลังบ้าน */
.cx-app main .form-label, .cx-app main label { font-weight: 600; color: #374151; }
.cx-app main .form-control, .cx-app main .form-select { min-height: 40px; }

/* ปุ่ม back-to-top เดิมของ template: ให้ดูเบาลง */
.back-to-top {
    border-radius: 12px !important;
    box-shadow: var(--cx-shadow-hover);
}
/* มือถือ: ปุ่มเล็กลง ชิดมุม และจางลง ไม่บังปุ่มทางขวาของแถว (เช่น "ดูตัวอย่างฟรี") */
@media (max-width: 991.98px) {
    .back-to-top { right: 12px !important; bottom: 12px !important; width: 40px !important; height: 40px !important; padding: 0 !important; opacity: .85; font-size: 1rem !important; display: flex; align-items: center; justify-content: center; }
    .back-to-top i { line-height: 1; }
}

/* =========================================================================
   หน้า login / สมัครสมาชิก (.cx-auth) — การ์ดแคบกลางจอ + โลโก้จางๆ เป็นพื้นหลัง
   ========================================================================= */
.cx-auth {
    position: relative;
    isolation: isolate;
    overflow: hidden;
    min-height: calc(100vh - 70px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem 1rem;
    background:
        radial-gradient(1200px 600px at 10% -10%, #dbeafe 0%, transparent 60%),
        radial-gradient(900px 500px at 110% 110%, #e0f2fe 0%, transparent 55%),
        var(--cx-bg);
}
/* โลโก้จางๆ ขนาดใหญ่ด้านหลังการ์ด */
.cx-auth::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    background: url("../img/logoChemX-2025-NoBg.png") center / min(760px, 90vw) auto no-repeat;
    opacity: .07;
    pointer-events: none;
}
.cx-auth-card {
    width: 100%;
    max-width: 400px;
    padding: 2rem 1.75rem 1.75rem;
    background: rgba(255, 255, 255, .92);
    backdrop-filter: blur(6px);
    border: 1px solid var(--cx-border);
    border-radius: 18px;
    box-shadow: 0 2px 4px rgba(15, 23, 42, .04), 0 20px 50px rgba(13, 71, 161, .12);
    animation: cx-fade-up .35s ease both;
}
.cx-auth-card.is-wide { max-width: 460px; }
.cx-auth-head { text-align: center; margin-bottom: 1.5rem; }
.cx-auth-logo { height: 56px; width: auto; margin-bottom: .75rem; }
.cx-auth-icon {
    width: 56px;
    height: 56px;
    display: inline-grid;
    place-items: center;
    margin-bottom: .75rem;
    border-radius: 16px;
    background: var(--cx-primary-50);
    color: var(--cx-primary);
    font-size: 1.4rem;
}
.cx-auth-title { margin: 0; font-size: 1.45rem; font-weight: 800; color: var(--cx-navy); }
.cx-auth-subtitle { margin: .35rem 0 0; color: var(--cx-muted); font-size: .95rem; }
.cx-auth .form-label { font-weight: 600; color: #374151; margin-bottom: .35rem; }
.cx-auth .form-control { height: 44px; }
.cx-auth-submit { height: 46px; font-size: 1rem; }
.cx-auth .btn-outline-primary { height: 44px; display: flex; align-items: center; justify-content: center; }
.cx-auth-divider {
    display: flex;
    align-items: center;
    gap: .75rem;
    margin: 1.25rem 0 1rem;
    color: var(--cx-muted);
    font-size: .85rem;
}
.cx-auth-divider::before,
.cx-auth-divider::after { content: ""; flex: 1; height: 1px; background: var(--cx-border); }
.cx-auth-note { margin: 1rem 0 0; text-align: center; font-size: .82rem; color: var(--cx-muted); }
.cx-auth-switch { margin: 1.25rem 0 0; text-align: center; color: var(--cx-muted); }
.cx-auth-switch a { font-weight: 600; }
.cx-auth + .cx-footer { margin-top: 0; }
@media (max-width: 575.98px) {
    .cx-auth { padding: 1.5rem .75rem; align-items: flex-start; }
    .cx-auth-card { padding: 1.5rem 1.25rem; border-radius: 16px; }
}

/* ฟอร์มคอร์ส: ของที่จัดส่ง (admin/inc/course_materials_field.php) */
.cx-ship-items { margin-top: .5rem; padding: .75rem; border: 1px solid var(--cx-border); border-radius: .5rem; background: var(--cx-primary-50); }
.cx-ship-row { display: grid; grid-template-columns: 1fr 5.5rem auto; gap: .5rem; margin-bottom: .5rem; }

/* หน้าแพ็คของ (admin/packing_view.php) */
.cx-scan-status { padding: .5rem .75rem; border-radius: var(--cx-radius-sm); background: var(--cx-surface); border: 1px solid var(--cx-border); font-weight: 600; }
.cx-scan-status.is-success { background: var(--cx-success-50); color: var(--cx-success); border-color: transparent; }
.cx-scan-status.is-warning { background: var(--cx-warning-50); color: var(--cx-warning); border-color: transparent; }
.cx-scan-status.is-info { background: var(--cx-info-50); color: var(--cx-info); border-color: transparent; }
.cx-scan-status.is-danger { background: var(--cx-danger-50); color: var(--cx-danger); border-color: transparent; }
.cx-pack-table .cx-pack-check { width: 1.5rem; height: 1.5rem; }
/* สีพื้นใส่ที่ช่อง (ไม่ใช่แถว) — มือถือแถวเป็นการ์ด display:block แล้วสีพื้นของแถวแรกไม่ถูกวาด */
.cx-pack-table > tbody > tr.cx-pack-row.is-done,
.cx-pack-table > tbody > tr.cx-pack-row.is-done > td { background-color: var(--cx-success-50); }
.cx-address { line-height: 1.5; }

/* สินค้าที่จัดส่ง: ปรับสต็อก (admin/manage_document.php) */
.cx-stock-form { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .35rem; }
.cx-stock-form input { width: 7rem; }
.cx-dl-end { grid-template-columns: 1fr auto; max-width: 360px; margin-left: auto; }
.cx-dl-end dd { text-align: right; }
.cx-ship-head { margin-bottom: .25rem; font-size: .8rem; font-weight: 600; color: var(--cx-muted); }

/* เมนู admin แบบกลุ่มพับได้ (admin/nav-admin.php) — <details class="cx-nav-group"> */
.cx-app .sb-sidenav .cx-nav-group > summary { list-style: none; cursor: pointer; }
.cx-app .sb-sidenav .cx-nav-group > summary::-webkit-details-marker { display: none; }
.cx-app .sb-sidenav .cx-nav-group > summary::after { content: "\25BE"; margin-left: auto; padding-left: .5rem; font-size: .8rem; color: var(--cx-muted); transition: transform .15s; }
.cx-app .sb-sidenav .cx-nav-group:not([open]) > summary::after { transform: rotate(-90deg); }
.cx-app .sb-sidenav .cx-nav-group > summary .badge { margin-left: auto !important; }
.cx-app .sb-sidenav .cx-nav-group[open] > summary .cx-nav-group-count { display: none; } /* กางแล้ว ตัวเลขอยู่ที่เมนูย่อย */
.cx-app .sb-sidenav .cx-nav-group.is-current > summary { color: var(--cx-primary); font-weight: 700; }
.cx-app .sb-sidenav .sb-sidenav-menu .nav-link.cx-nav-sub { padding-left: 2.25rem; font-size: .92rem; }

/* การ์ดพับได้บนมือถือ: [data-cx-fold] (js/app.js applyCardFold) — จอใหญ่ไม่มีผล */
@media (max-width: 991.98px) {
    .cx-foldable .cx-fold-head { cursor: pointer; display: flex; align-items: center; gap: .5rem; }
    .cx-foldable .cx-fold-head::after { content: "ย่อ \25B4"; margin-left: auto; font-size: .8rem; font-weight: 600; color: var(--cx-primary); white-space: nowrap; }
    .cx-foldable.is-folded .cx-fold-head::after { content: "ดูเพิ่มเติม \25BE"; }
    .cx-foldable.card > .card-header.cx-fold-head::after { color: inherit; }
    /* พับ: ซ่อนทุกอย่างในการ์ดที่ไม่ใช่หัวการ์ด (และไม่ได้ติด data-cx-fold-keep) */
    .cx-foldable.is-folded > :not(.cx-fold-head):not([data-cx-fold-keep]):not(:has(.cx-fold-head)),
    .cx-foldable.is-folded > :has(.cx-fold-head) > :not(.cx-fold-head):not([data-cx-fold-keep]) { display: none !important; }
    .cx-foldable.is-folded > .card-header { border-bottom: 0; }
    /* หัวที่มีปุ่มหลายปุ่ม ([data-cx-fold-head]) — ป้าย ดูเพิ่มเติม/ย่อ ลงบรรทัดใหม่ชิดขวา ไม่เบียดชื่อ */
    .cx-foldable [data-cx-fold-head].cx-fold-head { flex-wrap: wrap; }
    .cx-foldable [data-cx-fold-head].cx-fold-head::after { flex-basis: 100%; text-align: right; }
}
.cx-due { padding: .6rem .9rem; border-radius: var(--cx-radius-sm); background: var(--cx-warning-50); color: var(--cx-text); }
.cx-ta-list { position: absolute; z-index: 20; left: 0; right: 0; max-height: 16rem; overflow-y: auto; box-shadow: var(--cx-shadow-hover); }

/* โจทย์/ตัวเลือกที่มีรูปหรือตาราง (ผลสอบ/ทำข้อสอบ) — ไม่ให้ล้นจอมือถือ */
.cx-app .question-text img, .cx-app .answer-text img { max-width: 100%; height: auto; }
.cx-app .question-text table { display: block; max-width: 100%; overflow-x: auto; }

/* ตัวยก/ตัวห้อยในโจทย์ (H₂O, 10⁻⁷) — เล็กแบบตำรา และไม่ดันระยะบรรทัด */
.question-text sub, .answer-text sub, .answer-option sub { font-size: .65em; line-height: 0; position: relative; vertical-align: baseline; bottom: -.25em; }
.question-text sup, .answer-text sup, .answer-option sup { font-size: .65em; line-height: 0; position: relative; vertical-align: baseline; top: -.5em; }

/* ══ หน้าจัดการข้อสอบ (admin/quiz_questions.php + js/quiz-editor.js) ══ */
.cx-qtool { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: 1rem; }
.cx-qtool .form-control { max-width: 280px; }
.cx-qtool-hint { margin-left: auto; font-size: .82rem; color: var(--cx-muted); }
.cx-qchip { border: 1px solid var(--cx-border); background: var(--cx-surface); border-radius: 999px; padding: .3rem .8rem; font-size: .85rem; color: var(--cx-muted); }
.cx-qchip.is-on { background: var(--cx-primary-50); border-color: var(--cx-primary-100); color: var(--cx-navy); font-weight: 600; }
.cx-qlist { display: flex; flex-direction: column; gap: .5rem; }
.cx-qrow { display: grid; grid-template-columns: 20px 34px minmax(0, 1fr) auto; gap: .75rem; align-items: start; border: 1px solid var(--cx-border); border-radius: var(--cx-radius-sm); padding: .75rem .9rem; background: var(--cx-surface); }
.cx-qrow:hover { border-color: var(--cx-primary-100); box-shadow: var(--cx-shadow); }
.cx-qrow.is-hidden { background: #f8fafc; opacity: .75; }
.cx-qrow.sortable-ghost { opacity: .4; }
.cx-qgrip { color: #c0c8d4; cursor: grab; padding-top: .35rem; }
.cx-qnum { width: 30px; height: 30px; border-radius: 50%; background: var(--cx-primary-50); color: var(--cx-navy); font-weight: 700; display: grid; place-items: center; font-size: .9rem; }
.cx-qtext { font-weight: 500; color: var(--cx-text); line-height: 1.55; overflow-wrap: anywhere; }
.cx-qtext p { margin: 0; }
.cx-qtext img { max-width: 100%; max-height: 180px; height: auto; border-radius: 6px; }
.cx-qtext table, .cx-ed-area table, .cx-qe-pv-q table { border-collapse: collapse; margin: .4rem 0; }
.cx-qtext td, .cx-qtext th, .cx-ed-area td, .cx-ed-area th, .cx-qe-pv-q td, .cx-qe-pv-q th { border: 1px solid var(--cx-border); padding: .2rem .5rem; min-width: 2.5rem; }
.cx-qmeta { display: flex; flex-wrap: wrap; gap: .35rem .9rem; margin-top: .35rem; font-size: .82rem; color: var(--cx-muted); align-items: center; }
.cx-qmeta p { display: inline; margin: 0; }
.cx-qans { color: var(--cx-success); font-weight: 600; }
.cx-qused { color: var(--cx-warning); }
.cx-qhidden { color: var(--cx-muted); font-weight: 600; }
.cx-qtype { border-radius: 6px; padding: .1rem .45rem; font-size: .75rem; font-weight: 600; }
.cx-qtype.is-mc { background: var(--cx-primary-50); color: var(--cx-navy); }
.cx-qtype.is-tf { background: var(--cx-accent-50); color: #92400e; }
.cx-qtype.is-es { background: var(--cx-info-50); color: var(--cx-info); }
.cx-qside { display: flex; gap: .25rem; align-items: center; }
.cx-qside .btn-light { padding: .2rem .5rem; }
.cx-qchoices { margin: .5rem 0 0; padding: 0; list-style: none; display: grid; grid-template-columns: 1fr 1fr; gap: .35rem .75rem; font-size: .9rem; }
.cx-qchoices li { padding: .3rem .6rem; border-radius: 8px; background: #f8fafc; overflow-wrap: anywhere; }
.cx-qchoices li.is-ok { background: var(--cx-success-50); color: #166534; font-weight: 600; }
.cx-qchoices li p { display: inline; margin: 0; }
.cx-qchoices b { color: var(--cx-muted); margin-right: .35rem; }
.cx-qchoice-img { display: block; max-height: 60px; margin-top: .25rem; border-radius: 4px; }
/* หน้าต่างแก้ไข */
#qeModal .modal-body { background: var(--cx-surface); }
.cx-qe-body { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: 1.5rem; }
.cx-qe-tabs { display: none; gap: .25rem; padding: .25rem 1rem 0; border-bottom: 1px solid var(--cx-border); }
.cx-qe-tabs button { border: 0; background: none; padding: .5rem .9rem; color: var(--cx-muted); border-bottom: 2px solid transparent; font-weight: 500; }
.cx-qe-tabs button.is-on { color: var(--cx-navy); border-color: var(--cx-primary); font-weight: 700; }
.cx-seg { display: inline-flex; border: 1px solid var(--cx-border); border-radius: 10px; overflow: hidden; }
.cx-seg button { border: 0; border-right: 1px solid var(--cx-border); background: var(--cx-surface); padding: .4rem .9rem; font-size: .88rem; color: var(--cx-muted); }
.cx-seg button:last-child { border-right: 0; }
.cx-seg button.is-on { background: var(--cx-primary); color: #fff; font-weight: 600; }
.cx-seg button:disabled:not(.is-on) { opacity: .45; cursor: not-allowed; }
.cx-ed { border: 1px solid var(--cx-border); border-radius: 10px; background: var(--cx-surface); }
.cx-ed:focus-within { border-color: var(--cx-primary-100); box-shadow: 0 0 0 3px var(--cx-primary-50); }
.cx-ed-optbar { border-radius: 10px; margin-bottom: .45rem; }
.cx-ed-optbar .cx-ed-bar { border-bottom: 0; border-radius: 10px; }
.cx-ed-bar { display: flex; flex-wrap: wrap; gap: 2px; padding: .3rem; border-bottom: 1px solid var(--cx-border); background: #f8fafc; border-radius: 10px 10px 0 0; position: relative; }
.cx-ed-b { min-width: 32px; height: 30px; border: 0; background: transparent; border-radius: 6px; font-size: .88rem; color: #334155; padding: 0 .45rem; }
.cx-ed-b:hover, .cx-ed-b[aria-expanded="true"] { background: var(--cx-primary-50); color: var(--cx-navy); }
.cx-ed-chem { color: var(--cx-navy); font-weight: 600; }
.cx-ed-sep { width: 1px; background: var(--cx-border); margin: 4px; }
.cx-ed-pop-wrap { position: relative; }
.cx-ed-palette { position: absolute; top: 34px; left: 0; width: 330px; background: var(--cx-surface); border: 1px solid var(--cx-border); border-radius: 12px; box-shadow: var(--cx-shadow-hover); padding: .75rem; z-index: 20; }
.cx-ed-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; }
.cx-ed-grid button { border: 1px solid var(--cx-border); background: var(--cx-surface); border-radius: 6px; padding: .25rem 0; font-size: .95rem; }
.cx-ed-grid button:hover { background: var(--cx-primary-50); }
.cx-ed-hint { font-size: .78rem; color: var(--cx-muted); margin-top: .6rem; line-height: 1.7; }
.cx-ed-hint code { background: #f1f5f9; padding: 0 .3rem; border-radius: 4px; color: #0f172a; }
.cx-ed-area { padding: .65rem .8rem; min-height: 90px; line-height: 1.6; outline: none; overflow-wrap: anywhere; }
.cx-ed-area img { max-width: 100%; height: auto; }
.cx-ed-area:empty::before { content: attr(data-placeholder); color: #9ca3af; }
.cx-ed-short { min-height: 54px; }
.cx-ed-line { min-height: 0; padding: .3rem .45rem; border-radius: 6px; }
.cx-ed-img { display: inline-flex; gap: .5rem; align-items: center; margin: 0 .8rem .7rem; padding: .3rem .5rem; border: 1px dashed var(--cx-border); border-radius: 8px; font-size: .82rem; color: var(--cx-muted); }
.cx-ed-img img { width: 60px; height: 40px; object-fit: cover; border-radius: 6px; }
.cx-qe-opts { display: flex; flex-direction: column; gap: .45rem; margin-bottom: .5rem; }
.cx-qe-opt { display: grid; grid-template-columns: 22px 20px minmax(0, 1fr) auto; gap: .45rem; align-items: center; border: 1px solid var(--cx-border); border-radius: 10px; padding: .35rem .5rem; background: var(--cx-surface); }
.cx-qe-opt.is-ok { border-color: #86efac; background: var(--cx-success-50); }
.cx-qe-opt .cx-ed-line { background: var(--cx-surface); border: 1px solid transparent; }
.cx-qe-opt .cx-ed-line:focus { border-color: var(--cx-primary-100); }
.cx-qe-letter { font-weight: 700; color: var(--cx-muted); text-align: center; }
.cx-qe-opt-img { display: flex; gap: .5rem; align-items: center; margin-top: .25rem; }
.cx-qe-opt-img img { max-height: 48px; border-radius: 4px; }
.cx-qe-opt-tools { display: flex; gap: 2px; align-items: center; color: #94a3b8; }
.cx-qe-opt-tools button, .cx-qe-opt-tools span { width: 30px; height: 30px; display: grid; place-items: center; border: 0; background: none; border-radius: 6px; color: inherit; }
.cx-qe-opt-tools button:hover { background: #f1f5f9; }
.cx-qe-opt-tools .text-danger { color: var(--cx-danger) !important; }
.cx-qe-grip { cursor: grab; }
.cx-qe-locked { color: var(--cx-warning); }
.cx-qe-tf { display: flex; gap: .75rem; }
.cx-qe-tf label { border: 1px solid var(--cx-border); border-radius: 10px; padding: .55rem 1rem; cursor: pointer; display: flex; gap: .45rem; align-items: center; }
.cx-qe-tf label:has(input:checked) { border-color: #86efac; background: var(--cx-success-50); font-weight: 600; }
.cx-qe-pv { border: 1px solid var(--cx-border); border-radius: var(--cx-radius); background: var(--cx-bg); padding: 1rem; align-self: start; position: sticky; top: 0; }
.cx-qe-pv-title { font-size: .8rem; font-weight: 700; color: var(--cx-muted); margin-bottom: .6rem; }
.cx-qe-pv-card { background: var(--cx-surface); border-radius: 12px; padding: 1rem; box-shadow: var(--cx-shadow); }
.cx-qe-pv-badge { display: inline-block; background: var(--cx-navy); color: #fff; border-radius: 999px; padding: .15rem .7rem; font-size: .75rem; margin-bottom: .6rem; }
.cx-qe-pv-q { font-weight: 600; margin-bottom: .75rem; overflow-wrap: anywhere; }
.cx-qe-pv-q img, .cx-qe-pv-img { max-width: 100%; height: auto; border-radius: 8px; margin-bottom: .6rem; }
.cx-qe-pv-o { border: 1px solid var(--cx-border); border-radius: 10px; padding: .5rem .75rem; margin-bottom: .45rem; display: flex; gap: .6rem; align-items: center; font-size: .92rem; flex-wrap: wrap; }
.cx-qe-pv-o p { margin: 0; }
.cx-qe-pv-o img { max-height: 70px; border-radius: 4px; }
.cx-qe-pv-o.is-ok { border-color: #86efac; }
.cx-qe-pv-r { width: 16px; height: 16px; border: 2px solid #94a3b8; border-radius: 50%; flex: 0 0 auto; }
.cx-qe-pv-ck { margin-left: auto; color: var(--cx-success); font-size: .75rem; }
.cx-qe-pv-essay { border: 1px dashed var(--cx-border); border-radius: 10px; padding: 1.2rem .75rem; color: var(--cx-muted); font-size: .9rem; }
.cx-qe-pv-expl { margin-top: .75rem; padding: .6rem .75rem; background: var(--cx-accent-50); border-radius: 8px; font-size: .88rem; }
.cx-qe-pv-expl p { display: inline; margin: 0; }
.cx-qe-foot { justify-content: flex-start; gap: .5rem; }
.cx-qe-lock { font-size: .85rem; color: #92400e; background: var(--cx-warning-50); border-radius: 8px; padding: .45rem .7rem; }
@media (max-width: 991.98px) {
    .cx-qe-body { grid-template-columns: 1fr; }
    .cx-qe-tabs { display: flex; }
    #qeModal:not(.is-preview) .cx-qe-pv { display: none; }
    #qeModal.is-preview .cx-qe-form { display: none; }
    .cx-qe-pv { position: static; }
    .cx-qrow { grid-template-columns: 30px minmax(0, 1fr); }
    .cx-qgrip { display: none; }
    .cx-qside { grid-column: 1 / 3; justify-content: flex-end; }
    .cx-qchoices { grid-template-columns: 1fr; }
    .cx-qtool-hint { display: none; }
    .cx-qtool .form-control { max-width: none; }
    .cx-ed-palette { position: fixed; left: 8px; right: 8px; width: auto; top: auto; }
}

/* หน้านำเข้าคำถาม (admin/quiz_import.php) */
.cx-cheat { font-size: .86rem; }
.cx-cheat td, .cx-cheat th { padding: .3rem .55rem !important; }
.cx-cheat code { background: #f1f5f9; padding: .05rem .35rem; border-radius: 4px; color: #0f172a; }
.cx-paste { font-family: ui-monospace, Menlo, monospace; font-size: .82rem; background: var(--cx-primary-50); border: 2px dashed var(--cx-primary-100); }
.cx-import-table tr.is-bad td { background: var(--cx-danger-50) !important; }
.cx-import-table td p { margin: 0; }

/* หน้าทำข้อสอบ/ผลสอบ: รูปในตัวเลือก + คำอธิบายเฉลย */
.answer-image { display: block; max-width: 100%; max-height: 160px; margin-top: .35rem; border-radius: 6px; }
.cx-explain { margin-top: .75rem; padding: .65rem .85rem; background: var(--cx-accent-50); border-radius: 10px; font-size: .92rem; }
.cx-explain p { display: inline; margin: 0; }

/* หน้าจัดการข้อสอบ: ปรับจากผลทดสอบ (มือถือ/ตัวกรอง) */
.cx-ed-img { max-width: calc(100% - 1.6rem); flex-wrap: wrap; }
.cx-ed-img span { display: none; } /* ชื่อไฟล์สุ่ม 32 ตัวอักษร ไม่มีความหมาย และทำให้มือถือล้นจอ */
.cx-qe-form { min-width: 0; }
.cx-qe-opt input[type=radio] { width: 20px; height: 20px; }
.cx-qlist.is-filtered [data-qe-move], .cx-qlist.is-filtered .cx-qgrip { visibility: hidden; }
@media (max-width: 991.98px) {
    .cx-qside .btn { min-width: 40px; min-height: 40px; }
    .cx-qmeta [data-qe-toggle] { padding: .35rem 0 !important; }
}

/* ══ แบบทดสอบฝั่งนักเรียน: การ์ดสถานะ (config/quiz_student.php — my_quiz + หน้าเรียน) ══ */
.cx-qz-tabs { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: .5rem; }
.cx-qz-tabs button { border: 1px solid var(--cx-border); background: var(--cx-surface); border-radius: 999px; padding: .35rem .9rem; font-size: .88rem; color: var(--cx-muted); }
.cx-qz-tabs button.is-on { background: var(--cx-primary-50); border-color: var(--cx-primary-100); color: var(--cx-navy); font-weight: 600; }
.cx-qz-course-h { display: flex; align-items: center; gap: .6rem; margin: 1.25rem 0 .6rem; font-size: 1.05rem; font-weight: 700; color: var(--cx-navy); }
.cx-qz-code { background: var(--cx-primary-50); color: var(--cx-navy); border-radius: 6px; padding: .1rem .5rem; font-size: .8rem; }
.cx-qz-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: .9rem; }
.cx-qz { background: var(--cx-surface); border: 1px solid var(--cx-border); border-radius: var(--cx-radius); padding: 1rem 1.1rem; display: flex; flex-direction: column; gap: .55rem; }
.cx-qz.is-locked { background: #f8fafc; }
.cx-qz-top { display: flex; justify-content: space-between; gap: .5rem; align-items: flex-start; }
.cx-qz-title { font-weight: 700; color: var(--cx-text); line-height: 1.35; }
.cx-qz-st { border-radius: 999px; padding: .15rem .6rem; font-size: .75rem; font-weight: 700; white-space: nowrap; background: var(--cx-primary-50); color: var(--cx-navy); }
.cx-qz-st.is-doing { background: var(--cx-warning-50); color: #92400e; }
.cx-qz-st.is-pass { background: var(--cx-success-50); color: #166534; }
.cx-qz-st.is-fail { background: var(--cx-danger-50); color: #991b1b; }
.cx-qz-st.is-wait { background: var(--cx-info-50); color: var(--cx-info); }
.cx-qz-st.is-locked, .cx-qz-st.is-not_yet, .cx-qz-st.is-closed { background: #f1f5f9; color: var(--cx-muted); }
.cx-qz-meta { display: flex; flex-wrap: wrap; gap: .3rem .9rem; font-size: .82rem; color: var(--cx-muted); }
.cx-qz-note { font-size: .82rem; color: var(--cx-muted); }
.cx-qz-best { display: flex; align-items: center; gap: .6rem; font-size: .85rem; }
.cx-qz-bar { flex: 1; height: 8px; background: #eef2f7; border-radius: 999px; position: relative; }
.cx-qz-bar i { position: absolute; inset: 0 auto 0 0; background: var(--cx-success); border-radius: 999px; }
.cx-qz-bar.is-fail i { background: var(--cx-danger); }
.cx-qz-bar b { position: absolute; top: -3px; bottom: -3px; width: 2px; background: #334155; }
.cx-qz-act { display: flex; gap: .5rem; margin-top: auto; padding-top: .2rem; }
.cx-qz-act .btn { flex: 1; }
@media (max-width: 575.98px) { .cx-qz-grid { grid-template-columns: 1fr; } }

/* หน้าเริ่มทำแบบทดสอบ (student/start_quiz.php) */
.cx-start { max-width: 760px; margin: 1.5rem auto; }
.cx-start-head { display: flex; gap: 1rem; align-items: center; margin-bottom: .75rem; }
.cx-start-icon { width: 56px; height: 56px; border-radius: 16px; background: var(--cx-primary-50); color: var(--cx-navy); display: grid; place-items: center; font-size: 1.5rem; flex: 0 0 auto; }
.cx-start-desc { color: var(--cx-muted); margin-bottom: 1rem; }
.cx-start-facts { display: grid; grid-template-columns: repeat(4, 1fr); gap: .6rem; margin-bottom: 1rem; }
.cx-start-facts div { background: #f8fafc; border-radius: 12px; padding: .7rem .6rem; text-align: center; }
.cx-start-facts i { color: var(--cx-primary); display: block; margin-bottom: .25rem; }
.cx-start-facts b { display: block; color: var(--cx-text); }
.cx-start-facts span { font-size: .78rem; color: var(--cx-muted); }
.cx-start-rules { background: var(--cx-warning-50); border-radius: 12px; padding: .8rem 1rem .8rem 2rem; font-size: .9rem; color: #78350f; }
.cx-start-rules li + li { margin-top: .25rem; }
.cx-start-actions { display: flex; justify-content: flex-end; gap: .5rem; flex-wrap: wrap; }
@media (max-width: 575.98px) { .cx-start-facts { grid-template-columns: repeat(2, 1fr); } .cx-start-actions .btn { flex: 1; } }

/* ══ หน้าทำแบบทดสอบ (student/take_quiz.php + js/take-quiz.js) — โหมดโฟกัส ไม่มีเมนูข้าง ══ */
.cx-tk-page { background: var(--cx-bg); font-family: var(--cx-font); }
.cx-tk-top { position: sticky; top: 0; z-index: 30; background: var(--cx-surface); border-bottom: 1px solid var(--cx-border); padding: .55rem 1.25rem; display: flex; align-items: center; gap: .9rem; }
.cx-tk-title { flex: 1; min-width: 0; }
.cx-tk-title b { display: block; color: var(--cx-navy); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cx-tk-title small { color: var(--cx-muted); }
.cx-tk-saved { font-size: .8rem; color: var(--cx-muted); white-space: nowrap; }
.cx-tk-saved.is-ok { color: var(--cx-success); }
.cx-tk-saved.is-bad { color: var(--cx-danger); }
.cx-tk-timer { background: var(--cx-navy); color: #fff; border-radius: 10px; padding: .35rem .8rem; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cx-tk-timer.is-warn { background: var(--cx-danger); }
.cx-tk-body { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 1.25rem; max-width: 1180px; margin: 1.25rem auto; padding: 0 1.25rem; }
.cx-tk-q { background: var(--cx-surface); border-radius: var(--cx-radius); box-shadow: var(--cx-shadow); padding: 1.4rem; }
.cx-tk-qhead { display: flex; align-items: center; gap: .6rem; margin-bottom: .9rem; }
.cx-tk-qbadge { background: var(--cx-navy); color: #fff; border-radius: 999px; padding: .2rem .8rem; font-size: .8rem; }
.cx-tk-pts { font-size: .8rem; color: var(--cx-muted); }
.cx-tk-flag { margin-left: auto; border: 1px solid var(--cx-border); background: var(--cx-surface); border-radius: 999px; padding: .3rem .85rem; font-size: .82rem; color: var(--cx-muted); }
.cx-tk-flag.is-on { background: var(--cx-warning-50); border-color: #fcd34d; color: #92400e; font-weight: 600; }
.cx-tk-qtext { font-weight: 600; font-size: 1.05rem; line-height: 1.65; margin-bottom: 1rem; overflow-wrap: anywhere; }
.cx-tk-qtext img, .cx-tk-qimg { max-width: 100%; height: auto; border-radius: 8px; }
.cx-tk-qimg { display: block; margin: -.25rem 0 1rem; max-height: 360px; }
.cx-tk-qtext table { border-collapse: collapse; } .cx-tk-qtext td, .cx-tk-qtext th { border: 1px solid var(--cx-border); padding: .25rem .5rem; }
.cx-tk-opt { border: 1.5px solid var(--cx-border); border-radius: 12px; padding: .75rem 1rem; display: flex; gap: .8rem; align-items: center; margin-bottom: .55rem; cursor: pointer; background: var(--cx-surface); }
.cx-tk-opt:hover { border-color: var(--cx-primary-100); }
.cx-tk-opt input { position: absolute; opacity: 0; pointer-events: none; }
.cx-tk-opt:focus-within { box-shadow: 0 0 0 3px var(--cx-primary-100); }
.cx-tk-k { width: 30px; height: 30px; border-radius: 50%; border: 1.5px solid #94a3b8; display: grid; place-items: center; font-weight: 700; font-size: .85rem; color: #475569; flex: 0 0 auto; }
.cx-tk-opt.is-sel { border-color: var(--cx-primary); background: var(--cx-primary-50); }
.cx-tk-opt.is-sel .cx-tk-k { background: var(--cx-primary); border-color: var(--cx-primary); color: #fff; }
.cx-tk-otext { overflow-wrap: anywhere; } .cx-tk-otext p { margin: 0; }
.cx-tk-essay { min-height: 160px; }
.cx-tk-nav { display: flex; justify-content: space-between; margin-top: 1rem; gap: .5rem; }
.cx-tk-panel { background: var(--cx-surface); border-radius: var(--cx-radius); box-shadow: var(--cx-shadow); padding: 1rem; align-self: start; position: sticky; top: 74px; }
.cx-tk-grab { display: none; }
.cx-tk-panel-head h2 { font-size: 1rem; font-weight: 700; color: var(--cx-navy); margin: 0 0 .2rem; }
.cx-tk-panel-head span { font-size: .85rem; }
.cx-tk-dots { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin: .7rem 0; max-height: 50vh; overflow: auto; padding: 8px 6px 2px 2px; }
.cx-tk-dots button { aspect-ratio: 1; border-radius: 10px; border: 1.5px solid var(--cx-border); background: var(--cx-surface); font-weight: 600; font-size: .85rem; position: relative; }
.cx-tk-dots button.is-a { background: var(--cx-success-50); border-color: #86efac; color: #166534; }
.cx-tk-dots button.is-c { border-color: var(--cx-primary); box-shadow: 0 0 0 2px var(--cx-primary-100); }
.cx-tk-dots button.is-f::after { content: "🚩"; position: absolute; top: -9px; right: -6px; font-size: .7rem; }
.cx-tk-legend { display: flex; flex-wrap: wrap; gap: .3rem .8rem; font-size: .75rem; color: var(--cx-muted); }
.cx-tk-legend i { display: inline-block; width: 11px; height: 11px; border-radius: 3px; border: 1.5px solid var(--cx-border); margin-right: .25rem; vertical-align: -1px; }
.cx-tk-legend i.is-a { background: var(--cx-success-50); border-color: #86efac; }
.cx-tk-hint { font-size: .78rem; color: var(--cx-muted); text-align: center; margin: .6rem 0 0; }
.cx-tk-mbar, .cx-tk-dim { display: none; }
@media (max-width: 991.98px) {
    .cx-tk-top { padding: .5rem .75rem; gap: .5rem; }
    .cx-tk-saved, .cx-tk-submit-top { display: none; }
    .cx-tk-body { grid-template-columns: 1fr; padding: 0 .75rem 80px; margin-top: .75rem; }
    .cx-tk-q { padding: 1rem; }
    .cx-tk-nav { display: none; }
    .cx-tk-mbar { display: flex; gap: .5rem; position: fixed; left: 0; right: 0; bottom: 0; background: var(--cx-surface); border-top: 1px solid var(--cx-border); padding: .55rem .75rem; z-index: 35; }
    .cx-tk-panel { position: fixed; left: 0; right: 0; bottom: 0; top: auto; z-index: 50; border-radius: 18px 18px 0 0; box-shadow: 0 -10px 30px rgba(15, 23, 42, .18); transform: translateY(105%); transition: transform .25s ease; max-height: 85vh; overflow: auto; }
    .cx-tk-panel.is-open { transform: none; }
    .cx-tk-grab { display: block; width: 40px; height: 4px; border-radius: 4px; background: #cbd5e1; margin: 0 auto .7rem; }
    .cx-tk-dim:not([hidden]) { display: block; position: fixed; inset: 0; background: rgba(15, 23, 42, .35); z-index: 45; }
}

/* ══ หน้าผลสอบ (student/quiz_result.php) — สรุปแนวนอนด้านบน เฉลยรายข้อด้านล่าง (เจ้าของขอ 2026-10-12) ══ */
.cx-rs-sum .cx-card-body { display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap; }
.cx-rs-ring { --p: 0; width: 132px; height: 132px; border-radius: 50%; display: grid; place-items: center; flex: 0 0 auto;
    background: conic-gradient(var(--cx-success) calc(var(--p) * 1%), #eef2f7 0); }
.cx-rs-ring.is-fail { background: conic-gradient(var(--cx-danger) calc(var(--p) * 1%), #eef2f7 0); }
.cx-rs-ring > div { width: 104px; height: 104px; border-radius: 50%; background: var(--cx-surface); display: grid; place-content: center; text-align: center; }
.cx-rs-ring b { font-size: 1.45rem; line-height: 1.1; color: var(--cx-text); }
.cx-rs-ring span { font-size: .85rem; color: var(--cx-muted); }
.cx-rs-verdict { min-width: 180px; }
.cx-rs-verdict .cx-qz-st { font-size: .95rem; padding: .3rem .9rem; }
.cx-rs-verdict p { margin: .45rem 0 0; font-size: .85rem; color: var(--cx-muted); }
.cx-rs-stats { display: flex; flex-wrap: wrap; gap: .5rem; margin: 0 0 0 auto; }
.cx-rs-stats div { background: #f8fafc; border-radius: 12px; padding: .55rem .9rem; min-width: 96px; text-align: center; }
.cx-rs-stats dt { font-size: .75rem; color: var(--cx-muted); font-weight: 500; }
.cx-rs-stats dd { margin: 0; font-weight: 700; }
.cx-rs-head { display: flex; justify-content: space-between; align-items: center; gap: .6rem; flex-wrap: wrap; margin-bottom: .8rem; }
.cx-rv { border: 1px solid var(--cx-border); border-left: 4px solid var(--cx-border); border-radius: 12px; padding: .85rem 1rem; margin-bottom: .65rem; }
.cx-rv.is-right { border-left-color: var(--cx-success); }
.cx-rv.is-wrong { border-left-color: var(--cx-danger); }
.cx-rv.is-blank { border-left-color: #94a3b8; }
.cx-rv.is-wait { border-left-color: var(--cx-info); }
.cx-rv-h { display: flex; justify-content: space-between; font-size: .85rem; margin-bottom: .35rem; }
.cx-rv.is-wrong .cx-rv-pts { color: var(--cx-danger); font-weight: 600; }
.cx-rv.is-right .cx-rv-pts { color: var(--cx-success); font-weight: 600; }
.cx-rv-q { font-weight: 600; margin-bottom: .55rem; overflow-wrap: anywhere; }
.cx-rv-q img, .cx-rv-img { max-width: 100%; height: auto; border-radius: 8px; }
.cx-rv-img { display: block; max-height: 300px; margin-bottom: .55rem; }
.cx-ra { border-radius: 8px; padding: .4rem .7rem; margin-bottom: .3rem; font-size: .92rem; display: flex; gap: .55rem; align-items: center; background: #f8fafc; }
.cx-ra p { margin: 0; }
.cx-ra.is-ok { background: var(--cx-success-50); color: #166534; font-weight: 600; }
.cx-ra.is-bad { background: var(--cx-danger-50); color: #991b1b; }
.cx-ra small { margin-left: auto; white-space: nowrap; }
.cx-ra-k { font-weight: 700; color: var(--cx-muted); min-width: 1rem; }
.cx-rv-essay { background: #f8fafc; border-radius: 8px; padding: .55rem .75rem; font-size: .92rem; }
.cx-rv-essay span { color: var(--cx-muted); }
@media (max-width: 767.98px) {
    .cx-rs-sum .cx-card-body { justify-content: center; text-align: center; }
    .cx-rs-stats { margin: 0; justify-content: center; }
    .cx-rs-stats div { min-width: 0; flex: 1 1 30%; }
}

/* ประวัติการสอบ (student/quiz_history.php) */
.cx-hs-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: .75rem; }
.cx-hs-stats div { background: var(--cx-surface); border: 1px solid var(--cx-border); border-radius: var(--cx-radius); padding: .8rem 1rem; }
.cx-hs-stats span { display: block; font-size: .8rem; color: var(--cx-muted); }
.cx-hs-stats b { font-size: 1.25rem; color: var(--cx-text); }
.cx-hs-stats small { margin-left: .35rem; color: var(--cx-muted); }
@media (max-width: 767.98px) { .cx-hs-stats { grid-template-columns: repeat(2, 1fr); } }

/* ฟอร์มแบ่งหมวด (admin/create_quiz.php) */
.cx-fsec { border: 1px solid var(--cx-border); border-radius: 12px; padding: .9rem 1.1rem 1rem; margin-bottom: 1rem; }
.cx-fsec legend { float: none; width: auto; font-size: 1rem; font-weight: 700; color: var(--cx-navy); padding: 0 .35rem; margin: 0 0 .3rem -.35rem; }
.cx-fsec .form-check { margin-bottom: .35rem; }

/* ให้คะแนนข้อเขียน (admin/quiz_review_detail.php) + แท็บที่เป็นลิงก์ */
.cx-grade { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; background: var(--cx-primary-50); border-radius: 10px; padding: .55rem .75rem; }
.cx-grade .form-control { width: 90px; }
a.cx-qz-tab { border: 1px solid var(--cx-border); background: var(--cx-surface); border-radius: 999px; padding: .35rem .9rem; font-size: .88rem; color: var(--cx-muted); text-decoration: none; }
a.cx-qz-tab.is-on { background: var(--cx-primary-50); border-color: var(--cx-primary-100); color: var(--cx-navy); font-weight: 600; }

/* ปรับจากผลทดสอบแบบทดสอบขั้น 2 */
.cx-w-date { max-width: 240px; }
@media (max-width: 767.98px) {
    /* ช่องที่มีหลายบรรทัด (ชื่อ + รายละเอียด) ในตารางแบบการ์ด: ป้ายอยู่บน เนื้อหาเต็มความกว้าง */
    .cx-table-stack > tbody > tr > td.cx-stack-block { display: block; text-align: left !important; }
    .cx-table-stack > tbody > tr > td.cx-stack-block::before { display: block; margin-bottom: .2rem; }
}
@media (max-width: 991.98px) {
    /* มือถือ: สถานะการบันทึกเป็นจุดเล็กๆ ข้างตัวจับเวลา (เดิมซ่อน = ไม่รู้ว่าบันทึกแล้ว) */
    .cx-tk-saved { display: inline; font-size: 0; }
    .cx-tk-saved::before { content: "●"; font-size: .75rem; color: var(--cx-muted); }
    .cx-tk-saved.is-ok::before { color: var(--cx-success); }
    .cx-tk-saved.is-bad::before { content: "● ยังไม่ได้บันทึก"; font-size: .7rem; color: var(--cx-danger); }
}

/* อุปกรณ์ที่เข้าสู่ระบบ (student/devices.php) */
.cx-device-list { list-style: none; margin: 0; padding: 0; }
.cx-device { display: flex; align-items: center; gap: .85rem; padding: .85rem 0; border-bottom: 1px solid var(--cx-border); }
.cx-device:last-child { border-bottom: 0; }
.cx-device-icon { flex: 0 0 2.5rem; height: 2.5rem; border-radius: var(--cx-radius-sm); display: inline-flex; align-items: center; justify-content: center;
    background: var(--cx-primary-50); color: var(--cx-primary); font-size: 1.1rem; }
.cx-device.is-current .cx-device-icon { background: var(--cx-success-50); color: var(--cx-success); }
.cx-device-main { flex: 1 1 0; min-width: 0; }
@media (max-width: 575.98px) {
    .cx-device { flex-wrap: wrap; }
    .cx-device form { flex-basis: 100%; margin-left: 3.35rem !important; }
}

/* ═══ ถาม-ตอบ (student/view_course.php + js/course-qa.js · admin/manage_comment.php) ═══ */
.cx-qa-title { font-weight: 700; color: var(--cx-navy); margin-bottom: .75rem; }
.cx-qa-count { color: var(--cx-muted); font-weight: 400; font-size: .9rem; }
.cx-qa-ask, .cx-qa-follow { background: var(--cx-surface); border: 1px solid var(--cx-border); border-radius: var(--cx-radius); padding: .85rem 1rem; margin-bottom: 1rem; }
.cx-qa-follow { margin: .6rem 0 0; padding: .7rem .8rem; background: var(--cx-bg); }
.cx-qa-ask-foot { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem; margin-top: .6rem; }
.cx-qa-chip { display: inline-flex; align-items: center; gap: .35rem; background: var(--cx-primary-50); color: var(--cx-navy); border-radius: 999px; padding: .2rem .4rem .2rem .7rem; font-size: .8rem; max-width: 100%; }
.cx-qa-chip-label { white-space: nowrap; }
.cx-qa-chip [data-qa-lesson-title] { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 260px; }
.cx-qa-chip-x { border: 0; background: transparent; color: var(--cx-navy); width: 22px; height: 22px; border-radius: 50%; line-height: 1; }
.cx-qa-chip-x:hover { background: var(--cx-primary-100); }
.cx-qa-file { font-size: .82rem; color: var(--cx-text); }
.cx-qa-bar { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin-bottom: .75rem; }
.cx-qa-tabs { display: flex; gap: .4rem; flex-wrap: wrap; }
.cx-qa-tab { border: 1px solid var(--cx-border); background: var(--cx-surface); border-radius: 999px; padding: .3rem .85rem; font-size: .85rem; color: var(--cx-muted); text-decoration: none; }
.cx-qa-tab:hover { color: var(--cx-navy); }
.cx-qa-tab.is-on { background: var(--cx-primary-50); border-color: var(--cx-primary-100); color: var(--cx-navy); font-weight: 600; }
.cx-qa-search { margin-left: auto; max-width: 240px; border-radius: 999px; }
.cx-qa-newpill { display: block; margin: 0 auto .75rem; border: 0; background: var(--cx-primary); color: var(--cx-surface); border-radius: 999px; padding: .3rem 1rem; font-size: .85rem; box-shadow: var(--cx-shadow); }
.cx-qa-q { background: var(--cx-surface); border: 1px solid var(--cx-border); border-radius: var(--cx-radius); padding: .85rem 1rem; margin-bottom: .75rem; }
.cx-qa-q.is-pin { border-color: var(--cx-accent); background: var(--cx-accent-50); }
.cx-qa-q.is-new, .cx-qa-q.is-focus { box-shadow: 0 0 0 3px var(--cx-primary-100); }
.cx-qa-msg-top { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.cx-qa-av { width: 32px; height: 32px; border-radius: 50%; background: var(--cx-primary-50); color: var(--cx-navy); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: .85rem; flex: none; }
.cx-qa-av.is-tutor { background: var(--cx-navy); color: var(--cx-surface); }
.cx-qa-time { color: var(--cx-muted); font-size: .8rem; }
.cx-qa-end { margin-left: auto; display: inline-flex; gap: .35rem; align-items: center; }
.cx-qa-st { border-radius: 999px; padding: .1rem .55rem; font-size: .74rem; font-weight: 700; white-space: nowrap; }
.cx-qa-st.is-ok { background: var(--cx-success-50); color: var(--cx-success); }
.cx-qa-st.is-wait { background: var(--cx-warning-50); color: var(--cx-warning); }
.cx-qa-st.is-pin { background: var(--cx-surface); color: var(--cx-warning); border: 1px solid var(--cx-accent); }
.cx-qa-st.is-tutor { background: var(--cx-navy); color: var(--cx-surface); }
.cx-qa-st.is-new { background: var(--cx-danger); color: var(--cx-surface); }
.cx-qa-body { margin: .5rem 0 .35rem 2.55rem; line-height: 1.65; overflow-wrap: anywhere; }
.cx-qa-body img { max-width: 100%; height: auto; }
.cx-qa-body table { border-collapse: collapse; margin: .4rem 0; }
.cx-qa-body td, .cx-qa-body th { border: 1px solid var(--cx-border); padding: .25rem .5rem; }
.cx-qa-img { display: inline-block; margin: .2rem 0 .4rem 2.55rem; }
.cx-qa-img img { max-width: 260px; max-height: 200px; border-radius: 8px; border: 1px solid var(--cx-border); object-fit: contain; background: var(--cx-bg); }
.cx-qa-lesson { margin-left: 2.55rem; font-size: .8rem; color: var(--cx-muted); }
.cx-qa-lesson-link { text-decoration: none; }
.cx-qa-thread { margin: .65rem 0 0 2.55rem; border-left: 3px solid var(--cx-primary-100); padding-left: .85rem; }
.cx-qa-msg { padding: .4rem 0; }
.cx-qa-msg.is-tutor .cx-qa-body { background: var(--cx-primary-50); border-radius: 10px; padding: .55rem .75rem; }
.cx-qa-actions { margin: .5rem 0 0 2.55rem; display: flex; gap: .4rem; align-items: center; }
.cx-qa-follow { margin-left: 2.55rem; }
.cx-qa-more { display: block; margin: .25rem auto 0; }
.cx-qa-empty { text-align: center; color: var(--cx-muted); padding: 1.5rem 1rem; background: var(--cx-surface); border: 1px dashed var(--cx-border); border-radius: var(--cx-radius); }
.cx-qa-new-answer { display: block; text-align: center; font-size: .85rem; font-weight: 600; color: var(--cx-danger); background: var(--cx-danger-50); border-radius: var(--cx-radius-sm); padding: .3rem .5rem; text-decoration: none; }
/* แอดมิน: กล่องรวม */
.cx-qa-filters { display: flex; gap: .5rem; flex-wrap: wrap; margin: .5rem 0 1rem; }
.cx-qa-filters .form-select { max-width: 320px; }
.cx-qa-filters .form-control { max-width: 300px; }
.cx-qa-inbox { display: grid; grid-template-columns: minmax(300px, 380px) 1fr; gap: 1rem; align-items: start; }
.cx-qa-list { background: var(--cx-surface); border: 1px solid var(--cx-border); border-radius: var(--cx-radius); overflow: hidden; }
.cx-qa-list .cx-pagination { padding: .6rem .8rem; }
.cx-qa-item { display: flex; gap: .6rem; padding: .75rem .9rem; border-bottom: 1px solid var(--cx-border); color: var(--cx-text); text-decoration: none; }
.cx-qa-item:hover { background: var(--cx-bg); color: var(--cx-text); }
.cx-qa-item.is-on { background: var(--cx-primary-50); box-shadow: inset 3px 0 0 var(--cx-primary); }
.cx-qa-item-main { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: .15rem; }
.cx-qa-item-top { display: flex; gap: .4rem; align-items: center; font-size: .9rem; }
.cx-qa-item-top .cx-qa-st { margin-left: auto; }
.cx-qa-item-top .cx-qa-st + .cx-qa-st { margin-left: 0; }
.cx-qa-item-text { font-size: .83rem; color: var(--cx-muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.cx-qa-item-meta { font-size: .75rem; color: var(--cx-muted); display: flex; gap: .35rem; flex-wrap: wrap; align-items: center; }
.cx-qa-code { background: var(--cx-primary-50); color: var(--cx-navy); border-radius: 6px; padding: 0 .4rem; font-size: .72rem; font-weight: 600; }
.cx-qa-detail { background: var(--cx-surface); border: 1px solid var(--cx-border); border-radius: var(--cx-radius); padding: 1rem 1.2rem; min-width: 0; }
.cx-qa-detail-head { display: flex; gap: .6rem; align-items: flex-start; padding-bottom: .7rem; border-bottom: 1px solid var(--cx-border); margin-bottom: .6rem; flex-wrap: wrap; }
.cx-qa-detail-who { flex: 1 1 0; min-width: 0; }
.cx-qa-detail-actions { margin-left: auto; display: flex; gap: .4rem; align-items: center; }
.cx-qa-detail > .cx-qa-body, .cx-qa-detail > .cx-qa-img { margin-left: 0; }
.cx-qa-detail .cx-qa-thread { margin-left: 0; margin-top: .8rem; }
.cx-qa-back { display: inline-block; margin-bottom: .6rem; font-size: .9rem; }
.cx-qa-reply { margin-top: 1rem; }
.cx-qa-ed-area { min-height: 120px; }
.cx-qa-ed-area:empty::before { content: attr(data-placeholder); color: var(--cx-muted); }
.cx-qa-ed-foot { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; padding: .5rem .7rem; border-top: 1px solid var(--cx-border); }
@media (max-width: 991.98px) {
    .cx-qa-inbox { grid-template-columns: 1fr; }
    .cx-qa-inbox.has-selection .cx-qa-list { display: none; }
    .cx-qa-inbox:not(.has-selection) .cx-qa-detail { display: none; }
}
@media (max-width: 575.98px) {
    .cx-qa-search { margin-left: 0; max-width: none; flex: 1 1 100%; }
    .cx-qa-body, .cx-qa-img, .cx-qa-lesson, .cx-qa-thread, .cx-qa-actions, .cx-qa-follow { margin-left: 0; }
    .cx-qa-img img { max-width: 100%; }
    .cx-qa-detail-actions { flex-basis: 100%; justify-content: flex-end; }
}

/* ถาม-ตอบบนจอเล็ก: พับ/ตัดให้หน้าไม่ยาวเกิน (เจ้าของขอ 2026-10-12) */
.cx-qa-fold-btn { display: none; border: 0; background: transparent; color: var(--cx-primary); font-size: .82rem; font-weight: 600; padding: .3rem 0; margin-left: 2.55rem; }
.cx-qa-more-text { border: 0; background: transparent; color: var(--cx-primary); font-size: .8rem; font-weight: 600; padding: 0; margin-left: 2.55rem; }
.cx-qa-search-btn { display: none; }
@media (min-width: 992px) {
    .cx-qa-filters-fold > summary { display: none; }
}
@media (max-width: 991.98px) {
    .cx-qa-fold-btn { display: inline-block; }
    .cx-qa-thread.is-folded { display: none; }
    /* ตัดที่ความสูง (ไม่ใช้ line-clamp — กล่องคำตอบติวเตอร์มี padding บรรทัดถัดไปจะโผล่) + จางท้าย */
    .cx-qa-body.is-clamped { max-height: calc(1.65em * 4); overflow: hidden; -webkit-mask-image: linear-gradient(180deg, #000 65%, transparent); mask-image: linear-gradient(180deg, #000 65%, transparent); }
    .cx-qa-msg.is-tutor .cx-qa-body.is-clamped { max-height: calc(1.65em * 4 + 1.1rem); }
    .cx-qa-body.is-clamped.is-clamped-6 { max-height: calc(1.65em * 6); }
    .cx-qa-msg.is-tutor .cx-qa-body.is-clamped.is-clamped-6 { max-height: calc(1.65em * 6 + 1.1rem); }
    .cx-qa-lesson { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .cx-qa-ask textarea { min-height: 0; height: 3.4rem; }
    .cx-qa-ask textarea:focus { height: 6rem; }
    .cx-qa-search-btn { display: inline-flex; align-items: center; }
    /* แท็บเป็นแถวเดียว เลื่อนซ้าย-ขวาได้ (ไม่ให้ซ้อน 2–3 แถว) */
    .cx-qa-bar { flex-wrap: wrap; }
    .cx-qa-bar .cx-qa-tabs { flex: 1 1 0; min-width: 0; }
    .cx-qa-tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
    .cx-qa-tabs::-webkit-scrollbar { display: none; }
    .cx-qa-tab { flex: none; white-space: nowrap; }
    .cx-qa-bar .cx-qa-search { display: none; }
    .cx-qa-bar.is-search .cx-qa-search { display: block; margin-left: 0; max-width: none; flex: 1 1 100%; }
    .cx-qa-detail .cx-qa-fold-btn, .cx-qa-detail .cx-qa-more-text { margin-left: 0; }
    .cx-qa-filters-fold { margin: .5rem 0 1rem; }
    .cx-qa-filters-fold .cx-qa-filters { margin: .6rem 0 0; }
}
@media (max-width: 575.98px) {
    .cx-qa-fold-btn, .cx-qa-more-text { margin-left: 0; }
}

/* ═══ หน้าเรียน (student/view_course.php + js/lesson-page.js) ═══ */
.cx-lp-head { display: flex; align-items: center; gap: .6rem .75rem; flex-wrap: wrap; margin-bottom: 1rem; }
.cx-lp-back { color: var(--cx-muted); font-size: .9rem; text-decoration: none; }
.cx-lp-back:hover { color: var(--cx-primary); }
.cx-lp-title { font-weight: 700; color: var(--cx-navy); font-size: 1.3rem; margin: 0; flex: 1 1 320px; min-width: 0; }
.cx-lp-chip { display: inline-flex; align-items: center; gap: .4rem; background: var(--cx-surface); border: 1px solid var(--cx-border); border-radius: 999px; padding: .25rem .75rem; font-size: .82rem; color: var(--cx-text); text-decoration: none; white-space: nowrap; }
.cx-lp-chip.is-warn { background: var(--cx-warning-50); border-color: var(--cx-warning); color: var(--cx-warning); font-weight: 600; }
.cx-lp-bar { width: 80px; height: 6px; background: var(--cx-border); border-radius: 9px; overflow: hidden; display: inline-block; }
.cx-lp-bar i { display: block; height: 100%; background: var(--cx-success); transition: width .4s; }
.cx-lp-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; grid-template-areas: "main toc" "tabs toc"; gap: 0 1.25rem; align-items: start; }
.cx-lp-main { grid-area: main; min-width: 0; }
.cx-lp-toc { grid-area: toc; position: sticky; top: calc(var(--cx-topbar-h) + 1rem); max-height: calc(100vh - var(--cx-topbar-h) - 2rem); overflow: auto; background: var(--cx-surface); border: 1px solid var(--cx-border); border-radius: var(--cx-radius); }
.cx-lp-tabs-col { grid-area: tabs; min-width: 0; }
.cx-lp-player { position: relative; background: #0f172a; border-radius: var(--cx-radius); aspect-ratio: 16 / 9; overflow: hidden; user-select: none; }
.cx-lp-video, .cx-lp-video iframe, .cx-lp-video video, .cx-lp-video > div { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.cx-lp-video video { background: #000; }
.cx-lp-msg { display: flex; flex-direction: column; align-items: center; justify-content: center; color: #cbd5e1; text-align: center; padding: 1rem; }
.cx-lp-fs-exit { display: none; position: absolute; z-index: 4; right: .8rem; top: .8rem; border: 0; background: rgba(15, 23, 42, .7); color: #fff; border-radius: 8px; padding: .35rem .7rem; font-size: .85rem; }
.cx-lp-player.is-fs .cx-lp-fs-exit { display: inline-block; }
.cx-lp-player:fullscreen, .cx-lp-player.is-pseudo-fs { border-radius: 0; aspect-ratio: auto; width: 100vw; height: 100vh; }
.cx-lp-player.is-pseudo-fs { position: fixed; inset: 0; z-index: 2000; }
body.cx-lp-noscroll { overflow: hidden; }
.cx-lp-next { position: absolute; inset: 0; z-index: 5; background: rgba(15, 23, 42, .85); color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .6rem; text-align: center; padding: 1rem; }
.cx-lp-next[hidden] { display: none; }
.cx-lp-next-ring { width: 64px; height: 64px; border-radius: 50%; border: 4px solid var(--cx-primary); display: flex; align-items: center; justify-content: center; font-size: 1.6rem; font-weight: 700; }
.cx-lp-lessonbar { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; margin: .85rem 0 .5rem; }
.cx-lp-lessonbar-t { flex: 1 1 280px; min-width: 0; }
.cx-lp-lessonbar-t small { color: var(--cx-muted); display: block; font-size: .8rem; }
.cx-lp-lessonbar-t h2 { font-size: 1.08rem; font-weight: 700; color: var(--cx-text); margin: 0; }
.cx-lp-lessonbar-actions { display: flex; gap: .4rem; flex-wrap: wrap; }
.cx-lp-hint { font-size: .82rem; color: var(--cx-muted); background: var(--cx-info-50); border-radius: var(--cx-radius-sm); padding: .4rem .7rem; margin-bottom: .5rem; }
.cx-lp-toc-fold { margin: 0; }
.cx-lp-toc-head { padding: .8rem 1rem; font-weight: 700; color: var(--cx-navy); border-bottom: 1px solid var(--cx-border); }
.cx-lp-toc-count { font-weight: 400; font-size: .82rem; color: var(--cx-muted); margin-left: auto; }
.cx-lp-ch > summary { list-style: none; display: flex; justify-content: space-between; gap: .5rem; padding: .65rem 1rem; background: var(--cx-bg); font-weight: 600; font-size: .88rem; border-bottom: 1px solid var(--cx-border); cursor: pointer; }
.cx-lp-ch > summary::-webkit-details-marker { display: none; }
.cx-lp-ch > summary small { color: var(--cx-muted); font-weight: 400; white-space: nowrap; }
.cx-lp-ch > summary small::after { content: " \25BE"; }
.cx-lp-ch[open] > summary small::after { content: " \25B4"; }
.cx-lp-ls { display: flex; gap: .6rem; padding: .6rem 1rem; font-size: .87rem; border-bottom: 1px solid var(--cx-border); color: var(--cx-text); text-decoration: none; align-items: flex-start; }
.cx-lp-ls:hover { background: var(--cx-bg); color: var(--cx-text); }
.cx-lp-ls small { display: block; color: var(--cx-muted); font-size: .76rem; }
.cx-lp-ic { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--cx-border); flex: none; margin-top: .1rem; display: inline-flex; align-items: center; justify-content: center; font-size: .62rem; color: var(--cx-surface); }
.cx-lp-ls.is-done .cx-lp-ic { background: var(--cx-success); border-color: var(--cx-success); }
.cx-lp-ls.is-done .cx-lp-ic::before { content: "\2713"; font-weight: 700; }
.cx-lp-ls.is-now { background: var(--cx-primary-50); box-shadow: inset 3px 0 0 var(--cx-primary); font-weight: 600; }
.cx-lp-ls.is-now:not(.is-done) .cx-lp-ic { border-color: var(--cx-primary); }
.cx-lp-ls.is-now:not(.is-done) .cx-lp-ic::before { content: "\25B6"; color: var(--cx-primary); font-size: .55rem; }
.cx-lp-tabs { display: flex; gap: .2rem; border-bottom: 1px solid var(--cx-border); margin: .5rem 0 1rem; overflow-x: auto; scrollbar-width: none; }
.cx-lp-tabs::-webkit-scrollbar { display: none; }
.cx-lp-tab { border: 0; background: transparent; padding: .55rem .9rem; font-size: .92rem; color: var(--cx-muted); border-bottom: 2px solid transparent; white-space: nowrap; flex: none; }
.cx-lp-tab:hover { color: var(--cx-navy); }
.cx-lp-tab.is-on { color: var(--cx-navy); border-color: var(--cx-primary); font-weight: 600; }
.cx-lp-n { background: var(--cx-primary-50); color: var(--cx-navy); border-radius: 999px; padding: 0 .45rem; font-size: .74rem; }
.cx-lp-n:empty { display: none; }
.cx-lp-box { padding: .9rem 1rem; margin-bottom: .9rem; }
.cx-lp-box-title { font-size: 1rem; font-weight: 700; color: var(--cx-navy); margin-bottom: .6rem; }
.cx-lp-desc { white-space: pre-line; font-size: .92rem; color: var(--cx-text); }
.cx-lp-files { list-style: none; margin: 0; padding: 0; }
.cx-lp-files li { display: flex; align-items: center; gap: .6rem; padding: .5rem 0; border-bottom: 1px solid var(--cx-border); font-size: .92rem; }
.cx-lp-files li:last-child { border-bottom: 0; }
.cx-lp-files li > span { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.cx-lp-files li > i { color: var(--cx-primary); }
.cx-lp-sol-img { max-height: 70vh; }
.cx-lp-start { max-width: 660px; margin: 1rem auto 2rem; background: var(--cx-surface); border: 1px solid var(--cx-border); border-radius: var(--cx-radius); overflow: hidden; box-shadow: var(--cx-shadow); }
.cx-lp-start > img { width: 100%; aspect-ratio: 16 / 7; object-fit: cover; display: block; }
.cx-lp-start-body { padding: 1.3rem 1.5rem; }
.cx-lp-start-title { font-size: 1.3rem; font-weight: 700; color: var(--cx-navy); margin: .5rem 0 0; }
.cx-lp-facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; margin: 1rem 0; }
.cx-lp-facts div { background: var(--cx-bg); border-radius: var(--cx-radius-sm); padding: .6rem; text-align: center; font-size: .82rem; color: var(--cx-muted); }
.cx-lp-facts b { display: block; color: var(--cx-text); font-size: 1rem; }
.cx-lp-start-warn { background: var(--cx-warning-50); color: var(--cx-warning); border-radius: var(--cx-radius-sm); padding: .7rem .9rem; font-size: .9rem; }
.cx-lp-start-actions { display: flex; gap: .5rem; margin-top: 1rem; }
@media (min-width: 992px) {
    .cx-lp-toc-head { pointer-events: none; }
}
@media (max-width: 575.98px) {
    /* นับถอยหลังบทถัดไปต้องพอดีกรอบวิดีโอ 16:9 บนมือถือ */
    .cx-lp-next { gap: .3rem; font-size: .82rem; padding: .5rem; }
    .cx-lp-next-ring { width: 40px; height: 40px; border-width: 3px; font-size: 1.1rem; }
    .cx-lp-next [data-lp-next-title] { display: inline-block; max-width: 60vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
}
@media (max-width: 991.98px) {
    .cx-lp-grid { grid-template-columns: 1fr; grid-template-areas: "main" "toc" "tabs"; }
    .cx-lp-toc { position: static; max-height: none; margin: .25rem 0 .5rem; }
    .cx-lp-title { font-size: 1.1rem; flex-basis: 100%; }
    .cx-lp-toc-fold:not([open]) > .cx-lp-toc-head { border-bottom: 0; }
    .cx-lp-btn-t { display: none; }
    .cx-lp-head { gap: .4rem .5rem; margin-bottom: .75rem; }
    .cx-lp-back { flex-basis: 100%; }
    .cx-lp-chip { padding: .2rem .6rem; font-size: .78rem; }
    .cx-lp-chip .cx-lp-bar { width: 50px; }
    .cx-lp-lessonbar-actions { width: 100%; }
    .cx-lp-lessonbar-actions .cx-lp-done { flex: 1; }
}

/* คอร์สของฉัน: ความคืบหน้า + เรียนต่อ */
.cx-mc-prog { display: flex; align-items: center; gap: .5rem; font-size: .82rem; color: var(--cx-muted); margin-bottom: .2rem; }
.cx-mc-prog .cx-lp-bar { flex: 1; width: auto; height: 8px; }
.cx-mc-next { font-size: .8rem; color: var(--cx-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: .5rem; }

/* เนื้อหาคอร์ส (admin/course_content.php) — บทเป็นการ์ด บทเรียน/ไฟล์/แบบทดสอบเป็นแถว · มือถือพับทุกบท */
.cc-head-course { display: flex; align-items: center; gap: .5rem 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.cc-sel-form { min-width: 0; flex: 0 1 420px; }
.cc-sel-form .form-select { font-weight: 600; color: var(--cx-navy); }
.cc-stats { font-size: .88rem; color: var(--cx-muted); }
.cc-stats b { color: var(--cx-navy); }
.cc-warn { margin-bottom: 1rem; padding: .7rem .9rem; border-radius: 12px; background: var(--cx-warning-50); border: 1px solid #f5d98b; color: #7a5a00; font-size: .88rem; }
.cc-warn > summary { list-style: none; display: flex; align-items: center; gap: .5rem; cursor: default; }
.cc-warn > summary::-webkit-details-marker { display: none; }
.cc-warn-more { display: none; font-weight: 600; text-decoration: underline; }
.cc-warn-list { margin: .3rem 0 0; padding-left: 1.6rem; }
.cc-warn-list li { margin: .15rem 0; }
.cc-warn-list .btn-link { color: #7a5a00; font-weight: 700; }
.cc-mbar { display: none; }
.cc-ch { background: var(--cx-surface); border: 1px solid var(--cx-border); border-radius: var(--cx-radius); box-shadow: var(--cx-shadow); margin-bottom: 1rem; }
.cc-ch.sortable-ghost { opacity: .45; }
.cc-ch-h { display: flex; align-items: center; gap: .5rem; padding: .55rem .75rem .55rem .6rem; background: var(--cx-primary-50); border-radius: var(--cx-radius) var(--cx-radius) 0 0; border-bottom: 1px solid var(--cx-border); }
.cc-ch.is-folded .cc-ch-h { border-bottom: 0; border-radius: var(--cx-radius); }
.cc-ch.is-folded .cc-ch-body { display: none; }
.cc-ch-toggle { display: flex; align-items: center; gap: .55rem; flex: 1; min-width: 0; padding: .2rem 0; border: 0; background: none; text-align: left; color: inherit; }
.cc-chev { color: var(--cx-muted); font-size: .75rem; width: 12px; transition: transform .15s; }
.cc-ch.is-folded .cc-chev { transform: rotate(-90deg); }
.cc-ch-tt { min-width: 0; flex: 1; display: flex; align-items: baseline; gap: .45rem; flex-wrap: wrap; }
.cc-ch-tt .no { font-weight: 800; color: var(--cx-primary); white-space: nowrap; }
.cc-ch-tt .t { font-weight: 700; color: var(--cx-navy); min-width: 0; }
.cc-ch-tt .n { font-size: .78rem; color: var(--cx-muted); }
.cc-n-warn { color: #8a6100; font-weight: 600; }
.cc-end { margin-left: auto; display: flex; align-items: center; gap: .3rem; flex-shrink: 0; }
.cc-ud { display: inline-flex; gap: .25rem; }
.cc-ib { width: 30px; height: 30px; display: inline-grid; place-items: center; border: 1px solid var(--cx-border); border-radius: 8px; background: var(--cx-surface); color: var(--cx-muted); font-size: .8rem; }
.cc-ib:hover { color: var(--cx-primary); border-color: var(--cx-primary-100); }
.cc-act { border: 1px solid var(--cx-border); background: var(--cx-surface); border-radius: 8px; padding: .25rem .6rem; font-size: .8rem; color: var(--cx-text); white-space: nowrap; }
.cc-act .fa-chevron-down { font-size: .6rem; margin-left: .2rem; }
.cc-act-dots { display: none; }
.cc-grip { color: #9aa7b8; cursor: grab; padding: .3rem .2rem; touch-action: none; }
.cc-list { min-height: 4px; }
.cc-row { display: flex; align-items: center; gap: .6rem; padding: .5rem .75rem .5rem .6rem; border-bottom: 1px solid #eef2f7; min-height: 52px; background: var(--cx-surface); transition: background .3s; }
.cc-row:hover, .cc-row.is-moved { background: #f7faff; }
.cc-row.sortable-ghost { background: var(--cx-primary-50); outline: 2px dashed var(--cx-primary-100); outline-offset: -2px; }
.cc-row.is-hidden .cc-t { color: var(--cx-muted); }
.cc-row.is-hidden .cc-kind { opacity: .5; }
.cc-kind { flex: 0 0 32px; width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; font-size: .85rem; }
.cc-kind.k-yt { background: var(--cx-danger-50); color: #d32f2f; }
.cc-kind.k-file { background: var(--cx-primary-50); color: var(--cx-primary); }
.cc-kind.k-drive { background: var(--cx-warning-50); color: #a87500; }
.cc-kind.k-none { background: #f1f3f6; color: #8a94a3; }
.cc-kind.k-doc { background: var(--cx-success-50); color: var(--cx-success); }
.cc-kind.k-link { background: #eef0fb; color: #3949ab; }
.cc-kind.k-quiz { background: #f3e9fb; color: #7b1fa2; }
.cc-main { display: flex; flex-direction: column; min-width: 0; flex: 1; padding: 0; border: 0; background: none; text-align: left; color: inherit; text-decoration: none; }
.cc-main:hover .cc-t { color: var(--cx-primary); }
.cc-t { font-weight: 600; color: var(--cx-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cc-sub { font-size: .78rem; color: var(--cx-muted); display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; min-width: 0; }
.cc-b { font-size: .72rem; font-weight: 700; padding: .1rem .45rem; border-radius: 999px; }
.cc-b.b-free { background: var(--cx-success-50); color: var(--cx-success); }
.cc-b.b-hide { background: #eceff3; color: #5f6b7a; }
.cc-b.b-warn { background: var(--cx-warning-50); color: #8a6100; }
.cc-b.b-bad { background: var(--cx-danger-50); color: var(--cx-danger); }
.cc-sep { padding: .4rem 1rem; font-size: .78rem; font-weight: 700; color: var(--cx-primary); background: var(--cx-primary-50); border-bottom: 1px solid #eef2f7; }
.cc-add { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; padding: .6rem .9rem; background: #fbfcfe; border-radius: 0 0 var(--cx-radius) var(--cx-radius); }
.cc-add > .btn { border-style: dashed; }
.cc-add .dropdown-item i, .cc-actions .dropdown-item i { width: 1.2rem; margin-right: .35rem; }
.cc-mini { font-size: .65rem; }
.cc-newch { display: block; width: 100%; border: 2px dashed #c7d6ea; border-radius: var(--cx-radius); background: transparent; color: var(--cx-primary); font-weight: 700; padding: .8rem; margin-bottom: 1rem; }
.cc-newch:hover { background: var(--cx-primary-50); }
.cc-course-lvl .cc-ch-h, .cc-loose .cc-ch-h { background: #f6f7f9; }
.cc-course-lvl .cc-ch-tt .no { color: var(--cx-muted); }
.cc-lesson-body { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, .85fr); gap: 1.25rem; }
.cc-seg { margin-bottom: .6rem; }
.cc-check { font-size: .84rem; margin-top: .35rem; min-height: 1.2em; }
.cc-sw { display: flex; gap: .7rem; align-items: flex-start; padding: .65rem .8rem; border: 1px solid var(--cx-border); border-radius: 12px; margin-bottom: .6rem; cursor: pointer; }
.cc-sw.form-switch { padding-left: .8rem; }
.cc-sw .form-check-input { flex: 0 0 auto; width: 2.4em; height: 1.3em; margin: .1rem 0 0; float: none; cursor: pointer; }
.cc-sw b { display: block; font-size: .92rem; color: var(--cx-text); }
.cc-sw small { color: var(--cx-muted); }
.cc-sw-note { margin: -.2rem 0 .6rem; font-size: .8rem; color: var(--cx-info); }
.cc-prev-wrap > summary { margin: .4rem 0 .5rem; }
.cc-prev { border-radius: 12px; overflow: hidden; background: #0f172a; aspect-ratio: 16 / 9; display: grid; place-items: center; color: #cbd5e1; }
.cc-prev > div, .cc-prev iframe, .cc-prev video { width: 100%; height: 100%; display: block; border: 0; }
.cc-prev-empty { padding: 1rem; text-align: center; font-size: .88rem; }
.cc-upload { width: 140px; height: 8px; }
@media (max-width: 991.98px) {
    .cc-sel-form { flex-basis: 100%; }
    .cc-mbar { display: flex; justify-content: space-between; align-items: center; font-size: .82rem; color: var(--cx-muted); margin: -.3rem 0 .6rem; }
    .cc-warn:not([open]) .cc-warn-more { display: inline; }
    .cc-warn > summary { cursor: pointer; }
    .cc-ch { margin-bottom: .6rem; }
    .cc-ch-h { padding: .5rem .55rem; }
    .cc-ud { display: none; }
    .cc-ch-tt { display: block; }
    .cc-ch-tt .n { display: block; }
    .cc-act { padding: .35rem .7rem; }
    .cc-act-lbl { display: none; }
    .cc-act-dots { display: inline; }
    .cc-row { padding: .5rem .55rem .5rem .4rem; gap: .5rem; }
    .cc-t { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; line-height: 1.35; }
    .cc-lesson-body { grid-template-columns: 1fr; }
    .cc-seen { display: none; }
    .cc-course-lvl .cc-ch-tt .t, .cc-loose .cc-ch-tt .t { display: none; }
}

/* หน้าเรียน: เอกสาร/แบบทดสอบประจำบท ใต้บทเรียนของบทนั้นในสารบัญ */
.cx-lp-extra { display: flex; align-items: center; gap: .6rem; padding: .55rem 1rem .55rem 1.35rem; font-size: .85rem; border-bottom: 1px solid var(--cx-border); background: #f7f9fc; color: var(--cx-text); text-decoration: none; }
a.cx-lp-extra:hover { background: var(--cx-primary-50); color: var(--cx-text); }
button.cx-lp-extra { width: 100%; border: 0; border-bottom: 1px solid var(--cx-border); text-align: left; }
button.cx-lp-extra:hover { background: var(--cx-primary-50); }
.cx-lp-extra.is-sol > i { color: var(--cx-primary); }
.cx-lp-extra.is-sol small { margin-left: auto; color: var(--cx-muted); }
.cx-lp-sol-h { font-size: .92rem; margin: 1rem 0 .4rem; }
.cx-lp-sol-h:first-child { margin-top: 0; }
.cx-lp-extra > i { width: 18px; text-align: center; color: var(--cx-success); }
.cx-lp-extra.is-quiz > i { color: #7b1fa2; }
.cx-lp-extra-t { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.35; overflow-wrap: anywhere; }
.cx-lp-extra-k { font-size: .7rem; color: var(--cx-muted); }
.cx-lp-extra > small { margin-left: auto; color: var(--cx-muted); font-size: .74rem; white-space: nowrap; }
.cx-lp-extra .cx-qz-st { margin-left: auto; font-size: .7rem; }

/* หน้าคอร์ส (courses/detail.php) — ย้ายจาก <style> ในหน้า */
.cd-page { background: var(--cx-bg); padding: 1.5rem 0 3rem; }
.cd-crumb { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; margin-bottom: 1.25rem; font-size: .88rem; color: var(--cx-muted); }
.cd-crumb a { color: var(--cx-muted); text-decoration: none; }
.cd-crumb a:hover { color: var(--cx-primary); }
.cd-crumb i { font-size: .65rem; opacity: .6; }
/* desktop: [รูป | การ์ดซื้อ] / [เนื้อหา | การ์ดซื้อ (ติดจอ)] — มือถือ: รูป → การ์ดซื้อ → เนื้อหา */
.cd-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 380px;
    grid-template-areas: "media buy" "content buy";
    gap: 1.5rem;
    align-items: start;
}
.cd-media { grid-area: media; }
.cd-buy { grid-area: buy; position: sticky; top: 88px; }
.cd-content { grid-area: content; display: grid; gap: 1.25rem; }
@media (max-width: 991.98px) {
    .cd-grid { grid-template-columns: 1fr; grid-template-areas: "media" "buy" "content"; }
    .cd-buy { position: static; }
}
.cd-media-frame { position: relative; overflow: hidden; border-radius: 18px; box-shadow: var(--cx-shadow-hover); background: var(--cx-primary-50); }
.cd-media-frame img { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; }
.cd-media-frame.is-draft img { filter: grayscale(60%); opacity: .8; }
.cd-media-overlay {
    position: absolute; inset: auto 1rem 1rem auto;
    padding: .45rem 1rem; border-radius: 999px;
    background: rgba(17, 24, 39, .8); color: #fff; font-weight: 700; font-size: .9rem;
}
.cd-buy-card { padding: 1.4rem; }
.cd-status { display: inline-flex; align-items: center; gap: .35rem; padding: .3rem .75rem; border-radius: 999px; font-size: .8rem; font-weight: 700; margin-bottom: .75rem; }
.cd-status.is-preorder { background: #fdecec; color: var(--cx-danger); }
.cd-status.is-draft { background: #eef0f4; color: #4b5563; }
.cd-release { font-weight: 600; color: var(--cx-navy); margin: -.25rem 0 .75rem; }
.cd-status.is-open { background: var(--cx-success-50); color: var(--cx-success); }
.cd-title { margin: 0 0 .5rem; font-size: 1.45rem; font-weight: 800; line-height: 1.35; color: var(--cx-navy); }
.cd-code { display: inline-block; padding: .15rem .6rem; border-radius: 6px; background: var(--cx-primary-50); color: var(--cx-primary); font-weight: 700; font-size: .82rem; }
.cd-price { margin: 1rem 0 .25rem; font-size: 2rem; font-weight: 800; color: var(--cx-primary); line-height: 1; }
.cd-price-note { margin: 0 0 1rem; font-size: .85rem; color: var(--cx-muted); }
.cd-soon { margin: 1rem 0; font-weight: 700; color: var(--cx-muted); }
.cd-facts { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; margin: 1rem 0 1.25rem; }
.cd-fact { display: flex; gap: .6rem; align-items: center; padding: .65rem .7rem; border: 1px solid var(--cx-border); border-radius: 12px; background: #fbfcfe; min-width: 0; }
.cd-fact i { flex: 0 0 34px; width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; background: var(--cx-primary-50); color: var(--cx-primary); }
.cd-fact span { display: block; font-size: .72rem; color: var(--cx-muted); }
.cd-fact strong { display: block; font-size: .88rem; color: var(--cx-text); overflow-wrap: anywhere; line-height: 1.3; }
.cd-buy .btn { padding: .7rem 1rem; font-size: 1rem; border-radius: 12px; }
.cd-section { padding: 1.4rem 1.5rem; }
.cd-section h2 { display: flex; align-items: center; gap: .55rem; margin: 0 0 1rem; font-size: 1.15rem; font-weight: 800; color: var(--cx-navy); }
.cd-section h2 i { color: var(--cx-primary); }
.cd-prose { font-size: 1rem; line-height: 1.85; color: #374151; overflow-wrap: anywhere; }
.cd-prose > *:last-child { margin-bottom: 0; }
.cd-prose ul, .cd-prose ol { padding-left: 1.3rem; }
.cd-prose li { margin-bottom: .3rem; }
.cd-prose h1, .cd-prose h2, .cd-prose h3, .cd-prose h4 { font-size: 1.05rem; font-weight: 800; color: var(--cx-navy); margin: 1.1rem 0 .5rem; }
.cd-prose img { max-width: 100%; height: auto; border-radius: 12px; }
.cd-tutor { display: flex; align-items: center; gap: 1rem; padding: 1.1rem 1.5rem; text-decoration: none; color: inherit; transition: box-shadow .2s ease, transform .2s ease; }
.cd-tutor:hover { box-shadow: var(--cx-shadow-hover); transform: translateY(-2px); color: inherit; }
.cd-tutor img { width: 72px; height: 72px; border-radius: 50%; object-fit: cover; object-position: top; border: 3px solid var(--cx-primary-100); }
.cd-tutor strong { display: block; font-size: 1.05rem; color: var(--cx-navy); }
.cd-tutor small { color: var(--cx-muted); }
.cd-tutor .cd-tutor-link { margin-left: auto; white-space: nowrap; color: var(--cx-primary); font-weight: 600; font-size: .9rem; }
.cd-related-title { margin: 2.5rem 0 1rem; font-size: 1.25rem; font-weight: 800; color: var(--cx-navy); }
.cd-rel { display: flex; flex-direction: column; height: 100%; overflow: hidden; border-radius: 14px; background: #fff; border: 1px solid var(--cx-border); box-shadow: var(--cx-shadow); text-decoration: none; color: inherit; transition: transform .2s ease, box-shadow .2s ease; }
.cd-rel:hover { transform: translateY(-3px); box-shadow: var(--cx-shadow-hover); color: inherit; }
.cd-rel img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; display: block; }
.cd-rel-body { padding: .7rem .85rem .85rem; display: flex; flex-direction: column; gap: .3rem; flex: 1; }
.cd-rel-body .cd-code { align-self: flex-start; font-size: .72rem; }
.cd-rel-body p { margin: 0; font-weight: 700; font-size: .9rem; line-height: 1.4; color: var(--cx-navy); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.cd-rel-price { margin-top: auto; font-weight: 800; color: var(--cx-primary); }
@media (max-width: 575.98px) {
    .cd-title { font-size: 1.25rem; }
    .cd-section { padding: 1.1rem; }
    .cd-tutor { flex-wrap: wrap; }
    .cd-tutor .cd-tutor-link { margin-left: 0; }
}

/* หน้าคอร์ส (courses/detail.php): สารบัญ + ดูตัวอย่างฟรี (js/course-detail.js) */
.cd-ol-sum { margin: -.5rem 0 1rem; font-size: .88rem; color: var(--cx-muted); }
.cd-ol-ch { border: 1px solid var(--cx-border); border-radius: 12px; margin-bottom: .6rem; background: var(--cx-surface); overflow: hidden; }
.cd-ol-ch > summary { list-style: none; display: flex; gap: .6rem; align-items: center; padding: .75rem 1rem; background: #fbfcfe; cursor: pointer; font-weight: 700; color: var(--cx-navy); }
.cd-ol-ch > summary::-webkit-details-marker { display: none; }
.cd-ol-ch > summary small { margin-left: auto; color: var(--cx-muted); font-weight: 500; white-space: nowrap; }
.cd-ol-chev { color: var(--cx-muted); font-size: .75rem; transition: transform .15s; }
.cd-ol-ch:not([open]) .cd-ol-chev { transform: rotate(-90deg); }
.cd-ol-t { min-width: 0; }
.cd-ol-ls { display: flex; gap: .6rem; align-items: center; padding: .6rem 1rem; border-top: 1px solid #eef2f7; font-size: .93rem; }
.cd-ol-ic { width: 18px; text-align: center; color: #9aa7b8; }
.cd-ol-ls.is-free .cd-ol-ic { color: var(--cx-success); }
.cd-ol-lt { min-width: 0; flex: 1; }
.cd-ol-ls small { color: var(--cx-muted); white-space: nowrap; }
.cd-ol-extra { color: var(--cx-muted); font-size: .86rem; }
.cd-free { display: inline-flex; align-items: center; gap: .3rem; border: 1px solid var(--cx-success); color: var(--cx-success); background: var(--cx-surface); border-radius: 999px; padding: .15rem .65rem; font-size: .78rem; font-weight: 700; white-space: nowrap; }
button.cd-free:hover { background: var(--cx-success-50); }
.cd-free.is-static { flex-shrink: 0; margin-right: .6rem; }
.cd-pv-link { display: block; width: 100%; margin-top: .65rem; border: 0; background: none; font-weight: 700; color: var(--cx-success); }
.cd-pv-link:hover { text-decoration: underline; }
.cd-pv { border-radius: 16px; overflow: hidden; }
.cd-pv-player { background: #0f172a; aspect-ratio: 16 / 9; }
.cd-pv-player iframe, .cd-pv-player video { width: 100%; height: 100%; display: block; border: 0; }
.cd-pv-foot { display: flex; gap: .6rem; align-items: center; justify-content: space-between; flex-wrap: wrap; padding: .8rem 1rem; }
.cd-pv-act { display: flex; gap: .5rem; align-items: center; margin-left: auto; }
.cd-pv-act > div { width: auto !important; }
.cd-prose.is-clamped { max-height: 7.5rem; overflow: hidden; -webkit-mask-image: linear-gradient(#000 55%, transparent); mask-image: linear-gradient(#000 55%, transparent); }
.cd-more { display: inline-flex; align-items: center; gap: .3rem; margin-top: .4rem; padding: 0; border: 0; background: none; font-weight: 600; font-size: .9rem; color: var(--cx-primary); }
.cd-more i { font-size: .7rem; }
@media (max-width: 991.98px) {
    .cd-ol-ch > summary { flex-wrap: wrap; display: grid; grid-template-columns: auto 1fr; column-gap: .6rem; align-items: start; }
    .cd-ol-ch > summary small { grid-column: 2; margin-left: 0; }
    .cd-ol-ls { flex-wrap: wrap; padding-left: .8rem; }
    .cd-ol-ls .cd-free { order: 3; margin-left: 1.6rem; }
}

/* คอร์สของฉัน (student/my_course.php) — ย้ายจาก <style> ในหน้า · ครอบด้วย .my-courses-container (ชื่อ .course-card ซ้ำกับหน้ารวมคอร์ส) */
.my-courses-container { background: var(--cx-surface); min-height: 100vh; padding: 1.5rem 0; }
.my-courses-container .my-courses-title { color: var(--cx-navy); font-weight: 700; font-size: 2rem; text-align: center; margin-bottom: 2rem; animation: cx-mc-fadeInDown 0.5s ease-out; }
.my-courses-container .my-courses-title i { color: var(--cx-primary); font-size: 1.8rem; }
.my-courses-container .my-courses-tabs { border: none; margin-bottom: 2rem; display: flex; justify-content: center; gap: 0.5rem; flex-wrap: wrap; }
.my-courses-container .my-courses-tabs .nav-item { margin: 0; }
.my-courses-container .my-courses-tabs .nav-link { background: white; border: 2px solid var(--cx-border); border-radius: 12px; padding: 0.85rem 1.5rem; font-weight: 600; color: #64748b; transition: all 0.3s ease; display: flex; align-items: center; gap: 0.5rem; margin: 0.25rem; }
.my-courses-container .my-courses-tabs .nav-link i { font-size: 1rem; }
.my-courses-container .my-courses-tabs .nav-link:hover { background: linear-gradient(135deg, #f8fafc, #f1f5f9); border-color: var(--cx-primary); color: var(--cx-primary); transform: translateY(-2px); }
.my-courses-container .my-courses-tabs .nav-link.active { background: linear-gradient(135deg, var(--cx-primary) 0%, var(--cx-navy) 100%); border-color: transparent; color: white; box-shadow: 0 4px 15px rgba(25, 118, 210, 0.3); }
.my-courses-container .course-card { border-radius: 15px; border: none; box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08); overflow: hidden; transition: all 0.3s ease; animation: cx-mc-fadeInUp 0.5s ease-out; height: 100%; }
.my-courses-container .course-card:hover { transform: translateY(-8px); box-shadow: 0 12px 35px rgba(25, 118, 210, 0.2); }
.my-courses-container .course-card-img { width: 100%; aspect-ratio: 16 / 9; height: auto; object-fit: contain; background-color: #f8f9fa; border-radius: 15px 15px 0 0; }
.my-courses-container .course-purchase-badge { background: linear-gradient(135deg, var(--cx-primary) 0%, var(--cx-navy) 100%); color: white; font-size: 0.75rem; font-weight: 600; padding: 0.4rem 0.75rem; border-radius: 8px; position: absolute; top: 0.75rem; right: 0.75rem; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15); z-index: 10; }
.my-courses-container .course-card-body { padding: 1.5rem; display: flex; flex-direction: column; }
.my-courses-container .course-card-title { color: var(--cx-navy); font-weight: 700; font-size: 1.1rem; margin-bottom: 0.75rem; line-height: 1.4; }
.my-courses-container .course-card-description { color: #64748b; font-size: 0.9rem; margin-bottom: 1rem; line-height: 1.6; flex-grow: 1; }
.my-courses-container .course-countdown { background: linear-gradient(135deg, #fef3c7, #fde68a); border: none; color: #92400e; font-weight: 600; font-size: 0.85rem; padding: 0.5rem; border-radius: 8px; margin-bottom: 1rem; text-align: center; }
.my-courses-container .course-countdown i { color: #f59e0b; }
.my-courses-container .course-status-alert { border: none; font-weight: 600; font-size: 0.85rem; padding: 0.5rem; border-radius: 8px; margin-bottom: 1rem; text-align: center; }
.my-courses-container .course-status-secondary { background: linear-gradient(135deg, #f1f5f9, var(--cx-border)); color: #475569; }
.my-courses-container .course-status-warning { background: linear-gradient(135deg, #fef3c7, #fde68a); color: #92400e; }
.my-courses-container .course-btn-primary { background: linear-gradient(135deg, var(--cx-primary) 0%, var(--cx-navy) 100%) !important; border: none; border-radius: 12px; padding: 0.75rem 1.5rem; font-size: 1rem; font-weight: 700; transition: all 0.3s ease; box-shadow: 0 4px 15px rgba(25, 118, 210, 0.3); color: white; width: 100%; display: flex; align-items: center; justify-content: center; gap: 0.5rem; }
.my-courses-container .course-btn-primary:hover { transform: translateY(-2px); box-shadow: 0 8px 25px rgba(25, 118, 210, 0.4); color: white; }
.my-courses-container .course-btn-success-outline { background: white; border: 2px solid #10b981; border-radius: 12px; padding: 0.75rem 1.5rem; font-size: 1rem; font-weight: 700; color: #10b981; transition: all 0.3s ease; width: 100%; display: flex; align-items: center; justify-content: center; gap: 0.5rem; }
.my-courses-container .course-btn-success-outline:hover { background: linear-gradient(135deg, #10b981, #059669); color: white; transform: translateY(-2px); box-shadow: 0 8px 25px rgba(16, 185, 129, 0.3); }
.my-courses-container .course-btn-secondary-outline { background: white; border: 2px solid #94a3b8; border-radius: 12px; padding: 0.75rem 1.5rem; font-size: 1rem; font-weight: 700; color: #64748b; width: 100%; display: flex; align-items: center; justify-content: center; gap: 0.5rem; cursor: not-allowed; opacity: 0.6; }
.my-courses-container .course-btn-disabled { background: var(--cx-border); border: none; border-radius: 12px; padding: 0.75rem 1.5rem; font-size: 1rem; font-weight: 700; color: #94a3b8; width: 100%; display: flex; align-items: center; justify-content: center; gap: 0.5rem; cursor: not-allowed; }
.my-courses-container .course-card-expired { opacity: 0.7; position: relative; }
.my-courses-container .course-expired-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.6); color: white; font-size: 1.5rem; font-weight: 700; display: flex; justify-content: center; align-items: center; border-radius: 15px; z-index: 5; }
.my-courses-container .course-empty-state { background: linear-gradient(135deg, #f8fafc, #f1f5f9); border: 2px dashed #cbd5e1; border-radius: 15px; padding: 3rem 2rem; text-align: center; color: #64748b; font-size: 1.1rem; margin-top: 2rem; }
@keyframes cx-mc-fadeInUp { from { opacity: 0; transform: translateY(30px); } to { opacity: 1; transform: translateY(0); } }
@keyframes cx-mc-fadeInDown { from { opacity: 0; transform: translateY(-20px); } to { opacity: 1; transform: translateY(0); } }
.my-courses-container .course-col:nth-child(1) .course-card { animation-delay: 0.1s; }
.my-courses-container .course-col:nth-child(2) .course-card { animation-delay: 0.2s; }
.my-courses-container .course-col:nth-child(3) .course-card { animation-delay: 0.3s; }
.my-courses-container .course-col:nth-child(4) .course-card { animation-delay: 0.4s; }
.my-courses-container .course-col:nth-child(5) .course-card { animation-delay: 0.5s; }
.my-courses-container .course-col:nth-child(6) .course-card { animation-delay: 0.6s; }
.my-courses-container .course-col:nth-child(7) .course-card { animation-delay: 0.7s; }
.my-courses-container .course-col:nth-child(8) .course-card { animation-delay: 0.8s; }
@media (max-width: 768px) {
    .my-courses-container .my-courses-title { font-size: 1.5rem; }
    .my-courses-container .my-courses-title i { font-size: 1.3rem; }
    .my-courses-container .my-courses-tabs .nav-link { padding: 0.65rem 1rem; font-size: 0.9rem; }
    .my-courses-container .course-card-body { padding: 1.25rem; }
    .my-courses-container .course-card-title { font-size: 1rem; }
    .my-courses-container .course-card-description { font-size: 0.85rem; }
    .my-courses-container .course-btn-primary, .my-courses-container .course-btn-success-outline, .my-courses-container .course-btn-secondary-outline, .my-courses-container .course-btn-disabled { padding: 0.65rem 1.25rem; font-size: 0.95rem; }
}
@media (max-width: 576px) {
    .my-courses-container .my-courses-title { font-size: 1.3rem; }
    .my-courses-container .my-courses-tabs { flex-direction: column; align-items: stretch; }
    .my-courses-container .my-courses-tabs .nav-link { width: 100%; justify-content: center; }
    .my-courses-container .course-card-body { padding: 1rem; }
    .my-courses-container .course-card-title { font-size: 0.95rem; }
    .my-courses-container .course-card-description { font-size: 0.8rem; }
    .my-courses-container .course-purchase-badge { font-size: 0.7rem; padding: 0.3rem 0.6rem; }
}

/* หน้าจัดการคอร์สรวม (admin/manage_courses.php · admin/course.php) — ตาราง + แท็บต่อคอร์ส · มือถือ: แถวเป็นการ์ด */
.ca-filters { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; margin-bottom: 1rem; }
.ca-tabs { display: flex; gap: .3rem; flex-wrap: wrap; }
.ca-tab { padding: .4rem .85rem; border-radius: 999px; border: 1px solid var(--cx-border); background: var(--cx-surface); font-size: .86rem; font-weight: 600; color: var(--cx-muted); text-decoration: none; white-space: nowrap; }
.ca-tab:hover { color: var(--cx-primary); border-color: var(--cx-primary-100); }
.ca-tab.is-on { background: var(--cx-primary); border-color: var(--cx-primary); color: #fff; }
.ca-tab b { margin-left: .15rem; opacity: .8; }
.ca-tab.is-soon:not(.is-on) { color: #a85f00; border-color: #f5d98b; background: var(--cx-warning-50); }
.ca-search-form { display: flex; gap: .4rem; flex: 1; min-width: 220px; }
.ca-search-form .form-select { max-width: 160px; }
.ca-st-actions { display: flex; gap: .4rem; flex-wrap: wrap; }
.ca-table td { vertical-align: middle; }
.ca-course { display: flex; gap: .75rem; align-items: center; min-width: 0; color: inherit; text-decoration: none; }
.ca-course:hover .ca-name { color: var(--cx-primary); }
.ca-thumb { width: 72px; height: 40px; border-radius: 6px; object-fit: cover; flex-shrink: 0; border: 1px solid var(--cx-border); }
.ca-thumb-empty { display: grid; place-items: center; background: #f1f3f6; color: #9aa3af; }
.ca-course-t { display: flex; flex-direction: column; min-width: 0; }
.ca-code { display: inline-block; font-size: .74rem; font-weight: 700; color: var(--cx-primary); background: var(--cx-primary-50); padding: .05rem .4rem; border-radius: 5px; }
.ca-name { font-weight: 600; color: var(--cx-text); line-height: 1.3; }
.ca-sub { font-size: .78rem; color: var(--cx-muted); overflow-wrap: anywhere; }
.ca-warn-t { color: #a85f00; }
.ca-st { font-size: .74rem; font-weight: 700; padding: .15rem .55rem; border-radius: 999px; white-space: nowrap; display: inline-block; }
.ca-st.st-open { background: var(--cx-success-50); color: var(--cx-success); }
.ca-st.st-pre { background: var(--cx-warning-50); color: #a85f00; }
.ca-st.st-draft { background: #eef0f4; color: #4b5563; }
.ca-st.st-arch { background: #f1f5f9; color: #64748b; border: 1px dashed #cbd5e1; }
.ca-num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.ca-mlbl { display: none; }
.ca-c-act { text-align: right; width: 1%; }
.ca-tag { font-size: .68rem; font-weight: 700; padding: .05rem .4rem; border-radius: 5px; background: #f3e9fb; color: #7b1fa2; margin-left: .35rem; vertical-align: middle; }
.ca-exp { font-size: .84rem; white-space: nowrap; }
.ca-exp.is-soon { color: #b45309; font-weight: 600; }
.ca-exp.is-gone { color: var(--cx-danger); }
.ca-prog { display: flex; align-items: center; gap: .4rem; min-width: 110px; }
.ca-prog i { flex: 1; height: 6px; border-radius: 999px; background: #e5e7eb; position: relative; overflow: hidden; display: block; }
.ca-prog i::after { content: ""; position: absolute; inset: 0; width: var(--w); background: var(--cx-primary); border-radius: 999px; }
.ca-prog small { font-variant-numeric: tabular-nums; color: var(--cx-muted); }
.ca-head { display: flex; gap: 1rem; align-items: center; margin-bottom: .75rem; flex-wrap: wrap; }
.ca-head img { width: 112px; height: 63px; border-radius: 10px; object-fit: cover; border: 1px solid var(--cx-border); }
.ca-head-t { min-width: 0; flex: 1; }
.ca-head h1 { font-size: 1.35rem; font-weight: 800; color: var(--cx-navy); margin: .2rem 0 0; }
.ca-head-end { display: flex; gap: .5rem; flex-wrap: wrap; }
.ca-head-end .dropdown-item i, .ca-c-act .dropdown-item i { width: 1.2rem; margin-right: .3rem; color: var(--cx-muted); }
.ca-head-end form, .ca-c-act form { margin: 0; }
.ca-ptabs { display: flex; gap: .2rem; border-bottom: 1px solid var(--cx-border); margin-bottom: 1.25rem; overflow-x: auto; scrollbar-width: none; }
.ca-ptabs::-webkit-scrollbar { display: none; }
.ca-ptab { padding: .7rem .9rem; font-weight: 600; font-size: .9rem; color: var(--cx-muted); border-bottom: 2px solid transparent; white-space: nowrap; text-decoration: none; }
.ca-ptab:hover { color: var(--cx-primary); }
.ca-ptab.is-on { color: var(--cx-primary); border-bottom-color: var(--cx-primary); }
.ca-ptab .n { background: var(--cx-primary-50); color: var(--cx-primary); border-radius: 999px; padding: 0 .45rem; font-size: .74rem; margin-left: .3rem; }
.ca-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .9rem; margin-bottom: 1rem; }
.ca-stat { background: var(--cx-surface); border: 1px solid var(--cx-border); border-radius: var(--cx-radius); padding: 1rem 1.1rem; box-shadow: var(--cx-shadow); }
.ca-stat b { display: block; font-size: 1.5rem; color: var(--cx-navy); line-height: 1.2; }
.ca-stat span { font-size: .82rem; color: var(--cx-muted); }
.ca-grid2 { display: grid; grid-template-columns: 1.3fr 1fr; gap: 1rem; }
.ca-wide { grid-column: 1 / -1; }
.ca-card { padding: 1.1rem 1.25rem; }
.ca-card h3 { font-size: 1rem; font-weight: 800; color: var(--cx-navy); margin: 0 0 .7rem; display: flex; align-items: center; gap: .5rem; }
.ca-check { display: flex; gap: .6rem; align-items: flex-start; padding: .5rem 0; border-bottom: 1px dashed #eef2f7; font-size: .9rem; }
.ca-check:last-child { border-bottom: 0; }
.ca-check > i { margin-top: .2rem; width: 16px; }
.ca-check > a { margin-left: auto; font-size: .82rem; white-space: nowrap; }
.ca-ok { color: var(--cx-success); }
.ca-warn { color: #d97706; }
.ca-okfold > summary { list-style: none; font-size: .88rem; color: var(--cx-muted); padding: .5rem 0 .2rem; cursor: pointer; }
.ca-okfold > summary::-webkit-details-marker { display: none; }
.ca-links { display: grid; gap: .4rem; }
.ca-links a { display: flex; gap: .6rem; align-items: center; padding: .55rem .7rem; border: 1px solid var(--cx-border); border-radius: 10px; font-size: .9rem; color: var(--cx-text); text-decoration: none; }
.ca-links a:hover { border-color: var(--cx-primary-100); background: #fafcff; }
.ca-links i { width: 18px; color: var(--cx-primary); }
.ca-radio { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .6rem; margin-bottom: .5rem; }
.ca-radio-opt { position: relative; border: 1px solid var(--cx-border); border-radius: 12px; padding: .7rem .8rem .7rem 2.1rem; font-size: .84rem; background: var(--cx-surface); cursor: pointer; }
.ca-radio-opt input { position: absolute; left: .75rem; top: .9rem; }
.ca-radio-opt b { display: block; font-size: .92rem; color: var(--cx-text); }
.ca-radio-opt small { color: var(--cx-muted); }
.ca-radio-opt.is-on { border-color: var(--cx-primary); background: var(--cx-primary-50); box-shadow: 0 0 0 2px var(--cx-primary-50); }
.ca-radio-opt.is-on b { color: var(--cx-primary); }
.ca-save { position: sticky; bottom: 0; z-index: 5; margin: 1.25rem -1.25rem -1.1rem; padding: .8rem 1.25rem; background: rgba(255, 255, 255, .96); backdrop-filter: blur(6px); border-top: 1px solid var(--cx-border); border-radius: 0 0 var(--cx-radius) var(--cx-radius); display: flex; align-items: center; gap: .75rem; justify-content: flex-end; }
.ca-save-note { margin-right: auto; font-size: .84rem; color: #a85f00; }
.ca-save-note i { font-size: .45rem; vertical-align: middle; margin-right: .3rem; }
.ca-quill { background: var(--cx-surface); }
.ca-quill.ql-container { height: auto; } /* quill.snow.css ตั้ง 100% → ตัวที่ 2 ทับตัวแรก */
.ca-quill .ql-editor { min-height: 180px; font-size: .95rem; }
.ca-quill-sm .ql-editor { min-height: 100px; }
.ca-thumb-row { display: flex; gap: .8rem; align-items: flex-start; }
.ca-thumb-row img { width: 128px; height: 72px; object-fit: cover; border-radius: 8px; border: 1px solid var(--cx-border); }
.ca-chips { display: flex; gap: .4rem; flex-wrap: wrap; }
.ca-chips label { margin: 0; cursor: pointer; }
.ca-chips input { position: absolute; opacity: 0; pointer-events: none; }
.ca-chips span { display: inline-block; padding: .35rem .75rem; border: 1px solid var(--cx-border); border-radius: 999px; font-size: .85rem; font-weight: 600; background: var(--cx-surface); }
.ca-chips input:checked + span { background: var(--cx-primary-50); border-color: var(--cx-primary); color: var(--cx-primary); }
.ca-chips input:focus-visible + span { outline: 2px solid var(--cx-primary); outline-offset: 2px; }
.ca-chips input:disabled + span { opacity: .45; cursor: not-allowed; }
.ca-note { background: var(--cx-primary-50); border-radius: 10px; padding: .6rem .8rem; font-size: .9rem; }
.ca-note:empty { display: none; }
.ca-lookup { margin-top: .5rem; font-size: .88rem; }
.ca-lookup-card { border: 1px solid var(--cx-border); border-radius: 10px; padding: .55rem .75rem; }
.cc-help { font-size: .82rem; color: var(--cx-muted); margin: -.4rem 0 1rem; }
.cc-head-course .btn { flex-shrink: 0; }
@media (max-width: 991.98px) {
    .ca-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .ca-grid2 { grid-template-columns: 1fr; }
    .ca-radio { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .ca-head img { width: 72px; height: 40px; }
    .ca-head h1 { font-size: 1.1rem; }
    .ca-ptabs { -webkit-mask-image: linear-gradient(90deg, #000 85%, transparent); mask-image: linear-gradient(90deg, #000 85%, transparent); }
    .ca-search-form { flex-basis: 100%; }
    .ca-mob-cards thead { display: none; }
    .ca-mob-cards, .ca-mob-cards tbody { display: block; }
    .ca-mob-cards tr { display: flex; flex-wrap: wrap; gap: .35rem .8rem; padding: .75rem .8rem; border-bottom: 1px solid #eef2f7; align-items: center; }
    .ca-mob-cards td { display: block; padding: 0 !important; border: 0 !important; order: 2; }
    .ca-mob-cards td.ca-c1 { order: 0; flex: 1 1 calc(100% - 100px); min-width: 0; }
    .ca-mob-cards td.ca-c-act { order: 1; align-self: flex-start; width: auto; }
    .ca-mob-cards .ca-thumb { width: 56px; height: 32px; }
    .ca-head-end { width: 100%; }
    .ca-mob-cards td.ca-hide-m { display: none; }
    .ca-mob-cards .ca-prog { min-width: 90px; }
    .ca-mlbl { display: inline; color: var(--cx-muted); font-size: .76rem; }
    .ca-thumb-row { flex-direction: column; }
}
.ca-meta { display: flex; align-items: center; gap: .3rem; white-space: nowrap; }

/* เฉลยแบบฝึกหัด (แท็บ "เฉลย" ของ admin/course.php) — ใช้การ์ดบท/แถวชุดเดียวกับแท็บเนื้อหา (.cc-*) */
.cs-thumb { flex: 0 0 44px; width: 44px; height: 44px; border-radius: 8px; object-fit: cover; border: 1px solid var(--cx-border); background: var(--cx-bg); }
.cs-thumb-empty { display: grid; place-items: center; color: var(--cx-muted); }
.cs-imgs { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: .6rem; margin-bottom: .6rem; }
.cs-imgs:empty { display: none; }
.cs-img { position: relative; border: 1px solid var(--cx-border); border-radius: 10px; overflow: hidden; background: var(--cx-bg); cursor: grab; aspect-ratio: 4 / 3; }
.cs-img img { width: 100%; height: 100%; object-fit: contain; display: block; }
.cs-img.sortable-ghost { opacity: .4; }
.cs-img-n { position: absolute; left: .35rem; top: .35rem; padding: .05rem .45rem; border-radius: 999px; background: var(--cx-navy); color: var(--cx-surface); font-size: .72rem; font-weight: 600; }
.cs-img-n:empty { display: none; }
.cs-img-x { position: absolute; right: .3rem; top: .3rem; width: 26px; height: 26px; border: 0; border-radius: 50%; background: rgba(255, 255, 255, .92); color: var(--cx-danger); display: grid; place-items: center; box-shadow: var(--cx-shadow); }
.cs-drop { min-height: 120px; }
.cs-bulk-list { margin-top: .75rem; }

/* กำลังโหลด (js/app.js): ปุ่มที่ส่งฟอร์มแล้ว + กรอบรูปที่ยังโหลดไม่เสร็จ (img[data-cx-wait]) */
.cx-busy { pointer-events: none; opacity: .8; }
.cx-busy .cx-busy-spin { margin-right: .4rem; vertical-align: -.15em; }
.cx-busy .cx-busy-spin ~ i { display: none; }
.cx-img-loading { position: relative; display: block; min-height: 140px; background: var(--cx-bg); border-radius: 10px; }
.cx-img-loading > img[data-cx-wait] { opacity: 0; }
.cx-img-loading::after { content: ""; position: absolute; left: 50%; top: 50%; width: 2rem; height: 2rem; margin: -1rem 0 0 -1rem; border: .25rem solid var(--cx-primary-100); border-right-color: var(--cx-primary); border-radius: 50%; animation: cx-spin .75s linear infinite; }
@keyframes cx-spin { to { transform: rotate(360deg); } }

/* ค้นหาตามที่พิมพ์ (js/app.js) — ส่วนที่กำลังโหลดผลใหม่ */
.cx-live-loading { opacity: .55; transition: opacity .15s; pointer-events: none; }

/* ราคา (config/pricing.php): ราคาเต็มขีดฆ่า + ราคาลด + ป้ายลด */
.cx-price.is-sale .cx-price-now, .cx-course-price.is-sale .cx-price-now, .price-tag.is-sale .cx-price-now, .cd-price-v.is-sale .cx-price-now { color: var(--cx-danger); }
.cx-price-old { color: var(--cx-muted); font-weight: 500; font-size: .8em; text-decoration: line-through; margin-right: .15rem; }
.cx-sale-badge { display: inline-block; padding: .15rem .55rem; border-radius: 999px; background: var(--cx-danger-50); color: var(--cx-danger); font-size: .78rem; font-weight: 700; white-space: nowrap; }
.cd-sale-line { margin: -.35rem 0 .75rem; }
.cx-course-sale { position: absolute; top: .6rem; right: .6rem; z-index: 2; padding: .2rem .6rem; border-radius: 999px; background: var(--cx-danger); color: var(--cx-surface); font-size: .78rem; font-weight: 800; box-shadow: var(--cx-shadow); }
.ca-sale { border: 1px solid var(--cx-border); border-radius: 14px; padding: .9rem 1.1rem 1rem; }
.ca-sale legend { float: none; width: auto; font-size: 1rem; font-weight: 800; color: var(--cx-navy); padding: 0 .4rem; margin: 0 0 .2rem -.4rem; }
.ca-sale legend i { color: var(--cx-primary); margin-right: .25rem; }
.ca-sale legend small { font-weight: 400; font-size: .8rem; color: var(--cx-muted); }
.ca-sale-now { margin: .8rem 0 .3rem; font-size: .9rem; }
.ca-sale-now:empty { display: none; }
.ca-sale-now > i { color: var(--cx-success); }
.cx-bundle-kid td { background: var(--cx-bg); font-size: .92em; }
.cx-bundle-kid td:first-child { padding-left: 1.5rem; }
.cx-mc-bundle-head { display: flex; align-items: center; gap: .5rem; padding-top: .25rem; border-top: 1px solid var(--cx-border); color: var(--cx-navy); }
.cx-mc-bundle-head:first-child { border-top: 0; padding-top: 0; }
.ca-radio-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); max-width: 640px; }

/* แพ็กรวม — แท็บ "คอร์สในแพ็ก" (admin/course.php) */
.ca-bundle-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; margin-bottom: .75rem; }
.ca-bundle-head h3 { margin: 0; font-size: 1.1rem; font-weight: 800; color: var(--cx-navy); display: flex; gap: .5rem; align-items: center; }
.ca-bundle-head h3 i { color: var(--cx-primary); }
.ca-bundle-add { display: flex; gap: .5rem; min-width: 0; flex: 0 1 460px; }
.ca-bundle-row { display: flex; align-items: center; gap: .75rem; padding: .6rem .25rem; border-bottom: 1px solid var(--cx-border); }
.ca-bundle-row img, .ca-bundle-row .ca-thumb-empty { flex: 0 0 64px; width: 64px; height: 36px; object-fit: cover; border-radius: 6px; display: grid; place-items: center; background: var(--cx-bg); color: var(--cx-muted); }
.ca-bundle-row .t { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ca-bundle-row .t a { color: var(--cx-text); text-decoration: none; }
.ca-bundle-row .t small { color: var(--cx-muted); }
.ca-bundle-ops { display: inline-flex; gap: .25rem; }
.ca-bundle-ops .cc-ib:disabled { opacity: .35; }
.ca-bundle-sum { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .75rem; margin-top: 1rem; }
.ca-bundle-sum > div { background: var(--cx-bg); border-radius: 12px; padding: .7rem .9rem; display: flex; flex-direction: column; gap: .15rem; }
.ca-bundle-sum span { font-size: .8rem; color: var(--cx-muted); }
.ca-bundle-sum b { font-size: 1.2rem; color: var(--cx-navy); }
@media (max-width: 767.98px) { .ca-bundle-sum { grid-template-columns: 1fr; } .ca-bundle-row { flex-wrap: wrap; } }

/* แพ็กรวม — หน้าสาธารณะ */
.cx-course-bundle { position: absolute; bottom: .6rem; left: .6rem; z-index: 2; padding: .2rem .6rem; border-radius: 999px; background: var(--cx-navy); color: var(--cx-surface); font-size: .76rem; font-weight: 700; box-shadow: var(--cx-shadow); }
.cx-save-badge { display: inline-block; padding: .15rem .55rem; border-radius: 999px; background: var(--cx-success-50); color: var(--cx-success); font-size: .78rem; font-weight: 700; white-space: nowrap; }
.cd-bundle-note { display: flex; gap: .4rem; align-items: flex-start; margin: .75rem 0 0; padding: .55rem .75rem; border-radius: 10px; background: var(--cx-warning-50); color: #7a5a00; font-size: .85rem; }
.cd-in-bundle { display: flex; gap: .65rem; align-items: center; margin-top: .9rem; padding: .6rem .7rem; border: 1px solid var(--cx-border); border-radius: 12px; text-decoration: none; color: var(--cx-text); }
.cd-in-bundle:hover { border-color: var(--cx-primary-100); background: var(--cx-primary-50); }
.cd-in-bundle img { width: 64px; height: 36px; object-fit: cover; border-radius: 6px; flex: 0 0 64px; }
.cd-in-bundle span { display: flex; flex-direction: column; min-width: 0; font-size: .88rem; }
.cd-in-bundle small { color: var(--cx-primary); font-weight: 700; }
.cd-bundle-list { display: flex; flex-direction: column; }
.cd-bundle-item { display: flex; gap: .75rem; align-items: center; padding: .65rem .25rem; border-bottom: 1px solid var(--cx-border); text-decoration: none; color: var(--cx-text); }
.cd-bundle-item:hover { background: var(--cx-primary-50); }
.cd-bundle-item img { width: 80px; height: 45px; object-fit: cover; border-radius: 8px; flex: 0 0 80px; }
.cd-bundle-item span { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.cd-bundle-item small { color: var(--cx-muted); }
.cd-bundle-item > i { color: var(--cx-muted); }

/* SSO: หน้า login เว็บหลักตอนมาจากระบบลูก (config/sso.php) */
.cx-sso-banner { display: flex; gap: .75rem; align-items: flex-start; margin: -.5rem 0 1.25rem; padding: .85rem 1rem; border-radius: 12px; background: var(--cx-primary-50); border: 1px solid var(--cx-border); color: var(--cx-navy); font-size: .92rem; line-height: 1.55; }
.cx-sso-banner > i { margin-top: .2rem; color: var(--cx-primary); }
.cx-sso-banner strong { display: block; }
.cx-sso-cancel { display: inline-block; margin-top: .25rem; font-size: .82rem; color: var(--cx-muted); }

/* ===== สไลด์ส่วนบนหน้าแรก (index.php · js/hero-slider.js) ===== */
:root {
    /* Mock Exam โทนแดงเต็ม (สไลด์โฆษณาบนเว็บหลัก — เจ้าของเลือก 2026-10-14) */
    --cx-mx-red: #7f1022;
    --cx-mx-red-2: #b3132f;
    --cx-mx-gold: #ffd166;
    --cx-mx-paper: #fffdf6;
    --cx-mx-ink: #151a2d;
}
.cx-hero-slider { position: relative; }
.cx-slides { display: grid; overflow: hidden; }
/* เลื่อนแนวนอน (เจ้าของขอ — ไม่ใช่จาง/กระพริบ): js ใช้ Web Animations (el.animate) ไม่ใช้ css transition
   — กฎกลาง prefers-reduced-motion ด้านบนปิด transition ทุกชิ้น ทำให้แผ่นกระโดด · is-leaving = แผ่นที่กำลังเลื่อนออก */
.cx-slide { grid-area: 1 / 1; visibility: hidden; display: flex; flex-direction: column; }
.cx-slide > * { flex: 1; }
.cx-slide.is-active, .cx-slide.is-leaving { visibility: visible; }
@media (max-width: 767.98px) {
    /* มือถือ: แผ่นแรก (การ์ดพี่เอ็กซ์) สูงมาก — แต่ละแผ่นสูงเท่าเนื้อหาตัวเอง ไม่ยืดเท่ากัน · ไม่เลื่อนเอง (js) เนื้อหาข้างล่างไม่กระโดด */
    .cx-slide:not(.is-active) { display: none; }
}
/* แถบควบคุมด้านล่าง: ลูกศร · จุด · หยุด/เล่น (ไม่วางลูกศรกลางขอบจอ — บังปุ่มของแผ่นแรกที่จอ ~1024px) */
.cx-slider-bar { position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); z-index: 5; display: flex; align-items: center; gap: .4rem;
    padding: .3rem .45rem; border-radius: 999px; background: rgba(0,0,0,.22); backdrop-filter: blur(4px); }
.cx-slider-btn { width: 32px; height: 32px; border: 0; border-radius: 50%; background: transparent; color: #fff; display: grid; place-items: center; font-size: .85rem; transition: background .2s; }
.cx-slider-btn:hover, .cx-slider-btn:focus-visible { background: rgba(255,255,255,.25); }
.cx-slider-dots { display: flex; align-items: center; gap: .45rem; padding: 0 .2rem; }
.cx-slider-dots button { width: 10px; height: 10px; padding: 0; border: 0; border-radius: 999px; background: rgba(255,255,255,.55); transition: width .25s, background .25s; }
.cx-slider-dots button.is-active { width: 28px; background: #fff; }
/* WOW.js ใส่ visibility: visible แบบ inline ให้ชิ้นส่วนในแผ่นแรก — แผ่นที่ซ่อนอยู่ต้องซ่อนชิ้นพวกนี้ด้วย */
.cx-slide.is-gone .wow { visibility: hidden !important; } /* is-gone = เลื่อนออกเสร็จแล้ว (ระหว่างเลื่อนยังเห็นอยู่) */

.cx-mx-slide { position: relative; overflow: hidden; display: flex; align-items: center; padding: 4rem 0 4.5rem; color: #fff;
    background: linear-gradient(135deg, var(--cx-mx-red) 0%, var(--cx-mx-red-2) 100%); }
.cx-mx-slide::before { content: ""; position: absolute; inset: 0; pointer-events: none;
    background-image: linear-gradient(rgba(255,255,255,.05) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.05) 1px, transparent 1px); background-size: 28px 28px; }
.cx-mx-slide .container { position: relative; }
.cx-mx-soon { display: inline-flex; align-items: center; padding: .35rem .9rem; border-radius: 999px; background: var(--cx-mx-gold); color: var(--cx-mx-red); font-weight: 800; font-size: .95rem; }
.cx-mx-title { margin: .9rem 0 .4rem; font-size: clamp(2.1rem, 4.6vw, 3.4rem); line-height: 1.18; font-weight: 800; color: #fff; text-shadow: 0 2px 14px rgba(0,0,0,.28); }
.cx-mx-hl { color: var(--cx-mx-gold); }
.cx-mx-name { margin: 0 0 .9rem; font-weight: 700; color: var(--cx-mx-gold); letter-spacing: .02em; }
.cx-mx-lead { font-size: 1.1rem; color: #fff; text-shadow: 0 1px 8px rgba(0,0,0,.2); max-width: 580px; margin: 0 0 1.5rem; }
.text-center .cx-mx-lead { margin-left: auto; margin-right: auto; }
@media (min-width: 992px) { .text-lg-start .cx-mx-lead { margin-left: 0; } }
.cx-mx-cta { display: flex; flex-wrap: wrap; gap: .75rem; justify-content: center; margin-bottom: 1.4rem; }
@media (min-width: 992px) { .cx-mx-cta, .cx-mx-trust { justify-content: flex-start; } }
.cx-mx-btn { display: inline-flex; align-items: center; gap: .5rem; padding: .8rem 1.4rem; border-radius: 12px; font-weight: 700; text-decoration: none; border: 2px solid transparent; transition: transform .15s; }
.cx-mx-btn:hover { transform: translateY(-2px); }
.cx-mx-btn.is-gold { background: var(--cx-mx-gold); color: var(--cx-mx-red); }
.cx-mx-btn.is-ghost { border-color: rgba(255,255,255,.6); color: #fff; }
.cx-mx-trust { display: flex; flex-wrap: wrap; gap: .6rem 1.5rem; justify-content: center; font-size: .92rem; color: #fff; font-weight: 600; }
.cx-mx-trust i { color: var(--cx-mx-gold); margin-right: .25rem; }
.cx-mx-visual { position: relative; max-width: 460px; margin: 0 auto; }
.cx-mx-sheet { position: relative; background: var(--cx-mx-paper); color: var(--cx-mx-ink); border-radius: 16px; padding: 1.1rem 1.2rem; transform: rotate(-2.5deg); box-shadow: 0 30px 60px rgba(0,0,0,.35); }
.cx-mx-sheet-head { display: flex; justify-content: space-between; gap: .5rem; margin-bottom: .6rem; font-size: .85rem; font-weight: 700; color: var(--cx-mx-red-2); }
.cx-mx-time { font-variant-numeric: tabular-nums; }
.cx-mx-mark { position: absolute; left: -12px; top: -20px; transform: rotate(-12deg); font-weight: 800; font-size: 1.4rem; color: var(--cx-mx-red-2);
    /* ขอบขาวตามรูปตัวอักษร (เจ้าของขอ) — ตัดกับพื้นแดง เหมือนครูให้คะแนนด้วยปากกาแดง */
    text-shadow: 2px 0 #fff, -2px 0 #fff, 0 2px #fff, 0 -2px #fff, 2px 2px #fff, -2px -2px #fff, 2px -2px #fff, -2px 2px #fff,
        3px 0 #fff, -3px 0 #fff, 0 3px #fff, 0 -3px #fff, 0 4px 10px rgba(0,0,0,.3); }
.cx-mx-omr { display: grid; grid-template-columns: repeat(3, 1fr); gap: .25rem .8rem; font-size: .72rem; }
.cx-mx-omr div { display: flex; align-items: center; gap: .18rem; }
.cx-mx-omr em { font-style: normal; width: 1.3rem; text-align: right; color: #6b7280; margin-right: .1rem; }
.cx-mx-omr i { font-style: normal; width: 1rem; height: 1rem; border: 1.3px solid #8a94a6; border-radius: 50%; display: inline-grid; place-items: center; font-size: .55rem; color: #8a94a6; }
.cx-mx-omr i.is-on { background: var(--cx-mx-ink); border-color: var(--cx-mx-ink); color: var(--cx-mx-ink); }
@media (max-width: 767.98px) {
    .cx-mx-visual { max-width: 330px; margin-bottom: 1.5rem; }
    .cx-mx-omr { grid-template-columns: repeat(2, 1fr); }
    .cx-mx-omr div:nth-child(n+15) { display: none; }
}
.cx-mx-rank { position: absolute; right: -6px; bottom: -28px; background: #fff; color: var(--cx-mx-ink); border-radius: 14px; padding: .75rem 1rem; transform: rotate(3deg); box-shadow: 0 18px 40px rgba(0,0,0,.3); min-width: 180px; }
.cx-mx-rank b { display: block; font-size: 1.9rem; line-height: 1.1; color: var(--cx-mx-red-2); }
.cx-mx-rank small { color: #6b7280; font-size: .78rem; }
@media (max-width: 767.98px) {
    .cx-mx-slide { padding: 3rem 0 4rem; }
    .cx-slider-btn.is-play { display: none; } /* มือถือไม่เลื่อนเอง — ไม่ต้องมีปุ่มหยุด */
}

/* admin/site_settings.php — รูป QR สำรองปัจจุบัน */
.cx-qr-preview { display: block; max-width: 220px; margin-bottom: .5rem; padding: 8px; border: 1px solid var(--cx-border); border-radius: 12px; background: var(--cx-surface); }

/* admin/admins.php — ทีมแอดมิน (สิทธิ์แยกหมวด · config/admin_perms.php) */
.cx-perm-chip { display: inline-flex; align-items: center; gap: .25rem; margin: .1rem .2rem .1rem 0; padding: .1rem .5rem; border-radius: 6px; font-size: .75rem; font-weight: 600; background: var(--cx-primary-50); color: var(--cx-navy); }
.cx-perm-chip.is-super { background: var(--cx-warning-50); color: var(--cx-warning); }
.cx-perm-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.cx-perm-box { display: flex; gap: .6rem; align-items: flex-start; padding: .65rem .8rem; border: 1.5px solid var(--cx-border); border-radius: 12px; cursor: pointer; }
.cx-perm-box:has(input:checked), .cx-perm-box.is-on { border-color: var(--cx-primary); background: var(--cx-primary-50); }
.cx-perm-box input { margin-top: .3rem; }
.cx-perm-box b { display: block; font-size: .95rem; }
.cx-perm-box small { color: var(--cx-muted); font-size: .8rem; }
@media (max-width: 575.98px) { .cx-perm-grid { grid-template-columns: 1fr; } }
