/* สร้างโดย build_web.py จาก _build/src อย่าแก้ไฟล์นี้โดยตรง
   ฉบับนักเรียน: เน้นมือถือ เลือกห้องก่อน แล้วเห็นคาบที่กำลังเรียน ตารางรายวัน และตารางทั้งสัปดาห์ */
/* Layout: ธีม dsudemy.net (Bento Grid โทนน้ำเงิน) บนพื้นลายจุด ใช้ร่วมกันทั้งสองฉบับ ตารางทั้งสัปดาห์ตามแบบฟอร์มเดิมของโรงเรียน พิมพ์เป็น A4 แนวนอนหนึ่งตารางต่อหน้า */
:root {
  --bg: #f2f4f7;
  --dot: rgba(16, 24, 40, 0.12);
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --ink: #101828;
  --ink-2: #354052;
  --muted: #5d6b82;
  --line: rgba(16, 24, 40, 0.08);
  --line-strong: rgba(16, 24, 40, 0.14);
  --accent: #0033ff;
  --accent-hover: #002cde;
  --on-accent: #ffffff;
  --accent-ink: #0033ff;
  --accent-soft: #e9f0ff;
  --accent-soft-2: #d0dfff;
  --navy: #0a1a4f;
  --navy-deep: #071238;
  --on-navy: #ffffff;
  --on-navy-2: #c7d3f5;
  --on-navy-accent: #8fa9ff;
  --navy-line: rgba(255, 255, 255, 0.14);
  --warn-bg: #fffaeb;
  --warn-fg: #b54708;
  --chip-bg: #f2f4f7;
  --chip-fg: #354052;
  --glow: rgba(0, 51, 255, 0.38);
  --shadow: rgba(16, 24, 40, 0.35);
  --grid-line: #cbced4;
  --chip-on: #0a1a4f;
  --qr-bg: #ffffff;
  --qr-fg: #000000;
  --font-display: "Anuphan", "IBM Plex Sans Thai", "Noto Sans Thai", system-ui, sans-serif;
  --font-body: "IBM Plex Sans Thai", "Noto Sans Thai", system-ui, sans-serif;
  --r-xl: 28px;
  --r-lg: 22px;
  --r-md: 18px;
  --r-sm: 12px;
  --r-pill: 999px;
  --gutter: clamp(16px, 3vw, 24px);
  --maxw: 1240px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #060f33;
    --dot: rgba(255, 255, 255, 0.07);
    --surface: #0d1a47;
    --surface-2: #12215a;
    --ink: #f2f4f7;
    --ink-2: #c7d3f5;
    --muted: #93a4c8;
    --line: rgba(255, 255, 255, 0.1);
    --line-strong: rgba(255, 255, 255, 0.18);
    --accent: #2952ff;
    --accent-hover: #3d63ff;
    --on-accent: #ffffff;
    --accent-ink: #9fb4ff;
    --accent-soft: rgba(143, 169, 255, 0.16);
    --accent-soft-2: rgba(143, 169, 255, 0.28);
    --navy: #16245e;
    --navy-deep: #040a24;
    --on-navy: #ffffff;
    --on-navy-2: #c7d3f5;
    --on-navy-accent: #8fa9ff;
    --navy-line: rgba(255, 255, 255, 0.16);
    --warn-bg: #3a2a10;
    --warn-fg: #fdb022;
    --chip-bg: rgba(255, 255, 255, 0.08);
    --chip-fg: #c7d3f5;
    --glow: rgba(41, 82, 255, 0.45);
    --shadow: rgba(0, 0, 0, 0.6);
    --grid-line: #3f4a6e;
    --chip-on: #2952ff;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #060f33;
  --dot: rgba(255, 255, 255, 0.07);
  --surface: #0d1a47;
  --surface-2: #12215a;
  --ink: #f2f4f7;
  --ink-2: #c7d3f5;
  --muted: #93a4c8;
  --line: rgba(255, 255, 255, 0.1);
  --line-strong: rgba(255, 255, 255, 0.18);
  --accent: #2952ff;
  --accent-hover: #3d63ff;
  --on-accent: #ffffff;
  --accent-ink: #9fb4ff;
  --accent-soft: rgba(143, 169, 255, 0.16);
  --accent-soft-2: rgba(143, 169, 255, 0.28);
  --navy: #16245e;
  --navy-deep: #040a24;
  --on-navy: #ffffff;
  --on-navy-2: #c7d3f5;
  --on-navy-accent: #8fa9ff;
  --navy-line: rgba(255, 255, 255, 0.16);
  --warn-bg: #3a2a10;
  --warn-fg: #fdb022;
  --chip-bg: rgba(255, 255, 255, 0.08);
  --chip-fg: #c7d3f5;
  --glow: rgba(41, 82, 255, 0.45);
  --shadow: rgba(0, 0, 0, 0.6);
  --grid-line: #3f4a6e;
  --chip-on: #2952ff;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}
[hidden] {
  display: none !important;
}
html {
  scroll-behavior: smooth;
}
body {
  margin: 0;
  background-color: var(--bg);
  background-image: radial-gradient(var(--dot) 1px, transparent 1px);
  background-size: 18px 18px;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}
h1,
h2,
h3 {
  font-family: var(--font-display);
  line-height: 1.3;
  letter-spacing: -0.01em;
  text-wrap: balance;
  margin: 0;
}
p {
  margin: 0;
}
a {
  color: var(--accent-ink);
}
a:hover {
  color: var(--accent-hover);
}
:focus-visible {
  outline: 3px solid var(--on-navy-accent);
  outline-offset: 3px;
  border-radius: 10px;
}
button {
  font: inherit;
  color: inherit;
}
.wrap {
  max-width: var(--maxw);
  margin-inline: auto;
  padding-inline: var(--gutter);
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.skip:focus {
  position: fixed;
  left: 16px;
  top: 16px;
  width: auto;
  height: auto;
  clip: auto;
  z-index: 60;
  background: var(--surface);
  color: var(--accent-ink);
  padding: 10px 14px;
  border-radius: 12px;
}
section {
  scroll-margin-top: 96px;
}
.tnum {
  font-variant-numeric: tabular-nums;
}
.nw {
  white-space: nowrap;
}

/* Header */
.site-header {
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  z-index: 20;
  padding-block: 14px 0;
}
.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 8px 8px 8px 14px;
  box-shadow: 0 10px 26px -18px var(--shadow);
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--ink);
  min-width: 0;
}
.logo {
  flex: 0 0 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  display: grid;
  place-items: center;
}
.logo svg {
  width: 24px;
  height: 24px;
}
.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.3;
  min-width: 0;
}
.brand-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px 8px;
  min-width: 0;
}
.brand-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 17px;
}
.brand-sub {
  font-size: 12px;
  color: var(--muted);
}
.ed-badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 10px;
  border-radius: var(--r-pill);
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.6;
  white-space: nowrap;
}
.tools {
  display: flex;
  gap: 6px;
  align-items: center;
}
.icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  display: grid;
  place-items: center;
  cursor: pointer;
  color: var(--ink);
}
.icon-btn:hover {
  border-color: var(--accent-soft-2);
  color: var(--accent-ink);
}
.icon-btn svg {
  width: 20px;
  height: 20px;
}
@media (max-width: 520px) {
  .brand-sub {
    display: none;
  }
  .brand-name {
    font-size: 15px;
  }
  .logo {
    flex-basis: 40px;
    height: 40px;
  }
}

