/* โครงหลัก: token สี ตัวอักษร เปลือกแอป — ยึดระบบเดียวกับ AI Teaching Lab */
/* ฟอนต์ IBM Plex Sans Thai เก็บในเว็บเอง (SIL OFL 1.1 ดู fonts/OFL.txt) — ไม่ต้องต่อ Google Fonts 2 โดเมน
   unicode-range ทำให้โหลดเฉพาะชุดอักษรที่หน้านั้นใช้ */
@font-face {
  font-family: "IBM Plex Sans Thai";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(../fonts/plex-thai-400-thai.woff2) format("woff2");
  unicode-range: U+02D7, U+0303, U+0331, U+0E01-0E5B, U+200C-200D, U+25CC;
}
@font-face {
  font-family: "IBM Plex Sans Thai";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(../fonts/plex-thai-400-latin-ext.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "IBM Plex Sans Thai";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(../fonts/plex-thai-400-latin.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "IBM Plex Sans Thai";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url(../fonts/plex-thai-600-thai.woff2) format("woff2");
  unicode-range: U+02D7, U+0303, U+0331, U+0E01-0E5B, U+200C-200D, U+25CC;
}
@font-face {
  font-family: "IBM Plex Sans Thai";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url(../fonts/plex-thai-600-latin-ext.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "IBM Plex Sans Thai";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url(../fonts/plex-thai-600-latin.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "IBM Plex Sans Thai";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url(../fonts/plex-thai-700-thai.woff2) format("woff2");
  unicode-range: U+02D7, U+0303, U+0331, U+0E01-0E5B, U+200C-200D, U+25CC;
}
@font-face {
  font-family: "IBM Plex Sans Thai";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url(../fonts/plex-thai-700-latin-ext.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "IBM Plex Sans Thai";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url(../fonts/plex-thai-700-latin.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
:root {
  --text-meta: 0.8125rem;
  --text-small: 0.875rem;
  --text-body: 1rem;
  --text-lead: 1.125rem;
  --text-h2: 1.5rem;
  --text-h3: 1.3125rem;
  --text-h1: clamp(1.875rem, 1.1rem + 2.2vw, 2.75rem);
  /* ระยะห่างตาม DESIGN.md: แน่นในกลุ่ม ห่างระหว่างกลุ่ม */
  --space-xs: 6px;
  --space-sm: 8px;
  --space-md: 12px;
  --space-lg: 16px;
  --space-xl: 24px;
  --space-page: 36px;
  --space-section: 56px;
  --measure: 46rem; /* ≈ 76 อักขระที่ขนาดตัวอักษรเนื้อหา ใช้ rem เพื่อให้ทุกส่วนกว้างเท่ากันแม้ขนาดตัวอักษรต่างกัน */
  --font-sans: "IBM Plex Sans Thai", "Sukhumvit Set", "Noto Sans Thai", Tahoma, sans-serif;
  --bg: #f1f5fa;
  --paper: #fff;
  --ink: #182a43;
  --muted: #536781;
  --line: #dce4ee;
  --blue: #2357c8;
  --blue-solid: #2357c8;
  --soft: #eaf1ff;
  --gold: #f1cf6e;
  --navy: #122e57;
  --ok: #1f7a4d;
  --ok-soft: #e6f4ec;
  --warn: #8a6212;
  --warn-soft: #fdf6e3;
  --warn-line: #efdca6;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --focus: #8a6212;
  /* เงา 3 ชั้น สีกลางเสมอ มี offset และ blur: วาง · พื้นที่ทำงาน · ยกขึ้น */
  --shadow-1: 0 1px 2px rgb(0 0 0 / 5%), 0 3px 8px -3px rgb(0 0 0 / 9%);
  --shadow-2: 0 2px 4px rgb(0 0 0 / 5%), 0 14px 32px -14px rgb(0 0 0 / 24%);
  --shadow-3: 0 4px 10px rgb(0 0 0 / 7%), 0 24px 48px -18px rgb(0 0 0 / 32%);
  --duration-lift: 220ms;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --radius: 12px;
  --duration-fast: 150ms;
  --top-h: 72px;
  --selection: #c6d9ff;
  --blue-deep: #1b47a8;
  --scrim: rgb(10 20 35 / 40%);
  --scrim-strong: rgb(10 20 35 / 82%);
  --gold-ink: #a9781a;
  /* สีกรมท่าสำหรับ "ตัวอักษรและเส้น" — ต้องสลับเป็นโทนสว่างในธีมมืด ต่างจาก --navy ที่เป็นสีพื้น */
  --navy-ink: #122e57;
  /* พื้นกรมท่าเข้มเท่ากันทั้งสองธีม ตัวอักษรบนพื้นนั้นจึงใช้ค่าเดียวกันทั้งสองธีมด้วย */
  --on-navy-gold: #f0cf7d;
  --on-navy-muted: #c9d6ea;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #101b2c;
  --paper: #192940;
  --ink: #edf2fa;
  --muted: #aabbd2;
  --line: #354760;
  --soft: #203959;
  --blue: #8aafff;
  --ok: #6fd3a0;
  --ok-soft: #173a2b;
  --warn: #f0cf7d;
  --warn-soft: #2d2818;
  --warn-line: #5c4d24;
  --danger: #ff9c8f;
  --danger-soft: #3a1f1d;
  --focus: #f0cf7d;
  --shadow-1: 0 1px 2px rgb(0 0 0 / 30%), 0 3px 8px -3px rgb(0 0 0 / 40%);
  --shadow-2: 0 2px 4px rgb(0 0 0 / 30%), 0 14px 32px -14px rgb(0 0 0 / 60%);
  --shadow-3: 0 4px 10px rgb(0 0 0 / 35%), 0 24px 48px -18px rgb(0 0 0 / 70%);
  --selection: #33507f;
  --gold-ink: #f0cf7d;
  --navy-ink: #9fc0ff;
  color-scheme: dark;
}
* {
  box-sizing: border-box;
}
html {
  scroll-padding-top: calc(var(--top-h) + 14px);
}
body {
  margin: 0;
  font: 1rem/1.75 var(--font-sans);
  color: var(--ink);
  background: var(--bg);
  text-rendering: optimizeLegibility;
  /* ข้อความยาวไม่มีช่องว่าง เช่น URL ตัดขึ้นบรรทัดใหม่แทนการล้นจอ */
  overflow-wrap: break-word;
}
::selection {
  background: var(--selection);
  color: var(--ink);
}
html {
  scrollbar-color: var(--line) transparent;
  accent-color: var(--blue-solid);
  caret-color: var(--blue);
}
.ico {
  flex: none;
  display: block;
}
button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}
button,
.btn {
  cursor: pointer;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  padding: 7px 14px;
  font-size: var(--text-small);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: border-color var(--duration-fast), background var(--duration-fast), transform var(--duration-fast);
}
button:hover,
.btn:hover {
  border-color: var(--blue);
  background: var(--soft);
}
button:active,
.btn:active {
  transform: translateY(1px);
}
button:disabled {
  opacity: 0.45;
  cursor: default;
}
.primary,
.btn.primary {
  background: var(--blue-solid);
  color: #fff;
  border-color: var(--blue-solid);
  font-weight: 600;
}
.primary:hover,
.btn.primary:hover {
  background: var(--blue-deep);
  border-color: var(--blue-deep);
}
.ghost {
  background: transparent;
}
.danger {
  color: var(--danger);
}
a {
  color: var(--blue);
  text-underline-offset: 4px;
}
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}
.skip-link {
  position: absolute;
  left: -999px;
  top: 8px;
  z-index: 99;
  background: var(--paper);
  padding: 8px 14px;
  border-radius: 8px;
}
.skip-link:focus {
  left: 12px;
}
.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}

/* ---------- แถบบน ---------- */
.top {
  height: var(--top-h);
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 24px;
}
.brand {
  color: var(--ink);
  text-decoration: none;
  font-size: var(--text-lead);
  line-height: 1.2;
  font-weight: 700;
  white-space: nowrap;
}
.brand {
  min-height: 44px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
}
.brand small {
  display: block;
  font-size: 0.6875rem;
  letter-spacing: 2px;
  color: var(--muted);
  margin-top: 4px;
}
#tabs {
  display: flex;
  gap: 2px;
  flex: 1;
  overflow-x: auto;
  scrollbar-width: none;
}
.tab {
  font-size: var(--text-meta);
  text-decoration: none;
  color: var(--muted);
  padding: 8px 10px;
  border-radius: 7px;
  white-space: nowrap;
}
.tab:hover {
  color: var(--ink);
  background: var(--bg);
}
.tab.active {
  background: var(--soft);
  color: var(--blue);
  font-weight: 600;
}
.tools {
  display: flex;
  gap: 5px;
  white-space: nowrap;
}
.tools button {
  min-height: 40px;
  padding: 6px 10px;
  font-size: var(--text-meta);
}
.menu-btn {
  display: none;
  min-height: 40px;
  min-width: 40px;
  justify-content: center;
  padding: 0;
}

/* ---------- เปลือก ---------- */
.shell {
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr);
  max-width: 1600px;
  margin: auto;
}
/* main รับโฟกัสจากโค้ดหลังเปลี่ยนหน้า (ให้ screen reader เริ่มอ่านที่เนื้อหา) ไม่ต้องแสดงกรอบ */
main:focus {
  outline: none;
}
.shell > aside {
  position: sticky;
  top: var(--top-h);
  height: calc(100vh - var(--top-h));
  border-right: 1px solid var(--line);
  padding: 26px 18px;
  display: flex;
  flex-direction: column;
  overflow: auto;
}
#side {
  flex: 1;
}
.side-title {
  font-weight: 700;
  font-size: var(--text-lead);
  margin: 0 0 16px;
  line-height: 1.4;
}
.side-phase {
  border-top: 1px solid var(--line);
  padding: 8px 0;
}
.side-phase summary {
  cursor: pointer;
  font-size: var(--text-small);
  font-weight: 600;
  padding: 4px 0;
  list-style-position: inside;
}
.side-phase ol,
.side-list {
  list-style: none;
  margin: 6px 0 4px;
  padding: 0;
}
.side-phase a,
.side-list a {
  display: flex;
  gap: 10px;
  align-items: baseline;
  padding: 6px 8px;
  border-radius: 7px;
  color: var(--muted);
  text-decoration: none;
  font-size: var(--text-meta);
  line-height: 1.5;
}
.side-phase a:hover,
.side-list a:hover {
  background: var(--paper);
  color: var(--ink);
}
.side-phase a.active,
.side-list a.active {
  background: var(--soft);
  color: var(--blue);
  font-weight: 600;
}
.side-phase .n {
  flex: 0 0 18px;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  align-self: center;
}
.side-phase a.done .n {
  color: var(--ok);
}
.side-tabs {
  display: none;
  gap: 2px;
  padding-bottom: 14px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--line);
}
.side-tabs .tab {
  font-size: var(--text-small);
}
/* แท็บบนแถบบนไม่พอที่ (หน้าจอแคบหรือขยายตัวอักษร): ย้ายไปบนสุดของแถบด้านข้างแทนการตัดแท็บ
   ใช้ visibility เพื่อให้แถบยังวัดความกว้างได้ ไม่สลับไปมา */
