/* =========================================================
   31909-1002 เทคโนโลยี IoT — สไตล์กลางของทั้งเว็บ
   ธีม: DaisyUI "nord" + override สี (teal / copper / amber)
   Signature: หัวข้อแบบ "ลายทองแดงบน PCB" มีพัลส์สัญญาณวิ่ง
   ========================================================= */

html[data-theme="nord"] {
  --p: 57% 0.1 184;   --pc: 99% 0 0;
  --s: 65% 0.155 50;  --sc: 99% 0 0;
  --a: 80% 0.145 78;  --ac: 25% 0.02 240;
  --n: 25% 0.02 240;  --nc: 97% 0.005 95;
  --b1: 100% 0 0;     --b2: 96.5% 0.006 95;  --b3: 92% 0.01 95;  --bc: 25% 0.02 240;
  --in: 62% 0.12 230; --su: 62% 0.15 150; --wa: 78% 0.15 75; --er: 60% 0.19 25;
  --rounded-box: 0.875rem; --rounded-btn: 0.625rem; --rounded-badge: 9999px;
}

:root {
  --ink: #18232c;
  --ink-2: #4a5763;
  --ink-3: #7c8792;
  --paper: #f5f4ef;
  --card: #ffffff;
  --line: #e3e0d6;
  --teal: #0e8f86;
  --teal-soft: rgba(14, 143, 134, 0.08);
  --copper: #d9732b;
  --copper-soft: rgba(217, 115, 43, 0.09);
  --amber: #f2b33d;
  --ok: #1f9d55;
  --danger: #d64545;
  --warn: #e0a019;
  --scope: #0f1f1e;
  --phosphor: #43e0b8;

  --f-display: 'Space Grotesk', 'Prompt', sans-serif;
  --f-thai-head: 'Prompt', 'Space Grotesk', sans-serif;
  --f-body: 'Noto Sans Thai', 'Prompt', sans-serif;
  --f-mono: 'JetBrains Mono', ui-monospace, monospace;

  --sh-1: 0 4px 16px -4px rgba(24, 35, 44, 0.15);
  --sh-2: 0 14px 32px -12px rgba(24, 35, 44, 0.28);
  --r: 0.875rem;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

/* ---------- พื้นฐาน (scope ด้วย .course เพื่อชนะ preflight ของ Tailwind CDN) ---------- */
body.course {
  font-family: var(--f-body);
  background-color: var(--paper);
  background-image: radial-gradient(rgba(24, 35, 44, 0.055) 1px, transparent 1px);
  background-size: 22px 22px;
  color: var(--ink);
  font-size: 1.0625rem;
  -webkit-font-smoothing: antialiased;
}
.course h1, .course h2, .course h3, .course h4 {
  font-family: var(--f-thai-head);
  color: var(--ink);
  font-weight: 600;
}
.course h1 { line-height: 1.1; letter-spacing: -0.03em; font-size: clamp(2rem, 4.4vw, 3.1rem); }
.course h2 { line-height: 1.2; letter-spacing: -0.02em; font-size: clamp(1.45rem, 2.6vw, 1.9rem); }
.course h3 { line-height: 1.3; font-size: 1.25rem; letter-spacing: -0.01em; }
.course h4 { font-size: 1.05rem; }
.course p { line-height: 1.7; letter-spacing: 0.005em; }
.course .en { font-family: var(--f-display); }
.course strong { font-weight: 600; color: var(--ink); }
.course a.link-inline { color: var(--teal); text-decoration: underline; text-underline-offset: 3px; }
.course ::selection { background: rgba(242, 179, 61, 0.45); }
.material-symbols-outlined { font-size: 1.25em; line-height: 1; vertical-align: -0.2em; user-select: none; }

/* ---------- Top bar + แถบอ่าน ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 0.75rem;
  height: 3.5rem; padding: 0 1rem;
  background: rgba(245, 244, 239, 0.86);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar .crumb { display: flex; align-items: center; gap: 0.5rem; min-width: 0; font-size: 0.92rem; color: var(--ink-2); }
.topbar .crumb b { font-family: var(--f-display); color: var(--ink); font-weight: 700; letter-spacing: -0.01em; }
.topbar .crumb .sep { color: var(--ink-3); }
.topbar .crumb b { flex: none; }
#acct-slot, #acct-slot .btn { white-space: nowrap; flex: none; }
.topbar .crumb .cur { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.read-progress {
  position: absolute; left: 0; bottom: -1px; height: 2px; width: 100%;
  transform-origin: 0 50%; transform: scaleX(0);
  background: linear-gradient(90deg, var(--teal), var(--copper));
}

/* ---------- Sidebar ---------- */
.side {
  width: 18.5rem; min-height: 100%;
  background: var(--card);
  border-right: 1px solid var(--line);
  padding: 1.25rem 0.9rem 2rem;
  display: flex; flex-direction: column; gap: 1.25rem;
}
.side-brand { display: flex; gap: 0.75rem; align-items: center; padding: 0 0.4rem; text-decoration: none; }
.side-brand .chip {
  width: 2.6rem; height: 2.6rem; border-radius: 0.7rem;
  display: grid; place-items: center; color: #fff;
  background: var(--ink);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.08), var(--sh-1);
  position: relative;
}
.side-brand .chip::after { /* ขาไอซีเล็ก ๆ */
  content: ''; position: absolute; inset: -4px 6px;
  border-top: 2px dotted var(--copper); border-bottom: 2px dotted var(--copper);
}
.side-brand .t1 { font-family: var(--f-display); font-weight: 700; font-size: 0.8rem; color: var(--copper); letter-spacing: 0.06em; }
.side-brand .t2 { font-family: var(--f-thai-head); font-weight: 600; font-size: 1.05rem; color: var(--ink); line-height: 1.2; }
.side nav { display: grid; gap: 1.1rem; }
.side-unit { padding: 0 0.4rem; }
.side-unit h5 {
  display: flex; align-items: center; gap: 0.4rem;
  font-family: var(--f-display); font-size: 0.72rem; font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3);
  margin: 0 0 0.35rem 0.25rem;
}
.side-unit h5 .u { color: var(--copper); }
.wk-link {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.42rem 0.5rem; border-radius: 0.6rem;
  color: var(--ink-2); font-size: 0.93rem; line-height: 1.35;
  text-decoration: none;
  transition: background-color 150ms ease, color 150ms ease;
}
.wk-link:hover { background: var(--teal-soft); color: var(--ink); }
.wk-link .no {
  flex: none; width: 1.75rem; height: 1.75rem; border-radius: 0.5rem;
  display: grid; place-items: center;
  font-family: var(--f-display); font-weight: 700; font-size: 0.8rem;
  background: var(--paper); color: var(--ink-2); border: 1px solid var(--line);
}
.wk-link.is-ready .no { border-color: rgba(14, 143, 134, 0.35); color: var(--teal); }
.wk-link.is-current { background: var(--ink); color: #fff; }
.wk-link.is-current .no { background: var(--copper); border-color: var(--copper); color: #fff; }
.wk-link.is-soon { opacity: 0.55; cursor: default; }
.wk-link.is-soon:hover { background: transparent; color: var(--ink-2); }
.wk-link .soon { margin-left: auto; font-size: 0.7rem; color: var(--ink-3); }
.side-toc { margin: 0.35rem 0 0.4rem 1.4rem; padding-left: 0.85rem; border-left: 2px solid var(--line); }
.side-toc a {
  display: block; padding: 0.22rem 0.3rem; font-size: 0.85rem; color: var(--ink-3);
  text-decoration: none; position: relative;
  transition: color 150ms ease;
}
.side-toc a:hover { color: var(--ink); }
.side-toc a.on { color: var(--teal); font-weight: 600; }
.side-toc a.on::before {
  content: ''; position: absolute; left: calc(-0.85rem - 2px); top: 0.3rem; bottom: 0.3rem;
  width: 2px; background: var(--teal);
}

/* ---------- Layout หลัก ---------- */
.page { max-width: 62rem; margin: 0 auto; padding: 2rem 1rem 4rem; }
@media (min-width: 768px) { .page { padding: 2.75rem 2.5rem 5rem; } }

/* ---------- Hero ของสัปดาห์ ---------- */
.week-hero {
  position: relative; overflow: hidden;
  display: grid; gap: 1.5rem;
  grid-template-columns: 1fr;
  padding: 2rem 1.5rem 1.75rem;
  border-radius: 1.25rem;
  background: var(--ink); color: #e8ecef;
  box-shadow: var(--sh-2);
}
@media (min-width: 900px) { .week-hero { grid-template-columns: 1.55fr 1fr; padding: 2.5rem 2.5rem 2.25rem; } }
.week-hero::before { /* ลายวงจรจาง ๆ */
  content: ''; position: absolute; inset: 0; pointer-events: none; opacity: 0.5;
  background:
    linear-gradient(90deg, transparent 0 calc(100% - 1px), rgba(255,255,255,0.05) 0) 0 0 / 28px 28px,
    linear-gradient(0deg, transparent 0 calc(100% - 1px), rgba(255,255,255,0.05) 0) 0 0 / 28px 28px;
  mask-image: linear-gradient(115deg, transparent 30%, #000 85%);
}
.week-hero > * { position: relative; }
.week-hero .kicker {
  display: inline-flex; gap: 0.5rem; align-items: center;
  font-family: var(--f-display); font-size: 0.78rem; font-weight: 700; letter-spacing: 0.12em;
  color: var(--amber); text-transform: uppercase;
}
.course .week-hero h1 { color: #fff; margin: 0.6rem 0 0.9rem; }
.week-hero .lead { color: #b9c3cb; max-width: 36rem; }
.week-no {
  position: absolute; right: -0.5rem; bottom: -2.6rem;
  font-family: var(--f-display); font-weight: 700; font-size: 13rem; line-height: 1;
  color: transparent; -webkit-text-stroke: 1.5px rgba(217, 115, 43, 0.45);
  letter-spacing: -0.06em; pointer-events: none; user-select: none;
}
.hero-meta { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 1.1rem; }
.hero-meta span {
  display: inline-flex; gap: 0.35rem; align-items: center;
  padding: 0.3rem 0.7rem; border-radius: 9999px; font-size: 0.85rem;
  background: rgba(255, 255, 255, 0.07); color: #dfe5ea; border: 1px solid rgba(255,255,255,0.1);
}
.hero-obj {
  background: rgba(255, 255, 255, 0.05); border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 0.9rem; padding: 1.1rem 1.2rem; align-self: start;
}
.course .hero-obj h3 { color: #fff; font-size: 0.95rem; margin-bottom: 0.6rem; display: flex; gap: 0.4rem; align-items: center; }
.hero-obj ol { counter-reset: o; display: grid; gap: 0.55rem; }
.hero-obj li { counter-increment: o; display: grid; grid-template-columns: 1.6rem 1fr; font-size: 0.93rem; color: #cfd7dd; line-height: 1.55; }
.hero-obj li::before { content: counter(o, decimal-leading-zero); font-family: var(--f-display); font-weight: 700; color: var(--copper); font-size: 0.8rem; padding-top: 0.15rem; }

/* แผนเวลา 5 ชม. */
.timeplan { display: flex; gap: 4px; margin-top: 1.4rem; height: 2.2rem; border-radius: 0.6rem; overflow: hidden; font-size: 0.8rem; }
.timeplan div { display: flex; align-items: center; gap: 0.35rem; padding: 0 0.75rem; white-space: nowrap; color: var(--ink); font-weight: 600; }
.timeplan .th { flex: 2; background: var(--amber); }
.timeplan .lb { flex: 3; background: var(--copper); color: #fff; }

/* ---------- หัวข้อ Section: ลายทองแดง PCB (signature) ---------- */
.sec { margin-top: 4rem; scroll-margin-top: 4.5rem; }
.sec-head { display: grid; grid-template-columns: auto 1fr; gap: 0 1rem; align-items: center; margin-bottom: 1.4rem; }
.sec-head .pad {
  grid-row: span 2;
  width: 3rem; height: 3rem; border-radius: 50%;
  display: grid; place-items: center;
  font-family: var(--f-display); font-weight: 700; color: var(--copper);
  background: var(--card);
  border: 3px solid var(--copper);
  box-shadow: 0 0 0 5px var(--copper-soft), var(--sh-1);
}
.sec-head .eyebrow { font-family: var(--f-display); font-size: 0.75rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--teal); }
.course .sec-head h2 { margin: 0.1rem 0 0; }
.trace { grid-column: 2; position: relative; height: 3px; margin-top: 0.7rem; background: linear-gradient(90deg, rgba(217,115,43,0.55), rgba(217,115,43,0.08)); border-radius: 2px; overflow: hidden; }
.trace::after {
  content: ''; position: absolute; top: -2px; left: 0; width: 3.5rem; height: 7px; border-radius: 4px;
  background: radial-gradient(closest-side, var(--amber), transparent);
  transform: translateX(-4rem); opacity: 0;
}
.sec.in .trace::after { animation: trace-pulse 1.6s var(--ease-out) 0.25s 2 both; }
@keyframes trace-pulse { 0% { transform: translateX(-4rem); opacity: 1; } 100% { transform: translateX(60rem); opacity: 0; } }

.prose-c > * + * { margin-top: 1rem; }
.prose-c ul.dot { display: grid; gap: 0.45rem; }
.prose-c ul.dot li { position: relative; padding-left: 1.3rem; line-height: 1.65; }
.prose-c ul.dot li::before { content: ''; position: absolute; left: 0.2rem; top: 0.68em; width: 6px; height: 6px; border-radius: 2px; background: var(--copper); transform: rotate(45deg); }
ol.num { display: grid; gap: 0.45rem; counter-reset: obj; list-style: none; padding: 0; }
ol.num li { position: relative; padding-left: 1.9rem; line-height: 1.65; counter-increment: obj; }
ol.num li::before { content: counter(obj) '.'; position: absolute; left: 0; top: 0; font-weight: 700; color: var(--copper); font-variant-numeric: tabular-nums; }
.prose-c h3 { margin-top: 2rem; }

/* ---------- การ์ดเนื้อหาแบบต่าง ๆ (ไม่ให้เหมือนกันหมด) ---------- */
.card-c {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r);
  padding: 1.25rem 1.35rem; box-shadow: var(--sh-1);
  transition: transform 200ms var(--ease-out), box-shadow 200ms ease;
}
.card-c.lift:hover { transform: translateY(-3px); box-shadow: var(--sh-2); }
.card-ink { background: var(--ink); color: #dfe5ea; border-color: transparent; }
.course .card-ink h3, .course .card-ink h4 { color: #fff; }
.card-edge { border-left: 4px solid var(--teal); }
.card-edge.copper { border-left-color: var(--copper); }
.card-edge.danger { border-left-color: var(--danger); }
.card-tag {
  display: inline-flex; align-items: center; gap: 0.3rem;
  font-family: var(--f-display); font-size: 0.72rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--teal);
}
.grid-asym { display: grid; gap: 1rem; grid-template-columns: 1fr; }
@media (min-width: 768px) { .grid-asym { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); } .grid-asym.rev { grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); } }
.grid-3 { display: grid; gap: 0.9rem; grid-template-columns: 1fr; }
@media (min-width: 640px) { .grid-3 { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { .grid-3 { grid-template-columns: 1.2fr 1fr 1fr; } }

.icon-tile { width: 2.5rem; height: 2.5rem; border-radius: 0.7rem; display: grid; place-items: center; background: var(--teal-soft); color: var(--teal); margin-bottom: 0.65rem; }
.icon-tile.copper { background: var(--copper-soft); color: var(--copper); }
.icon-tile.danger { background: rgba(214, 69, 69, 0.1); color: var(--danger); }

/* Callout */
.callout { display: grid; grid-template-columns: auto 1fr; gap: 0.75rem; padding: 1rem 1.15rem; border-radius: 0 0.75rem 0.75rem 0; background: var(--teal-soft); border-left: 3px solid var(--teal); }
.callout > .material-symbols-outlined { color: var(--teal); font-size: 1.4rem; }
.callout.tip { background: rgba(31, 157, 85, 0.07); border-color: var(--ok); }
.callout.tip > .material-symbols-outlined { color: var(--ok); }
.callout.warn { background: rgba(242, 179, 61, 0.12); border-color: var(--warn); }
.callout.warn > .material-symbols-outlined { color: #b07a0c; }
.callout.danger { background: rgba(214, 69, 69, 0.07); border-color: var(--danger); }
.callout.danger > .material-symbols-outlined { color: var(--danger); }
.callout p { margin: 0; }
.callout b.t { display: block; font-family: var(--f-thai-head); font-weight: 600; margin-bottom: 0.15rem; }

/* สูตร */
.formula {
  font-family: var(--f-mono); font-size: 1rem; text-align: center;
  padding: 1rem; border-radius: 0.75rem; background: var(--card); border: 1px dashed rgba(217,115,43,0.5);
  color: var(--ink);
}
.formula .hl { color: var(--copper); font-weight: 600; }

/* ตาราง */
.tbl-wrap { overflow-x: auto; overflow-y: hidden; border-radius: var(--r); border: 1px solid var(--line); background: var(--card); box-shadow: var(--sh-1); }
.tbl { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
.tbl th { text-align: left; font-family: var(--f-thai-head); font-weight: 600; font-size: 0.85rem; color: var(--ink-2); background: var(--paper); padding: 0.7rem 0.9rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 0.65rem 0.9rem; border-bottom: 1px solid rgba(227, 224, 214, 0.7); vertical-align: top; line-height: 1.55; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr:nth-child(even) td { background: rgba(14, 143, 134, 0.025); }
.tbl .num { font-family: var(--f-mono); font-size: 0.88rem; white-space: nowrap; }
.tbl input.rec { width: 100%; min-width: 5rem; border: 0; border-bottom: 1px dashed var(--ink-3); background: transparent; font-family: var(--f-mono); padding: 0.1rem 0; }
.tbl input.rec:focus { outline: none; border-bottom-color: var(--teal); }

/* โค้ด */
.code {
  position: relative; border-radius: 0.8rem; overflow: hidden;
  background: #13202a; box-shadow: var(--sh-1);
}
.code .code-bar { display: flex; align-items: center; gap: 0.5rem; padding: 0.5rem 0.6rem 0.5rem 1rem; background: #0d171f; color: #8fa1ad; font-family: var(--f-mono); font-size: 0.78rem; }
.code .code-bar .lang { color: var(--amber); font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }
.code .code-bar .fn { color: #c7d2da; }
.code .code-bar button { margin-left: auto; display: inline-flex; gap: 0.3rem; align-items: center; color: #c7d2da; background: rgba(255,255,255,0.06); border-radius: 0.45rem; padding: 0.25rem 0.55rem; font-size: 0.76rem; transition: background-color 150ms ease; }
.code .code-bar button:hover { background: rgba(255,255,255,0.14); }
.code pre { margin: 0; padding: 1rem 1.15rem 1.15rem; overflow-x: auto; overflow-y: hidden; color: #e2e8ee; font-family: var(--f-mono); font-size: 0.86rem; line-height: 1.7; tab-size: 2; font-variant-ligatures: none; }
.code pre .c { color: #6f8796; font-style: italic; }
.code pre .k { color: #f5a65b; }
.code pre .s { color: #8ee0b5; }
.code pre .n { color: #ffd479; }
.code pre .f { color: #7cc7f2; }
code.inl { font-variant-ligatures: none; font-family: var(--f-mono); font-size: 0.86em; background: rgba(24, 35, 44, 0.07); padding: 0.1em 0.38em; border-radius: 0.35rem; }

/* ใบงาน (Lab) */
.lab { border-radius: 1.25rem; background: var(--card); border: 1px solid var(--line); box-shadow: var(--sh-1); overflow: hidden; }
.lab-head { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem 1rem; padding: 1.25rem 1.5rem; background: linear-gradient(100deg, var(--copper-soft), transparent 70%); border-bottom: 1px solid var(--line); }
.lab-head .lab-no { font-family: var(--f-display); font-weight: 700; font-size: 2.6rem; line-height: 1; color: rgba(217, 115, 43, 0.3); letter-spacing: -0.04em; }
.course .lab-head h3 { margin: 0; }
.lab-body { padding: 1.5rem; display: grid; grid-template-columns: minmax(0, 1fr); gap: 1.6rem; }
.lab-body > *, .grid-asym > *, .grid-3 > * { min-width: 0; }
.course .lab-body h4 { display: flex; align-items: center; gap: 0.45rem; margin-bottom: 0.65rem; }
.course .lab-body h4 .material-symbols-outlined { color: var(--copper); }
.steps-c { counter-reset: s; display: grid; gap: 0.9rem; }
.steps-c > li { counter-increment: s; display: grid; grid-template-columns: 2.25rem minmax(0, 1fr); gap: 0.6rem; line-height: 1.65; }
.steps-c > li::before {
  content: counter(s); width: 2.25rem; height: 2.25rem; border-radius: 0.6rem;
  display: grid; place-items: center; font-family: var(--f-display); font-weight: 700;
  background: var(--ink); color: #fff; font-size: 0.9rem;
}
.steps-c > li > div > * + * { margin-top: 0.6rem; }
.checklist { display: grid; gap: 0.4rem; }
.checklist label { display: flex; gap: 0.65rem; align-items: flex-start; padding: 0.55rem 0.75rem; border-radius: 0.6rem; cursor: pointer; transition: background-color 150ms ease; line-height: 1.55; }
.checklist label:hover { background: var(--teal-soft); }
.checklist input { margin-top: 0.2rem; }
.checklist input:checked + span { color: var(--ink-3); text-decoration: line-through; text-decoration-color: rgba(14,143,134,0.6); }

/* ---------- แบบทดสอบ ---------- */
.quiz { display: grid; gap: 1rem; }
.quiz-bar { position: sticky; top: 4rem; z-index: 5; display: flex; align-items: center; gap: 1rem; padding: 0.75rem 1rem; border-radius: 0.8rem; background: var(--ink); color: #fff; box-shadow: var(--sh-2); }
.quiz-bar .score { font-family: var(--f-display); font-weight: 700; font-size: 1.15rem; white-space: nowrap; }
.quiz-bar .meter { flex: 1; height: 6px; border-radius: 4px; background: rgba(255,255,255,0.15); overflow: hidden; }
.quiz-bar .meter i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--teal), var(--amber)); transition: width 400ms var(--ease-out); }
.quiz-bar .best { font-size: 0.8rem; color: #aab6bf; white-space: nowrap; }
.q { position: relative; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 1.25rem 1.25rem 1.1rem 1.25rem; box-shadow: var(--sh-1); }
.q .q-no { position: absolute; right: 1rem; top: 0.25rem; font-family: var(--f-display); font-weight: 700; font-size: 3.5rem; line-height: 1; color: rgba(14, 143, 134, 0.1); pointer-events: none; }
.q .q-text { font-weight: 500; padding-right: 3rem; margin-bottom: 0.85rem; }
.q .q-opts { display: grid; gap: 0.45rem; }
@media (min-width: 640px) { .q .q-opts.two { grid-template-columns: 1fr 1fr; } }
.q .q-opts button {
  display: flex; gap: 0.6rem; align-items: flex-start; text-align: left;
  padding: 0.6rem 0.8rem; border-radius: 0.6rem; border: 1px solid var(--line); background: var(--paper);
  font-size: 0.97rem; line-height: 1.5;
  transition: background-color 150ms ease, border-color 150ms ease, transform 150ms ease;
}
.q .q-opts button:hover:not(:disabled) { border-color: var(--teal); transform: translateX(2px); }
.q .q-opts button .k { flex: none; font-family: var(--f-display); font-weight: 700; color: var(--ink-3); width: 1.2rem; }
.q .q-opts button.right { background: rgba(31, 157, 85, 0.1); border-color: var(--ok); }
.q .q-opts button.right .k { color: var(--ok); }
.q .q-opts button.wrong { background: rgba(214, 69, 69, 0.08); border-color: var(--danger); }
.q .q-opts button.wrong .k { color: var(--danger); }
.q .q-opts button:disabled { cursor: default; }
.q .q-explain { display: none; margin-top: 0.8rem; padding: 0.7rem 0.9rem; border-radius: 0.6rem; background: var(--teal-soft); font-size: 0.93rem; }
.q.done .q-explain { display: block; animation: rise 300ms var(--ease-out) both; }

/* ---------- Entrance ---------- */
.reveal { opacity: 0; transform: translateY(14px); transition: opacity 400ms var(--ease-out), transform 400ms var(--ease-out); }
.reveal.in { opacity: 1; transform: none; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ปุ่มก่อน/ถัดไป */
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 4.5rem; }
.pager a, .pager span.pg {
  display: flex; flex-direction: column; gap: 0.15rem; padding: 1rem 1.2rem; border-radius: var(--r);
  background: var(--card); border: 1px solid var(--line); text-decoration: none; color: var(--ink);
  transition: transform 200ms var(--ease-out), box-shadow 200ms ease, border-color 150ms ease;
}
.pager a:hover { transform: translateY(-3px); box-shadow: var(--sh-2); border-color: var(--teal); }
.pager .dir { font-size: 0.78rem; color: var(--ink-3); display: flex; gap: 0.3rem; align-items: center; }
.pager .nx { text-align: right; }
.pager .nx .dir { justify-content: flex-end; }
.pager .ttl { font-family: var(--f-thai-head); font-weight: 600; font-size: 0.98rem; line-height: 1.35; }
.pager span.pg { opacity: 0.5; }

.foot { margin-top: 3rem; padding-top: 1.5rem; border-top: 1px solid var(--line); font-size: 0.85rem; color: var(--ink-3); display: flex; flex-wrap: wrap; gap: 0.5rem 1.5rem; justify-content: space-between; }
.foot a { color: var(--ink-2); text-decoration: underline; text-underline-offset: 3px; }

/* =========================================================
   Toast (popover="manual" → top layer)
   ========================================================= */
#toast-box { min-width: 0; white-space: normal; display: grid; gap: 0.5rem; inset: auto; top: 4.25rem; right: 1rem; left: auto; bottom: auto; margin: 0; border: 0; padding: 0; background: transparent; overflow: visible; width: min(24rem, calc(100vw - 2rem)); }
#toast-box:not(:popover-open) { display: none; }
#toast-box .toast-item {
  display: grid; grid-template-columns: auto 1fr auto; gap: 0.7rem; align-items: start;
  padding: 0.85rem 0.85rem 0.85rem 1rem; border-radius: 0.85rem;
  background: var(--card); color: var(--ink); border: 1px solid var(--line);
  border-left: 4px solid var(--teal);
  box-shadow: var(--sh-2); user-select: text; text-align: left; white-space: normal;
  animation: toast-in 280ms var(--ease-out) both;
  transition: opacity 220ms ease, transform 220ms ease;
}
#toast-box .toast-item.settled { animation: none; }
#toast-box .toast-item.leaving { opacity: 0; transform: translateX(16px); }
#toast-box .toast-item .ic { font-size: 1.4rem; color: var(--teal); }
#toast-box .toast-item.success { border-left-color: var(--ok); } #toast-box .toast-item.success .ic { color: var(--ok); }
#toast-box .toast-item.error { border-left-color: var(--danger); } #toast-box .toast-item.error .ic { color: var(--danger); }
#toast-box .toast-item.warning { border-left-color: var(--warn); } #toast-box .toast-item.warning .ic { color: #b07a0c; }
#toast-box .toast-item b { display: block; font-family: var(--f-thai-head); font-weight: 600; font-size: 0.95rem; }
#toast-box .toast-item p { font-size: 0.88rem; color: var(--ink-2); line-height: 1.5; margin: 0.1rem 0 0; }
#toast-box .toast-item .cp { width: 1.9rem; height: 1.9rem; border-radius: 0.5rem; display: grid; place-items: center; color: var(--ink-3); transition: background-color 150ms ease, color 150ms ease; }
#toast-box .toast-item .cp:hover { background: var(--paper); color: var(--ink); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-10px) scale(0.98); } to { opacity: 1; transform: none; } }

/* =========================================================
   ระบบแอนิเมชันประกอบคำอธิบาย (IoTAnim)
   ========================================================= */
.anim {
  margin: 1.75rem 0; border-radius: 1.1rem; overflow: hidden;
  background: var(--card); border: 1px solid var(--line); box-shadow: var(--sh-1);
}
.anim-head { display: flex; align-items: center; gap: 0.75rem; padding: 0.7rem 0.75rem 0.7rem 1.1rem; border-bottom: 1px solid var(--line); }
.anim-head .tag { font-family: var(--f-display); font-size: 0.68rem; font-weight: 700; letter-spacing: 0.1em; color: #fff; background: var(--teal); padding: 0.2rem 0.5rem; border-radius: 0.35rem; }
.anim-head .tag.d3 { background: var(--copper); }
.course .anim-head h4 { flex: 1; min-width: 0; margin: 0; font-size: 1rem; }
.anim-ctrl { display: flex; gap: 0.25rem; }
.anim-ctrl button { width: 2.1rem; height: 2.1rem; border-radius: 0.55rem; display: grid; place-items: center; color: var(--ink-2); transition: background-color 150ms ease, color 150ms ease; }
.anim-ctrl button:hover { background: var(--paper); color: var(--ink); }
.anim-ctrl button.main { background: var(--ink); color: #fff; }
.anim-ctrl button.main:hover { background: #2a3843; }
.anim-body { display: grid; grid-template-columns: 1fr; }
@media (min-width: 900px) { .anim.has-steps .anim-body { grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); align-items: start; } }
.anim-stage {
  position: relative; min-height: 14rem;
  display: flex; flex-direction: column; justify-content: center;
  background-color: #fbfaf7;
  background-image: radial-gradient(rgba(24, 35, 44, 0.08) 1px, transparent 1px);
  background-size: 16px 16px;
  overflow: hidden;
}
.anim-stage.dark { background: var(--scope); }
.anim-steps { list-style: none; margin: 0; padding: 0.6rem; display: grid; gap: 0.3rem; align-content: start; border-top: 1px solid var(--line); background: var(--card); overflow: visible; }
@media (min-width: 900px) { .anim-steps { border-top: 0; border-left: 1px solid var(--line); } .anim.has-steps .anim-stage { min-height: 20rem; } }
.anim:not(.has-steps) .anim-steps, .anim.no-panel .anim-steps { display: none; }
@media (min-width: 900px) { .anim.no-panel .anim-body { grid-template-columns: 1fr; } .anim.has-steps.no-panel .anim-stage { min-height: 0; } }
.anim-steps li { position: relative; }
.anim-steps li button {
  width: 100%; text-align: left; display: grid; grid-template-columns: 1.7rem 1fr; gap: 0.5rem;
  padding: 0.6rem 0.65rem; border-radius: 0.6rem; font-size: 0.92rem; line-height: 1.55; color: var(--ink-3);
  transition: background-color 200ms ease, color 200ms ease;
}
.anim-steps li button:hover { background: var(--paper); color: var(--ink-2); }
.anim-steps li .sn { width: 1.7rem; height: 1.7rem; border-radius: 50%; display: grid; place-items: center; font-family: var(--f-display); font-weight: 700; font-size: 0.75rem; border: 1.5px solid var(--line); color: var(--ink-3); transition: background-color 200ms ease, border-color 200ms ease, color 200ms ease; }
.anim-steps li.on button { background: var(--teal-soft); color: var(--ink); }
.anim-steps li.on .sn { background: var(--teal); border-color: var(--teal); color: #fff; }
.anim-steps li.past .sn { border-color: rgba(14, 143, 134, 0.5); color: var(--teal); }
.anim-steps li .bar { position: absolute; left: 2.95rem; right: 0.65rem; bottom: 0.25rem; height: 2px; border-radius: 2px; background: var(--teal); transform-origin: 0 50%; transform: scaleX(0); opacity: 0; }
.anim-steps li.on .bar { opacity: 0.55; }
.anim-foot { display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; align-items: center; padding: 0.7rem 1.1rem; border-top: 1px solid var(--line); font-size: 0.85rem; color: var(--ink-2); background: #fdfcf9; }
.anim-foot:empty { display: none; }
.anim-foot label { display: inline-flex; align-items: center; gap: 0.5rem; }
.anim-foot input[type=range] { width: 8rem; accent-color: var(--copper); }
.anim-foot select { border: 1px solid var(--line); border-radius: 0.45rem; padding: 0.2rem 0.4rem; background: #fff; }
.anim-foot .read { font-family: var(--f-mono); font-size: 0.82rem; color: var(--ink); background: var(--paper); padding: 0.2rem 0.5rem; border-radius: 0.4rem; }
.anim-foot .read b { color: var(--copper); font-weight: 600; }
.anim-load { position: absolute; inset: 0; display: grid; place-items: center; gap: 0.5rem; color: var(--ink-3); font-size: 0.85rem; align-content: center; }
.anim-hint { position: absolute; left: 0.75rem; bottom: 0.6rem; font-size: 0.75rem; color: var(--ink-3); display: flex; gap: 0.3rem; align-items: center; pointer-events: none; }

/* packet-flow */
.pf { position: relative; width: 100%; }
.pf svg.pf-links { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.pf-links line { stroke: #c9c4b6; stroke-width: 2; stroke-dasharray: 5 6; vector-effect: non-scaling-stroke; transition: stroke 200ms ease; }
.pf-links line.hot { stroke: var(--copper); stroke-dasharray: 8 6; animation: dash 600ms linear infinite; }
.pf-links line.hot.secure { stroke: var(--teal); }
.pf-links line.hot.attack { stroke: var(--danger); }
@keyframes dash { to { stroke-dashoffset: -14; } }
.pf-node { position: absolute; transform: translate(-50%, -50%); display: flex; flex-direction: column; align-items: center; gap: 0.3rem; width: 7.5rem; text-align: center; transition: opacity 300ms ease, transform 300ms var(--ease-out); }
.pf-node.off { opacity: 0; transform: translate(-50%, -40%) scale(0.9); pointer-events: none; }
.pf-node .ic { position: relative; width: 3.2rem; height: 3.2rem; border-radius: 0.9rem; display: grid; place-items: center; background: var(--card); color: var(--ink); border: 1.5px solid var(--line); box-shadow: var(--sh-1); font-size: 1.55rem; transition: border-color 200ms ease, background-color 200ms ease, color 200ms ease; }
.pf-node .ic .material-symbols-outlined { font-size: 1.6rem; vertical-align: 0; }
.pf-node.t-teal .ic { color: var(--teal); }
.pf-node.t-copper .ic { color: var(--copper); }
.pf-node.t-danger .ic { color: var(--danger); border-color: rgba(214,69,69,0.4); background: #fff6f5; }
.pf-node.t-ink .ic { background: var(--ink); color: #fff; border-color: var(--ink); }
.pf-node.t-cloud .ic { background: #2f86dc; color: #fff; border-color: #2f86dc; }
.pf-node.focus .ic { border-color: var(--copper); }
.pf-node.focus .ic::after { content: ''; position: absolute; inset: -6px; border-radius: 1.1rem; border: 2px solid var(--copper); animation: ring 1.4s ease-out infinite; }
@keyframes ring { from { opacity: 0.8; transform: scale(0.92); } to { opacity: 0; transform: scale(1.18); } }
.pf-node .lb { font-family: var(--f-thai-head); font-weight: 600; font-size: 0.82rem; line-height: 1.2; color: var(--ink); }
.pf-node .sb { font-family: var(--f-mono); font-size: 0.7rem; line-height: 1.3; color: var(--ink-3); min-height: 1em; max-width: 8.5rem; transition: color 200ms ease; }
.pf-node .sb.flash { color: var(--copper); animation: rise 300ms var(--ease-out); }
.pf.pf-sm { width: 84%; margin: 0 auto; }
.pf-sm .pf-node { width: 4.8rem; gap: 0.2rem; }
.pf-sm .pf-node .ic { width: 2.4rem; height: 2.4rem; border-radius: 0.7rem; }
.pf-sm .pf-node .ic .material-symbols-outlined { font-size: 1.2rem; }
.pf-sm .pf-node .lb { font-size: 0.68rem; }
.pf-sm .pf-node .sb { font-size: 0.6rem; max-width: 5.5rem; }
.pf-sm .pf-pk { font-size: 0.6rem; padding: 0.12rem 0.38rem; }
.pf-pk { position: absolute; transform: translate(-50%, -50%); z-index: 3; display: inline-flex; gap: 0.25rem; align-items: center; padding: 0.2rem 0.5rem; border-radius: 9999px; background: var(--copper); color: #fff; font-family: var(--f-mono); font-size: 0.7rem; white-space: nowrap; box-shadow: 0 6px 14px -6px rgba(217,115,43,0.8); }
.pf-pk .material-symbols-outlined { font-size: 0.9rem; vertical-align: 0; }
.pf-pk.secure { background: var(--teal); box-shadow: 0 6px 14px -6px rgba(14,143,134,0.8); }
.pf-pk.attack { background: var(--danger); box-shadow: 0 6px 14px -6px rgba(214,69,69,0.8); }
.pf-pk.ack { background: var(--ok); }
.pf-pk.data { background: var(--ink); }

/* circuit / scope / power / neural */
.anim svg.full, .anim canvas.full { display: block; width: 100%; height: auto; }
.nn-node { transition: fill 250ms ease, stroke 250ms ease; }
.nn-edge { transition: stroke-opacity 250ms ease, stroke 250ms ease; }

/* 3D overlay labels */
.lbl3d { position: absolute; left: 0; top: 0; transform: translate(-50%, -120%); pointer-events: none; white-space: nowrap; font-family: var(--f-mono); font-size: 0.72rem; padding: 0.15rem 0.45rem; border-radius: 0.35rem; background: var(--ink); color: #fff; box-shadow: var(--sh-1); transition: opacity 200ms ease; }
.lbl3d.hl { background: var(--copper); }
.lbl3d.layer { font-family: var(--f-body); font-size: 0.8rem; transform: translate(0, -50%); background: rgba(255,255,255,0.94); color: var(--ink); border: 1px solid var(--line); padding: 0.3rem 0.6rem; white-space: normal; width: 12rem; }
.lbl3d.layer b { display: block; font-family: var(--f-thai-head); font-weight: 600; }
.lbl3d.layer small { color: var(--ink-3); font-size: 0.72rem; line-height: 1.35; display: block; }
.lbl3d.layer.hl { background: var(--ink); color: #fff; border-color: var(--ink); }
.lbl3d.layer.hl small { color: #c9d2d9; }
.tip3d { position: absolute; z-index: 4; pointer-events: none; padding: 0.5rem 0.65rem; border-radius: 0.55rem; background: rgba(24,35,44,0.95); color: #fff; font-size: 0.78rem; line-height: 1.45; max-width: 15rem; box-shadow: var(--sh-2); opacity: 0; transition: opacity 150ms ease; }
.tip3d b { font-family: var(--f-mono); color: var(--amber); }

/* ---------- Index ---------- */
.home-hero { display: grid; gap: 2rem; align-items: center; grid-template-columns: 1fr; padding: 1rem 0 2rem; }
@media (min-width: 960px) { .home-hero { grid-template-columns: 1.15fr 1fr; } }
.home-hero .code-chip { display: inline-flex; gap: 0.5rem; align-items: center; font-family: var(--f-display); font-weight: 700; font-size: 0.8rem; letter-spacing: 0.08em; padding: 0.35rem 0.75rem; border-radius: 9999px; background: var(--ink); color: #fff; }
.home-hero .code-chip i { width: 7px; height: 7px; border-radius: 50%; background: var(--phosphor); box-shadow: 0 0 0 3px rgba(67,224,184,0.25); font-style: normal; }
.course .home-hero h1 { font-size: clamp(2.4rem, 6vw, 4.2rem); margin: 1rem 0 1rem; }
.home-hero h1 .hl { color: var(--copper); }
.unit-row { display: grid; gap: 0.75rem; grid-template-columns: 1fr; margin-top: 1rem; }
@media (min-width: 768px) { .unit-row { grid-template-columns: 13rem 1fr; gap: 1.5rem; } }
.unit-row + .unit-row { margin-top: 2.25rem; }
.unit-label .u { font-family: var(--f-display); font-weight: 700; font-size: 2.6rem; line-height: 1; color: rgba(217,115,43,0.35); }
.course .unit-label h3 { font-size: 1.05rem; margin-top: 0.3rem; }
.wk-cards { display: grid; gap: 0.75rem; grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); }
.wk-card { position: relative; display: flex; flex-direction: column; gap: 0.4rem; padding: 1rem 1.1rem 1.05rem; border-radius: var(--r); background: var(--card); border: 1px solid var(--line); text-decoration: none; color: var(--ink); box-shadow: var(--sh-1); transition: transform 200ms var(--ease-out), box-shadow 200ms ease, border-color 150ms ease; overflow: hidden; }
a.wk-card:hover { transform: translateY(-4px); box-shadow: var(--sh-2); border-color: var(--teal); }
.wk-card .top { display: flex; justify-content: space-between; align-items: center; }
.wk-card .wn { font-family: var(--f-display); font-weight: 700; font-size: 0.78rem; letter-spacing: 0.08em; color: var(--ink-3); }
.wk-card .ic { color: var(--teal); }
.wk-card .tt { font-family: var(--f-thai-head); font-weight: 600; line-height: 1.35; font-size: 1rem; }
.wk-card .tp { font-size: 0.82rem; color: var(--ink-3); line-height: 1.5; }
.wk-card.soon { background: transparent; box-shadow: none; border-style: dashed; }
.wk-card.soon .tt { color: var(--ink-2); }
.wk-card.soon .ic { color: var(--ink-3); }
.wk-card.exam { background: var(--ink); color: #fff; border-color: var(--ink); }
.wk-card.exam .tt { color: #fff; } .wk-card.exam .tp, .wk-card.exam .wn { color: #9fb0bb; } .wk-card.exam .ic { color: var(--amber); }
.wk-card .badge-ready { position: absolute; right: 0; bottom: 0; padding: 0.2rem 0.6rem; font-size: 0.7rem; border-top-left-radius: 0.6rem; background: var(--teal); color: #fff; }

@media (max-width: 480px) { .anim-head { padding-left: 0.8rem; } .course .anim-head h4 { font-size: 0.92rem; } .anim-ctrl button[title="เริ่มใหม่"] { display: none; } }

@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; transition: none; }
  .sec.in .trace::after, .pf-links line.hot, .pf-node.focus .ic::after, #toast-box .toast-item { animation: none; }
  .card-c.lift:hover, a.wk-card:hover, .pager a:hover { transform: none; }
}

/* =========================================================
   บัญชีสมาชิก (assets/js/account.js) + หน้ากลางวิชา + หน้าแอดมิน
   ========================================================= */
.acct-btn { border-radius: 0.625rem; flex-wrap: nowrap; white-space: nowrap; flex-shrink: 0; height: auto; min-height: 2rem; }
.acct-btn span:not(.material-symbols-outlined) { white-space: nowrap; }
.acct-chip { display: inline-flex; align-items: center; gap: 0.5rem; padding: 0.2rem 0.45rem 0.2rem 0.25rem; border-radius: 9999px; border: 1px solid var(--line); background: var(--card); font-size: 0.88rem; transition: border-color 150ms ease, box-shadow 150ms ease; }
.acct-chip:hover { border-color: var(--teal); box-shadow: 0 4px 12px -6px rgba(14, 143, 134, 0.5); }
.acct-chip i { width: 1.65rem; height: 1.65rem; border-radius: 50%; display: grid; place-items: center; background: var(--copper); color: #fff; font-style: normal; font-family: var(--f-display); font-weight: 700; font-size: 0.82rem; }
.acct-chip .nm { max-width: 8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 480px) { .acct-chip .nm { display: none; } }
.acct-chip .material-symbols-outlined { font-size: 1.1rem; color: var(--ink-3); }
.acct-menu { list-style: none; margin: 0.5rem 0 0; padding: 0.4rem; width: 16rem; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--sh-2); z-index: 50; }
.acct-menu li { list-style: none; }
.acct-menu .who { padding: 0.55rem 0.7rem 0.7rem; margin-bottom: 0.3rem; border-bottom: 1px solid var(--line); display: grid; gap: 0.1rem; }
.acct-menu .who b { font-family: var(--f-thai-head); font-weight: 600; }
.acct-menu .who span { font-size: 0.82rem; color: var(--ink-3); overflow-wrap: anywhere; }
.acct-menu .who em { font-style: normal; font-size: 0.78rem; color: var(--teal); font-weight: 600; }
.acct-menu a, .acct-menu button { display: flex; align-items: center; gap: 0.6rem; width: 100%; padding: 0.5rem 0.7rem; border-radius: 0.5rem; font-size: 0.92rem; color: var(--ink); text-align: left; transition: background-color 150ms ease; }
.acct-menu a:hover, .acct-menu button:hover { background: var(--teal-soft); }
.acct-menu .material-symbols-outlined { font-size: 1.2rem; color: var(--ink-2); }

.acct-modal .modal-box { max-width: 26rem; border-radius: 1.1rem; padding: 1.5rem; background: var(--card); box-shadow: var(--sh-2); animation: acct-in 220ms var(--ease-out) both; }
@keyframes acct-in { from { opacity: 0; transform: translateY(10px) scale(0.98); } to { opacity: 1; transform: none; } }
.acct-h { font-family: var(--f-thai-head); font-size: 1.25rem; margin: 0 0 1rem; }
.acct-tabs { position: relative; display: grid; grid-template-columns: 1fr 1fr; padding: 0.25rem; border-radius: 0.8rem; background: var(--paper); border: 1px solid var(--line); margin: 0 0 1.4rem; }
.acct-tabs::before { content: ''; position: absolute; top: 0.25rem; bottom: 0.25rem; left: 0.25rem; width: calc(50% - 0.25rem); border-radius: 0.6rem; background: var(--card); box-shadow: 0 4px 12px -4px rgba(24, 35, 44, 0.3); transition: transform 280ms cubic-bezier(0.34, 1.3, 0.5, 1); }
.acct-tabs[data-pos="1"]::before { transform: translateX(100%); }
.acct-tabs button { position: relative; display: flex; align-items: center; justify-content: center; gap: 0.4rem; padding: 0.5rem; font-family: var(--f-thai-head); font-weight: 500; font-size: 0.92rem; color: var(--ink-3); transition: color 200ms ease; }
.acct-tabs button .material-symbols-outlined { font-size: 1.15rem; }
.acct-tabs button[aria-selected="true"] { color: var(--ink); font-weight: 600; }
.acct-tabs button[aria-selected="true"] .material-symbols-outlined { color: var(--copper); }
@media (prefers-reduced-motion: reduce) { .acct-tabs::before { transition: none; } }
.acct-note { font-size: 0.9rem; color: var(--ink-2); margin: 0 0 1rem; line-height: 1.6; }
.acct-form { display: grid; gap: 0.85rem; }
.acct-f { display: grid; gap: 0.3rem; }
.acct-f > span { font-size: 0.88rem; font-weight: 600; color: var(--ink); }
.acct-f small { font-size: 0.8rem; color: var(--ink-3); }
.acct-f[hidden], .k-stu[hidden] { display: none; }
.acct-consent { display: flex; align-items: center; gap: 0.5rem; cursor: pointer; font-size: 0.92rem; }
.acct-consent { align-items: center; gap: 0.8rem; font-size: 0.92rem; line-height: 1.5; color: var(--ink); padding: 0.8rem 1rem; border: 1.5px solid var(--line); border-radius: 0.8rem; }
.acct-consent input { flex: none; width: 1.4rem; height: 1.4rem; border-radius: 0.45rem; }
.acct-consent a { color: #2b5fc4; font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
.acct-consent i { color: var(--danger); font-style: normal; font-weight: 700; }
.acct-occrow { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.acct-occl { display: grid; gap: 0.1rem; }
.acct-occl b { font-size: 0.88rem; font-weight: 600; }
.acct-occl small { font-size: 0.78rem; color: var(--ink-3); }
.acct-seg { position: relative; display: grid; grid-template-columns: 1fr 1fr; width: 15.5rem; padding: 0.25rem; border-radius: 0.8rem; background: var(--paper); border: 1px solid var(--line); }
.acct-seg::before { content: ''; position: absolute; top: 0.25rem; bottom: 0.25rem; left: 0.25rem; width: calc(50% - 0.25rem); border-radius: 0.6rem; background: var(--card); box-shadow: 0 4px 12px -4px rgba(24, 35, 44, 0.3); transition: transform 280ms cubic-bezier(0.34, 1.3, 0.5, 1); }
.acct-seg:has(label:nth-child(2) input:checked)::before { transform: translateX(100%); }
.acct-seg label { position: relative; cursor: pointer; }
.acct-seg input { position: absolute; opacity: 0; pointer-events: none; }
.acct-seg span { display: flex; align-items: center; justify-content: center; gap: 0.35rem; padding: 0.45rem 0.5rem; font-size: 0.92rem; font-weight: 500; color: var(--ink-3); transition: color 200ms ease; white-space: nowrap; }
.acct-seg span .material-symbols-outlined { font-size: 1.15rem; }
.acct-seg input:checked + span { color: var(--ink); font-weight: 600; }
.acct-seg input:checked + span .material-symbols-outlined { color: var(--copper); }
.acct-seg:has(input:focus-visible) { outline: 2px solid var(--teal); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { .acct-seg::before { transition: none; } }
.acct-welcome { text-align: center; margin: 0 0 1.2rem; }
.acct-modal .modal-box:has(.acct-welcome) { padding-top: 1.8rem; }
.acct-welcome b { display: block; font-family: var(--f-thai-head); font-size: 1.4rem; line-height: 1.2; margin-bottom: 0.25rem; }
.acct-welcome small { color: var(--ink-2); font-size: 0.85rem; }
.acct-form.is-login { gap: 1.1rem; }
.acct-form.is-login > * { animation: acct-in 320ms var(--ease-out) both; }
.acct-form.is-login > :nth-child(2) { animation-delay: 60ms; }
.acct-form.is-login > :nth-child(3) { animation-delay: 120ms; }
.acct-form.is-login > :nth-child(4) { animation-delay: 180ms; }
.acct-iw { position: relative; display: flex; align-items: center; }
.acct-iw > .material-symbols-outlined { position: absolute; left: 0.8rem; font-size: 1.2rem; color: var(--ink-3); pointer-events: none; transition: color 150ms ease; }
.acct-iw .input { padding-left: 2.7rem; padding-right: 2.7rem; }
.acct-iw:focus-within > .material-symbols-outlined { color: var(--teal); }
.acct-eye { position: absolute; right: 0.35rem; display: grid; place-items: center; width: 2rem; height: 2rem; border-radius: 0.5rem; color: var(--ink-3); transition: background-color 150ms ease, color 150ms ease; }
.acct-eye:hover { background: var(--teal-soft); color: var(--teal); }
.acct-eye .material-symbols-outlined { font-size: 1.2rem; }
.acct-switch { text-align: center; font-size: 0.9rem; color: var(--ink-2); margin: 0; }
.acct-switch a { color: var(--copper); font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
@media (prefers-reduced-motion: reduce) { .acct-form.is-login > * { animation: none; } }
.acct-err { display: none; font-style: normal; font-size: 0.8rem; line-height: 1.4; color: var(--danger); }
.acct-err.on { display: flex; align-items: center; gap: 0.3rem; animation: acct-err-in 200ms var(--ease-out) both; }
.acct-err.on::before { content: 'error'; font-family: 'Material Symbols Outlined'; font-size: 1rem; }
@keyframes acct-err-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.acct-f.has-err .input { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(214, 69, 69, 0.12); }
.acct-consent.has-err { border-color: var(--danger); background: rgba(214, 69, 69, 0.05); }
.acct-formerr { margin: 0; padding: 0.6rem 0.8rem; border-radius: 0.7rem; background: rgba(214, 69, 69, 0.08); color: var(--danger); font-size: 0.88rem; line-height: 1.5; }
.acct-formerr[hidden] { display: none; }
.acct-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 440px) { .acct-row { grid-template-columns: 1fr; } }
.acct-form.is-reg { gap: 1.1rem; }
.acct-form.is-reg .acct-f { gap: 0.4rem; }
.acct-form.is-reg .acct-kind small { display: none; }
.acct-form.is-reg .acct-kind > label > span { padding: 0.5rem 0.7rem; grid-template-columns: auto 1fr; align-items: center; column-gap: 0.5rem; }
.acct-modal .modal-box:has(.is-reg) { max-width: 34rem; padding: 3rem 1.8rem 1.6rem; }
.acct-modal .modal-box { padding-top: 3rem; max-height: calc(100dvh - 1.5rem); overflow-y: auto; }
.acct-f > span small { font-weight: 400; }
.acct-kind { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }
.acct-kind label { cursor: pointer; }
.acct-kind input { position: absolute; opacity: 0; pointer-events: none; }
.acct-kind > label > span { display: grid; align-content: start; gap: 0.15rem; padding: 0.7rem 0.8rem; border: 1.5px solid var(--line); border-radius: 0.75rem; transition: border-color 150ms ease, background-color 150ms ease; height: 100%; }
.acct-kind > label > span .material-symbols-outlined { color: var(--copper); }
.acct-kind b { font-family: var(--f-thai-head); font-weight: 600; font-size: 0.95rem; }
.acct-kind small { font-size: 0.78rem; color: var(--ink-3); line-height: 1.4; }
.acct-kind input:checked + span { border-color: var(--teal); background: var(--teal-soft); }
.acct-kind input:focus-visible + span { outline: 2px solid var(--teal); outline-offset: 2px; }

/* ---------- หน้ากลางวิชา ---------- */
.hub-hero { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem; padding: 2.5rem 0 1.5rem; }
.hub-hero .code-chip { justify-self: start; display: inline-flex; gap: 0.5rem; align-items: center; font-family: var(--f-display); font-weight: 700; font-size: 0.8rem; letter-spacing: 0.08em; padding: 0.35rem 0.75rem; border-radius: 9999px; background: var(--ink); color: #fff; }
.hub-hero .code-chip i { width: 7px; height: 7px; border-radius: 50%; background: var(--phosphor); box-shadow: 0 0 0 3px rgba(67, 224, 184, 0.25); }
.hub-hero h1 { font-family: var(--f-thai-head); font-size: clamp(2rem, 5vw, 3.2rem); line-height: 1.1; letter-spacing: -0.03em; font-weight: 700; margin: 0; }
.hub-hero h1 .hl { color: var(--copper); }
.hub-hero p { color: var(--ink-2); max-width: 40rem; line-height: 1.7; margin: 0; }
.hub-grid { display: grid; gap: 1.25rem; grid-template-columns: repeat(auto-fill, minmax(min(16rem, 100%), 1fr)); }
.hub-grid > * { min-width: 0; }
.course-card { display: flex; flex-direction: column; background: var(--card); border: 1px solid var(--line); border-radius: 1.1rem; box-shadow: var(--sh-1); color: var(--ink); overflow: hidden; transition: transform 200ms var(--ease-out), box-shadow 200ms ease; }
.course-card:hover { transform: translateY(-4px); box-shadow: var(--sh-2); }
.cc-cover { position: relative; aspect-ratio: 16 / 10; display: grid; align-content: end; gap: 0.25rem; padding: 1rem 1.1rem; color: #fff; overflow: hidden; background: linear-gradient(135deg, var(--c1), var(--c2)); isolation: isolate; }
.cc-cover::before { content: ""; position: absolute; inset: 0; z-index: -1; background: radial-gradient(circle at 85% 15%, rgba(255, 255, 255, 0.22), transparent 45%), repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.05) 0 2px, transparent 2px 14px); }
.cc-cover .cc-art { position: absolute; right: -0.6rem; top: 0.9rem; z-index: -1; font-size: 7.5rem; line-height: 1; opacity: 0.22; transition: transform 400ms var(--ease-out); font-variation-settings: 'wght' 300; }
.course-card:hover .cc-art { transform: scale(1.1) rotate(-4deg); }
.cc-badge { position: absolute; left: 0.8rem; top: 0.8rem; display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.3rem 0.7rem; border-radius: 9999px; background: rgba(12, 20, 26, 0.62); backdrop-filter: blur(6px); font-size: 0.78rem; font-weight: 600; color: #fff; }
.cc-badge i { width: 7px; height: 7px; border-radius: 50%; background: var(--phosphor); }
.cc-cover .cc-big { font-family: var(--f-display); font-weight: 700; font-size: clamp(1.35rem, 2.4vw, 1.7rem); line-height: 1.1; letter-spacing: -0.03em; text-shadow: 0 2px 12px rgba(0, 0, 0, 0.3); }
.cc-cover .cc-sub { font-size: 0.82rem; opacity: 0.9; }
.cc-body { display: flex; flex-direction: column; gap: 0.55rem; padding: 1rem 1.1rem 1.1rem; flex: 1; }
.cc-meta { font-size: 0.8rem; color: var(--ink-3); }
.course-card h3 { font-family: var(--f-thai-head); font-size: 1.12rem; line-height: 1.3; margin: 0; }
.course-card p { margin: 0; color: var(--ink-2); font-size: 0.92rem; line-height: 1.6; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.cc-facts { display: flex; flex-direction: row; align-items: center; justify-content: space-between; gap: 0.6rem; margin-top: auto; padding-top: 0.5rem; font-size: 0.82rem; color: var(--ink-2); }
.cc-facts span { display: inline-flex; align-items: center; gap: 0.25rem; }
.cc-facts .material-symbols-outlined { font-size: 1.05rem; color: var(--teal); }
.cc-facts .lv { display: inline-flex; align-items: center; gap: 2px; font-weight: 600; color: var(--ink); }
.cc-facts .lv i { display: inline-block; width: 4px; border-radius: 1px; background: var(--line); margin-right: 0; }
.cc-facts .lv i:nth-child(1) { height: 7px; } .cc-facts .lv i:nth-child(2) { height: 11px; } .cc-facts .lv i:nth-child(3) { height: 15px; margin-right: 4px; }
.cc-facts .lv.lv1 i:nth-child(-n+1), .cc-facts .lv.lv2 i:nth-child(-n+2), .cc-facts .lv.lv3 i { background: var(--teal); }
.cc-facts .lv.lv3 i { background: var(--copper); }
.cc-facts .lv { gap: 2px; } .cc-facts .lv { padding-left: 0; }
.course-card .cc-pre { font-size: 0.82rem; color: var(--ink-3); line-height: 1.5; -webkit-line-clamp: 2; margin: 0; }
.course-card .cc-pre b { color: var(--ink-2); font-weight: 600; }
.course-card .cc-go { display: inline-flex; align-items: center; gap: 0.35rem; font-weight: 600; font-size: 0.92rem; padding-top: 0.6rem; border-top: 1px solid var(--line); }
.course-card .cc-go .material-symbols-outlined { transition: transform 200ms var(--ease-out); }
.course-card:hover .cc-go .material-symbols-outlined { transform: translateX(4px); }
.course-card.locked { opacity: 0.88; }
.course-card.locked .cc-cover { filter: grayscale(0.7); }
.interest-card { display: grid; gap: 0.6rem; margin: 0.5rem 0 2rem; padding: 1.4rem; border-radius: var(--r); background: var(--ink); color: #fff; box-shadow: var(--sh-2); }
.interest-card h3 { color: #fff !important; font-family: var(--f-thai-head); margin: 0; }
.interest-card p { color: #c9d2d9; margin: 0; line-height: 1.65; font-size: 0.95rem; }
@media (min-width: 720px) { .interest-card { grid-template-columns: auto 1fr auto; align-items: center; column-gap: 1.2rem; } .interest-card h3, .interest-card p { grid-column: 2; } .interest-card > .material-symbols-outlined { grid-row: 1 / span 2; } .interest-card #interest-act { grid-column: 3; grid-row: 1 / span 2; } }

/* ---------- หัวหน้าแรกแบบ MOOC ---------- */
.mooc-hero { position: relative; overflow: hidden; background: radial-gradient(ellipse at 80% 15%, #12857b 0%, #0a4f4c 42%, #082f33 100%); color: #fff; isolation: isolate; }
.mooc-hero canvas { position: absolute; inset: 0; width: 100%; height: 100%; z-index: -1; opacity: 0.9; }
.mooc-in { max-width: 78rem; margin: 0 auto; padding: 3.5rem 1rem 2.5rem; display: grid; gap: 1.1rem; }
.mooc-eyebrow { font-family: var(--f-display); font-weight: 700; font-size: 0.78rem; letter-spacing: 0.32em; color: var(--phosphor); }
.mooc-hero h1 { font-family: var(--f-thai-head); font-weight: 700; font-size: clamp(2.1rem, 6vw, 4rem); line-height: 1.1; letter-spacing: -0.03em; margin: 0; color: #fff; }
.mooc-hero h1 .hl { color: var(--amber); font-size: 0.62em; letter-spacing: -0.01em; display: inline-block; margin-top: 0.4rem; }
.mooc-hero p { max-width: 40rem; margin: 0; color: #cfe3df; line-height: 1.75; }
@media (min-width: 768px) { .mooc-in { padding-inline: 2.5rem; } }
.mooc-search { display: flex; align-items: center; gap: 0.5rem; max-width: 40rem; padding: 0.35rem 0.4rem 0.35rem 0.9rem; border-radius: 0.8rem; background: rgba(255, 255, 255, 0.08); border: 1px solid rgba(255, 255, 255, 0.18); backdrop-filter: blur(6px); transition: border-color 150ms ease, background-color 150ms ease; }
.mooc-search:focus-within { border-color: var(--phosphor); background: rgba(255, 255, 255, 0.12); }
.mooc-search .material-symbols-outlined { color: #b4d0cb; }
.mooc-search input { flex: 1; min-width: 0; background: transparent; border: 0; outline: 0; color: #fff; font: inherit; padding: 0.55rem 0; }
.mooc-search input::placeholder { color: #9dbfb9; }
.mooc-search button { padding: 0.55rem 1.3rem; border-radius: 0.6rem; background: var(--amber); color: var(--ink); font-weight: 700; transition: background-color 150ms ease, transform 150ms ease; }
.mooc-search button:hover { background: #f7c35f; transform: translateY(-1px); }
.course-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.75rem 1rem; margin-bottom: 1.4rem; }
.course-head .sec-head { margin-bottom: 0; }
.course-search { display: flex; align-items: center; gap: 0.4rem; flex: 1 1 16rem; max-width: 24rem; margin-left: auto; padding: 0.25rem 0.3rem 0.25rem 0.75rem; border-radius: 0.75rem; background: var(--card); border: 1px solid var(--line); box-shadow: var(--sh-1); transition: border-color 150ms ease; }
.course-search:focus-within { border-color: var(--teal); }
.course-search .material-symbols-outlined { color: var(--ink-3); }
.course-search input { flex: 1; min-width: 0; background: transparent; border: 0; outline: 0; font: inherit; color: var(--ink); padding: 0.45rem 0; }
.course-search button { padding: 0.45rem 1rem; border-radius: 0.55rem; background: var(--ink); color: #fff; font-weight: 600; font-size: 0.9rem; transition: background-color 150ms ease; }
.course-search button:hover { background: var(--teal); }
.mooc-stats { display: grid; gap: 0.9rem; grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 1.4rem; }
@media (min-width: 900px) { .mooc-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.mooc-stat { display: flex; align-items: center; gap: 0.9rem; padding: 1rem 1.1rem; border-radius: 0.8rem; background: rgba(255, 255, 255, 0.06); border: 1px solid rgba(255, 255, 255, 0.12); backdrop-filter: blur(6px); }
.mooc-stat .ico { display: grid; place-items: center; width: 2.9rem; height: 2.9rem; border-radius: 0.7rem; flex: none; }
.mooc-stat .ico .material-symbols-outlined { font-size: 1.6rem; }
.mooc-stat b { display: block; font-family: var(--f-display); font-size: 1.7rem; line-height: 1.1; letter-spacing: -0.02em; }
.mooc-stat small { color: #b4d0cb; font-size: 0.82rem; }
.mooc-stat.s1 .ico { background: rgba(255, 255, 255, 0.14); color: #fff; }
.mooc-stat.s2 .ico { background: rgba(67, 224, 184, 0.16); color: var(--phosphor); }
.mooc-stat.s3 .ico { background: rgba(242, 179, 61, 0.18); color: var(--amber); }
.mooc-stat.s4 .ico { background: rgba(217, 115, 43, 0.2); color: #f0925a; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- หน้าแอดมิน ---------- */
.adm-tabs { position: relative; display: flex; gap: 0.25rem; padding: 0.25rem; background: var(--card); border: 1px solid var(--line); border-radius: 0.85rem; width: fit-content; max-width: 100%; overflow-x: auto; }
.adm-tabs button { display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.5rem 0.9rem; border-radius: 0.6rem; font-family: var(--f-thai-head); font-weight: 500; font-size: 0.92rem; color: var(--ink-2); white-space: nowrap; transition: background-color 150ms ease, color 150ms ease; }
.adm-tabs button .material-symbols-outlined { font-size: 1.15rem; }
.adm-tabs { scrollbar-width: none; }
.adm-tabs::-webkit-scrollbar { display: none; }
.adm-tabs button { position: relative; }
.adm-tabs button[aria-selected="true"] { color: #fff; }
.adm-pill { position: absolute; top: 0.25rem; bottom: 0.25rem; left: 0; border-radius: 0.6rem; background: var(--ink); box-shadow: 0 4px 12px -4px rgba(24, 35, 44, 0.45); pointer-events: none; }
.adm-pill.slide { transition: transform 300ms cubic-bezier(0.22, 1, 0.36, 1), width 300ms cubic-bezier(0.22, 1, 0.36, 1); }
@media (prefers-reduced-motion: reduce) { .adm-pill.slide { transition: none; } }
.adm-stats { display: grid; gap: 0.75rem; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 720px) { .adm-stats { grid-template-columns: 1.3fr 1fr 1fr 1fr; } }
.adm-stat { padding: 0.9rem 1.1rem; border-radius: var(--r); background: var(--card); border: 1px solid var(--line); box-shadow: var(--sh-1); }
.adm-stat b { display: block; font-family: var(--f-display); font-size: 2rem; line-height: 1.1; letter-spacing: -0.02em; }
.adm-stat span { font-size: 0.85rem; color: var(--ink-2); }
.adm-stat.warn b { color: var(--copper); }
.adm-stat.main { background: var(--ink); border-color: var(--ink); }
.adm-stat.main b { color: var(--phosphor); } .adm-stat.main span { color: #c9d2d9; }
.adm-bar { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.adm-chips { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.adm-chips button { padding: 0.3rem 0.75rem; border-radius: 9999px; border: 1px solid var(--line); background: var(--card); font-size: 0.85rem; transition: background-color 150ms ease, border-color 150ms ease; }
.adm-chips button[aria-pressed="true"] { background: var(--teal); border-color: var(--teal); color: #fff; }
.adm-table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--sh-1); }
.adm-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.adm-table th { text-align: left; padding: 0.65rem 0.8rem; background: var(--paper); font-family: var(--f-thai-head); font-weight: 600; font-size: 0.82rem; color: var(--ink-2); white-space: nowrap; border-bottom: 1px solid var(--line); }
.adm-table td { padding: 0.65rem 0.8rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.adm-table tbody tr:last-child td { border-bottom: 0; }
.adm-table tbody tr:hover { background: var(--teal-soft); }
.adm-table .sub { display: block; font-size: 0.8rem; color: var(--ink-3); overflow-wrap: anywhere; }
.adm-table .acts { display: flex; gap: 0.25rem; flex-wrap: wrap; }
.adm-empty { padding: 2.5rem 1rem; text-align: center; color: var(--ink-3); }
.pill { display: inline-block; padding: 0.1rem 0.55rem; border-radius: 9999px; font-size: 0.78rem; font-weight: 600; white-space: nowrap; }
.pill.active { background: rgba(31, 157, 85, 0.12); color: #17753f; }
.pill.pending { background: rgba(242, 179, 61, 0.2); color: #8a5d00; }
.pill.disabled { background: rgba(214, 69, 69, 0.12); color: #b03030; }
.pill.role { background: var(--teal-soft); color: var(--teal); }
.pill.role.admin { background: var(--copper-soft); color: #b45a1a; }
.tmp-pw { font-family: var(--f-mono); font-size: 1.6rem; letter-spacing: 0.15em; text-align: center; padding: 0.8rem; border-radius: 0.75rem; background: var(--scope); color: var(--phosphor); user-select: all; }

.btn-prog { position: relative; overflow: hidden; }
@media (prefers-reduced-motion: reduce) {
  .course-card:hover, .course-card:hover .cc-go .material-symbols-outlined { transform: none; }
  .acct-modal .modal-box { animation: none; }
}

[hidden] { display: none !important; }

/* ---------- แอนิเมชันวิชาใหม่ (anim-prog / anim-image / anim-embedded) ---------- */
.px-cell { transition: fill 320ms ease; }
.px-bar { transition: y 320ms ease, height 320ms ease; }
.cv-win { transition: x 140ms ease-out, y 140ms ease-out; }
.mm-cell { transition: opacity 300ms ease; }
.fsm-state rect { transition: fill 250ms ease; }
.fsm-lamp { transition: fill 200ms ease; }
.tm-lane { transition: opacity 300ms ease; }
@media (prefers-reduced-motion: reduce) { .px-cell, .px-bar, .cv-win, .mm-cell, .fsm-state rect, .fsm-lamp, .tm-lane { transition: none; } }
/* ภาพที่มีตัวเลขเยอะ: จอแคบให้เลื่อนดูแนวนอนแทนการย่อจนอ่านไม่ออก */
@media (max-width: 640px) {
  .anim-stage:has(> svg.wide) { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .anim svg.full.wide { min-width: 600px; }
}

.acct-more { border: 1px solid var(--line); border-radius: 0.75rem; padding: 0.5rem 0.8rem; }
.acct-more > summary { cursor: pointer; font-weight: 600; font-size: 0.9rem; color: var(--ink-2); padding: 0.2rem 0; }
.acct-more[open] > summary { margin-bottom: 0.6rem; }
.acct-more .acct-f + .acct-f { margin-top: 0.6rem; }
.course-card h3.en-h { font-family: var(--f-display); font-size: 1.3rem; line-height: 1.2; letter-spacing: -0.02em; }
.course-card .cc-en { font-size: 0.85rem; color: var(--ink-3); margin: -0.35rem 0 0; font-family: var(--f-thai-head); }
.adm-table td.ord { white-space: nowrap; }
.adm-table td.ord .grip { cursor: grab; color: var(--ink-3); vertical-align: middle; margin-right: 0.15rem; }
.adm-table td.ord b { display: inline-block; min-width: 1.2rem; margin-right: 0.25rem; }
.adm-table td.ord .btn { min-height: 1.5rem; height: 1.5rem; width: 1.5rem; padding: 0; }
.adm-table tr.dragging { opacity: 0.45; }
.adm-table tr.over td { box-shadow: inset 0 3px 0 var(--teal); }

/* รูปปกการ์ดวิชา (อัปโหลดจากหลังบ้าน) */
.cc-cover.has-img { background: linear-gradient(180deg, rgba(0, 0, 0, 0.05) 30%, rgba(0, 0, 0, 0.72)), var(--img) center / cover no-repeat, linear-gradient(135deg, var(--c1), var(--c2)); }
.cc-cover.has-img::before, .cc-cover.has-img .cc-art { display: none; }

/* ---------- แบบทดสอบก่อน/หลังเรียนระดับบท ---------- */
.ut-intro { margin-bottom: 1rem; }
.q .q-week { display: inline-block; margin-bottom: 0.4rem; padding: 0.1rem 0.55rem; border-radius: 999px; background: var(--teal-soft); color: var(--teal); font-size: 0.75rem; font-weight: 600; }
.q .q-opts button.sel { background: var(--teal-soft); border-color: var(--teal); }
.q .q-opts button.sel .k { color: var(--teal); }
.ut-quiz.locked .q-opts button.sel:disabled { opacity: 1; }
.ut-actions { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-top: 1rem; }
.ut-count { font-size: 0.9rem; color: var(--ink-3); }
.ut-result { display: flex; flex-wrap: wrap; align-items: center; gap: 1.25rem; margin-top: 1rem; padding: 1.1rem 1.25rem; border-radius: var(--r); background: var(--ink); color: #fff; box-shadow: 0 4px 16px -4px rgba(0, 0, 0, 0.15); animation: rise 300ms var(--ease-out) both; }
.ut-result[hidden] { display: none; }
.ut-result h4 { color: #fff; margin-bottom: 0.3rem; }
.ut-score { display: flex; align-items: baseline; gap: 0.3rem; }
.ut-score b { font-size: 2.6rem; line-height: 1; color: var(--amber); }
.ut-score span { color: #aab6bf; }
.ut-chips { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.4rem; }
.ut-chip { padding: 0.15rem 0.6rem; border-radius: 999px; background: rgba(255, 255, 255, 0.12); font-size: 0.8rem; }
.ut-delta { margin-left: 0.4rem; padding: 0.1rem 0.6rem; border-radius: 999px; background: rgba(255, 255, 255, 0.15); font-weight: 700; }
.ut-delta.up { background: rgba(31, 157, 85, 0.3); }
.ut-delta.down { background: rgba(214, 69, 69, 0.3); }
@media (prefers-reduced-motion: reduce) { .ut-result { animation: none; } }

/* ---------- ผู้เรียนในเทอมนี้ ---------- */
.learner-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(5.5rem, 1fr)); gap: 1.1rem 0.6rem; margin-top: 0.9rem; }
.learner-grid li { display: grid; justify-items: center; gap: 0.4rem; text-align: center; }
.avatar-c { width: 3.6rem; height: 3.6rem; border-radius: 50%; display: grid; place-items: center; overflow: hidden; color: #fff; font-family: var(--f-display); font-weight: 700; font-size: 1.3rem; box-shadow: 0 4px 16px -4px rgba(0, 0, 0, 0.25); transition: transform 200ms var(--ease-out); }
.learner-grid li:hover .avatar-c { transform: translateY(-3px); }
.avatar-c img { width: 100%; height: 100%; object-fit: cover; }
.learner-grid .nm { font-size: 0.82rem; line-height: 1.35; }

/* ---------- ย่อแถบเมนูข้าง (จอกว้าง) เลื่อนเข้า-ออก ---------- */
@media (min-width: 1024px) {
  .drawer { grid-template-columns: 18.5rem minmax(0, 1fr); transition: grid-template-columns 320ms cubic-bezier(.4, 0, .2, 1); }
  .drawer.side-collapsed { grid-template-columns: 0 minmax(0, 1fr); }
  .drawer > .drawer-side { overflow-x: hidden; }
  .drawer .side { transition: transform 320ms cubic-bezier(.4, 0, .2, 1), opacity 240ms ease; }
  .drawer.side-collapsed .side { transform: translateX(-100%); opacity: 0; pointer-events: none; }
}
@media (prefers-reduced-motion: reduce) {
  .drawer, .drawer .side { transition: none !important; }
}
#side-toggle { flex: none; margin-right: 0.35rem; }

/* แถบบน: (รหัสวิชา) ชื่อวิชา / เนื้อหาที่เปิดอยู่ */
.topbar .crumb .course-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 0 1 auto; }
.topbar .crumb .course-name .ccode { font-family: var(--f-display); color: var(--copper); font-weight: 700; }
.topbar .crumb .course-name b { flex: none; }
.topbar .crumb .cur { flex: 0 0 auto; max-width: 55%; }
@media (max-width: 640px) { .topbar .crumb .course-name .ccode { display: none; } }

/* ---------- แผนการเรียนแบบรายการ ---------- */
.unit-list + .unit-list { margin-top: 1.75rem; }
.unit-head { display: flex; align-items: center; gap: 0.75rem; padding: 0 0.25rem 0.6rem; }
.unit-head .u { width: 1.9rem; height: 1.9rem; border-radius: 0.55rem; display: grid; place-items: center; background: var(--ink); color: #fff; font-family: var(--f-display); font-weight: 700; font-size: 0.9rem; }
.unit-head h3 { flex: 1; font-size: 1.05rem; margin: 0; }
.unit-head .rng { font-size: 0.82rem; color: var(--ink-3); white-space: nowrap; }
.wk-list { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; box-shadow: 0 4px 16px -4px rgba(0, 0, 0, 0.1); }
.wk-list li + li { border-top: 1px solid var(--line); }
.wk-row { display: flex; align-items: center; gap: 1rem; padding: 0.85rem 1.1rem; color: var(--ink); text-decoration: none; transition: background-color 150ms ease; }
.wk-row .no { flex: none; width: 2.2rem; font-family: var(--f-display); font-weight: 700; font-size: 1.1rem; color: var(--copper); }
.wk-row .bd { flex: 1; min-width: 0; display: grid; gap: 0.15rem; }
.wk-row .tt { font-weight: 600; line-height: 1.35; }
.wk-row .tp { font-size: 0.85rem; color: var(--ink-3); line-height: 1.45; }
.wk-row:hover { background: var(--teal-soft); }
.wk-row .prog { flex: none; width: 5.2rem; display: grid; gap: 0.25rem; justify-items: end; }
.wk-row .prog .pct { font-weight: 700; font-size: 0.9rem; color: var(--ink); line-height: 1; }
.wk-row .prog .bar { width: 100%; height: 5px; border-radius: 3px; background: var(--line); overflow: hidden; }
.wk-row .prog .bar i { display: block; height: 100%; border-radius: 3px; background: linear-gradient(90deg, var(--teal), var(--amber)); transition: width 400ms var(--ease-out); }
.wk-row .go { flex: none; }
.wk-row .go .material-symbols-outlined { font-size: 1.1rem; transition: transform 150ms ease; }
.wk-row .go:hover .material-symbols-outlined { transform: translateX(3px); }
@media (max-width: 560px) { .wk-row { flex-wrap: wrap; } .wk-row .bd { flex-basis: calc(100% - 3.5rem); } .wk-row .prog { margin-left: 3.2rem; } .wk-row .go { margin-left: auto; } }
.wk-row .soon { flex: none; font-size: 0.78rem; color: var(--ink-3); }
.wk-row.soon { opacity: 0.6; }
.wk-row.exam .no { color: var(--teal); }

/* ป้าย "! คำแนะนำ" นำหน้าข้อความแนะนำแบบทดสอบ */
.ut-tip { display: inline-flex; align-items: center; gap: 0.3rem; margin-right: 0.55rem; padding: 0.05rem 0.6rem 0.05rem 0.4rem; border-radius: 999px; background: rgba(217, 115, 43, 0.12); color: var(--copper); vertical-align: middle; }
.ut-tip .material-symbols-outlined { font-size: 1.15rem; }
.ut-tip b { font-weight: 700; }

/* ---------- ย่อ/ขยายแบบทดสอบก่อน-หลังเรียน ---------- */
.ut-fold { display: grid; grid-template-rows: 1fr; transition: grid-template-rows 320ms cubic-bezier(.4, 0, .2, 1), opacity 240ms ease; }
.ut-fold > .ut-fold-in { min-height: 0; overflow: clip; overflow-clip-margin: 0.5rem; }
.ut-fold.collapsed { grid-template-rows: 0fr; opacity: 0; visibility: hidden; transition: grid-template-rows 320ms cubic-bezier(.4, 0, .2, 1), opacity 200ms ease, visibility 0s linear 320ms; }
#pretest .sec-head, #posttest .sec-head { position: relative; }
.ut-fold-btn { position: absolute; right: 0; top: 0; border: 1px solid var(--line); }
#pretest .sec-head h2, #posttest .sec-head h2 { padding-right: 6rem; }   /* เว้นที่ให้ปุ่มย่อ/ขยาย หัวข้อยาวจะขึ้นบรรทัดใหม่แทนการลอดใต้ปุ่ม */
@media (max-width: 560px) { .ut-fold-btn { position: static; grid-column: 1 / -1; justify-self: end; margin-top: 0.4rem; } #pretest .sec-head h2, #posttest .sec-head h2 { padding-right: 0; } }
@media (prefers-reduced-motion: reduce) { .ut-fold, .ut-fold.collapsed { transition: none; } }

/* คลิกเมนูสารบัญด้านข้าง: เลื่อนนุ่ม + หัวข้อที่ไปถึงเฟดไฮไลต์สั้น ๆ */
@keyframes sec-flash { 0% { background-color: rgba(14, 143, 134, 0.14); } 100% { background-color: transparent; } }
.sec.sec-flash { animation: sec-flash 1400ms ease-out; border-radius: 1rem; }
@media (prefers-reduced-motion: reduce) { .sec.sec-flash { animation: none; } }

/* ภาพตัดผลิตภัณฑ์: ฝังอยู่ในผลิตภัณฑ์ (สลับ "เปิดฝาดูข้างใน") */
.emb-fig { margin: 1.25rem 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 1rem 1.1rem 1rem; box-shadow: 0 4px 16px -4px rgba(0,0,0,.12); position: relative; }
.emb-chk { position: absolute; opacity: 0; pointer-events: none; }
.emb-bar { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; margin-bottom: .5rem; }
.emb-switch { display: inline-flex; align-items: center; gap: .6rem; cursor: pointer; font-weight: 600; font-size: .92rem; user-select: none; }
.emb-switch .on { display: none; }
.emb-chk:checked ~ .emb-bar .emb-switch .on { display: inline; }
.emb-chk:checked ~ .emb-bar .emb-switch .off { display: none; }
.emb-switch .tg { width: 2.6rem; height: 1.45rem; border-radius: 999px; background: var(--line); position: relative; transition: background-color 200ms ease; }
.emb-switch .tg i { position: absolute; left: .18rem; top: .18rem; width: 1.09rem; height: 1.09rem; border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.3); transition: transform 250ms var(--ease-out); }
.emb-chk:checked ~ .emb-bar .emb-switch .tg { background: var(--teal); }
.emb-chk:checked ~ .emb-bar .emb-switch .tg i { transform: translateX(1.15rem); }
.emb-chk:focus-visible ~ .emb-bar .emb-switch .tg { outline: 2px solid var(--teal); outline-offset: 2px; }
.emb-fig svg { width: 100%; height: auto; display: block; font-family: inherit; }
.emb-fig .lb { font-size: 15px; fill: var(--ink-2); font-weight: 600; }
.emb-fig .u circle, .emb-fig .u path { fill: var(--ink-3); opacity: .55; }
.emb-fig .arr { stroke: var(--ink-3); stroke-width: 3; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.emb-fig .body { fill: #fff; stroke: var(--ink); stroke-width: 4; }
.emb-fig .panel { fill: #e8e5db; stroke: var(--ink-3); stroke-width: 2; }
.emb-fig .disp { fill: var(--ink); } .emb-fig .dtxt { fill: var(--amber); font-size: 16px; font-weight: 700; font-family: var(--f-display); }
.emb-fig .btn1 { fill: #fff; stroke: var(--ink-3); stroke-width: 2; } .emb-fig .btn2 { fill: var(--copper); }
.emb-fig .door { fill: #dfe9ea; stroke: var(--ink); stroke-width: 5; } .emb-fig .door2 { fill: #c3d4d6; stroke: var(--ink-3); stroke-width: 3; }
.emb-fig .shell { transition: opacity 450ms ease; }
.emb-chk:checked ~ svg .shell { opacity: .08; }
.emb-fig .inner { opacity: 0; transition: opacity 450ms ease 120ms; }
.emb-chk:checked ~ svg .inner { opacity: 1; }
.emb-fig .pcb { fill: #cfe6df; stroke: var(--teal); stroke-width: 2.5; }
.emb-fig .chip { fill: var(--ink); stroke: var(--copper); stroke-width: 3; }
.emb-chk:checked ~ svg .chip { animation: emb-pulse 1.6s ease-in-out infinite; }
@keyframes emb-pulse { 0%,100% { stroke-width: 3; } 50% { stroke-width: 7; } }
.emb-fig .ctxt { fill: #fff; font-size: 17px; font-weight: 700; font-family: var(--f-display); }
.emb-fig .pins path { stroke: var(--ink-3); stroke-width: 3; }
.emb-fig .wire { stroke: var(--teal); stroke-width: 3; fill: none; stroke-dasharray: 6 5; }
.emb-chk:checked ~ svg .wire { animation: emb-dash 700ms linear infinite; }
@keyframes emb-dash { to { stroke-dashoffset: -11; } }
.emb-fig .sens { fill: #fdf3dc; stroke: var(--amber); stroke-width: 2.5; }
.emb-fig .motor { fill: #e8eef0; stroke: var(--ink); stroke-width: 3; }
.emb-fig .pwr { fill: #fde8d8; stroke: var(--copper); stroke-width: 2.5; }
.emb-fig .stxt { fill: var(--ink); font-size: 14px; font-weight: 600; }
.emb-fig .lead { stroke: var(--copper); stroke-width: 2; fill: none; } .emb-fig .lead.hid { display: none; }
.emb-fig .note { font-size: 16px; fill: var(--ink); font-weight: 700; } .emb-fig .note .hl { fill: var(--copper); }
.emb-fig .cap { font-size: 15px; fill: var(--ink-2); transition: opacity 350ms ease; }
.emb-fig .cap-on { opacity: 0; } .emb-chk:checked ~ svg .cap-on { opacity: 1; } .emb-chk:checked ~ svg .cap-off { opacity: 0; }
.emb-cap { margin-top: .5rem; font-size: .88rem; color: var(--ink-3); line-height: 1.6; }
@media (max-width: 560px) { .emb-fig .cap, .emb-fig .note { font-size: 13px; } }
@media (prefers-reduced-motion: reduce) { .emb-chk:checked ~ svg .chip, .emb-chk:checked ~ svg .wire { animation: none; } .emb-fig .shell, .emb-fig .inner, .emb-switch .tg, .emb-switch .tg i { transition: none; } }

/* ภาพตัดผลิตภัณฑ์: เลือกตัวอย่าง 4 แบบ (เครื่องซักผ้า/ตู้เย็น/ลิฟต์/ประตูอัตโนมัติ) */
.emb-r { position: absolute; opacity: 0; pointer-events: none; }
.emb-fig svg { display: none; }
.emb-r1:checked ~ .emb-s1, .emb-r2:checked ~ .emb-s2, .emb-r3:checked ~ .emb-s3, .emb-r4:checked ~ .emb-s4 { display: block; animation: rise 300ms var(--ease-out) both; }
.emb-tabs { display: flex; flex-wrap: wrap; gap: .4rem; margin: .3rem 0 .6rem; }
.emb-tabs label { cursor: pointer; padding: .3rem .85rem; border-radius: 999px; border: 1px solid var(--line); font-size: .88rem; font-weight: 600; color: var(--ink-2); background: var(--card); transition: background-color 150ms ease, color 150ms ease, border-color 150ms ease; }
.emb-tabs label:hover { border-color: var(--teal); }
.emb-r1:checked ~ .emb-tabs label[for=emb-p1], .emb-r2:checked ~ .emb-tabs label[for=emb-p2], .emb-r3:checked ~ .emb-tabs label[for=emb-p3], .emb-r4:checked ~ .emb-tabs label[for=emb-p4] { background: var(--ink); color: #fff; border-color: var(--ink); }
.emb-r:focus-visible ~ .emb-tabs { outline: 2px solid var(--teal); outline-offset: 3px; border-radius: 999px; }
.emb-fig .hdl { fill: var(--ink-3); }
.emb-fig .glass { fill: #d6e6ea; stroke: var(--ink-3); stroke-width: 2.5; }
.emb-fig .cab { fill: #fdf3dc; stroke: var(--amber); stroke-width: 2.5; }
.emb-fig .stxt-s { font-size: 12px; } .emb-fig .ctxt-s { font-size: 14px; } .emb-fig .dtxt-l { font-size: 26px; }
.emb-fig .arr-o { stroke: var(--copper); stroke-width: 4; }

/* แอนิเมชันกำลังตรวจคำตอบ (หลังกดส่งแบบทดสอบก่อนเรียน) */
.ut-result.grading { gap: 1rem; }
.ut-spin { display: inline-flex; color: var(--amber); }
.ut-spin .material-symbols-outlined { font-size: 2.2rem; animation: ut-rot 900ms linear infinite; }
@keyframes ut-rot { to { transform: rotate(360deg); } }
.ut-gr { display: grid; gap: .35rem; min-width: min(18rem, 70vw); }
.ut-gr b { color: #fff; }
.ut-gr-n { font-size: .85rem; color: #aab6bf; }
.ut-gr-bar { height: 6px; border-radius: 4px; background: rgba(255,255,255,.15); overflow: hidden; }
.ut-gr-bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--teal), var(--amber)); transition: width 120ms linear; }
@media (prefers-reduced-motion: reduce) { .ut-spin .material-symbols-outlined { animation: none; } }

.ut-actions[hidden] { display: none; }
#pretest .ut-result, #posttest .ut-result { margin-top: 1rem; }

/* ผลรายหัวข้อ: สีบอกจุดแข็ง/จุดอ่อน */
.ut-chip.good { background: rgba(31, 157, 85, 0.35); }
.ut-chip.mid { background: rgba(242, 179, 61, 0.35); }
.ut-chip.weak { background: rgba(214, 69, 69, 0.45); }
.ut-legend { flex-basis: 100%; font-size: .75rem; color: #aab6bf; }

/* กล่อง callout ที่ต่อจากการ์ด/ตาราง: เว้นระยะเท่าส่วนอื่น (1.5rem) ไม่ให้ติดกัน */
.sec .card-c + .callout, .sec .tbl-wrap + .callout, .sec .code + .callout, .sec .emb-fig + .callout { margin-top: 1.5rem; }

/* แผนผังความคิด: องค์ประกอบหลักของระบบสมองกลฝังตัว */
.mm-fig { margin: 1.25rem 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 1rem 1.1rem 1.1rem; box-shadow: 0 4px 16px -4px rgba(0,0,0,.12); }
.mm-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: .3rem .75rem; margin-bottom: .4rem; }
.mm-head span { font-size: .85rem; color: var(--ink-3); }
.mm-scroll { overflow-x: auto; overflow-y: hidden; overscroll-behavior-y: auto; }
.mm-scroll svg { display: block; width: 100%; min-width: 600px; height: auto; font-family: inherit; }
.mm-br { fill: none; stroke: var(--ink-3); stroke-width: 3; stroke-linecap: round; stroke-dasharray: 7 6; animation: mm-dash 900ms linear infinite; opacity: .7; }
@keyframes mm-dash { to { stroke-dashoffset: -13; } }
.mm-center ellipse { fill: var(--ink); stroke: var(--copper); stroke-width: 5; animation: emb-pulse 2.2s ease-in-out infinite; }
.mm-cap { fill: #fff; font-size: 24px; font-weight: 700; font-family: var(--f-display); }
.mm-cs { fill: #c9d2d9; font-size: 13px; }
.mm-node { opacity: 0; animation: mm-pop 520ms var(--ease-out) forwards; transform-origin: center; transform-box: fill-box; }
@keyframes mm-pop { from { opacity: 0; transform: scale(.88); } to { opacity: 1; transform: none; } }
.mm-node rect { fill: #fff; stroke-width: 3; }
.mm-node.c-teal rect { stroke: var(--teal); } .mm-node.c-copper rect { stroke: var(--copper); } .mm-node.c-amber rect { stroke: var(--amber); } .mm-node.c-ink rect { stroke: var(--ink); }
.mm-ic { font-family: 'Material Symbols Outlined'; font-size: 30px; fill: var(--ink-2); }
.mm-node.c-teal .mm-ic { fill: var(--teal); } .mm-node.c-copper .mm-ic { fill: var(--copper); } .mm-node.c-amber .mm-ic { fill: #b07a0c; }
.mm-t { font-size: 18px; font-weight: 700; fill: var(--ink); }
.mm-s { font-size: 14px; fill: var(--ink-2); }
@media (prefers-reduced-motion: reduce) { .mm-br, .mm-center ellipse { animation: none; } .mm-node { animation: none; opacity: 1; } }

/* เว้นระยะระหว่างบล็อกที่ต่อกันในหัวข้อ (ตาราง/การ์ด/ข้อความ) 1.5rem ไม่ให้ติดกัน */
.sec .tbl-wrap + .card-c, .sec .tbl-wrap + .prose-c, .sec .card-c + .card-c, .sec .card-c + .prose-c, .sec .card-c + .callout, .sec .prose-c + .card-c, .sec .callout + .card-c, .sec .callout + .prose-c, .sec .mm-fig + .tbl-wrap, .sec .mm-fig + .prose-c { margin-top: 1.5rem; }

.off-screen, .off-screen * { animation-play-state: paused !important; }

.sec .card-c .steps-c { margin-top: 1rem; }
.sec .mm-fig + .card-c, .sec .tbl-wrap + .mm-fig { margin-top: 1.5rem; }
.sec .tbl-wrap + .tbl-wrap, .sec .card-c + .tbl-wrap { margin-top: 1.5rem; }

/* สีสถานะอุปกรณ์ในแผนผัง: แสงสว่าง เปิด=เหลือง ปิด=เทา · อุปกรณ์ เปิด=ฟ้า ปิด=เทา (node kind:'light' | 'device') */
.pf-node.k-light .ic, .pf-node.k-device .ic { background: #eceff1; color: #8b97a1; border-color: #cfd6db; transition: background-color 250ms ease, color 250ms ease, border-color 250ms ease; }
.pf-node.k-light.on .ic { background: #fde68a; color: #a86f00; border-color: #f2b33d; box-shadow: 0 0 0 4px rgba(242, 179, 61, 0.25), var(--sh-1); }
.pf-node.k-device.on .ic { background: #cfe5fb; color: #1f6fc2; border-color: #3b8ee0; box-shadow: 0 0 0 4px rgba(59, 142, 224, 0.2), var(--sh-1); }

/* เซ็นเซอร์ที่ทำงาน = สีส้ม (node kind:'sensor', สถานะ on = กำลังตรวจจับ) */
.pf-node.k-sensor .ic { background: var(--card); color: #8b97a1; border-color: #cfd6db; transition: background-color 250ms ease, color 250ms ease, border-color 250ms ease; }
.pf-node.k-sensor.on .ic { background: #ffd9b3; color: #c25a00; border-color: #f08a24; box-shadow: 0 0 0 4px rgba(240, 138, 36, 0.25), var(--sh-1); }
/* ป้ายจำลอง: ตัวเลขแบบไฟ LED (node disp:'3') */
.pf-node .disp { font-family: var(--f-mono); font-weight: 700; font-size: 1.55rem; letter-spacing: .06em; line-height: 1; color: #ffcf57; text-shadow: 0 0 8px rgba(255, 207, 87, .55); }
.pf-node .disp.flash { animation: rise 300ms var(--ease-out); }
.pf-node.k-sign .ic { width: 5.4rem; background: #1b2630; border-color: #3a4a58; }
.pf-sm .pf-node.k-sign .ic { width: 4rem; } .pf-sm .pf-node .disp { font-size: 1.1rem; }

/* โหนดกราฟ (node chart:"x,y x,y …"): เส้นกราฟขึ้น-ลงค่อย ๆ วาดเมื่อข้อมูลถึง (data-draw) */
.pf-node .ic:has(> svg.chart) { width: 7.4rem; height: 4rem; background: #1b2630; border-color: #3a4a58; }
.pf-sm .pf-node .ic:has(> svg.chart) { width: 5rem; height: 2.8rem; }
.pf-node svg.chart { width: 100%; height: 100%; display: block; }
.pf-node svg.chart .ax { stroke: #566676; stroke-width: 1.5; fill: none; }
.pf-node svg.chart .ln { fill: none; stroke: #ffcf57; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 260; stroke-dashoffset: 260; }
.pf-node.drawn svg.chart .ln { animation: pf-draw 2200ms ease-out forwards; }
@keyframes pf-draw { to { stroke-dashoffset: 0; } }
@media (prefers-reduced-motion: reduce) { .pf-node.drawn svg.chart .ln { animation: none; stroke-dashoffset: 0; } }

/* วงจรชีวิตผลิตภัณฑ์ 5 ขั้นตอน (กราฟิกนิ่ง) */
.lc-fig { margin: 1.25rem 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 1rem 1.1rem .8rem; box-shadow: 0 4px 16px -4px rgba(0,0,0,.12); }
.lc-scroll { overflow-x: auto; overflow-y: hidden; }
.lc-scroll svg { display: block; width: 100%; min-width: 640px; height: auto; font-family: inherit; }
.lc-card rect { fill: #fff; stroke-width: 3; }
.lc-card.c1 rect { stroke: var(--teal); } .lc-card.c2 rect { stroke: var(--copper); } .lc-card.c3 rect { stroke: var(--amber); } .lc-card.c4 rect { stroke: var(--ink); } .lc-card.c5 rect { stroke: var(--teal); }
.lc-n { fill: var(--ink); } .lc-nt { fill: #fff; font-size: 17px; font-weight: 700; font-family: var(--f-display); }
.lc-ic { font-family: 'Material Symbols Outlined'; font-size: 44px; fill: var(--ink-2); text-anchor: start; }
.lc-card.c1 .lc-ic, .lc-card.c5 .lc-ic { fill: var(--teal); } .lc-card.c2 .lc-ic { fill: var(--copper); } .lc-card.c3 .lc-ic { fill: #b07a0c; }
.lc-t { font-size: 18px; font-weight: 700; fill: var(--ink); } .lc-e { font-size: 13px; fill: var(--ink-3); font-family: var(--f-display); letter-spacing: .04em; }
.lc-d { font-size: 14px; fill: var(--ink-2); }
.lc-ar { fill: none; stroke: var(--ink-3); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.lc-back { fill: none; stroke: var(--ink-3); stroke-width: 3; stroke-dasharray: 8 7; stroke-linecap: round; }
.lc-bt { font-size: 15px; font-weight: 600; fill: var(--ink-2); }

/* การ์ดอธิบายแต่ละขั้นตอนของวงจรชีวิต: หัวข้อย่อย + รายการ */
.card-c .stage { margin-top: 1.1rem; }
.card-c .stage h4 { font-family: var(--f-thai-head); font-weight: 700; font-size: 1.02rem; margin: 0 0 .45rem; color: var(--ink); }
.card-c .stage + .stage { padding-top: 1rem; border-top: 1px dashed var(--line); }

/* กล่อง "ผลลัพธ์ที่ได้" ท้ายแต่ละขั้นของวงจรชีวิต */
.card-c .stage-result { display: flex; align-items: flex-start; gap: .6rem; margin-top: .85rem; padding: .7rem .95rem; border-radius: .8rem; background: rgba(14, 143, 134, 0.1); border: 1px solid rgba(14, 143, 134, 0.35); border-left: 5px solid var(--teal); line-height: 1.55; }
.card-c .stage-result > .material-symbols-outlined { flex: none; color: var(--teal); font-size: 1.5rem; margin-top: .05rem; }
.card-c .stage-result b { display: block; font-family: var(--f-thai-head); font-size: .8rem; letter-spacing: .04em; color: var(--teal); }

/* แผนภาพบล็อก 3 ตัวอย่าง (แท็บ) */
.bd-fig { margin: 1.25rem 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 1rem 1.1rem 1rem; box-shadow: 0 4px 16px -4px rgba(0,0,0,.12); position: relative; }
.bd-r { position: absolute; opacity: 0; pointer-events: none; }
.bd-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .4rem .9rem; }
.bd-bar span { font-size: .82rem; color: var(--ink-3); display: inline-flex; align-items: center; gap: .35rem; }
.bd-bar i { display: inline-block; width: 1.5rem; height: 0; border-top: 3px solid var(--teal); margin-left: .6rem; } .bd-bar i.k-p { border-top: 3px dashed var(--copper); }
.bd-tabs { display: flex; flex-wrap: wrap; gap: .4rem; margin: .5rem 0 .6rem; }
.bd-tabs label { cursor: pointer; padding: .3rem .85rem; border-radius: 999px; border: 1px solid var(--line); font-size: .88rem; font-weight: 600; color: var(--ink-2); background: var(--card); transition: background-color 150ms ease, color 150ms ease, border-color 150ms ease; }
.bd-tabs label:hover { border-color: var(--teal); }
.bd-r1:checked ~ .bd-tabs label[for=bd-p1], .bd-r2:checked ~ .bd-tabs label[for=bd-p2], .bd-r3:checked ~ .bd-tabs label[for=bd-p3], .bd-r4:checked ~ .bd-tabs label[for=bd-p4] { background: var(--ink); color: #fff; border-color: var(--ink); }
.bd-r1:checked ~ .bd-tabs label:nth-of-type(1), .bd-r2:checked ~ .bd-tabs label:nth-of-type(2), .bd-r3:checked ~ .bd-tabs label:nth-of-type(3), .bd-r4:checked ~ .bd-tabs label:nth-of-type(4) { background: var(--ink); color: #fff; border-color: var(--ink); }
.bd-r:focus-visible ~ .bd-tabs { outline: 2px solid var(--teal); outline-offset: 3px; border-radius: 999px; }
.bd-scroll { overflow-x: auto; overflow-y: hidden; }
.bd-scroll svg { display: none; width: 100%; min-width: 620px; height: auto; font-family: inherit; }
.bd-r1:checked ~ .bd-scroll .bd-s1, .bd-r2:checked ~ .bd-scroll .bd-s2, .bd-r3:checked ~ .bd-scroll .bd-s3, .bd-r4:checked ~ .bd-scroll .bd-s4 { display: block; animation: rise 300ms var(--ease-out) both; }
.bd-b rect { fill: #fff; stroke-width: 3; }
.bd-in rect, .bd-out rect, .bd-com rect, .bd-mcu rect { stroke: var(--teal); }
.bd-mt { fill: var(--ink); font-size: 26px; font-weight: 700; font-family: var(--f-display); } .bd-ms { fill: var(--ink-3); font-size: 13px; }
.bd-ic { font-family: 'Material Symbols Outlined'; font-size: 28px; fill: var(--teal); text-anchor: start; }
.bd-t { font-size: 15px; font-weight: 700; fill: var(--ink); } .bd-s { font-size: 12px; fill: var(--ink-3); }
.bd-a { fill: none; stroke: var(--teal); stroke-width: 3; stroke-linejoin: round; }
.bd-p { fill: none; stroke: var(--copper); stroke-width: 3; stroke-dasharray: 8 6; stroke-linejoin: round; }
.bd-l { font-size: 12px; fill: var(--ink-3); } .bd-lg { font-size: 12px; fill: var(--ink-3); }
.bd-cap { margin-top: .5rem; font-size: .88rem; color: var(--ink-3); line-height: 1.6; }
.bd-cap span { display: none; }
.bd-r1:checked ~ .bd-cap .bd-c1, .bd-r2:checked ~ .bd-cap .bd-c2, .bd-r3:checked ~ .bd-cap .bd-c3, .bd-r4:checked ~ .bd-cap .bd-c4 { display: inline; }

/* สวิตช์สลับชื่อตัวแปร ↔ ค่าจริง ในแผนภาพ (ทางที่ไม่ได้ไปจะจางลง) */
.bd-bar .bd-sw { display: inline-flex; align-items: center; gap: .5rem; cursor: pointer; font-size: .85rem; font-weight: 600; color: var(--ink-2); }
.bd-sw .toggle:checked { border-color: var(--teal); background-color: var(--teal); color: #fff; }
.bd-fig .bd-t.v1 { display: none; fill: var(--ink); }
.bd-fig .bd-t.v1 .n, .bd-fig .bd-t.v1.bd-pop { fill: var(--copper); }
.bd-fig .bd-t.v1 .k { fill: var(--teal); }
.bd-fig:has(.bd-v:checked) .bd-t.v1 { display: inline; }
.bd-fig:has(.bd-v:checked) .bd-t.v0 { display: none; }
[data-br] { transition: opacity 250ms ease; }
.bd-fig .bd-fade { opacity: .2; }

/* ปุ่มจำลองการทำงานของผังงาน (assets/js/flow-sim.js) แสดงเมื่อเปิดสวิตช์ค่าจริง */
.bd-ctl { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .8rem; }
.bd-bar .bd-play { display: none; align-items: center; gap: .3rem; padding: .3rem .85rem .3rem .6rem; border-radius: 999px; background: var(--ink); color: #fff; font-size: .82rem; font-weight: 600; cursor: pointer; transition: background-color 150ms ease, transform 150ms ease; }
.bd-bar .bd-play:hover { background: var(--copper); transform: translateY(-1px); }
.bd-bar .bd-play:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
.bd-bar .bd-play .material-symbols-outlined { font-size: 18px; color: inherit; }
.bd-fig:has(.bd-v:checked) .bd-play { display: inline-flex; }
.bd-status { display: none; margin-top: .6rem; padding: .55rem .85rem; border-radius: .6rem; border-left: 3px solid var(--copper); background: var(--copper-soft); color: var(--ink); font-size: .9rem; font-weight: 600; line-height: 1.6; }
.bd-fig:has(.bd-v:checked) .bd-status { display: block; }
.bd-b rect, .bd-b path { transition: fill 200ms ease, stroke 200ms ease; }
.bd-fig .bd-b.on rect, .bd-fig .bd-b.on path { stroke: var(--copper) !important; fill: #fdf0e6 !important; }
.bd-fig .bd-a.on { stroke: var(--copper); stroke-width: 4; }
.bd-pop { transform-box: fill-box; transform-origin: center; pointer-events: none; }
/* กรณีไม่ผ่าน: กล่องและลูกศรสีแดงค้างไว้จนรีเซ็ต */
.bd-fig .bd-b.bad rect, .bd-fig .bd-b.bad path { stroke: var(--danger) !important; fill: #fdecec !important; }
.bd-fig .bd-b.bad .bd-t, .bd-fig .bd-b.bad .bd-t .n, .bd-fig .bd-b.bad .bd-t.v1.bd-pop { fill: var(--danger); }
.bd-fig .bd-a.bad, .bd-fig .bd-a.bad-now { stroke: var(--danger); stroke-width: 4; }
.bd-status.bad { border-left-color: var(--danger); background: rgba(214, 69, 69, .08); color: var(--danger); }
/* โจทย์ของแต่ละแท็บ แสดงตามแท็บที่เลือก */
.bd-q { margin: .1rem 0 .7rem; padding: .6rem .9rem; border-radius: .6rem; border-left: 3px solid var(--teal); background: var(--teal-soft); color: var(--ink); font-size: .95rem; line-height: 1.6; }
.bd-q span { display: none; }
.bd-q b { color: var(--teal); margin-right: .5rem; }
.bd-r1:checked ~ .bd-q .bd-q1, .bd-r2:checked ~ .bd-q .bd-q2, .bd-r3:checked ~ .bd-q .bd-q3, .bd-r4:checked ~ .bd-q .bd-q4 { display: inline; }
/* แถบตัวแปรในหน่วยความจำระหว่างจำลอง (สร้างโดย flow-sim.js จาก data-vars) */
.bd-mem { display: none; flex-wrap: wrap; gap: .5rem; margin-top: .6rem; }
.bd-fig:has(.bd-v:checked) .bd-mem:not(:empty) { display: flex; }
.bd-mem::before { content: 'ตัวแปรในหน่วยความจำ'; width: 100%; font-size: .8rem; color: var(--ink-3); }
.bd-mem .mv { display: flex; flex-direction: column; min-width: 6rem; padding: .35rem .75rem .4rem; border: 1px solid var(--line); border-radius: .6rem; background: var(--card); transition: border-color 150ms ease, box-shadow 150ms ease; }
.bd-mem .mv b { font-size: .82rem; color: var(--ink-2); }
.bd-mem .mv span { font-family: var(--f-mono); font-size: 1.2rem; font-weight: 700; color: var(--copper); line-height: 1.3; }
.bd-mem .mv small { font-size: .72rem; color: var(--ink-3); }
.bd-mem .mv.chg { animation: memflash 600ms ease-out; }
.bd-mem .mv.out { border-color: var(--teal); box-shadow: 0 0 0 2px var(--teal-soft); }
.bd-mem .mv.out small::after { content: ' → แสดงผล'; color: var(--teal); font-weight: 700; }
@keyframes memflash { from { background-color: var(--copper-soft); transform: translateY(-3px); } to { background-color: var(--card); transform: none; } }
@media (prefers-reduced-motion: reduce) { .bd-mem .mv.chg { animation: none; } }
/* ปุ่มเลือกกรณี (สร้างโดย flow-sim.js) */
.bd-cases { display: none; flex-wrap: wrap; align-items: center; gap: .4rem; margin: .1rem 0 .6rem; }
.bd-fig:has(.bd-v:checked) .bd-cases:not(:empty) { display: flex; }
.bd-cases::before { content: 'กรณี'; font-size: .82rem; color: var(--ink-3); margin-right: .15rem; }
.bd-cases[data-title]::before { content: attr(data-title); }
.bd-cases.always:not(:empty) { display: flex; }
.bd-scroll .bd-variants { display: none; }
.bd-scroll .bd-variants svg { display: none; }
.bd-scroll .bd-variants svg.on { display: block; }
.bd-cases button { padding: .25rem .8rem; border-radius: 999px; border: 1px dashed var(--copper); background: var(--card); color: var(--ink-2); font-size: .82rem; font-weight: 600; cursor: pointer; transition: background-color 150ms ease, color 150ms ease; }
.bd-cases button:hover { background: var(--copper-soft); }
.bd-cases button[aria-pressed=true] { background: var(--copper); border-style: solid; color: #fff; }
@media (prefers-reduced-motion: reduce) { .bd-b rect, .bd-b path, .bd-bar .bd-play { transition: none; } }

/* การ์ดรหัสเทียมเทียบผังงาน: ซ้ายรหัสเทียม ขวาผังงาน ชี้บรรทัดหรือกล่องแล้วอีกฝั่งไฮไลต์ตาม (เลขบรรทัด = ป้ายเลขบนผัง) */
.pc-pane { display: none; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); gap: 1rem; align-items: start; }
.bd-r1:checked ~ .bd-scroll .pc-pane.bd-s1, .bd-r2:checked ~ .bd-scroll .pc-pane.bd-s2, .bd-r3:checked ~ .bd-scroll .pc-pane.bd-s3, .bd-r4:checked ~ .bd-scroll .pc-pane.bd-s4 { display: grid; }
@media (max-width: 720px) { .pc-pane { grid-template-columns: 1fr; } }
.bd-scroll .pc-pane svg { display: block; min-width: 0; width: 100%; }
.pc-pane .code { margin: 0; }
.pc-pane .code pre { counter-reset: pl; }
.pc-pane .pl { display: block; margin: 0 -.5rem; padding: 0 .5rem; border-radius: .35rem; cursor: pointer; outline: none; transition: background-color 150ms ease; }
.pc-pane .pl::before { counter-increment: pl; content: counter(pl); display: inline-block; width: 1.7rem; color: #6f8796; }
.pc-pane .bd-t { font-size: 21px; }
.pc-pane .bd-l { font-size: 15px; }
.pc-pane .bd-b rect, .pc-pane .bd-b path { cursor: pointer; }
.pc-tag circle { fill: var(--ink); transition: fill 150ms ease; }
.pc-tag text { fill: #fff; font-size: 14px; font-weight: 700; text-anchor: middle; }
.bd-bar .pc-hint { font-size: .8rem; color: var(--ink-3); }
.pc-pane:has([data-n="1"]:hover, [data-n="1"]:focus) .pl[data-n="1"] { background: rgba(217, 115, 43, .3); }
.pc-pane:has([data-n="1"]:hover, [data-n="1"]:focus) g.bd-b[data-n="1"] rect, .pc-pane:has([data-n="1"]:hover, [data-n="1"]:focus) g.bd-b[data-n="1"] path { stroke: var(--copper) !important; fill: #fdf0e6 !important; }
.pc-pane:has([data-n="1"]:hover, [data-n="1"]:focus) .bd-a[data-n="1"] { stroke: var(--copper); stroke-width: 4; }
.pc-pane:has([data-n="1"]:hover, [data-n="1"]:focus) .pc-tag[data-n="1"] circle { fill: var(--copper); }
.pc-pane:has([data-n="2"]:hover, [data-n="2"]:focus) .pl[data-n="2"] { background: rgba(217, 115, 43, .3); }
.pc-pane:has([data-n="2"]:hover, [data-n="2"]:focus) g.bd-b[data-n="2"] rect, .pc-pane:has([data-n="2"]:hover, [data-n="2"]:focus) g.bd-b[data-n="2"] path { stroke: var(--copper) !important; fill: #fdf0e6 !important; }
.pc-pane:has([data-n="2"]:hover, [data-n="2"]:focus) .bd-a[data-n="2"] { stroke: var(--copper); stroke-width: 4; }
.pc-pane:has([data-n="2"]:hover, [data-n="2"]:focus) .pc-tag[data-n="2"] circle { fill: var(--copper); }
.pc-pane:has([data-n="3"]:hover, [data-n="3"]:focus) .pl[data-n="3"] { background: rgba(217, 115, 43, .3); }
.pc-pane:has([data-n="3"]:hover, [data-n="3"]:focus) g.bd-b[data-n="3"] rect, .pc-pane:has([data-n="3"]:hover, [data-n="3"]:focus) g.bd-b[data-n="3"] path { stroke: var(--copper) !important; fill: #fdf0e6 !important; }
.pc-pane:has([data-n="3"]:hover, [data-n="3"]:focus) .bd-a[data-n="3"] { stroke: var(--copper); stroke-width: 4; }
.pc-pane:has([data-n="3"]:hover, [data-n="3"]:focus) .pc-tag[data-n="3"] circle { fill: var(--copper); }
.pc-pane:has([data-n="4"]:hover, [data-n="4"]:focus) .pl[data-n="4"] { background: rgba(217, 115, 43, .3); }
.pc-pane:has([data-n="4"]:hover, [data-n="4"]:focus) g.bd-b[data-n="4"] rect, .pc-pane:has([data-n="4"]:hover, [data-n="4"]:focus) g.bd-b[data-n="4"] path { stroke: var(--copper) !important; fill: #fdf0e6 !important; }
.pc-pane:has([data-n="4"]:hover, [data-n="4"]:focus) .bd-a[data-n="4"] { stroke: var(--copper); stroke-width: 4; }
.pc-pane:has([data-n="4"]:hover, [data-n="4"]:focus) .pc-tag[data-n="4"] circle { fill: var(--copper); }
.pc-pane:has([data-n="5"]:hover, [data-n="5"]:focus) .pl[data-n="5"] { background: rgba(217, 115, 43, .3); }
.pc-pane:has([data-n="5"]:hover, [data-n="5"]:focus) g.bd-b[data-n="5"] rect, .pc-pane:has([data-n="5"]:hover, [data-n="5"]:focus) g.bd-b[data-n="5"] path { stroke: var(--copper) !important; fill: #fdf0e6 !important; }
.pc-pane:has([data-n="5"]:hover, [data-n="5"]:focus) .bd-a[data-n="5"] { stroke: var(--copper); stroke-width: 4; }
.pc-pane:has([data-n="5"]:hover, [data-n="5"]:focus) .pc-tag[data-n="5"] circle { fill: var(--copper); }
.pc-pane:has([data-n="6"]:hover, [data-n="6"]:focus) .pl[data-n="6"] { background: rgba(217, 115, 43, .3); }
.pc-pane:has([data-n="6"]:hover, [data-n="6"]:focus) g.bd-b[data-n="6"] rect, .pc-pane:has([data-n="6"]:hover, [data-n="6"]:focus) g.bd-b[data-n="6"] path { stroke: var(--copper) !important; fill: #fdf0e6 !important; }
.pc-pane:has([data-n="6"]:hover, [data-n="6"]:focus) .bd-a[data-n="6"] { stroke: var(--copper); stroke-width: 4; }
.pc-pane:has([data-n="6"]:hover, [data-n="6"]:focus) .pc-tag[data-n="6"] circle { fill: var(--copper); }
.pc-pane:has([data-n="7"]:hover, [data-n="7"]:focus) .pl[data-n="7"] { background: rgba(217, 115, 43, .3); }
.pc-pane:has([data-n="7"]:hover, [data-n="7"]:focus) g.bd-b[data-n="7"] rect, .pc-pane:has([data-n="7"]:hover, [data-n="7"]:focus) g.bd-b[data-n="7"] path { stroke: var(--copper) !important; fill: #fdf0e6 !important; }
.pc-pane:has([data-n="7"]:hover, [data-n="7"]:focus) .bd-a[data-n="7"] { stroke: var(--copper); stroke-width: 4; }
.pc-pane:has([data-n="7"]:hover, [data-n="7"]:focus) .pc-tag[data-n="7"] circle { fill: var(--copper); }
.pc-pane:has([data-n="8"]:hover, [data-n="8"]:focus) .pl[data-n="8"] { background: rgba(217, 115, 43, .3); }
.pc-pane:has([data-n="8"]:hover, [data-n="8"]:focus) g.bd-b[data-n="8"] rect, .pc-pane:has([data-n="8"]:hover, [data-n="8"]:focus) g.bd-b[data-n="8"] path { stroke: var(--copper) !important; fill: #fdf0e6 !important; }
.pc-pane:has([data-n="8"]:hover, [data-n="8"]:focus) .bd-a[data-n="8"] { stroke: var(--copper); stroke-width: 4; }
.pc-pane:has([data-n="8"]:hover, [data-n="8"]:focus) .pc-tag[data-n="8"] circle { fill: var(--copper); }
.pc-pane:has([data-n="9"]:hover, [data-n="9"]:focus) .pl[data-n="9"] { background: rgba(217, 115, 43, .3); }
.pc-pane:has([data-n="9"]:hover, [data-n="9"]:focus) g.bd-b[data-n="9"] rect, .pc-pane:has([data-n="9"]:hover, [data-n="9"]:focus) g.bd-b[data-n="9"] path { stroke: var(--copper) !important; fill: #fdf0e6 !important; }
.pc-pane:has([data-n="9"]:hover, [data-n="9"]:focus) .bd-a[data-n="9"] { stroke: var(--copper); stroke-width: 4; }
.pc-pane:has([data-n="9"]:hover, [data-n="9"]:focus) .pc-tag[data-n="9"] circle { fill: var(--copper); }

/* แผนภาพบล็อกตัวอย่างพร้อมป้ายชี้ */
.bd-ann .bd-scroll svg { display: block; }
.bd-call rect { fill: var(--ink); stroke: none; }
.bd-call text { fill: #fff; font-size: 13px; font-weight: 700; text-anchor: middle; }
.bd-lead { fill: none; stroke: var(--ink); stroke-width: 1.6; stroke-linecap: round; }

/* ข้อสอบเห็นเฉพาะบทบาทที่มีสิทธิ์ quiz.save_score (course.js ตั้ง html[data-quiz="on"]) */
html:not([data-quiz="on"]) .sec:has(.quiz),
html:not([data-quiz="on"]) .sec#pretest,
html:not([data-quiz="on"]) .sec#posttest,
html:not([data-quiz="on"]) #side-toc a[href="#quiz"],
html:not([data-quiz="on"]) #side-toc a[href="#pretest"],
html:not([data-quiz="on"]) #side-toc a[href="#posttest"] { display: none; }

/* ---------- โปรไฟล์: รูปถ่าย ---------- */
.acct-chip i { overflow: hidden; }
.acct-chip i img { width: 100%; height: 100%; object-fit: cover; }
.acct-photo { display: flex; align-items: center; gap: 1.1rem; margin: 0 0 1.4rem; padding: 0.9rem 1rem; border-radius: 1rem; background: var(--paper); }
.acct-avatar { position: relative; flex: none; width: 5.2rem; height: 5.2rem; border-radius: 50%; background: var(--copper); color: #fff; display: grid; place-items: center; overflow: hidden; box-shadow: 0 6px 16px -6px rgba(24, 35, 44, 0.45); transition: transform 200ms ease; }
.acct-avatar:hover { transform: scale(1.04); }
.acct-avatar b { font-family: var(--f-display); font-size: 2rem; }
.acct-avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.acct-avatar .cam { position: absolute; inset: auto 0 0 0; height: 1.7rem; display: grid; place-items: center; background: rgba(24, 35, 44, 0.55); color: #fff; opacity: 0; transition: opacity 150ms ease; }
.acct-avatar:hover .cam, .acct-avatar:focus-visible .cam { opacity: 1; }
.acct-avatar .cam .material-symbols-outlined { font-size: 1.1rem; }
.acct-photo-t { display: grid; gap: 0.1rem; min-width: 0; }
.acct-photo-t b { font-size: 0.92rem; }
.acct-photo-t small { color: var(--ink-3); font-size: 0.78rem; line-height: 1.4; }
.acct-iw .input:disabled { background: var(--paper); color: var(--ink-2); cursor: not-allowed; }
@media (prefers-reduced-motion: reduce) { .acct-avatar { transition: none; } }

/* ตารางคะแนนสอบ: คอลัมน์ชื่อตรึงซ้าย + แถบเลื่อนแนวนอนแสดงค้างไว้ (macOS ซ่อนแถบเองถ้าไม่กำหนดสไตล์) */
.sc-wrap { scrollbar-width: thin; scrollbar-color: var(--ink-3) var(--paper); }
.sc-wrap::-webkit-scrollbar { height: 10px; }
.sc-wrap::-webkit-scrollbar-track { background: var(--paper); border-radius: 0 0 var(--r) var(--r); }
.sc-wrap::-webkit-scrollbar-thumb { background: var(--ink-3); border-radius: 9999px; border: 2px solid var(--paper); }
.sc-table { width: max-content; min-width: 100%; }
.sc-table th, .sc-table td { white-space: nowrap; text-align: center; }
.sc-table th:first-child, .sc-table td:first-child { position: sticky; left: 0; z-index: 1; text-align: left; background: var(--card); box-shadow: 1px 0 0 var(--line); min-width: 11rem; }
.sc-table th:first-child { background: var(--paper); }
.sc-table tbody tr:hover td:first-child { background: #eaf4f3; }

/* ---------- สถานะออนไลน์ + จัดการเทอม ---------- */
.on-dot { display: inline-block; width: 0.55rem; height: 0.55rem; margin-right: 0.45rem; border-radius: 50%; background: #c3c9ce; vertical-align: middle; flex: none; }
.on-dot.on { background: var(--ok); box-shadow: 0 0 0 3px rgba(31, 157, 85, 0.18); animation: on-pulse 2.2s ease-in-out infinite; }
@keyframes on-pulse { 50% { box-shadow: 0 0 0 5px rgba(31, 157, 85, 0.06); } }
.t-chips { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.t-chip { cursor: pointer; }
.t-chip input { position: absolute; opacity: 0; pointer-events: none; }
.t-chip span { display: block; padding: 0.45rem 0.8rem; border: 1.5px solid var(--line); border-radius: 0.75rem; font-size: 0.9rem; color: var(--ink-2); transition: border-color 150ms ease, background-color 150ms ease, color 150ms ease; }
.t-chip input:checked + span { border-color: var(--teal); background: var(--teal-soft); color: var(--ink); }
.t-chip input:focus-visible + span { outline: 2px solid var(--teal); outline-offset: 2px; }
.t-cell { display: inline-block; min-width: 3.2rem; padding: 0.1rem 0.5rem; border-radius: 9999px; font-family: var(--f-display); font-weight: 700; font-size: 0.82rem; background: var(--paper); color: var(--ink-3); }
.t-cell.part { background: rgba(242, 179, 61, 0.2); color: #8a5d00; }
.t-cell.full { background: rgba(31, 157, 85, 0.12); color: #17753f; }
.t-acts { display: inline-flex; margin-left: 0.3rem; }
.t-acts .btn { min-height: 1.6rem; height: 1.6rem; width: 1.6rem; padding: 0; }
.t-acts .btn .material-symbols-outlined { font-size: 1.1rem; }
.t-ch { font-weight: 700; text-decoration: underline; text-underline-offset: 3px; color: var(--ink-2); transition: color 150ms ease; }
.t-ch:hover { color: var(--teal); }
@media (prefers-reduced-motion: reduce) { .on-dot.on { animation: none; } }

.avatar-c { position: relative; }
.avatar-c .av-dot { position: absolute; right: 0.3rem; bottom: 0.3rem; margin: 0; width: 0.7rem; height: 0.7rem; border: 2px solid var(--card); }

/* ---------- ตัวตัดรูปโปรไฟล์ ---------- */
.crop-stage { position: relative; width: min(18rem, 100%); aspect-ratio: 1; margin: 0 auto; overflow: hidden; border-radius: 1rem; background: #1d262d; cursor: grab; touch-action: none; user-select: none; }
.crop-stage.grab { cursor: grabbing; }
.crop-stage:focus-visible { outline: 2px solid var(--teal); outline-offset: 3px; }
.crop-stage img { position: absolute; left: 0; top: 0; max-width: none; transform-origin: 0 0; pointer-events: none; }
.crop-mask { position: absolute; inset: 0; border-radius: 50%; box-shadow: 0 0 0 100vmax rgba(24, 35, 44, 0.55); border: 2px solid rgba(255, 255, 255, 0.85); pointer-events: none; }
.crop-zoom { display: flex; align-items: center; gap: 0.6rem; width: min(18rem, 100%); margin: 0 auto; color: var(--ink-3); }
.crop-zoom input { flex: 1; accent-color: var(--teal); }
.crop-hint { margin: 0; text-align: center; font-size: 0.8rem; color: var(--ink-3); }
.av-sm { display: inline-grid; place-items: center; width: 1.9rem; height: 1.9rem; margin-right: 0.5rem; border-radius: 50%; background: var(--copper); color: #fff; font-size: 0.8rem; font-weight: 700; overflow: hidden; vertical-align: middle; flex: none; }
.av-sm img { width: 100%; height: 100%; object-fit: cover; }

/* ---------- หน้านักเรียนรายคน (admin-student.html) ---------- */
.stu-grid { display: grid; grid-template-columns: minmax(0, 20rem) minmax(0, 1fr); gap: 1.25rem; align-items: start; }
@media (max-width: 860px) { .stu-grid { grid-template-columns: minmax(0, 1fr); } }
.stu-head { display: grid; gap: 0.5rem; justify-items: center; text-align: center; padding: 1.5rem 1.2rem; }
.stu-head .acct-avatar { width: 7rem; height: 7rem; }
.stu-head .acct-avatar b { font-size: 2.6rem; }
.stu-head h1 { font-family: var(--f-thai-head); font-size: 1.35rem; line-height: 1.2; letter-spacing: -0.02em; margin: 0.4rem 0 0; }
.stu-head > p { margin: 0; color: var(--ink-3); font-size: 0.95rem; }
.stu-meta { display: grid; gap: 0.5rem; width: 100%; margin: 0.6rem 0; padding: 0.8rem 0; border-block: 1px solid var(--line); text-align: left; }
.stu-meta > div { display: flex; justify-content: space-between; gap: 0.8rem; font-size: 0.88rem; }
.stu-meta dt { color: var(--ink-3); }
.stu-meta dd { margin: 0; text-align: right; overflow-wrap: anywhere; }
.course .card-c .stu-h { font-family: var(--f-thai-head); font-size: 1.05rem; line-height: 1.3; letter-spacing: 0; margin: 0 0 0.8rem; }
.stu-term { display: grid; gap: 0.4rem; padding: 0.7rem 0; border-bottom: 1px solid var(--line); }
.stu-term:last-child { border-bottom: 0; }
.stu-row { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; font-size: 0.92rem; }
.stu-add { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.8rem; }
.stu-bar { height: 6px; border-radius: 9999px; background: var(--paper); overflow: hidden; }
.stu-bar i { display: block; height: 100%; background: var(--teal); border-radius: inherit; }
.stu-weeks { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.stu-link { color: var(--ink); text-decoration: none; transition: color 150ms ease; }
.stu-link:hover { color: var(--teal); text-decoration: underline; text-underline-offset: 3px; }

/* ปฏิทิน Flatpickr ในหน้าต่าง: ช่องปลายทางชิดขวา กันล้นขอบ · อยู่เหนือปุ่มด้านล่าง */
.acct-modal .flatpickr-calendar { z-index: 30; box-shadow: 0 12px 28px -10px rgba(24, 35, 44, 0.35); }
.acct-modal .flatpickr-calendar.fp-right { left: auto !important; right: 0 !important; }
.acct-modal .flatpickr-calendar.fp-right::before, .acct-modal .flatpickr-calendar.fp-right::after { left: auto; right: 22px; }

/* ---------- เลือกหลายคน (รายชื่อนักเรียน) ---------- */
.s-bulk { display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.2rem 0.3rem 0.2rem 0.8rem; border-radius: 0.75rem; background: var(--copper-soft); font-size: 0.88rem; animation: acct-err-in 200ms var(--ease-out) both; }
.s-bulk[hidden] { display: none; }
.adm-table tbody tr.sel { background: var(--teal-soft); }
.del-list { margin: 0 0 0.8rem; padding: 0.6rem 0.9rem 0.6rem 1.6rem; list-style: disc; max-height: 11rem; overflow: auto; border-radius: 0.7rem; background: var(--paper); font-size: 0.9rem; line-height: 1.7; }

/* ---------- จุดส่งงาน (assets/js/submit.js) ---------- */
.sp-card { display: grid; gap: 0.9rem; padding: 1.1rem 1.2rem; border-radius: 1rem; background: #fff; border: 1px solid var(--line); box-shadow: 0 4px 16px -8px rgba(24, 35, 44, 0.18); }
.sp-hint { margin: 0; color: var(--ink-2); font-size: 0.92rem; }
.sp-login { grid-template-columns: auto 1fr; align-items: center; gap: 0.9rem; }
.sp-login > .material-symbols-outlined { font-size: 1.8rem; color: var(--copper); }
.sp-login p { margin: 0.15rem 0 0; color: var(--ink-3); font-size: 0.9rem; }
.sp-status { display: flex; gap: 0.7rem; align-items: flex-start; padding: 0.7rem 0.9rem; border-radius: 0.8rem; background: var(--paper); color: var(--ink-3); }
.sp-status > div { display: grid; gap: 0.15rem; min-width: 0; }
.sp-status b { color: var(--ink); }
.sp-status a { color: var(--teal); overflow-wrap: anywhere; text-decoration: underline; text-underline-offset: 3px; }
.sp-status small { font-size: 0.82rem; }
.sp-status.ok { background: rgba(31, 157, 85, 0.1); }
.sp-status.ok > .material-symbols-outlined { color: #17753f; }
.sp-form { display: grid; gap: 0.4rem; }
.sp-form label { font-weight: 600; font-size: 0.9rem; }
.sp-row { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.sp-row input { flex: 1 1 16rem; min-width: 0; padding: 0.6rem 0.8rem; border: 1px solid var(--line); border-radius: 0.7rem; background: #fff; font: inherit; transition: border-color 150ms ease, box-shadow 150ms ease; }
.sp-row input:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px rgba(14, 143, 134, 0.18); }
.sp-send { gap: 0.4rem; background: var(--ink); color: #fff; border: 0; }
.sp-send:hover { background: var(--teal); }
.sp-list { display: grid; gap: 0.5rem; min-width: 0; flex: 1; }
.sp-item { display: flex; align-items: center; gap: 0.6rem; padding: 0.5rem 0.7rem; border-radius: 0.7rem; background: rgba(255, 255, 255, 0.7); }
.sp-item > div { display: grid; gap: 0.1rem; min-width: 0; flex: 1; }
.sp-item > .material-symbols-outlined { color: var(--teal); }
.sp-item small { color: var(--ink-3); }
.sp-item a:not(.btn) { color: var(--teal); overflow-wrap: anywhere; text-decoration: underline; text-underline-offset: 3px; }
.sp-form + .sp-form { padding-top: 0.9rem; border-top: 1px dashed var(--line); }
.sp-row input[type=file] { padding: 0.45rem 0.6rem; }
.sp-row input[type=file]::file-selector-button { margin-right: 0.7rem; padding: 0.35rem 0.8rem; border: 0; border-radius: 0.5rem; background: var(--paper); font: inherit; cursor: pointer; transition: background-color 150ms ease; }
.sp-row input[type=file]::file-selector-button:hover { background: var(--teal-soft); }
.lab-link { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem; }
.lab-link .btn { gap: 0.4rem; }
.btn-share { gap: 0.4rem; background: #fff; border: 1px solid var(--line); color: var(--ink); transition: background-color 150ms ease, border-color 150ms ease; }
.btn-share:hover { background: var(--teal-soft); border-color: var(--teal); }
.sp-fs { display: grid; gap: 0.9rem; border: 0; padding: 0; margin: 0; min-width: 0; }
.sp-fs:disabled { opacity: 0.55; }
.sp-login-note { align-items: center; }
.sp-login-note > div { flex: 1; }
.sp-login-note > .material-symbols-outlined { color: var(--copper); }
.sp-lab { font-weight: 600; font-size: 0.9rem; }
.sp-drop { display: grid; justify-items: center; gap: 0.25rem; padding: 1.6rem 1rem; text-align: center; cursor: pointer; border: 2px dashed #b9c4cc; border-radius: 1rem; background: var(--paper); transition: background-color 150ms ease, border-color 150ms ease, transform 150ms ease; }
.sp-drop:hover { border-color: var(--teal); background: var(--teal-soft); }
.sp-drop.over { border-color: var(--copper); background: var(--copper-soft); transform: scale(1.01); }
.sp-drop.has { border-style: solid; border-color: var(--teal); }
.sp-drop > .material-symbols-outlined { font-size: 2.6rem; color: var(--teal); }
.sp-drop.over > .material-symbols-outlined { color: var(--copper); }
.sp-drop b { font-family: var(--f-thai-head); font-size: 1.05rem; }
.sp-drop span:not(.material-symbols-outlined) { color: var(--ink-2); font-size: 0.92rem; }
.sp-drop small { color: var(--ink-3); }
.sp-drop input[type=file] { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.sp-picked { display: flex; align-items: center; gap: 0.6rem; padding: 0.5rem 0.8rem; border-radius: 0.7rem; background: rgba(31, 157, 85, 0.1); }
.sp-picked[hidden] { display: none; }
.sp-picked > .material-symbols-outlined { color: #17753f; }
.sp-picked .sp-pname { flex: 1; min-width: 0; overflow-wrap: anywhere; font-weight: 600; }
.sp-up { justify-self: start; }
.sp-up:disabled { opacity: 0.45; }
@media (prefers-reduced-motion: reduce) { .sp-drop { transition: none; } .sp-drop.over { transform: none; } }

/* ---------- การ์ด 5 ส่วนในอุปกรณ์ IoT: กดเพื่อดูตัวอย่าง (<details>) ---------- */
.pc-grid { display: grid; gap: 1.5rem; grid-template-columns: repeat(6, minmax(0, 1fr)); align-items: start; margin-top: 1.5rem; }
.pc-grid > .pc { grid-column: span 2; padding: 0; overflow: hidden; }
.pc-grid > .pc:nth-child(n+4) { grid-column: span 3; }
@media (max-width: 900px) { .pc-grid { grid-template-columns: minmax(0, 1fr); } .pc-grid > .pc, .pc-grid > .pc:nth-child(n+4) { grid-column: auto; } }
.pc > summary { display: block; list-style: none; cursor: pointer; padding-bottom: 1rem; transition: background-color 150ms ease; }
.pc > summary::-webkit-details-marker { display: none; }
.pc > summary:hover { background: rgba(14, 143, 134, 0.04); }
.pc > summary:focus-visible { outline: 3px solid rgba(14, 143, 134, 0.45); outline-offset: -3px; border-radius: 1rem; }
.pc-art { background: var(--paper); margin-bottom: 0.9rem; }
.pc-head { display: flex; align-items: center; gap: 0.6rem; padding: 0 1.2rem; }
.pc-head h3 { margin: 0; }
.pc-no { display: inline-grid; place-items: center; width: 1.7rem; height: 1.7rem; border-radius: 9999px; background: var(--ink); color: #fff; font-family: var(--f-display); font-weight: 700; font-size: 0.85rem; flex: none; }
.pc-text { margin: 0.45rem 0 0; padding: 0 1.2rem; font-size: 0.92rem; color: var(--ink-2); line-height: 1.6; }
.pc-hint { display: inline-flex; align-items: center; gap: 0.3rem; margin: 0.8rem 1.2rem 0; padding: 0.3rem 0.75rem 0.3rem 0.9rem; border-radius: 9999px; background: var(--teal-soft); color: var(--teal); font-weight: 600; font-size: 0.85rem; }
.pc-hint .material-symbols-outlined { font-size: 1.2rem; transition: transform 200ms ease-out; }
.pc[open] .pc-hint .material-symbols-outlined { transform: rotate(180deg); }
.pc .when-open, .pc[open] .when-closed { display: none; }
.pc[open] .when-open { display: inline; }
.pc-body { padding: 0 1.2rem 1.3rem; border-top: 1px dashed var(--line); margin-top: 0.2rem; }
.pc[open] .pc-body { animation: pcIn 240ms ease-out; }
.pc-body h4 { margin: 1rem 0 0.5rem; font-size: 0.95rem; }
.pc-body ul { display: grid; gap: 0.45rem; margin: 0; padding: 0; list-style: none; }
.pc-body li { display: grid; gap: 0.05rem; padding: 0.5rem 0.8rem; border-radius: 0.7rem; background: var(--paper); }
.pc-body li b { font-size: 0.92rem; }
.pc-body li span { font-size: 0.85rem; color: var(--ink-3); }
@keyframes pcIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .pc[open] .pc-body { animation: none; } .pc-hint .material-symbols-outlined { transition: none; } }
.pc-grid > .pc { margin-top: 0 !important; }
.pc-art svg { display: block; width: 100%; height: 112px; }
@media (min-width: 901px) { .pc-grid > .pc:nth-child(n+4) .pc-body ul { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ---------- การ์ดส่วนประกอบเป็นปุ่มเปิดป๊อปอัปแผนที่ความคิด ---------- */
button.pc { display: block; width: 100%; text-align: left; font: inherit; color: inherit; cursor: pointer; padding: 0 0 1.1rem; transition: transform 200ms ease-out, box-shadow 200ms ease-out; }
button.pc:hover { transform: translateY(-3px); box-shadow: 0 12px 24px -10px rgba(24, 35, 44, 0.3); }
button.pc:focus-visible { outline: 3px solid rgba(14, 143, 134, 0.45); outline-offset: 2px; }
button.pc .pc-art, button.pc .pc-head, button.pc .pc-text { display: block; }
button.pc .pc-head { display: flex; }
button.pc .pc-hint { margin-top: 0.9rem; }
button.pc:hover .pc-hint { background: var(--teal); color: #fff; }
.pc-hint { transition: background-color 150ms ease, color 150ms ease; }
.pc-dlg { width: min(62rem, 94vw); max-width: none; max-height: 92vh; padding: 0; border: 0; border-radius: 1.2rem; background: var(--card, #fff); color: var(--ink); box-shadow: 0 24px 60px -16px rgba(0, 0, 0, 0.5); overflow: hidden; }
.pc-dlg[open] { animation: pcDlgIn 260ms ease-out; }
.pc-dlg::backdrop { background: rgba(24, 35, 44, 0.55); }
.pc-dlg[open]::backdrop { animation: pcFade 260ms ease-out; }
.pc-dlg-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.9rem 1.2rem; border-bottom: 1px solid var(--line); }
.pc-dlg-head h3 { display: flex; align-items: center; gap: 0.5rem; margin: 0; font-family: var(--f-thai-head); font-size: 1.2rem; }
.pc-dlg-head h3 .material-symbols-outlined { color: var(--copper); }
.pc-dlg .mm-scroll { padding: 0.6rem 1rem 0.2rem; max-height: calc(92vh - 7rem); }
.pc-dlg .mm-scroll svg { min-width: 640px; }
.pc-dlg-note { margin: 0; padding: 0.3rem 1.2rem 0.9rem; text-align: center; font-size: 0.82rem; color: var(--ink-3); }
.pm-txt { display: grid; gap: 0.15rem; align-content: center; height: 100%; font-family: inherit; line-height: 1.35; }
.pm-txt b { font-size: 16px; color: var(--ink); }
.pm-txt span { font-size: 13px; color: var(--ink-2); }
@keyframes pcDlgIn { from { opacity: 0; transform: translateY(12px) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes pcFade { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .pc-dlg[open], .pc-dlg[open]::backdrop { animation: none; } button.pc { transition: none; } button.pc:hover { transform: none; } }

/* ---------- การ์ดหลายหน้า: 5 ส่วนในอุปกรณ์ IoT ---------- */
.pc-pager { padding: 0; overflow: hidden; margin-top: 1.5rem; }
.pc-tabs { display: flex; gap: 0.4rem; padding: 0.7rem 0.8rem; overflow-x: auto; overflow-y: hidden; border-bottom: 1px solid var(--line); background: var(--paper); }
.pc-tab { display: inline-flex; align-items: center; gap: 0.45rem; flex: none; padding: 0.4rem 0.85rem 0.4rem 0.45rem; border: 0; border-radius: 9999px; background: transparent; color: var(--ink-2); font: inherit; font-weight: 600; font-size: 0.9rem; cursor: pointer; transition: background-color 150ms ease, color 150ms ease; }
.pc-tab:hover { background: rgba(14, 143, 134, 0.1); }
.pc-tab[aria-selected="true"] { background: var(--ink); color: #fff; }
.pc-tab[aria-selected="true"] .pc-no { background: var(--copper); }
.pc-tab:focus-visible { outline: 3px solid rgba(14, 143, 134, 0.45); outline-offset: 2px; }
.pc-page { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); align-items: stretch; }
.pc-page[hidden] { display: none; }
.pc-page.in { animation: pcSlide 260ms ease-out; }
.pc-page .pc-art { display: grid; align-items: center; margin: 0; background: var(--paper); padding: 1rem; }
.pc-page .pc-art svg { height: 210px; width: 100%; }
.pc-info { display: grid; align-content: center; gap: 0.6rem; padding: 1.4rem 1.6rem; justify-items: start; }
.pc-info .pc-head { padding: 0; }
.pc-info .pc-head h3 { font-size: 1.3rem; }
.pc-info .pc-text { margin: 0; padding: 0; font-size: 1rem; }
.pc-info .pc-hint { margin: 0.3rem 0 0; border: 0; font: inherit; font-weight: 600; font-size: 0.92rem; padding: 0.55rem 1rem 0.55rem 0.85rem; cursor: pointer; background: var(--teal); color: #fff; }
.pc-info .pc-hint:hover { background: var(--ink); }
.pc-info .pc-hint:focus-visible { outline: 3px solid rgba(14, 143, 134, 0.45); outline-offset: 2px; }
.pc-nav { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; padding: 0.55rem 0.8rem; border-top: 1px solid var(--line); background: var(--paper); }
.pc-count { font-family: var(--f-display); font-weight: 700; font-size: 0.9rem; color: var(--ink-3); }
.pc-dlg-foot { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; padding: 0.4rem 0.8rem 0.7rem; border-top: 1px solid var(--line); }
.pc-dlg-foot span { font-size: 0.8rem; color: var(--ink-3); text-align: center; }
@media (max-width: 760px) { .pc-page { grid-template-columns: minmax(0, 1fr); } .pc-page .pc-art svg { height: 170px; } .pc-dlg-foot span { display: none; } }
@keyframes pcSlide { from { opacity: 0; transform: translateX(14px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .pc-page.in { animation: none; } .pc-tab { transition: none; } }

/* ---------- 4 ชั้นของระบบ IoT แบบอ่านง่าย: เรียงแนวตั้งเหมือนชั้นของอาคาร (วัด · ส่ง · คิด · แสดง) ---------- */
.ls-wrap { margin: 1.25rem 0 1.5rem; display: grid; gap: 0.7rem; }
.ls-axes { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.ls-axis { display: flex; align-items: center; gap: 0.4rem; margin: 0; font-size: 0.9rem; font-weight: 700; }
.ls-axis .material-symbols-outlined { font-size: 1.25rem; }
.ls-up { color: var(--teal); }
.ls-down { color: var(--copper); justify-content: flex-end; }
.ls-body { display: grid; grid-template-columns: 1.4rem minmax(0, 1fr) 1.4rem; gap: 0.8rem; align-items: stretch; }
.ls-rail { position: relative; border-radius: 9999px; }
.ls-rail-up { background: repeating-linear-gradient(to top, var(--teal) 0 8px, transparent 8px 16px); width: 4px; justify-self: center; animation: lsUp 1.2s linear infinite; }
.ls-rail-down { background: repeating-linear-gradient(to bottom, var(--copper) 0 8px, transparent 8px 16px); width: 4px; justify-self: center; animation: lsDown 1.2s linear infinite; }
@keyframes lsUp { to { background-position: 0 -16px; } }
@keyframes lsDown { to { background-position: 0 16px; } }
.ls-flow { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.9rem; }
.ls { display: grid; grid-template-columns: 9.5rem minmax(0, 1.1fr) minmax(0, 1fr); gap: 1.1rem; align-items: center; padding: 1rem 1.2rem; border-radius: 1.1rem; background: #fff; border: 2px solid var(--ls, var(--teal)); border-left-width: 8px; box-shadow: 0 6px 18px -8px rgba(24, 35, 44, 0.25); transition: transform 200ms ease-out, box-shadow 200ms ease-out; }
.ls:hover { transform: translateX(3px); box-shadow: 0 10px 22px -8px rgba(24, 35, 44, 0.3); }
.ls-1 { --ls: #18232c; } .ls-2 { --ls: #c9741a; } .ls-3 { --ls: #2f86dc; } .ls-4 { --ls: #0e8f86; }
.ls-h { display: grid; grid-template-columns: auto 1fr; grid-template-areas: "ic step" "ic verb"; align-items: center; column-gap: 0.7rem; }
.ls-ic { grid-area: ic; display: grid; place-items: center; width: 3.2rem; height: 3.2rem; border-radius: 0.95rem; background: var(--ls); color: #fff; }
.ls-ic .material-symbols-outlined { font-size: 1.8rem; }
.ls-step { grid-area: step; align-self: end; font-size: 0.78rem; font-weight: 700; letter-spacing: 0.04em; color: var(--ink-3); }
.ls-verb { grid-area: verb; align-self: start; font-family: var(--f-thai-head); font-size: 2rem; line-height: 1.1; color: var(--ls); }
.ls-b, .ls-s { display: grid; gap: 0.4rem; min-width: 0; }
.ls-name { font-weight: 700; font-size: 1.05rem; }
.ls-name small { margin-left: 0.4rem; font-weight: 500; font-size: 0.75rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-3); }
.ls-role { margin: 0; font-size: 0.92rem; color: var(--ink-2); line-height: 1.55; }
.ls-like { margin: 0; font-size: 0.85rem; color: var(--ink-2); line-height: 1.5; padding: 0.35rem 0.6rem; border-radius: 0.6rem; background: var(--paper); }
.ls-like span { margin-right: 0.35rem; font-weight: 700; color: var(--ls); }
.ls-ex { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.ls-ex i { font-style: normal; font-size: 0.78rem; padding: 0.1rem 0.55rem; border-radius: 9999px; border: 1px solid var(--line); color: var(--ink-2); }
.ls-case { padding: 0.55rem 0.75rem; border-radius: 0.7rem; background: color-mix(in srgb, var(--ls) 9%, #fff); font-size: 0.9rem; line-height: 1.5; }
.ls-case span { display: block; margin-bottom: 0.1rem; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.05em; color: var(--ls); }
.ls-foot { margin: 0; font-size: 0.85rem; color: var(--ink-3); line-height: 1.6; }
@media (max-width: 960px) { .ls { grid-template-columns: 8.5rem minmax(0, 1fr); } .ls-s { grid-column: 1 / -1; } }
@media (max-width: 640px) { .ls-body { grid-template-columns: minmax(0, 1fr); } .ls-rail { display: none; } .ls { grid-template-columns: minmax(0, 1fr); } .ls-axes { grid-template-columns: 1fr; } .ls-down { justify-content: flex-start; } }
@media (prefers-reduced-motion: reduce) { .ls-rail-up, .ls-rail-down { animation: none; } .ls { transition: none; } .ls:hover { transform: none; } }

/* ---------- ตัวอย่างระบบจริงแยก 4 ชั้น + การ์ดการใช้งาน ---------- */
.sx-page { grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); }
.sx-page .pc-art svg { height: 270px; }
.sx-rows { display: grid; gap: 0.6rem; align-content: center; padding: 1.1rem 1.3rem; }
.sx-row { display: flex; align-items: center; gap: 0.8rem; padding: 0.6rem 0.8rem; border-radius: 0.9rem; background: color-mix(in srgb, var(--ls) 8%, #fff); border-left: 6px solid var(--ls); }
.sx-ic { display: grid; place-items: center; flex: none; width: 2.4rem; height: 2.4rem; border-radius: 0.7rem; background: var(--ls); color: #fff; }
.sx-ic .material-symbols-outlined { font-size: 1.4rem; }
.sx-row > div { display: grid; gap: 0.1rem; min-width: 0; }
.sx-tag { font-size: 0.74rem; font-weight: 700; letter-spacing: 0.03em; color: var(--ls); }
.sx-row b { font-size: 0.95rem; line-height: 1.45; }
.uc-grid { display: grid; gap: 1.5rem; grid-template-columns: repeat(3, minmax(0, 1fr)); margin: 0.6rem 0 1.6rem; }
.uc-grid > .card-c { margin-top: 0 !important; }
.uc-art { display: block; width: 100%; height: 120px; }
@media (max-width: 960px) { .uc-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .uc-grid { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 760px) { .sx-page { grid-template-columns: minmax(0, 1fr); } .sx-page .pc-art svg { height: 220px; } }


/* ประสิทธิภาพ: หยุดอนิเมชัน CSS ที่วนไม่รู้จบของแอนิเมชันที่อยู่นอกจอ + จำกัดการ repaint ให้อยู่ในกรอบ */
figure.anim.anim-offscreen *, figure.anim.anim-offscreen *::after { animation-play-state: paused !important; }