/* Expired banner */
.expired-wrap {
  padding-top: 16px;
}
.expired {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px 18px;
  border-radius: var(--r-lg);
  background: var(--warn-bg);
  color: var(--warn-fg);
  border: 1px solid currentColor;
  line-height: 1.6;
}
.expired svg {
  flex: 0 0 24px;
  width: 24px;
  height: 24px;
  margin-top: 2px;
}
.expired b {
  display: block;
  font-family: var(--font-display);
  font-size: 17px;
}
.expired .ex-msg {
  display: block;
  font-size: 15px;
  color: var(--ink-2);
}

/* Bento */
.bento {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}
.s2 {
  grid-column: span 2;
}
.r2 {
  grid-row: span 2;
}
.s4 {
  grid-column: 1/-1;
}
.page {
  padding-block: 24px 8px;
}
@media (max-width: 960px) {
  .bento {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .r2 {
    grid-row: auto;
  }
  .page > #top {
    order: 1;
  }
  .page > #nowTile {
    order: 2;
  }
  .page > #timetable {
    order: 3;
  }
  .page > #weekTile {
    order: 4;
  }
  .page > #notesTile {
    order: 5;
  }
  .page > #qrTile {
    order: 6;
  }
}
@media (max-width: 600px) {
  .bento {
    grid-template-columns: minmax(0, 1fr);
  }
  .s2 {
    grid-column: auto;
  }
  .hero-main .node-chip {
    display: none;
  }
}
.tile {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  min-width: 0;
}