.tabs-fold #tabs {
  visibility: hidden;
}
.tabs-fold .side-tabs {
  display: grid;
}
.side-extra {
  display: inline-block;
  margin-top: 10px;
  font-size: var(--text-small);
}
.sidefoot {
  border-top: 1px solid var(--line);
  padding-top: 16px;
  margin-top: 16px;
  font-size: var(--text-meta);
  color: var(--muted);
  display: grid;
  gap: 8px;
}
.sidefoot p {
  margin: 0;
}
.sidefoot button {
  justify-content: center;
}
.progress-label {
  display: flex;
  justify-content: space-between;
}
.progress-label b {
  color: var(--ink);
}
progress {
  width: 100%;
  height: 6px;
  appearance: none;
  border: 0;
  border-radius: 99px;
  background: var(--line);
  overflow: hidden;
}
progress::-webkit-progress-bar {
  background: var(--line);
}
progress::-webkit-progress-value {
  background: var(--ok);
  border-radius: 99px;
}
progress::-moz-progress-bar {
  background: var(--ok);
}
main {
  padding: 36px clamp(16px, 4vw, 64px) 72px;
  max-width: 1080px;
  width: 100%;
  outline: none;
}
.foot {
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: var(--text-meta);
  text-align: center;
  padding: 20px 16px;
}
.scrim {
  display: none;
}
#toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 20px);
  opacity: 0;
  pointer-events: none;
  background: var(--navy);
  color: #fff;
  padding: 10px 18px;
  border-radius: 99px;
  font-size: var(--text-small);
  transition: opacity var(--duration-fast), transform var(--duration-fast);
  z-index: 60;
}
#toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ---------- ภาพขยาย ---------- */
#zoom {
  border: 0;
  padding: 0;
  background: transparent;
  max-width: 96vw;
  max-height: 94vh;
}
#zoom::backdrop {
  background: var(--scrim-strong);
}
#zoom img {
  max-width: 96vw;
  max-height: 90vh;
  border-radius: 10px;
  background: #fff;
  display: block;
}
#zoomClose {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 40px;
  height: 40px;
  justify-content: center;
}

