/* ibrandingdigital — สไตล์กลาง
   🎨 สีแบรนด์ยังไม่เคาะ ทุกสีอยู่ในตัวแปรข้างล่างนี้ เปลี่ยนที่เดียวเปลี่ยนทั้งเว็บ */
:root {
  --bg: #f3f6fc;             /* ขาวอมฟ้าอ่อนมาก ไม่ใช่เทา */
  --card: #ffffff;
  --ink: #0b1b3d;            /* น้ำเงินเข้มเกือบดำ ใช้แทนสีดำทั้งเว็บ */
  --ink-2: #3b4c73;
  --muted: #6a7b9c;
  --line: #dfe7f5;           /* เส้นขอบอมฟ้า ไม่ใช่เทากลางๆ */
  --brand: #10307a;          /* น้ำเงินเข้ม — ปุ่มหลัก */
  --brand-hi: #164099;       /* น้ำเงินเข้มตอนชี้ */
  --accent: #1d5fe0;         /* น้ำเงินสด — ไฮไลต์บทที่กำลังเรียน */
  --accent-soft: #eaf1ff;
  --danger: #b42318;
  --ok: #067647;
  --r: 12px;
  --r-lg: 16px;
  /* เงาย้อมน้ำเงิน ทำให้ทั้งเว็บดูเป็นชุดเดียวกัน ไม่ใช่เงาเทาสำเร็จรูป */
  --shadow: 0 1px 2px rgba(11, 27, 61, .05), 0 10px 30px rgba(16, 48, 122, .09);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'IBM Plex Sans Thai', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 16.5px;
  font-weight: 400;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  /* กันคำไทยแตกกลางคำบนมือถือ */
  word-break: keep-all;
  overflow-wrap: break-word;
}

h1, h2, h3 { line-height: 1.35; margin: 0; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 26px; }
h2 { font-size: 19px; }
p { margin: 0; }
a { color: inherit; }

.wrap { max-width: 1120px; margin: 0 auto; padding: 0 18px; }
.stack { display: flex; flex-direction: column; }
.stack-8 { gap: 8px; } .stack-12 { gap: 12px; } .stack-16 { gap: 16px; }
.stack-24 { gap: 24px; } .stack-32 { gap: 32px; }
.row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.grow { flex: 1; }
.muted { color: var(--muted); font-size: 14.5px; }
.small { font-size: 14px; }
.hidden { display: none !important; }
.center { text-align: center; }

/* ───── หัวเว็บ ───── */
.topbar {
  background: rgba(255, 255, 255, .88);
  backdrop-filter: saturate(150%) blur(10px);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 40;
}
.topbar .wrap { display: flex; align-items: center; gap: 14px; height: 62px; }
.brand {
  font-weight: 600; font-size: 17px; letter-spacing: -.01em; color: var(--ink);
  text-decoration: none; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 9px;
}

/* เครื่องหมายแบรนด์ชั่วคราว — วาดเอง ไม่ใช่ภาพ AI
   ได้โลโก้จริงจากเจ้าของเมื่อไหร่ เปลี่ยนแค่ตรงนี้ที่เดียว */
.mark {
  flex: none; width: 30px; height: 30px; border-radius: 9px;
  background: var(--brand); color: #fff;
  display: grid; place-items: center;
  font-size: 14px; font-weight: 600; letter-spacing: -.02em;
  box-shadow: 0 2px 8px rgba(16, 48, 122, .28);
}
.mark.lg { width: 46px; height: 46px; border-radius: 13px; font-size: 19px; }
.topnav { margin-inline-start: auto; display: flex; align-items: center; gap: 6px; }
.topnav a, .topnav button {
  font: inherit; font-size: 14.5px; color: var(--ink-2);
  background: none; border: 0; border-radius: 9px;
  padding: 8px 11px; text-decoration: none; cursor: pointer;
  white-space: nowrap;   /* กันคำไทยสั้นๆ แตกกลางคำ เช่น "บทเรียน" -> "บท/เรียน" */
}
.topnav a:hover, .topnav button:hover { background: var(--accent-soft); color: var(--brand); }