/* Hero with class picker */
.hero-main {
  padding: clamp(20px, 3.5vw, 36px);
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.node-chip {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 6px 14px 6px 8px;
  border-radius: var(--r-pill);
  background: var(--chip-bg);
  font-size: 14px;
  font-weight: 500;
  color: var(--chip-fg);
}
.pulse {
  position: relative;
  flex: 0 0 10px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
}
.pulse::after {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  opacity: 0.5;
  animation: pulse 2.4s ease-out infinite;
}
@keyframes pulse {
  0% {
    transform: scale(0.6);
    opacity: 0.6;
  }
  100% {
    transform: scale(1.8);
    opacity: 0;
  }
}
.hero-main h1 {
  font-size: clamp(28px, 3.4vw, 42px);
  font-weight: 700;
  color: var(--ink);
}
.hero-main h1 em {
  font-style: normal;
  color: var(--accent-ink);
}
.lead {
  font-size: 16px;
  color: var(--ink-2);
  max-width: 34em;
}
.hero-text {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.picker {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.ctl {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ctl-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.grades {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 6px;
  max-width: 460px;
}
.chip {
  min-height: 44px;
  padding: 0 16px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink-2);
  font-size: 15px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.grades .chip {
  padding: 0 4px;
  font-weight: 600;
}
.chip:hover {
  border-color: var(--accent);
  color: var(--accent-ink);
}
.chip[aria-pressed="true"] {
  background: var(--chip-on);
  border-color: var(--chip-on);
  color: var(--on-navy);
}

/* Now and next */
.now {
  background: var(--navy);
  border-color: transparent;
  color: var(--on-navy);
  padding: clamp(20px, 3vw, 28px);
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.now-top {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 4px 16px;
}
.eyebrow-dark {
  font-size: 13px;
  font-weight: 600;
  color: var(--on-navy-accent);
  letter-spacing: 0.04em;
}
.now-clock {
  font-size: 14px;
  color: var(--on-navy-2);
}
.now-cls {
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 700;
  line-height: 1.2;
  color: var(--on-navy);
}
.now-block {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.now-lbl {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 600;
  color: var(--on-navy-accent);
}
.now .pulse {
  background: var(--on-navy-accent);
  margin-left: 4px;
}
.now .pulse::after {
  border-color: var(--on-navy-accent);
}
.now-subj {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 700;
  line-height: 1.35;
  color: var(--on-navy);
  overflow-wrap: anywhere;
}
.now-meta {
  font-size: 15px;
  color: var(--on-navy-2);
}
.now-next {
  border-top: 1px solid var(--navy-line);
  padding-top: 14px;
}
.now-next .now-subj {
  font-size: 19px;
}

/* Timetable panel */
.panel {
  padding: clamp(16px, 3.2vw, 32px);
  border-radius: 32px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.sec-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px 20px;
}
.sec-id {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 680px;
  min-width: 0;
}
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--accent-ink);
}
.eyebrow::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}
.sec-title {
  font-size: clamp(26px, 3vw, 36px);
  color: var(--ink);
}
.sec-desc {
  color: var(--ink-2);
  font-size: 15px;
}
.seg {
  display: inline-flex;
  padding: 4px;
  border-radius: 16px;
  background: var(--chip-bg);
  gap: 4px;
}
.seg button {
  min-height: 44px;
  padding: 0 18px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--ink-2);
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
}
.seg button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--accent-ink);
  box-shadow: 0 1px 4px var(--line-strong);
}
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}
.btn {
  min-height: 44px;
  padding: 0 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 14px;
  font-weight: 600;
  text-decoration: none;
  border: none;
  cursor: pointer;
  font-size: 15px;
}
.btn svg {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
}
.btn small {
  font-size: 13px;
  font-weight: 500;
  opacity: 0.85;
}
.btn-primary {
  background: var(--accent);
  color: var(--on-accent);
}
.btn-primary:hover {
  background: var(--accent-hover);
  color: var(--on-accent);
}
.btn-quiet {
  background: var(--chip-bg);
  color: var(--ink);
}
.btn .nm {
  display: inline-block;
  max-width: 100%;
}
.btn-quiet:hover {
  color: var(--accent-ink);
}
.dl-note {
  font-size: 14px;
  color: var(--muted);
}
.panel[data-view="day"] .weekview {
  display: none;
}
.panel[data-view="week"] .dayview {
  display: none;
}