/* ---------- โหมดนำเสนอ ---------- */
#presentation {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: var(--bg);
  display: grid;
  grid-template-rows: auto 1fr auto;
}
#presentation[hidden] {
  display: none;
}
body.presenting {
  overflow: hidden;
}
.presentation-top,
.presentation-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 24px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  font-size: var(--text-meta);
  color: var(--muted);
  flex-wrap: wrap;
}
.presentation-bottom {
  border-top: 1px solid var(--line);
  border-bottom: 0;
}
.presentation-controls,
.presentation-bottom > div {
  display: flex;
  gap: 8px;
  align-items: center;
}
.presentation-controls select {
  max-width: 280px;
  padding: 7px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--paper);
}
#slideCount {
  min-width: 64px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.timer b {
  font-size: 1.1875rem;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  min-width: 72px;
  text-align: center;
}
.timer b.over {
  color: var(--danger);
}
.presentation-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  min-height: 0;
}
.presentation-join {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 10px;
  padding: 24px;
  border-left: 1px solid var(--line);
  background: var(--paper);
}
.presentation-qr {
  display: grid;
  justify-items: center;
  gap: 6px;
  text-decoration: none;
  color: var(--muted);
  font-size: var(--text-small);
}
.presentation-qr img {
  width: 164px;
  height: 164px;
  border-radius: 12px;
  background: #fff;
  padding: 6px;
}
.presentation-url {
  font-weight: 600;
  font-size: var(--text-small);
  text-align: center;
}
#slide {
  overflow: auto;
  padding: clamp(24px, 5vw, 72px);
  display: grid;
  align-items: center;
  outline: none;
  font-size: clamp(1rem, 0.6rem + 1.1vw, 1.5rem);
}
#slide h1 {
  font-size: clamp(2rem, 1rem + 3vw, 3.75rem);
  line-height: 1.2;
  margin: 0.2em 0 0.5em;
}
#slide .lead {
  font-size: 1.15em;
  color: var(--muted);
}
.slide-cover {
  max-width: 1100px;
}
.slide-author {
  display: flex;
  gap: 18px;
  align-items: center;
  margin-top: 1.5em;
}
.slide-author img {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  object-fit: cover;
}
.slide-author b,
.slide-author span {
  display: block;
}
.slide-author span {
  color: var(--muted);
  font-size: 0.8em;
}
.slide-divider span {
  color: var(--blue);
  font-weight: 700;
}
.slide-divider ol {
  columns: 2;
  color: var(--muted);
}
.slide-lesson {
  display: grid;
  gap: 40px;
  align-items: center;
}
.slide-lesson.has-img {
  grid-template-columns: 1.1fr 1fr;
}
.slide-lesson ul {
  padding-left: 1.1em;
}
.slide-lesson li {
  margin: 0.5em 0;
}
.slide-img {
  width: 100%;
  height: auto;
  max-height: 60vh;
  object-fit: contain;
  border-radius: 12px;
  background: #fff;
}

