/* ═══ Jane TOEIC LMS — design tokens จาก design_handoff_janetoeic_lms ═══ */
:root {
  --ink: #0F2A38;
  --ink-2: #134A5F;
  --teal: #128FB2;
  --teal-deep: #0F6F8C;
  --bright: #1CB5D8;
  --cyan: #4FD0EE;
  --gold: #C6982F;
  --gold-2: #E8C766;
  --cream: #FAF6EE;
  --cream-2: #FAF8F2;
  --bg: #ECEAE3;
  --mut: #6A7A82;
  --mut-2: #7C8A90;
  --mut-3: #9AA8AE;
  --ondark: #9FBCC6;
  --ondark-2: #8FABB6;
  --ondark-3: #CFE6EE;
  --ok: #1F9D57;
  --bad: #E5484D;
  --line-green: #06C755;
  --bd: rgba(15,42,56,.1);
  --serif: 'Noto Serif Thai', serif;
  --sans: 'IBM Plex Sans Thai', sans-serif;
  --mono: 'Space Grotesk', monospace;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body { font-family: var(--sans); background: var(--bg); color: var(--ink); font-size: 13.5px; line-height: 1.6; -webkit-font-smoothing: antialiased; }
img { max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font-family: var(--sans); cursor: pointer; }

/* ═══ App shell ═══ */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 256px; flex-shrink: 0; background: var(--ink); color: var(--ondark);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
  box-shadow: 2px 0 24px -14px rgba(0,0,0,.6); z-index: 30;
}
.sb-brand { display: flex; align-items: center; gap: 12px; padding: 22px 18px 18px; text-decoration: none; }
.sb-brand .sb-logo { width: 40px; height: 40px; object-fit: contain; flex-shrink: 0; }
.sb-brand b { font-family: var(--serif); font-size: 17px; color: #fff; display: block; line-height: 1.15; letter-spacing: .01em; }
.sb-brand small { font-family: var(--mono); font-size: 9px; letter-spacing: .2em; color: var(--cyan); display: block; margin-top: 2px; }
.sb-label { font-family: var(--mono); font-size: 10px; letter-spacing: .16em; color: var(--ondark-2); padding: 14px 18px 6px; }
.sb-item {
  display: flex; align-items: center; gap: 11px; padding: 11px 18px; color: #A9C2CC;
  font-size: 13px; font-weight: 500; border: none; background: none; width: 100%; text-align: left;
}
.sb-item svg { width: 17px; height: 17px; flex-shrink: 0; }
.sb-item:hover { background: rgba(255,255,255,.05); color: #fff; }
.sb-item.on { background: rgba(28,181,216,.15); box-shadow: inset 3px 0 0 var(--bright); color: #F0FAFD; }
.sb-spacer { flex: 1; }
.sb-admin-badge {
  margin: 0 14px 10px; padding: 7px 12px; border-radius: 9px; text-align: center;
  background: linear-gradient(135deg, #C6982F, #A07A1E); color: #fff; font-size: 11.5px; font-weight: 700;
}
.sb-user { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-top: 1px solid rgba(255,255,255,.08); }
.sb-user .av { width: 36px; height: 36px; border-radius: 99px; background: linear-gradient(135deg, var(--bright), var(--teal)); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; flex-shrink: 0; }
.sb-user b { color: #fff; font-size: 12.5px; display: block; line-height: 1.3; }
.sb-user small { color: var(--ondark-2); font-size: 10.5px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
/* Header — v3: พื้นสว่างโปร่งใส + blur */
.hdr {
  position: sticky; top: 0; z-index: 20;
  background: rgba(255,255,255,.82); backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(15,42,56,.1);
  display: flex; align-items: center; gap: 16px; padding: 15px 30px; color: var(--ink);
}
.hdr h1 { font-family: var(--serif); font-size: 20px; font-weight: 700; line-height: 1.15; color: var(--ink); }
.hdr .sub { color: var(--mut); font-size: 12px; margin-top: 2px; }
.hdr .grow { flex: 1; }
.hdr .search {
  display: flex; align-items: center; gap: 8px;
  background: #F4F2EC; border: 1px solid rgba(15,42,56,.12); border-radius: 10px;
  color: var(--ink); padding: 9px 13px; font: inherit; font-size: 12.5px; width: 240px; max-width: 30vw;
}
.hdr .search::placeholder { color: var(--mut-3); }
.hdr .bell {
  position: relative; width: 40px; height: 40px; flex: none; border-radius: 11px;
  background: #F4F2EC; border: 1px solid rgba(15,42,56,.12); color: #46595F;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.hdr .bell .dot { position: absolute; top: 8px; right: 9px; width: 7px; height: 7px; background: var(--bad); border: 1.5px solid #fff; border-radius: 99px; }
.hdr-mobile-brand { display: none; align-items: center; gap: 9px; flex: 1; min-width: 0; text-decoration: none; }
.hdr-mobile-brand img { width: 38px; height: 38px; object-fit: contain; }
/* wordmark เหมือน landing: Cormorant Garamond, Jane=ink / TOEIC=teal */
.hdr-mobile-brand .brand-txt { display: flex; flex-direction: column; min-width: 0; }
.hdr-mobile-brand .wordmark { font: 600 22px 'Cormorant Garamond', serif; letter-spacing: .5px; line-height: 1; }
.hdr-mobile-brand .wordmark .jane { color: var(--ink); }
.hdr-mobile-brand .wordmark .toeic { color: var(--teal); }
.hdr-mobile-brand .brand-sub { font-family: var(--mono); font-size: 7.5px; font-weight: 600; letter-spacing: .18em; color: var(--teal-deep); margin-top: 3px; }
/* Header dropdowns: ผลค้นหา + การแจ้งเตือน */
.hdr-search, .hdr-bellwrap { position: relative; }
.hdr-drop {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 60;
  width: 330px; max-width: calc(100vw - 28px); max-height: 400px; overflow-y: auto;
  background: #fff; border: 1px solid rgba(15,42,56,.12); border-radius: 14px;
  box-shadow: 0 20px 44px -18px rgba(15,42,56,.35); padding: 6px;
}
.hdr-drop .drop-head { font-size: 12px; font-weight: 700; color: var(--ink); padding: 9px 11px 7px; border-bottom: 1px solid rgba(15,42,56,.07); margin-bottom: 4px; }
.hdr-drop .drop-item {
  display: block; width: 100%; text-align: left; background: none; border: none; cursor: pointer;
  border-radius: 9px; padding: 8px 11px; font: inherit;
}
.hdr-drop .drop-item:hover { background: #F4F2EC; }
.hdr-drop .drop-item .g { display: inline-block; font-size: 9.5px; font-weight: 700; letter-spacing: .06em; color: var(--teal-deep); background: rgba(18,143,178,.09); border-radius: 6px; padding: 2px 7px; margin-bottom: 3px; }
.hdr-drop .drop-item b { display: block; font-size: 12.5px; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hdr-drop .drop-item small { display: block; font-size: 10.5px; color: var(--mut); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hdr-drop .drop-item small.ago { color: var(--mut-3); font-size: 9.5px; margin-top: 2px; }
.hdr-drop .drop-item.warn { border-left: 3px solid var(--gold, #C6982F); background: rgba(198,152,47,.06); }
.hdr-drop .drop-item.warn:hover { background: rgba(198,152,47,.12); }
.hdr-drop .drop-empty { padding: 16px 12px; font-size: 12px; color: var(--mut); text-align: center; }
/* บัญชีผู้ใช้บน header — เฉพาะมือถือ (เดสก์ท็อปใช้ user block ใน sidebar) */
.hdr-acctwrap { display: none; position: relative; }
.hdr-acct { width: 40px; height: 40px; flex: none; padding: 0; border-radius: 11px; border: 1px solid rgba(15,42,56,.12); background: #F4F2EC; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.hdr-acct .av { width: 30px; height: 30px; border-radius: 99px; background: linear-gradient(135deg, var(--bright), var(--teal)); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 12px; }
.hdr-drop .acct-card { display: flex; align-items: center; gap: 11px; padding: 11px; border-bottom: 1px solid rgba(15,42,56,.07); margin-bottom: 4px; }
.hdr-drop .acct-card .av { width: 42px; height: 42px; flex: none; border-radius: 99px; background: linear-gradient(135deg, var(--bright), var(--teal)); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 15px; }
.hdr-drop .acct-meta { min-width: 0; }
.hdr-drop .acct-meta b { display: block; font-size: 13.5px; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hdr-drop .acct-meta small { display: block; font-size: 10.5px; color: var(--mut); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hdr-drop .acct-meta .acct-email { color: var(--mut-3); }
.hdr-drop .acct-admin-badge { margin: 2px 4px 6px; padding: 8px 12px; border-radius: 9px; text-align: center; background: linear-gradient(135deg, var(--gold), #A07A1E); color: #fff; font-size: 11.5px; font-weight: 700; }
.hdr-drop .drop-item.acct-logout b { color: var(--bad); }
/* E-Book: ปุ่มสลับมุมมอง การ์ด/รายการ */
.ebook-vtoggle { display: inline-flex; border: 1px solid var(--bd); border-radius: 9px; overflow: hidden; background: #fff; }
.ebook-vbtn { background: none; border: none; cursor: pointer; font: inherit; font-size: 12px; color: var(--mut); padding: 7px 12px; }
.ebook-vbtn + .ebook-vbtn { border-left: 1px solid var(--bd); }
.ebook-vbtn.on { background: var(--teal); color: #fff; }

/* ตัวกรองคลัง E-Book ตามคอร์ส — เลื่อนแนวนอนบนจอแคบ ไม่ตัดบรรทัดจนดันรายการลงไปพ้นจอ */
.ebook-chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 3px; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.ebook-chips::-webkit-scrollbar { display: none; }
.ebook-chip { flex-shrink: 0; background: #fff; border: 1px solid var(--bd); border-radius: 99px; cursor: pointer; font: inherit; font-size: 12px; color: var(--mut); padding: 6px 13px; white-space: nowrap; transition: border-color .15s, color .15s; }
.ebook-chip:hover { border-color: var(--teal); color: var(--teal-deep); }
.ebook-chip.on { background: var(--teal); border-color: var(--teal); color: #fff; font-weight: 600; }

.content { padding: 26px 30px 60px; max-width: 1180px; width: 100%; margin: 0 auto; animation: pageIn .32s ease; }
@keyframes pageIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* Bottom nav (mobile) — แถวเดียว ป้ายบรรทัดเดียวเสมอ; เมนูยาว (แอดมิน) เลื่อนแนวนอนได้ */
.bottom-nav { display: none; position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; background: var(--ink); border-top: 1px solid rgba(255,255,255,.1); padding: 4px 2px calc(4px + env(safe-area-inset-bottom)); }
.bottom-nav button { flex: 1 1 0; min-width: 0; background: none; border: none; cursor: pointer; color: var(--ondark-2); font: inherit; font-size: 10.5px; line-height: 1.25; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 7px 2px 6px; min-height: 50px; border-radius: 12px; transition: color .15s, background .15s; }
.bottom-nav button span { display: block; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bottom-nav button svg { width: 21px; height: 21px; flex-shrink: 0; }
.bottom-nav button.on { color: var(--cyan); background: rgba(28,181,216,.14); }
.bottom-nav button:active { background: rgba(255,255,255,.08); }

/* เมนูเกิน 5 ช่อง: เลื่อนนิ้วซ้าย-ขวา (ซ่อน scrollbar, ช่องกว้างคงที่ให้เห็นว่ายังมีต่อ) */
.bottom-nav.scrollable { overflow-x: auto; overflow-y: hidden; scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch; scrollbar-width: none; scroll-padding: 0 12px; padding-left: 6px; padding-right: 6px; overscroll-behavior-x: contain; }
.bottom-nav.scrollable::-webkit-scrollbar { display: none; }
.bottom-nav.scrollable button { flex: 0 0 64px; scroll-snap-align: center; }
@media (max-width: 899px) {
  .sidebar { display: none; }
  .bottom-nav { display: flex; }
  .hdr { padding: 11px 14px; gap: 9px; }
  .hdr .hdr-title-group, .hdr .grow, .hdr .hdr-search { display: none; }
  .hdr-mobile-brand { display: flex; }
  .hdr-acctwrap { display: block; }
  .content { padding: 16px 14px 98px; }
}

/* ═══ Components ═══ */
.card { background: #fff; border: 1px solid var(--bd); border-radius: 16px; padding: 20px; box-shadow: 0 12px 30px -24px rgba(15,42,56,.6); }
.card h3 { font-family: var(--serif); font-size: 15px; font-weight: 600; margin-bottom: 12px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: 1fr 1fr; } .g3 { grid-template-columns: repeat(3,1fr); } .g4 { grid-template-columns: repeat(4,1fr); }
.gmain { grid-template-columns: 1.6fr 1fr; }
@media (max-width: 899px) { .gmain { grid-template-columns: 1fr; } }
@media (max-width: 640px) { .g2, .g3 { grid-template-columns: 1fr; } .g4 { grid-template-columns: 1fr 1fr; } }

.hero {
  border-radius: 18px; padding: 26px; color: #fff; position: relative; overflow: hidden;
  background: linear-gradient(120deg, #0F2A38, #134A5F 60%, #0F6F8C);
  box-shadow: 0 20px 44px -26px rgba(15,42,56,.7);
}
.hero .tag { font-family: var(--mono); font-size: 10.5px; letter-spacing: .14em; color: var(--cyan); }
.hero h2 { font-family: var(--serif); font-size: 24px; font-weight: 600; margin: 8px 0 2px; }
.hero .lesson { color: var(--ondark-3); font-size: 12.5px; }

.pbar { background: rgba(15,42,56,.12); border-radius: 99px; height: 8px; overflow: hidden; }
.pbar > div { height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--bright), var(--cyan)); }
.pbar.dark { background: rgba(255,255,255,.18); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: none; border-radius: 10px; font-weight: 600; font-size: 13px; padding: 11px 20px; }
.btn-bright { background: var(--bright); color: #062A35; box-shadow: 0 8px 20px -10px rgba(18,143,178,.7); }
.btn-teal { background: var(--teal); color: #fff; box-shadow: 0 8px 20px -10px rgba(18,143,178,.7); }
.btn-ghost-w { background: transparent; color: #fff; border: 1.5px solid rgba(255,255,255,.4); }
.btn-outline { background: #fff; color: var(--ink); border: 1.5px solid var(--bd); }
.btn-line { background: var(--line-green); color: #fff; }
.btn-danger { background: #fff; color: var(--bad); border: 1.5px solid rgba(229,72,77,.4); }
.btn-sm { padding: 7px 13px; font-size: 12px; border-radius: 8px; }
.btn:hover { filter: brightness(.96); }

.kpi { background: #fff; border: 1px solid var(--bd); border-radius: 16px; padding: 16px 18px; }
.kpi .lb { font-size: 11px; color: var(--mut-2); font-weight: 600; }
.kpi .v { font-family: var(--mono); font-size: 25px; font-weight: 700; line-height: 1.25; }
.kpi .d { font-size: 10.5px; font-weight: 700; }
.kpi .d.up { color: var(--ok); } .kpi .d.dn { color: var(--bad); }

.badge { display: inline-block; border-radius: 99px; font-size: 10.5px; font-weight: 700; padding: 3px 10px; }
.b-teal { background: rgba(18,143,178,.12); color: var(--teal-deep); }
.b-ok { background: rgba(31,157,87,.12); color: var(--ok); }
.b-gold { background: rgba(198,152,47,.14); color: #8A6A1C; }
.b-bad { background: rgba(229,72,77,.1); color: var(--bad); }
.b-mut { background: rgba(15,42,56,.07); color: var(--mut); }

/* course cards */
.ccard { background: #fff; border: 1px solid var(--bd); border-radius: 16px; overflow: hidden; cursor: pointer; transition: transform .18s ease, box-shadow .18s ease; }
.ccard:hover { transform: translateY(-3px); box-shadow: 0 20px 44px -26px rgba(15,42,56,.7); }
.ccard .cover { height: 92px; position: relative; display: flex; align-items: flex-end; padding: 12px 16px; }
.ccard .cover .code { font-family: var(--mono); font-weight: 700; font-size: 20px; color: rgba(255,255,255,.95); }
.ccard .cover .st { position: absolute; top: 10px; right: 10px; }
/* badge บน cover ไล่เฉดสี: พื้นโปร่งแสงแบบปกติกลืนกับพื้นหลัง — บังคับพื้นขาวทึบให้อ่านชัดทุกสถานะ */
.ccard .cover .st .badge { background: rgba(255,255,255,.94); box-shadow: 0 2px 8px rgba(15,42,56,.3); }
.ccard .cover .st .b-mut { color: var(--ink); }
.ccard .body { padding: 14px 16px 16px; }
.ccard .body b { font-family: var(--serif); font-size: 14.5px; display: block; line-height: 1.4; }
.ccard .body .tag { color: var(--mut-2); font-size: 11.5px; }
.ccard .meta { display: flex; gap: 10px; color: var(--mut-3); font-size: 10.5px; margin: 8px 0; }

/* curriculum */
.sec-title { font-family: var(--sans); font-size: 13.5px; font-weight: 700; color: var(--mut); margin: 16px 0 8px; }
.lrow { display: flex; align-items: center; gap: 12px; background: #fff; border: 1px solid var(--bd); border-radius: 12px; padding: 12px 14px; margin-top: 8px; cursor: pointer; font-size: 13px; }
.lrow:hover { background: var(--cream-2); }
.lrow .ic { width: 30px; height: 30px; border-radius: 99px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: 12px; font-weight: 700; }
.lrow .ic.done { background: rgba(31,157,87,.12); color: var(--ok); }
.lrow .ic.cur { background: rgba(28,181,216,.15); color: var(--teal); }
.lrow .ic.todo { background: rgba(15,42,56,.06); color: var(--mut-2); }
.lrow .ic.lock { background: rgba(15,42,56,.05); color: var(--mut-3); }
.lrow.lock { cursor: not-allowed; opacity: .62; }
.lrow.cur { border-color: var(--bright); box-shadow: 0 0 0 1px var(--bright); }
.lrow .t { flex: 1; min-width: 0; }
.lrow .t small { color: var(--mut-3); font-size: 10.5px; display: block; }

/* tables (admin) */
.tblw { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 12.5px; min-width: 640px; }
.tbl th { text-align: left; font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--mut-2); padding: 8px 12px; border-bottom: 1px solid var(--bd); font-family: var(--mono); }
.tbl td { padding: 11px 12px; border-bottom: 1px solid rgba(15,42,56,.05); vertical-align: middle; }
.tbl tr.click { cursor: pointer; }
.tbl tr.click:hover { background: var(--cream-2); }
/* มือถือ: แปลงตารางเป็นการ์ด label:ค่า (แต่ละแถว = 1 การ์ด) */
@media (max-width: 720px) {
  .tblw { overflow-x: visible; }
  .tbl, .tbl tbody, .tbl tr, .tbl td { display: block; width: auto; }
  .tbl { min-width: 0; }
  .tbl tr:first-child { display: none; }                 /* ซ่อนแถวหัวตาราง */
  .tbl tr { border: 1px solid var(--bd); border-radius: 12px; background: #fff; padding: 4px 2px 8px; margin-bottom: 12px; }
  .tbl tr.click:hover { background: #fff; }
  .tbl td { border: none; padding: 6px 12px; display: flex; justify-content: space-between; align-items: center; gap: 14px; text-align: right; }
  .tbl td::before { content: attr(data-label); font-family: var(--mono); font-size: 10px; letter-spacing: .05em; text-transform: uppercase; color: var(--mut-2); text-align: left; flex-shrink: 0; }
  .tbl td:first-child { display: block; text-align: left; padding: 8px 12px 10px; border-bottom: 1px solid var(--bd); margin-bottom: 3px; }
  .tbl td:first-child::before { display: none; }
  .tbl td.acts { justify-content: flex-end; }
  .tbl td.acts::before { display: none; }
  .tbl td:not(:first-child) .row { flex-wrap: wrap; justify-content: flex-end; }
  .tbl td:empty { display: none; }
  .tbl td[style*="min-width"] { min-width: 0 !important; }
}

/* ═══ Record cards (admin mobile — design_handoff_admin_mobile) ═══
   สองเรนเดอร์คู่ขนาน: .dtable = ตาราง (จอใหญ่) / .mcards = การ์ด (มือถือ+แท็บเล็ตแนวตั้ง)
   ≤640 การ์ด 1 คอลัมน์ · 641–899 การ์ด 2 คอลัมน์ · ≥900 กลับเป็นตาราง */
.mcards { display: none; }
@media (max-width: 899px) {
  .dtable { display: none !important; }
  .mcards { display: flex; flex-direction: column; gap: 12px; }
}
@media (min-width: 641px) and (max-width: 899px) {
  .mcards { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: start; }
  .mcards .mfull { grid-column: 1 / -1; }
  .content { padding: 24px 22px 106px; }
  /* iPad: ปุ่มเมนูล่างยืดถัวเต็มความกว้าง (จอมือถือใช้ก้อน 64px เลื่อนเอา) — ล้นจริงค่อย scroll */
  .bottom-nav.scrollable button { flex: 1 0 76px; }
  .bottom-nav button { font-size: 11.5px; min-height: 56px; gap: 5px; }
  .bottom-nav button svg { width: 23px; height: 23px; }
}
@media (max-width: 1180px) { .g4 { grid-template-columns: 1fr 1fr; } }

.rc { background: #fff; border: 1px solid rgba(15,42,56,.09); border-radius: 16px; overflow: hidden; box-shadow: 0 12px 26px -22px rgba(15,42,56,.7); }
.rc-head { display: flex; gap: 12px; padding: 14px 14px 13px; align-items: flex-start; }
.rc-head.click { cursor: pointer; }
.rc-head.click:active { background: var(--cream-2); }
.rc-head .rc-cover { width: 48px; height: 48px; border-radius: 12px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; color: #fff; font-family: var(--mono); font-weight: 700; font-size: 12.5px; }
.rc-head .rc-av { width: 42px; height: 42px; border-radius: 99px; flex-shrink: 0; background: linear-gradient(135deg, #1CB5D8, #0F6F8C); display: flex; align-items: center; justify-content: center; color: #fff; font-family: var(--serif); font-weight: 600; font-size: 15px; }
.rc-head .rc-tt { flex: 1; min-width: 0; }
.rc-head .rc-tt b { font-size: 14px; font-weight: 600; color: var(--ink); display: block; line-height: 1.35; text-wrap: pretty; }
.rc-head .rc-tt b.ellip, .rc-head .rc-tt .ellip { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rc-head .rc-tt small { display: block; color: var(--mut-3); font-size: 10.5px; margin-top: 2px; }
.rc-head .rc-meta { display: flex; gap: 7px; flex-wrap: wrap; align-items: center; margin-top: 6px; }
.rc-chev { width: 17px; height: 17px; stroke: #C3CCD0; stroke-width: 2; fill: none; align-self: center; flex-shrink: 0; }
.rc-strip { display: flex; border-top: 1px solid rgba(15,42,56,.07); background: var(--cream-2); }
.rc-cell { flex: 1; padding: 9px 13px 10px; min-width: 0; border-right: 1px solid rgba(15,42,56,.07); }
.rc-cell:last-child { border-right: none; }
.rc-cell .lb { font-size: 9.5px; font-weight: 500; color: #8A969C; }
.rc-cell .v { font-family: var(--mono); font-size: 15px; font-weight: 600; color: var(--ink); margin-top: 2px; }
.rc-cell .v.txt { font-family: var(--sans); font-size: 11.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rc-body { padding: 12px 14px 13px; border-top: 1px solid rgba(15,42,56,.07); }
.rc-body .rowline { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.rc-body .rowline .lb { font-size: 10.5px; color: #8A969C; }
.rc-body .rowline .v { font-family: var(--mono); font-size: 11px; font-weight: 600; color: #46595F; }
.rc-body .rowline .v.big { font-size: 14.5px; font-weight: 700; color: var(--ink); }
.rc-track { height: 6px; border-radius: 99px; background: #ECEAE3; overflow: hidden; margin: 6px 0 4px; }
.rc-track > div { height: 100%; border-radius: 99px; background: var(--teal); }
/* ปุ่มท้ายการ์ด — pill สีชัด (เดิมเป็นตัวหนังสือเปล่าดูจืด/แยกปุ่มยาก) */
.rc-foot { display: flex; gap: 8px; padding: 10px 12px 12px; border-top: 1px solid rgba(15,42,56,.07); }
.rc-foot .fdiv { display: none; } /* เส้นคั่นไม่จำเป็นแล้วเมื่อปุ่มเป็น pill */
.rc-act { flex: 1; text-align: center; padding: 11px 8px; font-size: 12px; font-weight: 700; color: #fff; background: var(--teal); border: none; border-radius: 11px; min-height: 42px; box-shadow: 0 1px 2px rgba(15,42,56,.12); }
.rc-act.sec { color: var(--teal-deep); background: rgba(18,143,178,.10); box-shadow: none; }
.rc-act.bad { color: #fff; background: var(--bad); }
.rc-act.line { color: #fff; background: var(--line-green); } /* ปุ่มเกี่ยวกับ LINE — สีเขียวธีม LINE */
.rc-act:active { filter: brightness(.92); }
span.rc-act { background: none; box-shadow: none; color: var(--mut); } /* placeholder "—" ไม่ใช่ปุ่ม */
.rc-ring { width: 46px; height: 46px; border-radius: 99px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; align-self: center; }
.rc-ring > span { width: 35px; height: 35px; border-radius: 99px; background: #fff; display: flex; align-items: center; justify-content: center; font-family: var(--mono); font-size: 10.5px; font-weight: 700; color: var(--ink); }
.rc-mini { display: flex; gap: 8px; }
.rc-mini .m { flex: 1; background: #fff; border: 1px solid rgba(15,42,56,.08); border-radius: 12px; padding: 10px 12px; }
.rc-mini .m .lb { font-size: 9.5px; font-weight: 500; color: #8A969C; }
.rc-mini .m .v { font-family: var(--mono); font-size: 17px; font-weight: 700; color: var(--ink); }
.rc-mini .m.risk { border-color: rgba(229,72,77,.22); }
.rc-mini .m.risk .lb, .rc-mini .m.risk .v { color: #C33; }
.rc-mini .m.ok .v { color: var(--ok); }
@media (max-width: 640px) { .g3 { grid-template-columns: 1fr 1fr; } }

/* bars (charts) */
.card-fill { display: flex; flex-direction: column; }
.vbar-wrap { position: relative; display: flex; align-items: flex-end; gap: 10px; height: 150px; min-height: 150px; flex: 1 1 auto; padding-top: 8px; }
/* เส้นกริดแนวนอน 4 ระดับ ให้กราฟดูเต็มพื้นที่การ์ด */
.vbar-wrap::before { content: ''; position: absolute; left: 0; right: 0; top: 8px; bottom: 20px; background-image: linear-gradient(to top, rgba(15,42,56,.09) 1px, transparent 1px); background-size: 100% 25%; background-position: 0 100%; pointer-events: none; }
.vbar { position: relative; flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.vbar > div { width: 100%; max-width: 44px; border-radius: 7px 7px 3px 3px; background: linear-gradient(180deg, var(--bright), var(--teal)); }
.vbar small { font-size: 10px; color: var(--mut-3); font-family: var(--mono); }
.hbar { margin-top: 10px; }
.hbar .lb { display: flex; justify-content: space-between; font-size: 11.5px; margin-bottom: 4px; }

/* forms */
.fld { margin-bottom: 12px; }
.fld label { display: block; font-size: 11.5px; font-weight: 600; color: var(--mut); margin-bottom: 5px; }
.fld input, .fld select, .fld textarea { width: 100%; border: 1px solid var(--bd); background: var(--cream-2); border-radius: 9px; padding: 10px 12px; font: inherit; font-size: 13px; }
.fld input:focus, .fld textarea:focus { outline: 2px solid rgba(28,181,216,.4); border-color: var(--bright); }

/* video player */
.player { background: #000; border-radius: 16px; overflow: hidden; aspect-ratio: 16/9; }
.player iframe { width: 100%; height: 100%; border: 0; display: block; }

/* misc */
.mut { color: var(--mut-2); } .mono { font-family: var(--mono); }
.row { display: flex; align-items: center; gap: 10px; }
.spread { justify-content: space-between; }
.mt1 { margin-top: 10px; } .mt2 { margin-top: 16px; } .mt3 { margin-top: 24px; }
.tip { border-left: 3px solid var(--teal); background: rgba(18,143,178,.06); border-radius: 0 10px 10px 0; padding: 12px 14px; font-size: 12.5px; }
.gold-card { background: linear-gradient(135deg, #C6982F, #A07A1E); color: #fff; border-radius: 16px; padding: 20px; }
.ink-card { background: linear-gradient(135deg, #3A4D56, #0F2A38); color: #fff; border-radius: 16px; padding: 20px; }
.ink-card h3 { color: #fff; }
.loading { text-align: center; color: var(--mut-2); padding: 48px 0; }
.avatar-lg { width: 72px; height: 72px; border-radius: 99px; background: linear-gradient(135deg, var(--bright), var(--teal)); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 26px; font-family: var(--mono); }

/* ── Mock test choices ── */
.mk-choices { display: flex; flex-direction: column; gap: 8px; }
.mk-choice { display: flex; align-items: center; gap: 11px; border: 1.5px solid var(--bd); border-radius: 11px; padding: 11px 13px; cursor: pointer; font-size: 13px; transition: .12s; }
.mk-choice:hover { border-color: var(--bright); background: var(--cream-2); }
.mk-choice.on { border-color: var(--teal); background: rgba(18,143,178,.08); box-shadow: 0 0 0 1px var(--teal); }
.mk-letter { width: 26px; height: 26px; border-radius: 99px; background: rgba(15,42,56,.06); color: var(--mut); font-family: var(--mono); font-weight: 700; font-size: 12px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.mk-choice.on .mk-letter { background: var(--teal); color: #fff; }

/* ── In-app dialogs (toast / modal / confirm / prompt) ── */
#modal-root { position: fixed; inset: 0; z-index: 200; pointer-events: none; }
.toast-wrap { position: fixed; top: 18px; right: 18px; display: flex; flex-direction: column; gap: 10px; z-index: 210; }
.toast {
  display: flex; align-items: center; gap: 10px; min-width: 220px; max-width: 380px;
  background: #fff; border: 1px solid var(--bd); border-left: 4px solid var(--ok);
  border-radius: 12px; padding: 12px 15px; font-size: 13px; color: var(--ink);
  box-shadow: 0 14px 34px -18px rgba(15,42,56,.65); pointer-events: auto;
  opacity: 0; transform: translateX(16px); transition: opacity .22s ease, transform .22s ease;
}
.toast.in { opacity: 1; transform: none; }
.toast-err { border-left-color: var(--bad); }
.toast .ti { width: 22px; height: 22px; flex-shrink: 0; border-radius: 99px; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 12px; background: rgba(31,157,87,.14); color: var(--ok); }
.toast-err .ti { background: rgba(229,72,77,.14); color: var(--bad); }

.modal-ov {
  position: fixed; inset: 0; z-index: 205; background: rgba(15,42,56,.5); backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center; padding: 20px;
  opacity: 0; transition: opacity .2s ease; pointer-events: auto;
}
.modal-ov.in { opacity: 1; }
.modal-card {
  width: 100%; max-width: 420px; background: #fff; border-radius: 16px; padding: 24px;
  box-shadow: 0 30px 70px -28px rgba(15,42,56,.7);
  transform: translateY(10px) scale(.98); transition: transform .2s ease;
}
.modal-ov.in .modal-card { transform: none; }
.modal-title { font-family: var(--serif); font-size: 17px; font-weight: 600; color: var(--ink); margin-bottom: 8px; }
.modal-body { font-size: 13.5px; color: var(--body-text); line-height: 1.6; }
.modal-body .mono { font-family: var(--mono); }
.modal-label { display: block; font-size: 12px; font-weight: 600; color: var(--mut); margin-bottom: 6px; }
.modal-body input, .modal-body textarea, .modal-body select {
  width: 100%; margin-top: 2px; border: 1px solid var(--bd); background: var(--cream-2);
  border-radius: 9px; padding: 10px 12px; font: inherit; font-size: 13.5px; color: var(--ink);
}
.modal-body input:focus, .modal-body textarea:focus, .modal-body select:focus { outline: 2px solid rgba(28,181,216,.4); border-color: var(--bright); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* ═══ Admin: ลากเรียงลำดับบทเรียน ═══ */
.les-list { min-height: 6px; }
.lrow-edit { display: flex; align-items: center; gap: 10px; border: 1px solid var(--bd); border-radius: 11px; padding: 10px 12px; margin-top: 8px; font-size: 12.5px; background: #fff; }
.lrow-edit .grip { cursor: grab; color: var(--mut-3); font-size: 15px; padding: 2px 3px; user-select: none; flex-shrink: 0; touch-action: none; }
.lrow-edit .grip:active { cursor: grabbing; }
.lrow-edit.dragging { opacity: .45; border-style: dashed; border-color: var(--teal); }
.lrow-edit .lnum { color: var(--teal-deep); }

/* ═══ Admin: passage ในชุดข้อสอบ ═══ */
.mk-psg-admin { border: 1px solid var(--bd); border-left: 3px solid var(--teal); border-radius: 11px; padding: 11px 13px; background: #fff; font-size: 12.5px; }

/* ═══ Mock exam: ห้องสอบเสมือนจริง ═══ */
.mk-part-head { font-family: var(--mono); font-size: 11.5px; font-weight: 700; letter-spacing: .1em; color: var(--teal-deep); text-transform: uppercase; margin: 22px 0 4px; padding-bottom: 5px; border-bottom: 2px solid var(--teal); }
.mk-group { border-left: 3px solid rgba(18,143,178,.3); padding-left: 12px; margin-top: 14px; }
.mk-passage { background: #fff; border: 1px solid var(--bd); border-radius: 12px; padding: 14px 16px; margin-top: 8px; }
.mk-passage .mk-psg-content { font-size: 13px; line-height: 1.75; margin-top: 8px; overflow-x: auto; }
.mk-passage .mk-psg-content table { border-collapse: collapse; }
.mk-passage .mk-psg-content td, .mk-passage .mk-psg-content th { border: 1px solid var(--bd); padding: 5px 9px; font-size: 12px; }
.mk-img-wrap { margin-top: 8px; }
.mk-img-wrap img { max-width: 100%; max-height: 340px; border-radius: 9px; border: 1px solid var(--bd); display: block; }
.mk-audio { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.mk-audio audio { height: 36px; max-width: 100%; }
.mk-media-loading { opacity: .6; }

/* palette กระโดดไปแต่ละข้อ */
.mk-palette { display: flex; gap: 5px; flex-wrap: wrap; max-height: 92px; overflow-y: auto; }
.mk-chip { width: 30px; height: 30px; border-radius: 8px; border: 1.5px solid var(--bd); background: #fff; font-family: var(--mono); font-size: 11px; font-weight: 700; color: var(--mut); cursor: pointer; flex-shrink: 0; }
.mk-chip:hover { border-color: var(--bright); }
.mk-chip.done { background: var(--teal); border-color: var(--teal); color: #fff; }