/* Day view */
.dayview {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 780px;
}
.dtabs {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}
.dtab {
  min-height: 58px;
  border-radius: 14px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink-2);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1.3;
  cursor: pointer;
  padding: 4px 2px;
}
.dtab b {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
}
.dtab span {
  font-size: 12px;
  color: var(--muted);
}
.dtab:hover {
  border-color: var(--accent);
}
.dtab.today span {
  color: var(--accent-ink);
  font-weight: 600;
}
.dtab[aria-pressed="true"] {
  background: var(--chip-on);
  border-color: var(--chip-on);
}
.dtab[aria-pressed="true"] b,
.dtab[aria-pressed="true"] span {
  color: var(--on-navy);
}
.dhead {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 12px;
}
.dhead h3 {
  font-size: 19px;
  color: var(--ink);
}
.hol-tag {
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border-radius: var(--r-pill);
  background: var(--warn-bg);
  color: var(--warn-fg);
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.7;
}
.today-tag {
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border-radius: var(--r-pill);
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.7;
}
.dlist {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.drow {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--surface);
}
.drow .dt {
  display: flex;
  flex-direction: column;
  line-height: 1.4;
}
.drow .dp {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}
.drow .dtm {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}
.drow .dc {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
  line-height: 1.45;
}
.drow .k {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-ink);
}
.drow .n {
  font-size: 16px;
  font-weight: 600;
  color: var(--ink);
  overflow-wrap: anywhere;
}
.drow .t,
.drow .r {
  font-size: 14px;
  color: var(--ink-2);
  overflow-wrap: anywhere;
}
.drow.lunch {
  background: var(--chip-bg);
}
.drow.lunch .n {
  color: var(--muted);
  font-weight: 500;
}
.drow.note,
.drow.hm {
  background: var(--surface-2);
}
.drow.brk,
.drow.free {
  padding: 6px 14px;
  background: transparent;
  border-style: dashed;
  border-color: var(--line-strong);
}
.drow.brk .n,
.drow.free .n {
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
}
.drow.is-now {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
  background: var(--accent-soft);
}
.now-pill {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  margin-top: 6px;
  padding: 1px 10px;
  border-radius: var(--r-pill);
  background: var(--accent);
  color: var(--on-accent);
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.7;
}
@media (max-width: 480px) {
  .drow {
    grid-template-columns: 90px minmax(0, 1fr);
    gap: 10px;
    padding: 10px 12px;
  }
  .drow.brk,
  .drow.free {
    padding: 5px 12px;
  }
  .actions .btn {
    width: 100%;
  }
}

/* ช่องวิชาเลือก (เพิ่ม 2 พ.ย. 2569): รายวิชาในตารางรายวัน ส่วนรายวิชาเลือกใต้ตารางทั้งสัปดาห์ และปุ่มเลือกวิชาของฉัน */
.el-in {
  list-style: none;
  margin: 6px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}