/* ---------- จอเล็ก ---------- */
@media (max-width: 1100px) {
  #tabs {
    display: none;
  }
  .menu-btn {
    display: inline-flex;
  }
  .top {
    gap: 12px;
    padding: 0 16px;
  }
  .brand {
    flex: 1;
  }
  .shell {
    grid-template-columns: minmax(0, 1fr);
  }
  .shell > aside {
    position: fixed;
    left: 0;
    top: var(--top-h);
    z-index: 30;
    width: min(320px, 86vw);
    background: var(--bg);
    transform: translateX(-100%);
    transition: transform 220ms cubic-bezier(0.16, 1, 0.3, 1);
    border-right: 1px solid var(--line);
  }
  body.side-open .shell > aside {
    transform: none;
  }
  body.side-open .scrim {
    display: block;
    position: fixed;
    inset: var(--top-h) 0 0;
    background: var(--scrim);
    z-index: 25;
  }
  .side-tabs {
    display: grid !important;
  }
  .side-phase a,
  .side-list a,
  .side-tabs .tab {
    min-height: 44px;
    align-items: center;
  }
}
@media (max-width: 900px) {
  .presentation-join {
    display: none;
  }
  .presentation-body {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 560px) {
  /* โหมดนำเสนอใช้บนจอใหญ่ ซ่อนบนมือถือเพื่อให้ปุ่มบัญชีพอดี */
  .tools #fontDown,
  .tools #fontUp,
  .tools #present {
    display: none;
  }
  .top {
    gap: 10px;
    padding: 0 12px;
  }
  .slide-lesson.has-img {
    grid-template-columns: 1fr;
  }
  .slide-divider ol {
    columns: 1;
  }
}
/* ลดการเคลื่อนไหว: ตัดการเคลื่อนที่ (เลื่อน ยก หมุน วาดเส้น) แต่คงการเปลี่ยนสี ความทึบ และเงา
   ที่บอกสถานะ เช่น hover, focus, ตอบถูกหรือผิด จึงยังเห็นผลของการกดชัดเจน */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-property: color, background-color, border-color, outline-color, opacity, box-shadow !important;
    animation: none !important;
    scroll-behavior: auto !important;
  }
  button:active,
  .btn:active,
  .case-card:hover,
  .case-card:focus-visible,
  .path-card:hover {
    transform: none !important;
  }
}
@media print {
  /* พิมพ์และบันทึก PDF ใช้โทนสว่างเสมอ ไม่ว่าจะเปิดโหมดมืดอยู่ */
  :root,
  :root[data-theme="dark"] {
    --bg: #fff;
    --paper: #fff;
    --ink: #182a43;
    --muted: #536781;
    --line: #dce4ee;
    --blue: #2357c8;
    --soft: #eaf1ff;
    --ok: #1f7a4d;
    --ok-soft: #e6f4ec;
    --warn: #8a6212;
    --warn-soft: #fdf6e3;
    --warn-line: #efdca6;
    --danger: #b42318;
    --danger-soft: #fdecea;
    --gold-ink: #a9781a;
    --navy-ink: #122e57;
  }
  @page {
    margin: 14mm;
  }
  .top,
  .shell > aside,
  .foot,
  .tool-actions,
  .project-head a,
  .read-progress,
  .cf-toolbar,
  .cf-out-head .linkish,
  .lesson-end,
  .skip-link,
  #toast {
    display: none !important;
  }
  .shell {
    display: block;
  }
  body {
    background: #fff;
  }
  * {
    box-shadow: none !important;
  }
  /* ส่วนที่เลื่อนได้บนจอ แสดงเต็มบนกระดาษ */
  .table-wrap,
  .cf-scroll {
    overflow: visible !important;
  }
  .cf-board {
    min-width: 0 !important;
  }
  .cf-lane {
    position: static;
  }
  .project-grid {
    display: block;
  }
  /* การ์ดแบ่งหน้าได้ เพื่อไม่ให้เหลือที่ว่างครึ่งหน้า แต่ชิ้นเล็กข้างในไม่ถูกตัดกลาง */
  .project-card {
    margin-bottom: 12px;
    break-inside: auto !important;
  }
  .project-head,
  .rank li,
  .cf-box,
  .bone,
  tr,
  .aim,
  .matrix,
  .fish {
    break-inside: avoid;
  }
  /* แผนภาพ RCA เริ่มหน้าใหม่ จะได้ขาดกลางน้อยที่สุด */
  .project-card:has(.cf) {
    break-before: page;
  }
  :focus,
  :focus-visible {
    outline: none !important;
  }
  h1,
  h2,
  h3 {
    break-after: avoid;
  }
}

