/* =====================================================================
   Smart Robot Club — ดีไซน์ "บอร์ดโครงงาน"
   พื้นเว็บคือฟิวเจอร์บอร์ดสีน้ำเงิน เนื้อหาเป็นกระดาษพิมพ์ติดบนการ์ดสี
   สีทั้งหมดอยู่ที่ :root (โหมดสว่าง) และ [data-theme="dark"] (โหมดมืด)
   ===================================================================== */

:root {
  color-scheme: light;

  /* ฟิวเจอร์บอร์ด (พื้นหลังเว็บ) */
  --board: #2853b0;
  --board-deep: #1d4092;
  --board-wing: #2c5abd;
  --flute: rgba(255, 255, 255, .07);
  --on-board: #ffffff;
  --on-board-2: #dbe5ff;

  /* กระดาษที่ติดบนบอร์ด */
  --paper: #ffffff;
  --paper-2: #f1f4fa;
  --ink: #161d2b;
  --ink-2: #485468;
  --rule: #d3d9e4;

  /* การ์ดสีรองกระดาษ (สีจากโลโก้) */
  --mat-green: #2db673;
  --mat-yellow: #f4c400;
  --mat-red: #e8432f;
  --mat-blue: #22409a;
  --mat: var(--mat-yellow);

  --line-green: #06c755;
  --ok-bg: #e3f6ea;
  --ok-ink: #1d7a43;
  --error: #c92a1c;
  --lift: rgba(0, 0, 0, .3);

  --logo: url("images/logo.png");

  --font-display: "Mitr", "Anuphan", system-ui, sans-serif;
  --font-body: "Anuphan", system-ui, sans-serif;
  --font-hand: "Sriracha", "Anuphan", cursive;

  --line: 2px;          /* น้ำหนักเส้นเดียวทั้งเว็บ */
  --mat-w: 7px;         /* ขอบการ์ดสีรอบกระดาษ */
  --radius: 3px;
  --ease-out: cubic-bezier(.16, 1, .3, 1);
}

/* โหมดมืด: บอร์ดสีกรมท่า กระดาษสีเทาเข้ม */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --board: #14224a;
    --board-deep: #0d1836;
    --board-wing: #172852;
    --flute: rgba(255, 255, 255, .045);
    --on-board: #f1f4fb;
    --on-board-2: #b9c6e6;
    --paper: #1f2638;
    --paper-2: #283149;
    --ink: #eef1f8;
    --ink-2: #aeb8cd;
    --rule: #364058;
    --mat-green: #24955e;
    --mat-yellow: #cfa600;
    --mat-red: #c73a29;
    --mat-blue: #4766c9;
    --ok-bg: #1c3a2a;
    --ok-ink: #7ddc9f;
    --error: #ff8a7a;
    --lift: rgba(0, 0, 0, .55);
    --logo: url("images/logo-dark.png");
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --board: #14224a;
  --board-deep: #0d1836;
  --board-wing: #172852;
  --flute: rgba(255, 255, 255, .045);
  --on-board: #f1f4fb;
  --on-board-2: #b9c6e6;
  --paper: #1f2638;
  --paper-2: #283149;
  --ink: #eef1f8;
  --ink-2: #aeb8cd;
  --rule: #364058;
  --mat-green: #24955e;
  --mat-yellow: #cfa600;
  --mat-red: #c73a29;
  --mat-blue: #4766c9;
  --ok-bg: #1c3a2a;
  --ok-ink: #7ddc9f;
  --error: #ff8a7a;
  --lift: rgba(0, 0, 0, .55);
  --logo: url("images/logo-dark.png");
}

/* ---------------------------------------------------------------- base */

* { box-sizing: border-box; }

html { scrollbar-color: var(--board-deep) var(--board); }

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.65;
  color: var(--on-board);
  background-color: var(--board);
  /* ลอนฟิวเจอร์บอร์ด */
  background-image: repeating-linear-gradient(90deg, transparent 0 9px, var(--flute) 9px 10px);
  min-height: 100vh;
  display: flex; flex-direction: column;
}

/* โลโก้จาง ๆ เป็นพื้นหลังเว็บ (ปรับความจางที่ opacity: 0 = มองไม่เห็น, 1 = ชัดเต็มที่) */
body::before {
  content: "";
  position: fixed; inset: 0; z-index: -1;
  background: var(--logo) center / min(70vw, 640px) no-repeat;
  opacity: .25;
  pointer-events: none;
}