.el-in li {
  display: flex;
  flex-direction: column;
  padding: 7px 0;
  border-top: 1px dashed var(--line-strong);
  line-height: 1.45;
  min-width: 0;
}
.el-in .k {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-ink);
}
.el-in .n2 {
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  overflow-wrap: anywhere;
}
.el-in .m {
  font-size: 14px;
  color: var(--ink-2);
  overflow-wrap: anywhere;
}
.el-tag {
  align-self: flex-start;
  display: inline-flex;
  margin-top: 4px;
  padding: 0 10px;
  border-radius: var(--r-pill);
  border: 1px solid currentColor;
  background: var(--surface);
  color: var(--accent-ink);
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.7;
}
.el-pick {
  align-self: flex-start;
  margin-top: 8px;
  min-height: 44px;
  padding: 6px 16px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--accent-ink);
  font: 600 14px/1.3 var(--font-body);
  cursor: pointer;
}
.el-pick:hover {
  border-color: var(--accent);
}
#elecSec {
  margin-top: 14px;
}
.el-sec {
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.el-sec h3 {
  font-size: 18px;
  color: var(--ink);
}
.el-sec > p {
  margin: 0;
  font-size: 14px;
  color: var(--ink-2);
}
.el-sec .el-blk {
  margin-top: 12px;
  min-width: 0;
}
.el-bh {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px 12px;
  margin-bottom: 6px;
}
.el-bh h4 {
  font-size: 15px;
  color: var(--ink);
  margin: 0;
}
.el-bh h4 span {
  font-weight: 500;
  color: var(--ink-2);
}
.el-bh .el-pick {
  margin-top: 0;
}
.el-tbl {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 14px;
  line-height: 1.45;
}
.el-tbl col.c1 {
  width: 15%;
}
.el-tbl col.c2 {
  width: 37%;
}
.el-tbl col.c3 {
  width: 22%;
}
.el-tbl th,
.el-tbl td {
  border-bottom: 1px solid var(--line);
  text-align: left;
  padding: 7px 8px;
  vertical-align: top;
  overflow-wrap: anywhere;
}
.el-tbl th {
  font-weight: 600;
  color: var(--ink-2);
  background: var(--surface-2);
  font-size: 13px;
}
.el-tbl td.k {
  color: var(--accent-ink);
  font-weight: 600;
}
.el-tbl td.n {
  color: var(--ink);
}
.el-tbl td.t,
.el-tbl td.r {
  color: var(--ink-2);
}
.el-tbl tr.mine td {
  background: var(--accent-soft);
}
.el-tbl .el-tag {
  margin: 0 0 0 6px;
}
@media (max-width: 600px) {
  .el-sec {
    padding: 14px;
  }
  .el-tbl colgroup,
  .el-tbl thead {
    display: none;
  }
  .el-tbl,
  .el-tbl tbody,
  .el-tbl tr,
  .el-tbl td {
    display: block;
  }
  .el-tbl tr {
    padding: 8px 0;
    border-bottom: 1px solid var(--line);
  }
  .el-tbl td {
    border: 0;
    padding: 0 4px;
  }
  .el-tbl td.t,
  .el-tbl td.r {
    display: inline;
  }
  .el-tbl td.t::after {
    content: ", ";
  }
}

/* Week sheet */
.sheet {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}
.sh-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px 20px;
}
.sh-id {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.sh-school {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.02em;
}
.sh-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--ink);
}
.sh-meta {
  font-size: 14px;
  color: var(--ink-2);
}
.sh-badge {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border-radius: 16px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 13px;
  line-height: 1.35;
}
.sh-badge b {
  font-family: var(--font-display);
  font-size: 15px;
}
.sh-badge .dot {
  flex: 0 0 10px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft-2);
}
.tt-wrap {
  overflow-x: auto;
  border-radius: 14px;
  border: 1px solid var(--grid-line);
}
table.tt {
  border-collapse: collapse;
  width: 100%;
  min-width: 1040px;
  table-layout: fixed;
  font-size: 13px;
  line-height: 1.4;
}
table.tt col.w-day {
  width: 96px;
}
table.tt col.w-hm {
  width: 84px;
}
table.tt col.w-brk {
  width: 30px;
}
table.tt th,
table.tt td {
  border: 1px solid var(--grid-line);
  text-align: center;
  vertical-align: middle;
  padding: 6px 5px;
}
table.tt tr > *:first-child {
  border-left: 0;
}
table.tt tr > *:last-child {
  border-right: 0;
}
table.tt thead tr:first-child > * {
  border-top: 0;
}
table.tt tbody tr:last-child > * {
  border-bottom: 0;
}
table.tt thead th {
  background: var(--accent-soft);
  color: var(--ink);
  font-weight: 600;
  font-size: 13px;
}
table.tt thead th.sub {
  font-weight: 500;
  font-size: 12px;
  color: var(--ink-2);
  background: var(--surface-2);
}
table.tt thead th.hm-t {
  font-size: 11px;
}
table.tt th.c-day {
  background: var(--surface-2);
  font-weight: 600;
}
table.tt tbody th.c-day {
  padding: 6px 4px;
}
table.tt tr.is-today th.c-day {
  background: var(--accent-soft);
}
table.tt th.c-day .today-tag {
  margin-top: 4px;
}
.dn {
  display: block;
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  color: var(--ink);
}
.dd {
  display: block;
  font-size: 12px;
  color: var(--muted);
}
table.tt td.c-brk,
table.tt th.c-brk {
  background: var(--chip-bg);
  padding: 4px 1px;
  font-size: 11px;
}
table.tt td.c-hm {
  font-size: 12px;
  color: var(--ink-2);
}
table.tt td.c-hm span {
  display: block;
  overflow-wrap: anywhere;
}
table.tt td.c-hm.on {
  background: var(--surface-2);
}
table.tt td.slot {
  height: 96px;
}
table.tt td.slot span {
  display: block;
  overflow-wrap: anywhere;
}
table.tt td .k {
  font-weight: 600;
  color: var(--accent-ink);
  letter-spacing: 0.01em;
}
table.tt td .n {
  color: var(--ink);
}
table.tt td .t {
  color: var(--ink-2);
  font-size: 12px;
}
table.tt td .r {
  color: var(--muted);
  font-size: 12px;
}
table.tt td.lunch {
  background: var(--chip-bg);
}
table.tt td.lunch .n {
  color: var(--muted);
  font-weight: 500;
}
table.tt td.note {
  background: var(--surface-2);
}
table.tt td.note .n {
  font-weight: 600;
  color: var(--ink-2);
}
table.tt td.is-now {
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 2px var(--accent);
}
table.tt td .now-pill {
  display: inline-flex;
  margin: 4px auto 0;
  font-size: 11px;
}
.sh-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 6px 16px;
  font-size: 13px;
  color: var(--ink-2);
}
.sh-foot b {
  color: var(--ink);
}
.sh-foot .unit {
  color: var(--muted);
}
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  font-size: 13px;
  color: var(--muted);
  align-items: center;
}
.sw {
  display: inline-block;
  width: 14px;
  height: 12px;
  border-radius: 4px;
  margin-right: 6px;
  vertical-align: -1px;
  border: 1px solid var(--grid-line);
}
.sw-lunch {
  background: var(--chip-bg);
}
.sw-note {
  background: var(--surface-2);
}
.sw-now {
  background: var(--accent-soft);
  border-color: var(--accent);
}