/* ───── การ์ด / ปุ่ม / ฟอร์ม ───── */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 22px;
}
.btn {
  font: inherit; font-size: 16px; font-weight: 500;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 50px; padding: 12px 20px;
  border: 1px solid var(--brand); border-radius: var(--r);
  background: var(--brand); color: #fff; cursor: pointer;
  text-decoration: none;
  box-shadow: 0 1px 2px rgba(11, 27, 61, .18);
  transition: background .15s, box-shadow .15s, transform .1s;
}
.btn:hover { background: var(--brand-hi); box-shadow: 0 4px 14px rgba(16, 48, 122, .26); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .4; cursor: not-allowed; box-shadow: none; }
.btn.block { width: 100%; }
.btn.ghost {
  background: #fff; color: var(--brand); border-color: var(--line); box-shadow: none;
}
.btn.ghost:hover { background: var(--accent-soft); border-color: #c7d8f7; box-shadow: none; }
.btn.danger { background: #fff; color: var(--danger); border-color: #f3c9c5; box-shadow: none; }
.btn.danger:hover { background: #fdf3f2; border-color: #e9b3ae; }
.btn.sm { min-height: 40px; padding: 8px 14px; font-size: 14.5px; border-radius: 10px; }

label { font-size: 14.5px; font-weight: 500; color: var(--ink-2); display: block; margin-bottom: 6px; }
input, select, textarea {
  font: inherit; font-size: 16.5px; width: 100%;
  padding: 12px 14px; min-height: 50px;
  color: var(--ink); background: #fff;
  border: 1px solid var(--line); border-radius: var(--r);
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(29, 95, 224, .15);
}
textarea { min-height: 80px; resize: vertical; }

.note {
  border-radius: var(--r); padding: 12px 14px; font-size: 15px;
  border: 1px solid var(--line); background: #f7faff;
}
.note.err { border-color: #f3c9c5; background: #fdf3f2; color: var(--danger); }
.note.ok  { border-color: #c3e6d3; background: #f0faf4; color: var(--ok); }

.pill {
  display: inline-block; font-size: 13px; font-weight: 500; white-space: nowrap;
  padding: 3px 9px; border-radius: 999px;
  border: 1px solid #cfdff9; background: var(--accent-soft); color: var(--brand);
}
.pill.on  { color: var(--ok); border-color: #c3e6d3; background: #f0faf4; }
.pill.off { color: var(--danger); border-color: #f3c9c5; background: #fdf3f2; }

/* ───── หน้าเข้าสู่ระบบ ───── */
.login-wrap {
  min-height: 100dvh; display: flex; align-items: center; justify-content: center;
  padding: 24px 18px; position: relative; overflow: hidden;
}
/* แถบน้ำเงินทึบด้านบน — ให้หน้าล็อกอินมีน้ำหนัก ไม่ลอยกลางจอเปล่าๆ */
.login-wrap::before {
  content: ''; position: absolute; inset: 0 0 auto; height: 42vh; min-height: 230px;
  background: var(--brand); z-index: 0;
}
.login-card {
  width: 100%; max-width: 424px; position: relative; z-index: 1;
  box-shadow: 0 2px 6px rgba(11, 27, 61, .10), 0 24px 60px rgba(6, 20, 52, .28);
  border-color: transparent;
}
.login-top { display: flex; align-items: center; gap: 12px; }

/* ───── หน้าต้อนรับ ───── */
.hero {
  background: var(--brand); color: #fff; position: relative; overflow: hidden;
  padding-block: 56px 92px;
}
/* ลายเส้นบางๆ ทแยงมุม ให้พื้นน้ำเงินไม่แบนราบ */
.hero::after {
  content: ''; position: absolute; inset: 0; pointer-events: none; opacity: .09;
  background-image: repeating-linear-gradient(115deg,
    #fff 0 1px, transparent 1px 74px);
}
.hero > .wrap { position: relative; z-index: 1; }
.hero .eyebrow {
  font-size: 13.5px; letter-spacing: .16em; text-transform: uppercase;
  color: #9fc0ff; font-weight: 500;
}
.hero h1 { font-size: 38px; line-height: 1.25; margin-block: 10px 14px; }
.hero p { color: #c8d9f7; font-size: 17px; max-width: 46ch; }
.hero .btn {
  background: #fff; color: var(--brand); border-color: #fff; margin-top: 26px;
  box-shadow: 0 8px 24px rgba(4, 15, 40, .30);
}
.hero .btn:hover { background: #eef4ff; border-color: #eef4ff; }

/* การ์ดตัวเลขที่ยื่นทับขอบแถบน้ำเงิน */
.hero-cards {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px;
  margin-top: -48px; position: relative; z-index: 2;
}
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r);
  padding: 16px 18px; box-shadow: var(--shadow);
}
.stat b { display: block; font-size: 25px; line-height: 1.2; color: var(--brand); }
.stat span { font-size: 13.5px; color: var(--muted); }

/* ───── คอร์สของฉัน ───── */
.course-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.course-card {
  display: flex; flex-direction: column; text-decoration: none; color: inherit;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg);
  overflow: hidden; box-shadow: 0 1px 2px rgba(11, 27, 61, .05);
  transition: transform .16s, box-shadow .16s, border-color .16s;
}
.course-card:hover {
  transform: translateY(-3px); border-color: #c7d8f7;
  box-shadow: 0 10px 30px rgba(16, 48, 122, .14);
}
/* แถบปกวาดด้วย CSS ล้วน ไม่ต้องรอรูปจากลูกค้า */
.course-cover {
  height: 132px; position: relative; background: var(--brand); overflow: hidden;
  display: grid; place-items: center;
}
.course-cover::after {
  content: ''; position: absolute; inset: 0; opacity: .14;
  background-image: repeating-linear-gradient(115deg, #fff 0 1px, transparent 1px 54px);
}
.course-cover .mark { width: 52px; height: 52px; border-radius: 15px; font-size: 21px;
  background: rgba(255, 255, 255, .16); box-shadow: none; backdrop-filter: blur(3px); }
.course-card .body { padding: 17px 18px 19px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.course-card h2 { font-size: 18px; }
.course-card .sub { color: var(--muted); font-size: 14.5px; flex: 1; }
.course-card .meta {
  display: flex; gap: 14px; font-size: 13.5px; color: var(--ink-2);
  border-top: 1px solid var(--line); padding-top: 12px; margin-top: 4px;
}
.course-card .go { color: var(--accent); font-weight: 500; margin-inline-start: auto; }

.back {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 14.5px; color: var(--muted); text-decoration: none;
}
.back:hover { color: var(--brand); }

/* ───── หน้าเรียน ───── */
.learn-grid { display: grid; grid-template-columns: 1fr 340px; gap: 24px; align-items: start; }
.player-box {
  position: relative; background: #000;
  border-radius: var(--r-lg); overflow: hidden; aspect-ratio: 16 / 9;
}
.player-box iframe, .player-box video { width: 100%; height: 100%; border: 0; display: block; }
.player-empty {
  display: flex; align-items: center; justify-content: center; height: 100%;
  color: #9aa0aa; font-size: 15px; text-align: center; padding: 24px;
}
/* ลายน้ำอีเมลผู้เรียน — กันคนแคปจอส่งต่อ */
.watermark { position: absolute; inset: 0; pointer-events: none; z-index: 5; overflow: hidden; }
.watermark span {
  position: absolute; top: 6%; inset-inline-start: 58%;
  font-size: 12.5px; color: rgba(255, 255, 255, .40);
  letter-spacing: .02em; white-space: nowrap;
  text-shadow: 0 1px 3px rgba(0, 0, 0, .6);
  animation: wm 48s ease-in-out infinite alternate;
}
/* เดินเป็น % ของกรอบคลิป (ห้ามใช้ vw/vh — จอมือถือกรอบเตี้ย ลายน้ำจะวิ่งหลุดออกนอกกรอบแล้วหายไปเลย) */
@keyframes wm {
  0%   { top: 6%;  inset-inline-start: 58%; }
  35%  { top: 44%; inset-inline-start: 6%; }
  70%  { top: 80%; inset-inline-start: 52%; }
  100% { top: 26%; inset-inline-start: 22%; }
}

.chapter {
  border: 1px solid var(--line); border-radius: var(--r);
  background: var(--card); overflow: hidden;
  box-shadow: 0 1px 2px rgba(11, 27, 61, .04);
}
.chapter + .chapter { margin-top: 10px; }
.chapter > h3 {
  font-size: 15.5px; padding: 13px 15px; margin: 0; color: var(--brand);
  background: #f4f8ff; border-bottom: 1px solid var(--line);
}
.lesson {
  display: flex; align-items: center; gap: 11px; width: 100%;
  font: inherit; font-size: 15px; text-align: start;
  padding: 13px 15px; background: none; border: 0; border-top: 1px solid #eef3fb;
  cursor: pointer; color: var(--ink);
  position: relative; transition: background .12s;
}
.chapter .lesson:first-of-type { border-top: 0; }
.lesson:hover { background: #f7faff; }
.lesson.active { background: var(--accent-soft); color: var(--brand); font-weight: 500; }
/* ขีดน้ำเงินบางๆ ชี้บทที่กำลังดูอยู่ */
.lesson.active::before {
  content: ''; position: absolute; inset-inline-start: 0; inset-block: 0;
  width: 3px; background: var(--accent);
}
.lesson .num {
  flex: none; width: 25px; height: 25px; border-radius: 50%;
  display: grid; place-items: center; font-size: 12.5px;
  background: #eaf1ff; color: var(--ink-2);
}
.lesson.active .num { background: var(--accent); color: #fff; }
.lesson .len { margin-inline-start: auto; font-size: 13px; color: var(--muted); flex: none; }

/* ───── รายชื่อผู้เรียนหลังบ้าน (การ์ด — อ่านง่ายกว่าตารางบนมือถือ) ───── */
.user-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
.user-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r);
  padding: 15px 16px; display: flex; flex-direction: column; gap: 11px;
}
.user-card.off { background: #fbfbfc; }
.user-card .who { font-weight: 500; font-size: 16px; }
.user-card .mail { color: var(--muted); font-size: 14px; word-break: break-all; }
.user-card .facts { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13.5px; color: var(--muted); }
.user-card .acts { display: flex; flex-wrap: wrap; gap: 6px; }
.user-card .acts .btn { flex: 1 1 auto; min-width: 96px; }

.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); margin-bottom: 22px; flex-wrap: wrap; }
.tabs button {
  font: inherit; font-size: 15.5px; background: none; border: 0; cursor: pointer;
  padding: 12px 14px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs button:hover { color: var(--brand); }
.tabs button.active { color: var(--brand); border-bottom-color: var(--accent); font-weight: 500; }

dialog {
  border: 0; border-radius: var(--r-lg); padding: 0; width: min(520px, calc(100vw - 32px));
  box-shadow: var(--shadow);
}
dialog::backdrop { background: rgba(7, 22, 52, .48); backdrop-filter: blur(2px); }
dialog .card { border: 0; }

@media (max-width: 900px) {
  .learn-grid { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  body { font-size: 16px; }
  h1 { font-size: 22px; }
  .wrap { padding: 0 14px; }
  .card { padding: 18px; }

  /* มือถือ: หัวเว็บ 2 แถว — ชื่อเว็บแถวบน เมนูแถวล่าง
     (ถ้าอัดแถวเดียวที่ 390px เมนูจะเบียดจนคำไทยแตกกลางคำ) */
  .topbar .wrap {
    height: auto; flex-direction: column; align-items: stretch;
    gap: 2px; padding-block: 9px 5px;
  }
  .brand { font-size: 16px; }
  .topnav { margin-inline-start: -8px; gap: 0; }
  .topnav a, .topnav button { padding: 7px 8px; font-size: 14.5px; }

  .watermark span { font-size: 11.5px; }

  /* แถวคลิปในหลังบ้าน: ชื่อคลิปบรรทัดบน ปุ่มบรรทัดล่าง กันปุ่มล้นออกนอกจอ */
  .chapter > h3 { flex-wrap: wrap; }
  .chapter > h3 > .grow { flex: 1 1 100%; }
  .lesson.edit-row { flex-wrap: wrap; }
  .lesson.edit-row .acts { width: 100%; padding-inline-start: 36px; }
  .lesson.edit-row .acts .btn { flex: 1 1 auto; }
}