/* จอแคบมาก (320–360px): ซ่อนบรรทัดรองของโลโก้ ให้ปุ่มในหัวเว็บพอดีจอ */
@media (max-width: 360px) {
  .brand small {
    display: none;
  }
  .top {
    gap: 8px;
    padding: 0 10px;
  }
}

/* ---------- กล่องยืนยันของเว็บ (js/dialog.js) ---------- */
.ask-dlg {
  width: min(440px, calc(100vw - 24px));
  padding: 24px;
  border: 0;
  border-radius: 16px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: var(--shadow-3);
}
.ask-dlg::backdrop {
  background: var(--scrim);
}
.ask-dlg[open] {
  animation: ask-in var(--duration-lift) var(--ease-out);
}
@keyframes ask-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}
.ask-dlg h2 {
  margin: 0 0 var(--space-sm);
  font-size: var(--text-h3);
}
.ask-dlg p {
  margin: 0 0 var(--space-lg);
  color: var(--muted);
}
.ask-dlg .field {
  margin-bottom: var(--space-lg);
}
.ask-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--space-sm);
}
.ask-actions button {
  min-height: 44px;
}
.danger-solid {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}
:root[data-theme="dark"] .danger-solid {
  color: var(--bg);
}
.danger-solid:hover {
  filter: brightness(1.08);
}
/* จำนวนรายการรอตรวจบนแท็บผู้ดูแล */
.tab-badge {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  margin-left: 4px;
  border-radius: 99px;
  background: var(--danger);
  color: #fff;
  font-size: var(--text-meta);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
@media (prefers-reduced-motion: reduce) {
  .ask-dlg[open] {
    animation: none;
  }
}
:root[data-theme="dark"] .tab-badge {
  color: var(--bg);
}