/* More info */
.week {
  background: var(--navy);
  border-color: transparent;
  color: var(--on-navy);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.week-strip {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
}
.wday {
  border-radius: 14px;
  padding: 8px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: rgba(255, 255, 255, 0.1);
  line-height: 1.25;
  min-width: 0;
}
.wday b {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 700;
}
.wday span {
  font-size: 12px;
  color: var(--on-navy-2);
  white-space: nowrap;
}
.wday.off {
  background: transparent;
  border: 1px dashed rgba(255, 255, 255, 0.22);
}
.wday.off b {
  color: var(--on-navy-accent);
}
.wday.today {
  box-shadow: inset 0 0 0 2px var(--on-navy-accent);
}
.wday.today span {
  color: var(--on-navy);
  font-weight: 600;
}
.week-auto {
  font-size: 15px;
  font-weight: 600;
  color: var(--on-navy);
}
.week-note {
  font-size: 14px;
  color: var(--on-navy-2);
}
.notes {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.notes h2,
.qr h2 {
  font-size: 22px;
}
.note-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}
.note-list li {
  position: relative;
  padding-left: 18px;
  font-size: 14px;
  color: var(--ink-2);
  line-height: 1.6;
}
.note-list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.62em;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}
.note-list b {
  color: var(--ink);
  font-weight: 600;
}
@media (min-width: 961px) {
  .notes.s4 .note-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 40px;
  }
}
.qr {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: flex-start;
}
.qr-box {
  width: min(220px, 100%);
  background: var(--qr-bg);
  padding: 12px;
  border-radius: 14px;
  border: 1px solid var(--line);
}
.qr-box svg {
  display: block;
  width: 100%;
  height: auto;
}
.qr-url {
  font-size: 14px;
  color: var(--ink-2);
  overflow-wrap: anywhere;
  user-select: all;
}

/* Footer */
.footer {
  margin-top: 32px;
  background: var(--navy-deep);
  color: var(--on-navy-2);
}
.footer-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 36px;
  padding-block: 48px 28px;
}
.footer-grid > div {
  flex: 1 1 220px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 15px;
}
.footer-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 20px;
  color: var(--on-navy);
}
.footer h2 {
  font-size: 15px;
  color: var(--on-navy);
  font-family: var(--font-body);
  font-weight: 600;
}
.footer a {
  color: var(--on-navy);
}
.footer-grid > .footer-org {
  flex-grow: 1.4;
}
.link-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.footer-bottom {
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding-block: 16px;
  text-align: center;
  font-size: 14px;
  color: var(--on-navy-accent);
}
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 50;
  background: var(--navy);
  color: var(--on-navy);
  padding: 12px 18px;
  border-radius: 14px;
  font-size: 14px;
  box-shadow: 0 16px 30px -14px var(--shadow);
  max-width: calc(100vw - 32px);
}
.to-top {
  position: fixed;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  z-index: 30;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: var(--on-accent);
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 12px 24px -10px var(--glow);
}
.to-top svg {
  width: 22px;
  height: 22px;
}
#printArea {
  display: none;
}
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  .pulse::after {
    animation: none !important;
  }
}