::selection { background: var(--mat-yellow); color: #161d2b; }

a { color: inherit; text-decoration: none; }
img { max-width: 100%; }

:focus-visible {
  outline: 3px solid var(--mat-yellow);
  outline-offset: 3px;
  border-radius: var(--radius);
}

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.25;
  text-wrap: balance;
}

.icon { width: 1.15em; height: 1.15em; flex: none; vertical-align: -.2em; }

main {
  flex: 1;
  width: 100%;
  max-width: 1240px;
  margin: 0 auto;
  padding: 28px 24px 64px;
}

/* --------------------------------------------- กระดาษติดบนการ์ดสี */

.sheet {
  position: relative;
  background: var(--paper);
  color: var(--ink);
  border-radius: var(--radius);
  padding: 22px 24px;
  box-shadow: 0 0 0 var(--mat-w) var(--mat);
  margin: var(--mat-w);
}
:where(a.sheet), .sheet.lifts {
  display: block;
  transition: transform .35s var(--ease-out), box-shadow .35s var(--ease-out);
}
a.sheet:hover, a.sheet:focus-visible, .sheet.lifts:hover {
  transform: translateY(-4px);
  box-shadow: 0 0 0 var(--mat-w) var(--mat), 0 18px 26px -10px var(--lift);
}

.mat-green  { --mat: var(--mat-green); }
.mat-yellow { --mat: var(--mat-yellow); }
.mat-red    { --mat: var(--mat-red); }
.mat-blue   { --mat: var(--mat-blue); }

