/* ปุ่มสลับโหมด */
.theme-toggle{
  width:46px;height:46px;flex:0 0 46px;display:inline-flex;align-items:center;justify-content:center;
  border:2px solid #fff;border-radius:16px;background:#fff3d3;color:#805a18;
  box-shadow:0 4px 0 #e8d8b6,0 7px 16px rgba(80,104,150,.10);
  cursor:pointer;transition:transform .16s,filter .16s,background .2s;
}
.theme-toggle:hover{transform:translateY(-2px);filter:brightness(1.03)}
.theme-toggle:active{transform:translateY(1px)}
.theme-icon{font-size:23px;line-height:1}
.theme-toggle:focus-visible{outline:3px solid #65bce2;outline-offset:3px}

/* โหมดมืด: กลางคืนสีน้ำเงินม่วง อ่านสบายตา */
body[data-theme="dark"]{
  --ink:#edf1ff;--muted:#c0c9df;--paper:#111a2d;--line:#384866;
  --purple:#aaa0ff;--pale:#302e50;--shadow:0 12px 28px rgba(0,0,0,.26);
  color:var(--ink);
  background:
    radial-gradient(circle at 18px 18px,rgba(173,190,255,.12) 1.5px,transparent 2px) 0 0/38px 38px,
    linear-gradient(180deg,#101a30 0%,#171b35 58%,#211b38 100%);
}
body[data-theme="dark"] .topbar,
body[data-theme="dark"] .top{
  background:rgba(17,26,45,.97);border-bottom:2px solid #35435f;
  box-shadow:0 4px 16px rgba(0,0,0,.18);
}
body[data-theme="dark"] .brand-name,
body[data-theme="dark"] .brand{color:#edf1ff}
body[data-theme="dark"] .brand-sub,
body[data-theme="dark"] .sub{color:#b9c4dc}
body[data-theme="dark"] .grade-pill,
body[data-theme="dark"] .pill{
  background:#37334f;color:#ffe4a5;border-color:#665b83;
}
body[data-theme="dark"] .theme-toggle{
  background:#36334f;color:#ffe5a8;border-color:#686184;
  box-shadow:0 4px 0 #292740,0 7px 16px rgba(0,0,0,.2);
}
body[data-theme="dark"] .hero{
  background:linear-gradient(115deg,#263c62 0%,#443c72 55%,#59416f 100%);
  border-color:#465477;box-shadow:0 8px 0 #273653,0 17px 32px rgba(0,0,0,.28);
}
body[data-theme="dark"] .hero p{color:#e2e7fb}
body[data-theme="dark"] .stats .stat,
body[data-theme="dark"] .stat{
  background:#1b2942;border-color:#3a4b68;box-shadow:0 5px 0 #111b30;
}
body[data-theme="dark"] .stat-icon{background:#333451}
body[data-theme="dark"] .stat small{color:#c1cbe0}
body[data-theme="dark"] .sidebar{
  background:#1b2942;border-color:#3a4b68;box-shadow:0 7px 0 #111b30;
}
body[data-theme="dark"] .side-heading{color:#aebbd4}
body[data-theme="dark"] .side-link{color:#d2daed}
body[data-theme="dark"] .side-link:hover,
body[data-theme="dark"] .side-link.active{
  background:#393550;color:#ffe3a0;
}
body[data-theme="dark"] .side-divider{background:#384866}
body[data-theme="dark"] .side-note{color:#b6c1d8}
body[data-theme="dark"] .section-head h2,
body[data-theme="dark"] .intro h2{color:#f0edff}
body[data-theme="dark"] .section-head p,
body[data-theme="dark"] .intro p{color:#c0c9df}
body[data-theme="dark"] .text-link{color:#c3bbff}
body[data-theme="dark"] .strand-card,
body[data-theme="dark"] .lesson-card,
body[data-theme="dark"] .card{
  background:#1b2942;border-color:#3a4b68;
  box-shadow:0 5px 0 #111b30,0 9px 20px rgba(0,0,0,.16);
}
body[data-theme="dark"] .strand-card:hover,
body[data-theme="dark"] .lesson-card:hover,
body[data-theme="dark"] .card:hover{
  background:#23334f;border-color:#758ac0;
  box-shadow:0 7px 0 #111b30,0 14px 23px rgba(0,0,0,.23);
}
body[data-theme="dark"] .strand-card h3,
body[data-theme="dark"] .lesson-card h3,
body[data-theme="dark"] .card h3{color:#f0edff}
body[data-theme="dark"] .strand-card p,
body[data-theme="dark"] .lesson-card p,
body[data-theme="dark"] .card p{color:#c0c9df}
body[data-theme="dark"] .strand-meta{color:#b4bfd8}
body[data-theme="dark"] .strand-meta b{color:#c9c1ff}
body[data-theme="dark"] .lesson-number{background:#353553!important;color:#d4ceff}
body[data-theme="dark"] .detail,
body[data-theme="dark"] .online-media,
body[data-theme="dark"] .info,
body[data-theme="dark"] .curriculum-note{
  background:#1b2942;border-color:#3a4b68;
  box-shadow:0 6px 0 #111b30,0 12px 24px rgba(0,0,0,.17);
}
body[data-theme="dark"] .detail h2,
body[data-theme="dark"] .detail-block h3,
body[data-theme="dark"] .quiz h3,
body[data-theme="dark"] .online-head h2,
body[data-theme="dark"] .info strong,
body[data-theme="dark"] .curriculum-note strong{color:#f0edff}
body[data-theme="dark"] .detail-sub,
body[data-theme="dark"] .done-label,
body[data-theme="dark"] .curriculum-note,
body[data-theme="dark"] .info{color:#c0c9df}
body[data-theme="dark"] .learning-goal{
  background:#263c56;border-left-color:#69c5df;color:#e8f4ff;
}
body[data-theme="dark"] .point{color:#d6def0}
body[data-theme="dark"] .point i{color:#c5baff}
body[data-theme="dark"] .example-box{
  background:#403a32;border-color:#716044;color:#fff0cd;
}
body[data-theme="dark"] .activity-box{
  background:#203e3b;border-color:#3d7061;color:#d8f7e7;
}
body[data-theme="dark"] .quiz{
  background:#292846;border-color:#49456c;
}
body[data-theme="dark"] .quiz-question{color:#f0edff}
body[data-theme="dark"] .quiz-option{
  background:#1d2b45;border-color:#465675;color:#e4e9f8;
}
body[data-theme="dark"] .quiz-option.selected{background:#393553;border-color:#a69ae9;color:#f2edff}
body[data-theme="dark"] .quiz-option.correct{background:#204638;border-color:#56a980;color:#e0ffed}
body[data-theme="dark"] .quiz-option.wrong{background:#523536;border-color:#bd7975;color:#ffe9e6}
body[data-theme="dark"] .back,
body[data-theme="dark"] .btn-soft{
  background:#393651;color:#f5e7b8;
}
body[data-theme="dark"] .btn-primary{background:linear-gradient(135deg,#6861c9,#8c7bd4)}
body[data-theme="dark"] .online-mark{background:#283c56}
body[data-theme="dark"] .media-card{
  background:#202e49;border-color:#40516f;box-shadow:0 4px 0 #111b30;
}
body[data-theme="dark"] .media-card h3{color:#f1efff}
body[data-theme="dark"] .media-card p{color:#c5cfe2}
body[data-theme="dark"] .media-type{color:#c8c0ff}
body[data-theme="dark"] .media-credit{color:#b3bfd8;border-top-color:#455571}
body[data-theme="dark"] .media-note{
  background:#403b32;color:#ffedc5;
}
body[data-theme="dark"] .curriculum-note a,
body[data-theme="dark"] .info a{color:#c7c0ff}
body[data-theme="dark"] .empty{
  background:#1b2942;border-color:#596a89;color:#c0c9df;
}
body[data-theme="dark"] footer,
body[data-theme="dark"] .footer{color:#aebbd4}
body[data-theme="dark"] .toc-drawer{
  background:linear-gradient(160deg,#1e2d49 0%,#17243b 58%,#292342 100%);
  border-left-color:#465675;box-shadow:-18px 0 48px rgba(0,0,0,.4);
}
body[data-theme="dark"] .toc-drawer-head{border-bottom-color:#40516f}
body[data-theme="dark"] .toc-drawer-head h2{color:#f1efff}
body[data-theme="dark"] .toc-drawer-subtitle{color:#c0c9df}
body[data-theme="dark"] .toc-drawer-content .side-link{
  background:#24334f;border-color:#435473;color:#e4e9f8;
}
body[data-theme="dark"] .toc-drawer-content .side-link:hover{
  background:#393651;border-color:#77709e;color:#ffe5ac;
}
body[data-theme="dark"] .toc-drawer-content .side-link.active,
body[data-theme="dark"] .toc-drawer-content .side-link[aria-current="page"]{
  background:#29445d;border-color:#69b9d4;color:#e7f7ff;box-shadow:inset 4px 0 #69c5df;
}
body[data-theme="dark"] .toc-index{background:#383652;color:#e4ddff}
body[data-theme="dark"] .toc-home-link{background:#403b32!important;border-color:#75664a!important;color:#ffe8b5!important}
body[data-theme="dark"] .toc-home-icon{background:#5a4c35;color:#ffe6a9}
body[data-theme="dark"] .toc-close{background:#393651;border-color:#716b91;color:#f8e8b8}
body[data-theme="dark"] .toc-launcher{
  background:linear-gradient(120deg,#49446f,#3b5d7a);color:#f4efff;border-color:#8495ca;
  box-shadow:0 5px 0 #252d4b,0 12px 26px rgba(0,0,0,.28);
}
body[data-theme="dark"] .toc-backdrop{background:rgba(4,8,20,.62)}
body[data-theme="dark"] .search input{background:#202e49;border-color:#40516f;color:#f1efff}
body[data-theme="dark"] .search input::placeholder{color:#aebbd4}
body[data-theme="dark"] .search span{color:#c0c9df}