/* ===== พิมพ์ A4 แนวนอน (กด Ctrl+P เมื่อเปิดหน้านี้บนเว็บทั่วไป) ===== */
@page {
  size: A4 landscape;
  margin: 8mm;
}
/* ส่วนพิมพ์ (ไฟล์ PDF ปุ่มพิมพ์จากเบราว์เซอร์ และ Ctrl+P) ขนาดและเค้าโครงผูกกับ #printArea โดยไม่จำกัดเฉพาะตอนพิมพ์
   เพื่อให้ fitPrint() ใน core.js วัดและย่อช่องที่ข้อความยาวได้ก่อนเปิดหน้าต่างพิมพ์ บนจอ #printArea ซ่อนอยู่ จึงไม่กระทบหน้าเว็บ
   ตัวอักษรในช่องตาราง 9.5 pt ระยะบรรทัด 1.45 (ปรับ 1 พ.ย. 2569 จาก 8 pt และ 1.3) มุมตารางเหลี่ยม เพราะมุมมนทำให้พื้นหลังช่องทับเส้นขอบ */
#printArea .sheet {
  width: 281mm;
  height: 193mm;
  padding: 0;
  border: 0;
  border-radius: 0;
  gap: 2.4mm;
  break-after: page;
  overflow: visible;
}
#printArea .sheet:last-child {
  break-after: auto;
}
#printArea .sh-school {
  font-size: 8.5pt;
}
#printArea .sh-title {
  font-size: 14pt;
}
#printArea .sh-meta {
  font-size: 9pt;
}
#printArea .sh-badge {
  font-size: 8.5pt;
  padding: 2mm 3.5mm;
  border-radius: 3mm;
}
#printArea .sh-badge b {
  font-size: 10pt;
}
#printArea .tt-wrap {
  overflow: visible;
  border-radius: 0;
  flex: 1 1 auto;
}
#printArea table.tt {
  min-width: 0;
  font-size: 9.5pt;
  line-height: 1.45;
  height: 100%;
}
#printArea table.tt col.w-day {
  width: 17mm;
}
#printArea table.tt col.w-hm {
  width: 19mm;
}
#printArea table.tt col.w-brk {
  width: 5mm;
}
#printArea table.tt th,
#printArea table.tt td {
  padding: 0.8mm 0.9mm;
}
#printArea table.tt thead th {
  font-size: 9pt;
  height: 5.6mm;
}
#printArea table.tt thead th.sub {
  font-size: 8.2pt;
}
#printArea table.tt thead th.hm-t {
  font-size: 7.6pt;
  letter-spacing: -0.01em;
}
#printArea table.tt tbody tr {
  height: 27mm;
}
#printArea table.tt td.slot {
  height: auto;
  font-size: var(--fs, 9.5pt);
  line-height: var(--lh, 1.45);
}
#printArea table.tt td .t,
#printArea table.tt td .r {
  font-size: 8.5pt;
}
#printArea table.tt td.slot .t,
#printArea table.tt td.slot .r {
  font-size: calc(var(--fs, 9.5pt) - 1pt);
}
#printArea table.tt td.c-hm {
  font-size: 8.5pt;
}
#printArea table.tt td.c-brk,
#printArea table.tt th.c-brk {
  font-size: 6.6pt;
}
#printArea .dn {
  font-size: 11pt;
}
#printArea .dd {
  font-size: 7.6pt;
}
#printArea .sh-foot {
  font-size: 8pt;
}
/* แถบรายวิชาเลือกท้ายตาราง (เฉพาะตารางเรียนที่มีช่องวิชาเลือก) */
#printArea .el-strip {
  border: 1px solid var(--grid-line);
  padding: 1.1mm 2mm 1.3mm;
  display: flex;
  flex-direction: column;
  gap: 0.9mm;
  font-size: 7.8pt;
  line-height: 1.3;
  color: var(--ink);
}
#printArea .el-strip .el-blk {
  display: grid;
  grid-template-columns: 28mm minmax(0, 1fr);
  gap: 2mm;
  align-items: start;
}
#printArea .el-strip .el-g {
  font-weight: 600;
  font-size: 8pt;
  line-height: 1.25;
}
#printArea .el-strip .el-g small {
  display: block;
  font-weight: 500;
  color: var(--ink-2);
  font-size: 7.2pt;
}
#printArea .el-strip ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.2mm 3mm;
}
#printArea .el-strip li b {
  color: var(--accent-ink);
  font-weight: 600;
}
#printArea .el-strip li i {
  font-style: normal;
  color: var(--ink-2);
}
@media print {
  :root,
  :root[data-theme] {
    --bg: #ffffff;
    --dot: transparent;
    --surface: #ffffff;
    --surface-2: #f9fafb;
    --ink: #101828;
    --ink-2: #354052;
    --muted: #5d6b82;
    --line: rgba(16, 24, 40, 0.14);
    --line-strong: rgba(16, 24, 40, 0.24);
    --accent: #0033ff;
    --accent-ink: #0033ff;
    --accent-soft: #e9f0ff;
    --accent-soft-2: #d0dfff;
    --navy: #0a1a4f;
    --chip-bg: #f2f4f7;
    --chip-fg: #354052;
    --grid-line: #9aa0aa;
    color-scheme: light;
  }
  * {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  html,
  body {
    background: var(--surface) !important;
    background-image: none !important;
  }
  body > *:not(#printArea) {
    display: none !important;
  }
  #printArea {
    display: block !important;
  }
}