/* แถบหัวข้อพิมพ์ติดบอร์ด: เลขหัวข้อ + ชื่อ */
.strip {
  display: inline-flex; align-items: center; gap: 12px;
  margin: 0 0 18px var(--mat-w);
  padding: 6px 18px 6px 8px;
  background: var(--paper);
  color: var(--ink);
  border-radius: var(--radius);
  font-size: 1.3rem;
  box-shadow: 0 0 0 var(--mat-w) var(--mat);
}
.strip .no {
  flex: none;
  display: grid; place-items: center;
  width: 2rem; height: 2rem;
  border-radius: 50%;
  background: var(--mat);
  color: #fff;
  font-size: 1.05rem;
  font-variant-numeric: tabular-nums;
}
.mat-yellow .no, .strip.mat-yellow .no { color: #161d2b; }

/* บรรทัดสรุปสั้น เขียนบนบอร์ด */
.quick { margin: 0 0 18px; color: var(--on-board-2); font-size: .98rem; }

/* หัวหน้าเพจ (ตัวหนังสือบนบอร์ด) */
.page-head { margin: 8px 0 30px; }
.page-head h1 { margin: 0; font-size: clamp(2rem, 4.2vw, 3.1rem); color: var(--on-board); }
.page-head p { margin: 6px 0 0; color: var(--on-board-2); max-width: 62ch; }

/* ปุ่ม */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px;
  font: 500 1rem/1.3 var(--font-display);
  color: var(--ink);
  background: var(--paper);
  border: var(--line) solid var(--ink);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background .2s, transform .2s var(--ease-out);
}
.btn:hover { background: var(--paper-2); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--ink); color: var(--paper); }
.btn.primary:hover { background: #2a3448; }
:root[data-theme="dark"] .btn.primary:hover { background: #d9deea; }
.btn.ghost-on-board { background: transparent; color: var(--on-board); border-color: var(--on-board); }
.btn.ghost-on-board:hover { background: rgba(255,255,255,.12); }

/* การ์ด LINE: ชิ้นที่สว่างที่สุดบนบอร์ด */
.line-card {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 18px;
  background: var(--line-green);
  color: #fff;
  border-radius: var(--radius);
  font-family: var(--font-display);
  transition: transform .35s var(--ease-out), box-shadow .35s var(--ease-out);
}
.line-card:hover, .line-card:focus-visible {
  transform: translateY(-3px);
  box-shadow: 0 16px 24px -12px var(--lift);
}
.line-card .icon { width: 2.2rem; height: 2.2rem; }
.line-card strong { display: block; font-size: 1.2rem; font-weight: 600; line-height: 1.2; }
.line-card small { font-family: var(--font-body); opacity: .95; }

/* ช่องที่ยังไม่มีรูป/ข้อมูลจริง: กรอบเส้นประ + โน้ตปากกาเมจิก */
.slot {
  display: grid; place-items: center; gap: 4px;
  aspect-ratio: 4 / 3;
  border: var(--line) dashed var(--rule);
  border-radius: var(--radius);
  color: var(--ink-2);
  background: var(--paper-2);
  text-align: center;
  padding: 12px;
}
.slot .icon { width: 1.8rem; height: 1.8rem; }
.marker { font-family: var(--font-hand); color: var(--mat-red); font-size: 1.05rem; line-height: 1.3; }

.muted { color: var(--ink-2); }
.nowrap { white-space: nowrap; }

/* ---------------------------------------------------------------- topbar */

.topbar {
  position: sticky; top: 0; z-index: 20;
  background-color: var(--board-deep);
  background-image: repeating-linear-gradient(90deg, transparent 0 9px, var(--flute) 9px 10px);
  border-bottom: var(--line) solid rgba(0, 0, 0, .18);
}
.topbar-in {
  max-width: 1240px; margin: 0 auto;
  display: flex; align-items: center; gap: 18px;
  padding: 10px 24px;
}
.brand { display: flex; align-items: center; gap: 10px; flex: none; color: var(--on-board); }
.brand span { font: 600 1.05rem/1.1 var(--font-display); }

/* เมนูแถวเดียว ถ้ายาวเกินจอจะเลื่อนซ้าย-ขวาได้ (ลาก, ปัดนิ้ว หรือหมุนลูกกลิ้งเมาส์) */
#nav {
  display: flex; flex-wrap: nowrap; gap: 6px; flex: 1; min-width: 0;
  overflow-x: auto; overscroll-behavior-x: contain;
  padding: 8px 4px 10px;
  scrollbar-width: thin;
  scrollbar-color: var(--mat-yellow) transparent;
}
#nav::-webkit-scrollbar { height: 6px; }
#nav::-webkit-scrollbar-track { background: transparent; }
#nav::-webkit-scrollbar-thumb { background: var(--mat-yellow); border-radius: 999px; }
#nav a {
  display: inline-flex; align-items: center; gap: 6px;
  flex: none;
  padding: 4px 10px 4px 5px;
  background: var(--paper);
  color: var(--ink);
  border-radius: var(--radius);
  font: 500 .88rem/1.2 var(--font-display);
  white-space: nowrap;
  transition: transform .25s var(--ease-out), box-shadow .25s var(--ease-out);
}
#nav a .no {
  display: grid; place-items: center;
  min-width: 1.45rem; height: 1.45rem;
  border-radius: 50%;
  background: var(--paper-2);
  color: var(--ink-2);
  font-size: .78rem;
  font-variant-numeric: tabular-nums;
}
#nav a:hover { transform: translateY(-2px); }
#nav a.active { box-shadow: 0 0 0 4px var(--mat-yellow); }
#nav a.active .no { background: var(--mat-yellow); color: #161d2b; }
#nav a .icon { width: .95em; height: .95em; color: var(--ink-2); }

.userbox { display: flex; align-items: center; gap: 8px; flex: none; font-size: .9rem; color: var(--on-board); }
.userbox:empty { display: none; }
.userbox .btn, .theme-toggle { padding: 6px 10px; font-size: .9rem; }
.theme-toggle { flex: none; }
.theme-toggle .icon { width: 1.2rem; height: 1.2rem; }

/* ---------------------------------------------------------------- Home: บอร์ดสามพับ */

.trifold {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr) minmax(0, 1fr);
  align-items: stretch;
  perspective: 1600px;
  margin-bottom: 56px;
}
.panel {
  padding: 30px 26px 34px;
  background-color: var(--board-wing);
  background-image: repeating-linear-gradient(90deg, transparent 0 9px, var(--flute) 9px 10px);
}
.panel.left  { border-right: var(--line) solid var(--board-deep); transform-origin: right center; }
.panel.right { border-left: var(--line) solid var(--board-deep); transform-origin: left center; }
.panel.center { background-color: var(--board); padding-inline: 34px; }