/* เฉพาะฉบับนักเรียน: หน้าต่าง QR Code ของห้อง และข้อความชวนเลือกกลุ่มเมื่อเปิดลิงก์ของห้องที่แยกกลุ่ม */
.qr-dlg {
  width: min(400px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  overflow: auto;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 24px 48px -20px var(--shadow);
}
.qr-dlg::backdrop {
  background: rgba(10, 26, 79, 0.55);
}
.qr-dlg-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}
.qr-dlg h2 {
  font-family: var(--font-display);
  font-size: 20px;
  line-height: 1.35;
  margin: 0;
  padding-top: 8px;
}
.qr-dlg-box {
  width: min(260px, 100%);
  margin: 14px auto 10px;
}
.qr-dlg-note {
  font-size: 15px;
  line-height: 1.6;
  color: var(--ink-2);
  text-align: center;
  margin: 0 0 6px;
}
.qr-dlg .qr-url {
  text-align: center;
  font-size: 13px;
  margin: 0;
}
.qr-dlg-act {
  justify-content: center;
  margin-top: 14px;
}
.grp-hint {
  margin: 0;
  padding: 10px 14px;
  border-radius: var(--r-md);
  background: var(--warn-bg);
  color: var(--warn-fg);
  border: 1px solid currentColor;
  font-size: 15px;
  line-height: 1.6;
}
/* หน้าต่างเลือกวิชาของฉัน ในช่องวิชาเลือก (เพิ่ม 2 พ.ย. 2569) */
.el-dlg {
  width: min(460px, calc(100vw - 24px));
}
.el-when {
  margin: 6px 0 12px;
  color: var(--ink-2);
  font-size: 15px;
  line-height: 1.6;
}
.el-opts {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.el-opt {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  width: 100%;
  min-height: 44px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-2);
  color: var(--ink);
  font: inherit;
  line-height: 1.45;
  cursor: pointer;
}
.el-opt:hover {
  border-color: var(--accent);
}
.el-opt[aria-pressed="true"] {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
  background: var(--accent-soft);
}
.el-opt[aria-pressed="true"]::after {
  content: "เลือกอยู่";
  margin-top: 4px;
  padding: 0 10px;
  border-radius: var(--r-pill);
  background: var(--accent);
  color: var(--on-accent);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.7;
}
.el-opt .k {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-ink);
}
.el-opt .n {
  font-size: 16px;
  font-weight: 600;
  overflow-wrap: anywhere;
}
.el-opt .m {
  font-size: 14px;
  color: var(--ink-2);
  overflow-wrap: anywhere;
}
.el-all .n {
  font-size: 15px;
  color: var(--ink-2);
}
.el-note {
  margin: 12px 0 0;
  font-size: 14px;
  color: var(--muted);
  line-height: 1.6;
}