.trifold.unfold .panel.left  { animation: unfold-left .9s var(--ease-out) both; }
.trifold.unfold .panel.right { animation: unfold-right .9s var(--ease-out) .08s both; }
@keyframes unfold-left  { from { transform: rotateY(62deg); } to { transform: none; } }
@keyframes unfold-right { from { transform: rotateY(-62deg); } to { transform: none; } }

.title-sheet { text-align: center; padding: 30px 32px 32px; }
.title-sheet .logo { display: block; width: min(250px, 70%); margin: 0 auto 18px; }
.logo-dark { display: none !important; }
:root[data-theme="dark"] .logo-light { display: none !important; }
:root[data-theme="dark"] .logo-dark { display: block !important; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .logo-light { display: none !important; }
  :root:not([data-theme="light"]) .logo-dark { display: block !important; }
}
.title-sheet h1 { margin: 0 0 10px; font-size: clamp(1.75rem, 2.6vw, 2.45rem); }
.title-sheet .lead { margin: 0 auto 22px; color: var(--ink-2); max-width: 46ch; }
.title-sheet .hero-photo { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: var(--radius); margin: 0 0 20px; }
.title-sheet .strip { margin-left: 0; }
.start-row { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.start-row .line-card { width: 100%; justify-content: center; text-align: left; }
.text-link {
  display: inline-flex; align-items: center; gap: 6px;
  font: 500 1rem var(--font-display);
  color: var(--ink);
  text-decoration: underline; text-decoration-thickness: var(--line); text-underline-offset: 5px;
  text-decoration-color: var(--mat-yellow);
}
.text-link:hover { text-decoration-color: currentColor; }
.on-board .text-link, .text-link.on-board { color: var(--on-board); }

/* บันไดหลักสูตร (เรียงตามอายุ) */
.ladder { list-style: none; margin: 0; padding: 0; display: grid; gap: calc(var(--mat-w) * 2 + 4px); }
.ladder .sheet {
  display: grid; grid-template-columns: auto auto 1fr; align-items: center; gap: 12px;
  padding: 10px 14px;
}
.ladder .step {
  font: 600 1.35rem/1 var(--font-display);
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
  width: 1.4rem; text-align: center;
}
.ladder img { width: 40px; height: 40px; border-radius: var(--radius); display: block; }
.ladder strong { display: block; font: 500 1.02rem/1.25 var(--font-display); }
.ladder small { color: var(--ink-2); font-size: .85rem; }

/* เหตุผล 4 ข้อ */
.reasons { list-style: none; margin: 0; padding: 0; display: grid; gap: calc(var(--mat-w) * 2 + 4px); }
.reasons .sheet { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; padding: 14px 16px; }
.reasons .icon { grid-row: span 2; width: 1.9rem; height: 1.9rem; color: var(--mat-blue); margin-top: 2px; }
:root[data-theme="dark"] .reasons .icon { color: var(--on-board-2); }
.reasons strong { font: 500 1.05rem/1.3 var(--font-display); }
.reasons span { color: var(--ink-2); font-size: .92rem; line-height: 1.5; }

/* ส่วนใต้บอร์ดหน้า Home */
.board-section { margin-top: 52px; }
.two-col { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 40px; align-items: start; }
.prose p { margin: 0 0 12px; max-width: 68ch; }
.prose p:last-child { margin-bottom: 0; }

.results { width: 100%; border-collapse: collapse; }
.results td { padding: 12px 4px; border-bottom: var(--line) solid var(--rule); vertical-align: baseline; }
.results tr:last-child td { border-bottom: 0; }
.results td:first-child {
  font: 600 1.2rem/1.2 var(--font-display);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  padding-right: 18px;
  width: 1%;
}

/* รูปติดหมุด */
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 30px; }
.photo { margin: var(--mat-w); padding: 10px 10px 12px; }
.photo img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 2px; }
.photo figcaption { margin-top: 8px; font-size: .92rem; color: var(--ink-2); }
.photo h3 { margin: 10px 0 0; font-size: 1.05rem; }
.photo p { margin: 4px 0 0; font-size: .92rem; color: var(--ink-2); }
.photos > :nth-child(3n+1) { --mat: var(--mat-green); }
.photos > :nth-child(3n+2) { --mat: var(--mat-yellow); }
.photos > :nth-child(3n)   { --mat: var(--mat-red); }

/* ---------------------------------------------------------------- Shop / Franchise */

.product .price { margin-top: 8px; font: 600 1.15rem var(--font-display); color: var(--ink); font-variant-numeric: tabular-nums; }
.checklist, .steps { list-style: none; margin: var(--mat-w); padding: 18px 24px; }
.checklist li, .steps li { display: grid; grid-template-columns: auto 1fr; gap: 12px; align-items: start; padding: 10px 0; border-bottom: var(--line) solid var(--rule); }
.checklist li:last-child, .steps li:last-child { border-bottom: 0; }
.checklist .icon { color: var(--mat-green); margin-top: 3px; }
.steps .no {
  display: grid; place-items: center; width: 1.8rem; height: 1.8rem; border-radius: 50%;
  background: var(--mat-yellow); color: #161d2b; font: 600 .95rem var(--font-display);
}

/* ---------------------------------------------------------------- Courses */

.program-list { list-style: none; margin: 0; padding: 0; display: grid; gap: calc(var(--mat-w) * 2 + 10px); }
.program {
  display: grid;
  grid-template-columns: 3rem 72px minmax(0, 1fr) auto;
  align-items: center; gap: 22px;
  padding: 20px 26px;
}
.program .step { font: 600 2.2rem/1 var(--font-display); color: var(--ink-2); font-variant-numeric: tabular-nums; text-align: center; }
.program img { width: 72px; height: 72px; border-radius: 6px; display: block; }
.program h2 { margin: 0; font-size: 1.4rem; }
.program p { margin: 2px 0 0; color: var(--ink-2); max-width: 60ch; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 4px 12px;
  border: var(--line) solid var(--rule);
  border-radius: 999px;
  font-size: .85rem; white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.chip i { width: .6rem; height: .6rem; border-radius: 50%; background: var(--dot); }
.cta-row { display: flex; flex-wrap: wrap; align-items: center; gap: 16px 24px; margin-top: 40px; }

/* ---------------------------------------------------------------- Schedule */

.table-sheet { padding: 6px 0; overflow-x: auto; }
.table-sheet table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.table-sheet th, .table-sheet td { padding: 14px 24px; text-align: left; white-space: nowrap; }
.table-sheet th { font: 500 .9rem var(--font-display); color: var(--ink-2); border-bottom: var(--line) solid var(--ink); }
.table-sheet td { border-bottom: var(--line) solid var(--rule); }
.table-sheet tr:last-child td { border-bottom: 0; }
.table-sheet td:first-child { font-family: var(--font-display); font-weight: 500; }
.note-on-board { margin-top: 26px; color: var(--on-board-2); }

/* ---------------------------------------------------------------- Contact */

.contact-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 40px; align-items: start; }
.contact-grid .line-card { padding: 22px 24px; }
.contact-list { list-style: none; margin: 0; padding: 0; }
.contact-list li { display: grid; grid-template-columns: auto 1fr; gap: 2px 14px; padding: 14px 0; border-bottom: var(--line) solid var(--rule); }
.contact-list li:last-child { border-bottom: 0; }
.contact-list .icon { grid-row: span 2; width: 1.4rem; height: 1.4rem; color: var(--ink-2); margin-top: 3px; }
.contact-list small { color: var(--ink-2); font-size: .85rem; }
.contact-list a { text-decoration: underline; text-decoration-color: var(--mat-yellow); text-underline-offset: 4px; text-decoration-thickness: var(--line); overflow-wrap: anywhere; }

/* ---------------------------------------------------------------- Education */

.crumbs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; color: var(--on-board-2); font-size: .92rem; }
.crumbs a { color: var(--on-board); text-decoration: underline; text-underline-offset: 4px; text-decoration-color: rgba(255,255,255,.4); }
.crumbs a:hover { text-decoration-color: currentColor; }

.cat-title { display: flex; align-items: center; gap: 18px; margin: 4px 0 28px; }
.cat-title img { width: 64px; height: 64px; border-radius: 6px; background: #fff; }
.cat-title h1 { margin: 0; font-size: clamp(1.8rem, 3.6vw, 2.6rem); color: var(--on-board); }
.cat-title p { margin: 2px 0 0; color: var(--on-board-2); }

.levels { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 30px; }
.level { display: flex; flex-direction: column; gap: 10px; padding: 22px 24px; }
.level h2 { margin: 0; font-size: 1.5rem; }
.level p { margin: 0; color: var(--ink-2); flex: 1; }
.level .count { font-size: .9rem; color: var(--ink-2); font-variant-numeric: tabular-nums; }

.index-sheet { padding: 8px 0; }
.index-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 24px 14px; border-bottom: var(--line) solid var(--ink); }
.index-head h2 { margin: 0; font-size: 1.25rem; }
.lesson-list { list-style: none; margin: 0; padding: 0; }
.lesson-list a {
  display: grid; grid-template-columns: 2.4rem minmax(0, 1fr) auto; align-items: center; gap: 14px;
  padding: 12px 24px;
  border-bottom: var(--line) solid var(--rule);
  transition: background .2s;
}
.lesson-list li:last-child a { border-bottom: 0; }
.lesson-list a:hover { background: var(--paper-2); }
.lesson-list .num { font: 600 1.1rem var(--font-display); color: var(--ink-2); font-variant-numeric: tabular-nums; text-align: right; }
.lesson-list strong { font-weight: 500; }
.lesson-list small { display: block; color: var(--ink-2); }
.badge { font-size: .8rem; padding: 2px 10px; border-radius: 999px; border: var(--line) solid var(--rule); color: var(--ink-2); white-space: nowrap; }
.badge.ok { background: var(--ok-bg); border-color: transparent; color: var(--ok-ink); }

.empty { padding: 48px 20px; text-align: center; color: var(--ink-2); }
.empty .icon { width: 2rem; height: 2rem; display: block; margin: 0 auto 10px; }

.lesson h1 { margin: 0 0 4px; font-size: clamp(1.5rem, 3vw, 2.1rem); }
.lesson .lead { margin: 0 0 18px; color: var(--ink-2); }
.frame { width: 100%; height: 75vh; border: var(--line) solid var(--rule); border-radius: var(--radius); overflow: hidden; }
.frame.video { height: auto; aspect-ratio: 16 / 9; }
.frame iframe { width: 100%; height: 100%; border: 0; }
.media { display: block; max-width: 100%; border-radius: var(--radius); margin: 0 auto; }
.lesson .slot { aspect-ratio: auto; padding: 48px 16px; }
/* สไลด์บทเรียน (รูปจาก PDF ทีละหน้า) */
.slides { outline: none; }
.slide-stage {
  position: relative;
  background: var(--paper-2);
  border: var(--line) solid var(--rule);
  border-radius: var(--radius);
  overflow: hidden;
  aspect-ratio: 16 / 9;
  max-height: 82vh;
  margin: 0 auto;
  display: grid; place-items: center;
}
.slide-img { display: block; width: 100%; height: 100%; object-fit: contain; user-select: none; -webkit-user-drag: none; }
.slide-hit { position: absolute; top: 0; bottom: 0; width: 30%; border: 0; background: transparent; cursor: pointer; }
.slide-hit.prev { left: 0; cursor: w-resize; }
.slide-hit.next { right: 0; cursor: e-resize; }
/* สไลด์คลิกทีละขั้น: แตะตรงไหนก็ไปขั้นถัดไป ยกเว้นขอบซ้าย */
.slide-stage.stepped .slide-hit.next { width: 70%; cursor: pointer; }
.step-layer { position: absolute; pointer-events: none; }
.step-layer img { position: absolute; display: block; max-width: none; }
.step-old { position: absolute; inset: 0; display: grid; place-items: center; background: var(--paper-2); pointer-events: none; }
.slide-bar { display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.slide-count { min-width: 8.5rem; text-align: center; font: 500 1rem var(--font-display); font-variant-numeric: tabular-nums; color: var(--ink-2); }
.slide-full { padding-inline: 10px; }
.btn:disabled { opacity: .4; cursor: default; }
.slides:fullscreen { background: #000; display: flex; flex-direction: column; justify-content: center; padding: 12px; }
.slides:fullscreen .slide-stage { flex: 1; aspect-ratio: auto; background: #000; border: 0; }
.slides:fullscreen .slide-count { color: #fff; }

/* รูปตัวอย่างคู่มือ (ลอยตามเมาส์) */
.peek {
  position: fixed; left: 0; top: 0; z-index: 50;
  width: 320px;
  padding: 8px;
  background: var(--paper);
  border-radius: var(--radius);
  box-shadow: 0 0 0 var(--mat-w) var(--mat-yellow), 0 18px 30px -10px var(--lift);
  pointer-events: none;
  opacity: 0; visibility: hidden;
  transition: opacity .15s;
}
.peek.show { opacity: 1; visibility: visible; }
.peek img { display: block; width: 100%; max-height: 360px; object-fit: contain; border-radius: 2px; }

.pager { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-top: 26px; padding-top: 20px; border-top: var(--line) solid var(--rule); }

/* ล็อกอิน */
.login { max-width: 400px; margin: 40px auto; display: flex; flex-direction: column; gap: 14px; padding: 30px; }
.login .lock { width: 2.4rem; height: 2.4rem; color: var(--ink-2); }
.login h1 { margin: 0; font-size: 1.8rem; }
.login p { margin: 0; color: var(--ink-2); }
.login label { display: flex; flex-direction: column; gap: 6px; font: 500 .95rem var(--font-display); }
.login input {
  font: inherit; font-family: var(--font-body); font-weight: 400;
  padding: 10px 12px;
  color: var(--ink); background: var(--paper);
  border: var(--line) solid var(--rule); border-radius: var(--radius);
  caret-color: var(--mat-red);
}
.login input:focus { outline: none; border-color: var(--ink); }
.login .error { color: var(--error); font-weight: 500; }
.login .btn { margin-top: 6px; padding: 12px; }

/* ---------------------------------------------------------------- footer */

.foot {
  padding: 26px 24px 34px;
  text-align: center;
  color: var(--on-board-2);
  font-size: .9rem;
  border-top: var(--line) solid var(--board-deep);
}

/* ---------------------------------------------------------------- จอเล็ก */

@media (max-width: 980px) {
  .trifold { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .panel.center { grid-column: 1 / -1; order: -1; }
  .panel.left { border-right: var(--line) solid var(--board-deep); }
  .panel.right { border-left: 0; }
  .panel.center { border-bottom: var(--line) solid var(--board-deep); }
  .trifold.unfold .panel.left, .trifold.unfold .panel.right { animation: none; }
  .program { grid-template-columns: 2.2rem 56px minmax(0, 1fr); }
  .program img { width: 56px; height: 56px; }
  .program .chips { grid-column: 3; justify-content: flex-start; }
}

@media (max-width: 720px) {
  body { font-size: 1rem; }
  main { padding: 20px 16px 48px; }
  .topbar-in { flex-wrap: wrap; gap: 6px 10px; padding: 8px 16px; }
  #nav { order: 3; flex-basis: 100%; padding: 6px 2px 8px; }
  .userbox { margin-left: auto; }
  .theme-toggle { margin-left: auto; }
  .userbox:not(:empty) + .theme-toggle { margin-left: 0; }

  .trifold { grid-template-columns: minmax(0, 1fr); margin-inline: -16px; }
  .panel { padding: 24px 16px 28px; }
  .panel.center { padding-inline: 16px; }
  .panel.left { border-right: 0; border-bottom: var(--line) solid var(--board-deep); }
  .title-sheet { padding: 22px 20px 24px; }

  .two-col, .contact-grid { grid-template-columns: minmax(0, 1fr); gap: 34px; }
  .program { grid-template-columns: 44px minmax(0, 1fr); gap: 6px 14px; padding: 16px; }
  .program .step { display: none; }
  .program img { width: 44px; height: 44px; }
  .program .chips { grid-column: 1 / -1; }
  .lesson-list a { padding: 12px 16px; gap: 10px; grid-template-columns: 2rem minmax(0, 1fr); }
  .lesson-list .badge { grid-column: 2; justify-self: start; }
  .index-head { padding: 12px 16px; }
  .table-sheet th, .table-sheet td { padding: 12px 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
.sprite-stage { position: absolute; left: 0; top: 0; width: 1600px; height: 900px; transform-origin: 0 0; }
.sprite { position: absolute; }
.sprite img { display: block; width: 100%; height: 100%; }
