/* ═══════════════════════════════════════════════════════════════════════
   ตารางสอนครู — TeacherSchedules.php
   โรงเรียนเทศบาล ๑ กิตติขจร

   รอบ 24 ก.ย. 2569: ภาษาภาพเดียวกับ /zerodropout/ ชุดเดียวกับ css/tb1-school-profile.css
   และ css/tb1-personal-report.css หัวหน้าแถบน้ำเงินไล่เฉด การ์ดตัวเลขลอยทับขอบล่าง แผงมีแถบหัว
   จุดเด่นของหน้าคือใบตารางสอนรายครู: การ์ดครูมีรูป แถบส่วนผสมคาบ แถบวัน และผังรายสัปดาห์
   (แทน css/tb1-schedule.css + css/tb1-curriculum.css ของฉบับ 14 ก.ย. ซึ่งหน้านี้ไม่โหลดแล้ว)

   ★ โทเคนของหน้าทุกตัวเป็น alias ที่ชี้ไป --tb1-* โหมดมืดจึงพลิกให้เอง
   ★ สี่กลุ่มของคาบใช้สีชุดเดียวกับตารางเรียนรายห้อง และมีลายเส้นซ้ายบอกซ้ำเสมอ
   ★ สีส้มสงวนไว้สำหรับ "ต้องตรวจ / ซ้อนกัน / ใช้น้อยผิดปกติ" ทุกจุดมีข้อความบอกซ้ำ
   ★ ไม่มี opacity:0 เป็นสถานะพัก ที่ขยับได้มีแค่ตำแหน่ง ความยาวแถบ และความสูงคอลัมน์
   ★ ธีมกลางบังคับ font-family ของ span div li p a ด้วย !important
     ตัวเลขที่ต้องเป็นตัวเซริฟจึงใช้ <b> ซึ่งไม่อยู่ในรายการนั้น
   ★ ทุก selector ขึ้นต้นด้วย ts- ไม่ชนกับหน้าอื่นหรือไฟล์กลาง
   ═══════════════════════════════════════════════════════════════════════ */

.ts {
    --ts-ink: var(--tb1-ink-1, #0f172a);
    --ts-ink-2: var(--tb1-ink-2, #334155);
    --ts-muted: var(--tb1-ink-3, #5a697f);
    --ts-page: var(--tb1-page, #f8fafc);
    --ts-paper: var(--tb1-surface, #ffffff);
    --ts-paper-alt: var(--tb1-surface-alt, #f1f5f9);
    --ts-line: var(--tb1-border, #e2e8f0);
    --ts-line-bold: var(--tb1-border-bold, #cbd5e1);
    --ts-brand: var(--tb1-brand, #1d4ed8);
    --ts-brand-soft: color-mix(in srgb, var(--tb1-brand, #1d4ed8) 10%, var(--tb1-surface, #ffffff));
    --ts-brand-line: color-mix(in srgb, var(--tb1-brand, #1d4ed8) 35%, var(--tb1-border, #e2e8f0));
    --ts-page-max: var(--tb1-page-max-width, 1440px);
    --ts-gutter: var(--tb1-shell-gutter, 20px);
    --ts-ease: cubic-bezier(.4, 0, .2, 1);
    --ts-r: 16px;
    --ts-rs: 12px;
    --ts-serif: var(--tb1-font-display, 'Noto Serif Thai', serif);
    --ts-sans: var(--tb1-font-body, 'Sarabun', sans-serif);
    --ts-shadow: 0 14px 32px -24px rgba(15, 23, 42, .55), inset 0 1px 0 rgba(255, 255, 255, .6);
    --ts-shadow-float: 0 22px 44px -26px rgba(15, 23, 42, .6), inset 0 1px 0 rgba(255, 255, 255, .6);
    --ts-hero-a: color-mix(in srgb, var(--tb1-banner-1, #1d4ed8) 60%, var(--tb1-ink-surface, #0f172a));
    --ts-hero-b: var(--tb1-banner-1, #1d4ed8);
    --ts-hero-c: color-mix(in srgb, var(--tb1-banner-1, #1d4ed8) 78%, var(--tb1-accent-strong, #0284c7));

    /* ความหมายของสี */
    --ts-neutral: color-mix(in srgb, var(--tb1-ink-3, #5a697f) 80%, var(--tb1-surface, #ffffff));
    --ts-warn: var(--tb1-warning, #f59e0b);
    --ts-warn-fg: #9a4508;
    --ts-warn-bg: color-mix(in srgb, var(--tb1-warning, #f59e0b) 14%, var(--tb1-surface, #ffffff));
    --ts-crit: var(--tb1-danger, #ef4444);
    /* ★ โทเคน text-danger ของโหมดสว่าง (#dc2626) บนพื้นแดงอ่อนได้ 4.2:1 ไม่ผ่าน AA หน้านี้จึงใช้เฉดเข้มกว่า */
    --ts-crit-fg: #b91c1c;
    --ts-crit-bg: color-mix(in srgb, var(--tb1-danger, #ef4444) 11%, var(--tb1-surface, #ffffff));
    --ts-ok: var(--tb1-success, #10b981);
    --ts-ok-fg: var(--tb1-text-success, #047857);
    --ts-ok-bg: color-mix(in srgb, var(--tb1-success, #10b981) 13%, var(--tb1-surface, #ffffff));
    --ts-info: var(--tb1-info, #0ea5e9);
    --ts-info-fg: var(--tb1-text-info, #0e7490);
    --ts-info-bg: color-mix(in srgb, var(--tb1-info, #0ea5e9) 12%, var(--tb1-surface, #ffffff));
    --ts-tip-bg: var(--tb1-ink-surface, #0f172a);
    --ts-tip-ink: #f8fafc;

    /* สี่กลุ่มของคาบ — ชุดเดียวกับ css/tb1-classroom.css (ตารางเรียนรายห้อง) สีจึงหมายถึงสิ่งเดียวกันทั้งสองหน้า
       ★ สีไม่ใช่ตัวบอกเดียว: เส้นซ้ายของคาบมีลายต่างกัน (ทึบ เส้นคู่ เส้นประ จุด) และชื่อชนิดคาบพิมพ์ในทุกช่อง */
    --ts-g-subject: var(--tb1-brand, #1d4ed8);
    --ts-g-home: var(--tb1-text-info, #0e7490);
    /* ★ โทเคน text-warning ของโหมดสว่าง (#b45309) บนพื้นอ่อนของช่องคาบได้ 4.5:1 พอดีเส้น หน้านี้จึงใช้เฉดเข้มกว่า
       (บนพื้นอ่อนทุกแบบของหน้าได้ 5.5:1 ขึ้นไป) โหมดมืดกลับไปใช้โทเคนกลาง */
    --ts-g-develop: #9a4508;
    --ts-g-work: var(--tb1-ink-3, #5a697f);
    --ts-tone: var(--ts-g-work);
}

:is(html.dark, html.dark-mode, html[data-theme="dark"],
    body.dark-mode, body[data-theme="dark"]) .ts {
    --ts-brand-soft: color-mix(in srgb, var(--tb1-brand, #60a5fa) 16%, var(--tb1-surface, #111c31));
    --ts-shadow: 0 14px 32px -22px rgba(0, 0, 0, .75), inset 0 1px 0 rgba(255, 255, 255, .055);
    --ts-shadow-float: 0 22px 44px -24px rgba(0, 0, 0, .8), inset 0 1px 0 rgba(255, 255, 255, .055);
    --ts-neutral: color-mix(in srgb, var(--tb1-ink-3, #94a3b8) 72%, var(--tb1-surface, #111c31));
    --ts-crit-fg: var(--tb1-text-danger, #fda4af);
    --ts-warn-fg: var(--tb1-text-warning, #fbbf24);
    --ts-g-develop: var(--tb1-text-warning, #fbbf24);
    --ts-tip-bg: #1b2a47;
    color-scheme: dark;
}

/* โหมดมืดสีแบรนด์เป็นฟ้าอ่อน ตัวอักษรบนพื้นแบรนด์จึงต้องเป็นสีเข้ม */
:is(html.dark, html.dark-mode, html[data-theme="dark"],
    body.dark-mode, body[data-theme="dark"]) .ts :is(.ts-chip[aria-pressed="true"], .ts-nav-a[aria-current="location"]) {
    color: #0b1324;
}

/* ── เปลือกหน้า ────────────────────────────────────────────────────────
   ★ หน้านี้ไม่ได้โหลด Bootstrap แล้ว จึงต้องล้าง margin 8px ของ body เอง
   ★ หน้าที่ไม่ทาพื้น body เอง จะได้ตัวอักษรสว่างบนพื้นขาวในโหมดมืด */
body.ts-page {
    margin: 0;
    background: var(--tb1-page, #f8fafc);
    color: var(--tb1-ink-2, #334155);
}

/* ★ แถบเมนู (57px) กับแถบเครื่องมือของหน้า (sticky ทั้งคู่) ต้องไม่บังหัวข้อที่กระโดดไปถึง
   สคริปต์วัดความสูงจริงแล้วเขียน --ts-stick ให้ ไม่มีสคริปต์ใช้ค่าประมาณ */
html:has(body.ts-page) {
    scroll-padding-top: var(--ts-stick, 8.5rem);
}

main.ts {
    padding: 0 var(--ts-gutter) clamp(40px, 5vw, 72px);
    color: var(--ts-ink-2);
}

main.ts:focus {
    outline: none;
}

/* ★ ขอบเนื้อหาต้องตรงแนวกับแถบเมนู สูตรเดียวกับ .tb1-navbar-container */
.ts-wrap {
    max-width: calc(var(--ts-page-max) - 2 * var(--ts-gutter));
    margin-inline: auto;
}

.ts :where(h1, h2, h3, h4, p, ul, ol, dl, dd, dt, figure) {
    margin: 0;
}

.ts :where(ul, ol) {
    padding: 0;
    list-style: none;
}

.ts *,
.ts *::before,
.ts *::after {
    box-sizing: border-box;
}

/* ธีมรวมตั้ง display ให้ element หลายชนิด [hidden] ต้องชนะเสมอ */
.ts [hidden] {
    display: none !important;
}

.ts-icon {
    display: block;
    flex: 0 0 auto;
}

.ts .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;
}

.ts :focus-visible {
    outline: 2px solid var(--ts-brand);
    outline-offset: 2px;
}

/* ★ ลิงก์ข้ามไปเนื้อหาซ่อนด้วย clip ไม่ใช่ left:-9999px ซึ่งไปโดนตัวตรวจล้นแนวนอน */
.ts-skip {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 2000;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
}

body.ts-page a.ts-skip:focus {
    width: auto;
    height: auto;
    clip: auto;
    padding: 12px 18px;
    color: #ffffff;
    background: var(--tb1-banner-1, #1d4ed8);
    border-radius: 0 0 10px 0;
    text-decoration: underline;
}

html.tb1-contrast-high body.ts-page a.ts-skip:focus {
    color: #facc15;
    background: #000000;
    outline: 3px solid #facc15;
}

/* ═══════════════════════════════════════════════════════════════════════
   หัวหน้า
   ═══════════════════════════════════════════════════════════════════════ */

.ts-hero {
    position: relative;
    isolation: isolate;
    overflow: hidden;
    margin-inline: calc(-1 * var(--ts-gutter));
    padding: clamp(34px, 5vw, 58px) var(--ts-gutter) clamp(92px, 9vw, 120px);
    color: #ffffff;
    text-align: center;
    /* ★ สีพื้นทึบอยู่ใต้ไล่เฉด ตัวตรวจคอนทราสต์อ่านค่านี้ และเป็นสีที่เห็นจริงตรงกลางหัวหน้า */
    background-color: var(--ts-hero-b);
    background-image: linear-gradient(135deg, var(--ts-hero-a) 0%, var(--ts-hero-b) 52%, var(--ts-hero-c) 100%);
}

.ts-hero.is-plain {
    padding-bottom: clamp(34px, 5vw, 58px);
}

/* แสงนวลสองดวงกับตารางเส้นบาง ตกแต่งล้วน อยู่หลังตัวอักษร */
.ts-hero::before,
.ts-hero::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    pointer-events: none;
}

.ts-hero::before {
    background-image:
        radial-gradient(circle at 18% 40%, rgba(255, 255, 255, .09) 0%, transparent 48%),
        radial-gradient(circle at 84% 18%, rgba(255, 255, 255, .07) 0%, transparent 40%);
}

.ts-hero::after {
    background-image:
        linear-gradient(rgba(255, 255, 255, .035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, .035) 1px, transparent 1px);
    background-size: 56px 56px;
    -webkit-mask-image: linear-gradient(180deg, #000000 35%, transparent);
    mask-image: linear-gradient(180deg, #000000 35%, transparent);
}

.ts-hero-in {
    max-width: 60rem;
    margin-inline: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.ts-hero-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 16px;
    font-size: .88rem;
    font-weight: 500;
    color: #ffffff;
    background: rgba(255, 255, 255, .12);
    border: 1px solid rgba(255, 255, 255, .2);
    border-radius: 999px;
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
}

.ts-hero-eyebrow .ts-icon {
    width: 17px;
    height: 17px;
}

.ts-hero-title {
    margin-top: 16px;
    font-family: var(--ts-serif);
    font-size: clamp(1.9rem, 4.6vw, 2.9rem);
    font-weight: 600;
    line-height: 1.25;
    color: #ffffff;
    text-wrap: balance;
}

.ts-hero-sub {
    margin-top: 10px;
    max-width: 46rem;
    text-wrap: balance;
    font-size: clamp(.98rem, 1.5vw, 1.08rem);
    line-height: 1.75;
    color: #e0e7ff;
}

.ts-hero-date {
    margin-top: 4px;
    font-size: .92rem;
    color: #e0e7ff;
}

/* ═══════════════════════════════════════════════════════════════════════
   การ์ดตัวเลข ลอยทับขอบล่างของหัวหน้า (ทั้งใบเป็นลิงก์ไปหมวดของมัน)
   ═══════════════════════════════════════════════════════════════════════ */

.ts-figs {
    position: relative;
    z-index: 1;
    margin-top: calc(-1 * clamp(66px, 7vw, 86px));
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: clamp(10px, 1.2vw, 16px);
}

.ts-figs > li {
    min-width: 0;
    display: flex;
}

.ts .ts-fig {
    position: relative;
    overflow: hidden;
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 18px 16px 16px;
    color: var(--ts-muted);
    text-decoration: none;
    background: var(--ts-paper);
    border: 1px solid var(--ts-line);
    border-radius: var(--ts-r);
    box-shadow: var(--ts-shadow-float);
    transition: border-color .25s var(--ts-ease), box-shadow .25s var(--ts-ease);
}

.ts .ts-fig:hover {
    border-color: var(--ts-brand-line);
    box-shadow: 0 26px 48px -26px rgba(15, 23, 42, .7), inset 0 1px 0 rgba(255, 255, 255, .6);
}

.ts .ts-fig:focus-visible {
    outline-offset: 3px;
}

/* แถบสีบนขอบการ์ด เปลี่ยนสีตามสถานะ */
.ts-fig::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--tb1-banner-1, #1d4ed8), var(--tb1-accent, #0ea5e9));
    transform-origin: left center;
}

.ts-fig.is-warn::before {
    background: var(--ts-warn);
}

.ts-fig.is-crit::before {
    background: var(--ts-crit);
}

.ts-fig-k {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    font-size: .88rem;
    line-height: 1.45;
    color: var(--ts-muted);
}

.ts-fig-ic {
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    background: linear-gradient(135deg, var(--tb1-banner-1, #1d4ed8), var(--tb1-accent-strong, #0284c7));
    border-radius: 11px;
}

.ts-fig.is-warn .ts-fig-ic {
    background: linear-gradient(135deg, #b45309, #d97706);
}

.ts-fig.is-crit .ts-fig-ic {
    background: linear-gradient(135deg, #b91c1c, #dc2626);
}

.ts-fig-v {
    margin-top: 2px;
    color: var(--ts-muted);
    font-size: .95rem;
}

.ts-fig-v b {
    font-family: var(--ts-serif);
    font-size: clamp(1.6rem, 2.3vw, 2.05rem);
    font-weight: 600;
    line-height: 1.15;
    color: var(--ts-ink);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.ts-fig.is-warn .ts-fig-v b {
    color: var(--ts-warn-fg);
}

.ts-fig.is-crit .ts-fig-v b {
    color: var(--ts-crit-fg);
}

.ts-fig-s {
    font-size: .86rem;
    line-height: 1.5;
    color: var(--ts-muted);
    overflow-wrap: anywhere;
}

.ts-fig.is-warn .ts-fig-s {
    color: var(--ts-warn-fg);
    font-weight: 600;
}

.ts-fig.is-crit .ts-fig-s {
    color: var(--ts-crit-fg);
    font-weight: 600;
}

/* ═══════════════════════════════════════════════════════════════════════
   กล่องแจ้ง (ดึงข้อมูลไม่สำเร็จ · เปิดหน้าไม่ได้)
   ═══════════════════════════════════════════════════════════════════════ */

.ts-callout {
    margin-top: clamp(22px, 3vw, 32px);
    padding: 18px 22px;
    color: var(--ts-ink-2);
    background: var(--ts-paper);
    border: 1px solid var(--ts-line);
    border-left: 5px solid var(--ts-brand);
    border-radius: var(--ts-rs);
    box-shadow: var(--ts-shadow);
    line-height: 1.7;
}

.ts-callout.is-warn {
    background: var(--ts-warn-bg);
    border-color: var(--ts-warn);
}

.ts-callout-title {
    font-family: var(--ts-serif);
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--ts-ink);
}

.ts-callout p {
    margin-top: 4px;
}

.ts-callout ul {
    margin-top: 8px;
    padding-left: 1.3rem;
    list-style: disc;
}

/* ═══════════════════════════════════════════════════════════════════════
   บุคคลทั่วไป / บุคลากร
   ป้าย "เฉพาะบุคลากร" ขึ้นในมุมมองบุคลากรเท่านั้น (หน้าสาธารณะไม่มีส่วนเหล่านั้นอยู่ใน HTML เลย)
   ═══════════════════════════════════════════════════════════════════════ */

.ts-lock {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 10px 2px 8px;
    font-size: .78rem;
    font-weight: 600;
    line-height: 1.5;
    color: #6d28d9;
    background: color-mix(in srgb, #7c3aed 9%, var(--ts-paper));
    border: 1px solid color-mix(in srgb, #7c3aed 35%, var(--ts-paper));
    border-radius: 999px;
    white-space: nowrap;
    vertical-align: middle;
}

.ts-lock .ts-icon {
    width: 13px;
    height: 13px;
}

:is(html.dark, html.dark-mode, html[data-theme="dark"],
    body.dark-mode, body[data-theme="dark"]) .ts .ts-lock {
    color: #c4b5fd;
}

.ts-fig-lock {
    display: inline-flex;
    vertical-align: -2px;
    margin-left: 6px;
    color: #6d28d9;
}

.ts-fig-lock .ts-icon {
    width: 14px;
    height: 14px;
}

:is(html.dark, html.dark-mode, html[data-theme="dark"],
    body.dark-mode, body[data-theme="dark"]) .ts .ts-fig-lock {
    color: #c4b5fd;
}

.ts-audience {
    margin-top: clamp(18px, 2.4vw, 26px);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 14px;
    padding: 12px 16px;
    font-size: .92rem;
    line-height: 1.6;
    color: var(--ts-ink-2);
    background: color-mix(in srgb, #7c3aed 6%, var(--ts-paper));
    border: 1px solid color-mix(in srgb, #7c3aed 28%, var(--ts-line));
    border-radius: var(--ts-rs);
}

.ts-audience.is-preview {
    background: var(--ts-brand-soft);
    border-color: var(--ts-brand-line);
}

.ts-audience p {
    flex: 1 1 18rem;
    min-width: 0;
}

.ts-audience b {
    color: var(--ts-ink);
}

.ts-audience-ic {
    width: 34px;
    height: 34px;
    display: inline-flex;
    flex: none;
    align-items: center;
    justify-content: center;
    color: #6d28d9;
    background: var(--ts-paper);
    border-radius: 10px;
}

.ts-audience.is-preview .ts-audience-ic {
    color: var(--ts-brand);
}

:is(html.dark, html.dark-mode, html[data-theme="dark"],
    body.dark-mode, body[data-theme="dark"]) .ts .ts-audience-ic {
    color: #c4b5fd;
}

.ts .ts-audience .ts-btn {
    text-decoration: none;
}

.ts .ts-link {
    color: var(--ts-brand);
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.ts .ts-login {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 32px;
}

.ts-login .ts-icon {
    width: 18px;
    height: 18px;
}

/* ═══════════════════════════════════════════════════════════════════════
   แถบเครื่องมือ ติดใต้แถบเมนูตอนเลื่อน
   ═══════════════════════════════════════════════════════════════════════ */

.ts-tools {
    position: sticky;
    top: var(--ts-nav-h, 57px);
    z-index: 20;
    margin-top: clamp(22px, 3vw, 34px);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 14px;
    padding: 8px 10px;
    background: color-mix(in srgb, var(--ts-paper) 90%, transparent);
    border: 1px solid var(--ts-line);
    border-radius: 999px;
    box-shadow: var(--ts-shadow);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
}

.ts-nav {
    min-width: 0;
    flex: 1 1 auto;
}

.ts-nav-list {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.ts .ts-nav-a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 36px;
    padding: 6px 14px;
    font-size: .92rem;
    font-weight: 500;
    color: var(--ts-ink-2);
    text-decoration: none;
    border-radius: 999px;
    white-space: nowrap;
    transition: background-color .2s var(--ts-ease), color .2s var(--ts-ease);
}

.ts .ts-nav-a:hover {
    color: var(--ts-brand);
    background: var(--ts-brand-soft);
}

.ts .ts-nav-a[aria-current="location"] {
    color: #ffffff;
    background: var(--ts-brand);
}

.ts-nav-n {
    min-width: 22px;
    padding: 0 7px;
    font-size: .8rem;
    line-height: 20px;
    text-align: center;
    color: #ffffff;
    background: #b45309;
    border-radius: 999px;
}

.ts-tools-act {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 14px;
    margin-left: auto;
}

.ts-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 36px;
    padding: 6px 16px;
    font: inherit;
    font-size: .9rem;
    font-weight: 600;
    color: var(--ts-ink-2);
    background: var(--ts-paper);
    border: 1px solid var(--ts-line-bold);
    border-radius: 999px;
    cursor: pointer;
    transition: border-color .2s, color .2s, background-color .2s;
}

.ts-btn:hover {
    color: var(--ts-brand);
    border-color: var(--ts-brand);
}

.ts-btn .ts-icon {
    width: 18px;
    height: 18px;
}

/* ═══════════════════════════════════════════════════════════════════════
   หมวดและแผง
   ═══════════════════════════════════════════════════════════════════════ */

.ts-sec {
    margin-top: clamp(34px, 4.4vw, 56px);
}

.ts-sec-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 14px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--ts-line);
}

/* หัวเรื่องมีขีดสีนำ แบบหัวเรื่องย่อยของ zerodropout */
.ts-sec-title {
    position: relative;
    padding-left: 16px;
    font-family: var(--ts-serif);
    font-size: clamp(1.2rem, 2vw, 1.45rem);
    font-weight: 600;
    line-height: 1.4;
    color: var(--ts-ink);
    text-wrap: balance;
}

.ts-sec-title::before {
    content: "";
    position: absolute;
    left: 0;
    top: .2em;
    bottom: .2em;
    width: 5px;
    border-radius: 999px;
    background: linear-gradient(180deg, var(--tb1-banner-1, #1d4ed8), var(--tb1-accent, #0ea5e9));
    transform-origin: center top;
}

.ts-sec-count {
    padding: 3px 12px;
    font-size: .88rem;
    font-weight: 600;
    color: var(--ts-brand);
    background: var(--ts-brand-soft);
    border-radius: 999px;
    font-variant-numeric: tabular-nums;
}

.ts-sec-note {
    margin-top: 12px;
    font-size: .92rem;
    line-height: 1.6;
    color: var(--ts-muted);
}

.ts-grid-2 {
    margin-top: 18px;
    display: grid;
    gap: clamp(12px, 1.4vw, 18px);
    align-items: start;
}

.ts-grid-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.ts-panel {
    min-width: 0;
    background: var(--ts-paper);
    border: 1px solid var(--ts-line);
    border-radius: var(--ts-r);
    box-shadow: var(--ts-shadow);
    overflow: hidden;
}

.ts-sec > .ts-panel {
    margin-top: 18px;
}

.ts-panel-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 12px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--ts-line);
    background: linear-gradient(180deg, var(--ts-paper-alt), var(--ts-paper));
}

.ts-panel-ic {
    width: 34px;
    height: 34px;
    display: inline-flex;
    flex: none;
    align-items: center;
    justify-content: center;
    color: var(--ts-brand);
    background: var(--ts-brand-soft);
    border-radius: 10px;
}

.ts-panel-ic .ts-icon {
    width: 18px;
    height: 18px;
}

.ts-panel-title {
    font-family: var(--ts-serif);
    font-size: 1.08rem;
    font-weight: 600;
    line-height: 1.4;
    color: var(--ts-ink);
}

.ts-panel-note {
    margin-left: auto;
    font-size: .86rem;
    line-height: 1.5;
    color: var(--ts-muted);
}

.ts-panel-body {
    position: relative;
    padding: 16px 20px 18px;
}

.ts-note {
    margin-bottom: 14px;
    max-width: 72ch;
    font-size: .88rem;
    line-height: 1.65;
    color: var(--ts-muted);
}

.ts-empty {
    padding: 18px 0;
    font-size: .92rem;
    color: var(--ts-muted);
}

.ts-foot-note {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px dashed var(--ts-line-bold);
    font-size: .84rem;
    line-height: 1.6;
    color: var(--ts-muted);
}



.ts-bars {
    display: flex;
    flex-direction: column;
}

.ts-row {
    display: grid;
    grid-template-columns: minmax(0, 10rem) minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
    border-top: 1px solid var(--ts-line);
    transition: opacity .25s, filter .25s;
}

.ts-row:first-child {
    border-top: 0;
}

.ts-bars.is-wide .ts-row {
    grid-template-columns: minmax(0, 14rem) minmax(0, 1fr) minmax(0, 13rem);
}

.ts-row-n {
    font-size: .9rem;
    font-weight: 500;
    line-height: 1.4;
    color: var(--ts-ink);
    overflow-wrap: anywhere;
}

.ts-track {
    position: relative;
    display: block;
    height: 14px;
    background: var(--ts-paper-alt);
    border-radius: 4px;
    overflow: hidden;
}

.ts-bar {
    position: absolute;
    inset: 0 auto 0 0;
    width: var(--w);
    background: var(--ts-neutral);
    border-radius: 4px;
    transform-origin: left center;
}

.ts-bar.is-warn {
    background: var(--ts-warn);
}

.ts-bar.is-ok {
    background: var(--ts-ok);
}

.ts-row-v {
    font-size: .86rem;
    color: var(--ts-muted);
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.ts-row-v b {
    font-weight: 700;
    color: var(--ts-ink);
}

.ts-row.is-flag .ts-row-v b {
    color: var(--ts-warn-fg);
}

.ts-legend {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 18px;
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid var(--ts-line);
    font-size: .84rem;
    color: var(--ts-muted);
}

.ts-legend b {
    color: var(--ts-ink);
    font-variant-numeric: tabular-nums;
}

.ts-legend-end {
    margin-left: auto;
}




.ts-about {
    margin-top: clamp(28px, 3.4vw, 40px);
    padding: 18px 22px;
    background: var(--ts-paper-alt);
    border: 1px solid var(--ts-line);
    border-radius: var(--ts-r);
}

.ts-about-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: var(--ts-serif);
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--ts-ink);
}

.ts-about-title .ts-icon {
    color: var(--ts-brand);
}

.ts-about-list {
    margin-top: 10px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px 28px;
}

.ts-about-list li {
    font-size: .88rem;
    line-height: 1.65;
    color: var(--ts-muted);
}

.ts-about-list b {
    color: var(--ts-ink);
}

.ts-about-meta {
    margin-top: 12px;
    font-size: .82rem;
    color: var(--ts-muted);
}


.ts-tip {
    position: absolute;
    z-index: 30;
    max-width: 16rem;
    padding: 7px 11px;
    font-size: .84rem;
    line-height: 1.45;
    color: var(--ts-tip-ink);
    background: var(--ts-tip-bg);
    border-radius: 7px;
    box-shadow: 0 10px 24px -12px rgba(0, 0, 0, .5);
    pointer-events: none;
    transform: translate(-50%, calc(-100% - 10px));
}

.ts-tip b {
    color: #ffffff;
    font-variant-numeric: tabular-nums;
}

.ts .is-subject { --ts-tone: var(--ts-g-subject); }
.ts .is-home    { --ts-tone: var(--ts-g-home); }
.ts .is-develop { --ts-tone: var(--ts-g-develop); }
.ts .is-work    { --ts-tone: var(--ts-g-work); }

/* ═══════════════════════════════════════════════════════════════════════
   ภาคเรียนในหัวหน้า (ขึ้นเมื่อมีมากกว่าหนึ่งภาคเรียน)
   ═══════════════════════════════════════════════════════════════════════ */

.ts-terms {
    margin-top: 16px;
}

.ts-terms ul {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
}

.ts .ts-term {
    display: inline-flex;
    align-items: center;
    min-height: 36px;
    padding: 6px 16px;
    font-size: .9rem;
    font-weight: 600;
    color: #ffffff;
    text-decoration: none;
    background: rgba(255, 255, 255, .1);
    border: 1px solid rgba(255, 255, 255, .28);
    border-radius: 999px;
    transition: background-color .2s var(--ts-ease);
}

.ts .ts-term:hover {
    background: rgba(255, 255, 255, .2);
}

.ts .ts-term[aria-current="page"] {
    color: #0b1324;
    background: #ffffff;
    border-color: #ffffff;
}

/* การ์ดตัวเลขห้าหรือหกใบ */
.ts-figs.is-5 {
    grid-template-columns: repeat(5, minmax(0, 1fr));
}

.ts-fig-v small {
    font-size: .9rem;
}

/* ═══════════════════════════════════════════════════════════════════════
   เลือกครู
   ═══════════════════════════════════════════════════════════════════════ */

.ts-pick-card {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) minmax(0, 26rem);
    align-items: center;
    gap: 16px 22px;
    padding: 22px 24px;
    background:
        radial-gradient(circle at 100% 0%, var(--ts-brand-soft) 0%, transparent 55%),
        var(--ts-paper);
    border: 1px solid var(--ts-line);
    border-radius: var(--ts-r);
    box-shadow: var(--ts-shadow);
}

.ts-pick-ic {
    width: 56px;
    height: 56px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    background: linear-gradient(135deg, var(--tb1-banner-1, #1d4ed8), var(--tb1-accent-strong, #0284c7));
    border-radius: 16px;
}

.ts-pick-ic .ts-icon {
    width: 26px;
    height: 26px;
}

.ts-pick-t {
    font-family: var(--ts-serif);
    font-size: clamp(1.15rem, 1.8vw, 1.35rem);
    font-weight: 600;
    line-height: 1.4;
    color: var(--ts-ink);
}

.ts-pick-s {
    margin-top: 4px;
    font-size: .92rem;
    line-height: 1.65;
    color: var(--ts-muted);
}

.ts-pick {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.ts-pick-lb {
    font-size: .86rem;
    font-weight: 600;
    color: var(--ts-ink-2);
}

.ts-pick-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.ts .ts-select {
    flex: 1 1 12rem;
    min-width: 0;
    min-height: 44px;
    padding: 8px 36px 8px 14px;
    font: inherit;
    font-size: .95rem;
    color: var(--ts-ink);
    background-color: var(--ts-paper);
    border: 1px solid var(--ts-line-bold);
    border-radius: 12px;
}

.ts .ts-select:focus-visible {
    border-color: var(--ts-brand);
}

.ts .ts-btn.is-primary {
    min-height: 44px;
    padding: 8px 20px;
    color: #ffffff;
    text-decoration: none;
    background: var(--tb1-banner-1, #1d4ed8);
    border-color: var(--tb1-banner-1, #1d4ed8);
}

.ts .ts-btn.is-primary:hover {
    color: #ffffff;
    background: color-mix(in srgb, var(--tb1-banner-1, #1d4ed8) 85%, #000000);
}

.ts .ts-pick.is-compact {
    flex: 0 1 22rem;
    align-self: flex-start;
}

.ts .ts-pick.is-compact .ts-select,
.ts .ts-pick.is-compact .ts-btn {
    min-height: 40px;
}

/* ═══════════════════════════════════════════════════════════════════════
   การ์ดครู (หัวใบตารางสอน)
   ═══════════════════════════════════════════════════════════════════════ */

.ts-sheet-sec {
    scroll-margin-top: var(--ts-stick, 8.5rem);
}

.ts-sheet-sec:focus {
    outline: none;
}

.ts-who {
    position: relative;
    overflow: hidden;
    padding: clamp(18px, 2.4vw, 26px);
    background: var(--ts-paper);
    border: 1px solid var(--ts-line);
    border-radius: var(--ts-r);
    box-shadow: var(--ts-shadow);
}

/* แถบสีบนขอบการ์ด แบบเดียวกับการ์ดตัวเลข */
.ts-who::before {
    content: "";
    position: absolute;
    inset: 0 0 auto;
    height: 5px;
    background: linear-gradient(90deg, var(--tb1-banner-1, #1d4ed8), var(--tb1-accent, #0ea5e9));
    transform-origin: left center;
}

.ts-who-top {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 16px 22px;
}

.ts-who-face {
    flex: none;
    width: 96px;
    height: 96px;
    object-fit: cover;
    object-position: center top;
    background: var(--ts-paper-alt);
    border-radius: 50%;
    box-shadow: 0 0 0 4px var(--ts-paper), 0 0 0 7px var(--ts-brand-line);
}

.ts-who-txt {
    flex: 1 1 18rem;
    min-width: 0;
}

.ts-who-eyebrow {
    font-size: .86rem;
    font-weight: 600;
    color: var(--ts-brand);
}

.ts-who-name {
    margin-top: 2px;
    font-family: var(--ts-serif);
    font-size: clamp(1.4rem, 2.6vw, 1.9rem);
    font-weight: 600;
    line-height: 1.3;
    color: var(--ts-ink);
    overflow-wrap: anywhere;
}

.ts-who-dept {
    margin-top: 4px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 14px;
    font-size: .95rem;
    color: var(--ts-ink-2);
}

.ts-who-code {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--ts-muted);
}

.ts-who-links {
    margin-top: 8px;
}

.ts .ts-who-links .ts-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 28px;
}

.ts-who-links .ts-icon {
    width: 17px;
    height: 17px;
}

.ts-who-stats {
    margin-top: 18px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr));
    gap: 10px;
}

.ts-who-stat {
    padding: 10px 14px;
    background: var(--ts-paper-alt);
    border-left: 4px solid var(--ts-brand);
    border-radius: 0 10px 10px 0;
}

.ts-who-v {
    display: block;
    font-size: .88rem;
    color: var(--ts-muted);
}

.ts-who-v b {
    font-family: var(--ts-serif);
    font-size: 1.6rem;
    font-weight: 600;
    line-height: 1.2;
    color: var(--ts-ink);
    font-variant-numeric: tabular-nums;
}

.ts-who-l {
    display: flex;
    align-items: center;
    font-size: .86rem;
    color: var(--ts-muted);
}

.ts-who-foot {
    margin-top: 18px;
    padding-top: 16px;
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
    gap: 16px 28px;
    border-top: 1px dashed var(--ts-line-bold);
}

.ts-who-classes {
    grid-column: 1 / -1;
}

.ts-who-mix-t {
    margin-bottom: 8px;
    font-size: .88rem;
    font-weight: 600;
    color: var(--ts-ink-2);
}

.ts-who-mix-t span {
    font-weight: 400;
    color: var(--ts-muted);
}

/* แถบซ้อนสี่กลุ่ม */
.ts-stack {
    display: flex;
    gap: 2px;
    height: 16px;
    border-radius: 6px;
    overflow: hidden;
    background: var(--ts-paper-alt);
}

.ts-seg {
    min-width: 4px;
    background: var(--ts-tone);
    transform-origin: left center;
}

.ts-legend.is-tight {
    margin-top: 10px;
    padding-top: 0;
    border-top: 0;
    gap: 6px 16px;
}

.ts-sw {
    display: inline-block;
    width: 18px;
    height: 10px;
    margin-right: 7px;
    vertical-align: 0;
    background: var(--ts-tone);
    border-radius: 3px;
}

.ts-days {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(3.6rem, 1fr));
    gap: 6px;
}

.ts-day {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 4px 7px;
    text-align: center;
    background: var(--ts-paper-alt);
    border: 1px solid var(--ts-line);
    border-radius: 10px;
}

.ts-day-n {
    font-size: .82rem;
    color: var(--ts-muted);
}

.ts-day b {
    font-family: var(--ts-serif);
    font-size: 1.3rem;
    font-weight: 600;
    line-height: 1.25;
    color: var(--ts-ink);
    font-variant-numeric: tabular-nums;
}

.ts-day-u {
    font-size: .76rem;
    color: var(--ts-muted);
}

.ts-day.is-off b {
    color: var(--ts-muted);
}

/* วันนี้: ทำเครื่องหมายด้วยรูปทรง (กรอบหนาและคำว่า "วันนี้") ไม่ใช่สี เพราะสีบอกกลุ่มคาบไปแล้ว */
.ts-day.is-today {
    border: 2px solid var(--ts-brand);
    background: var(--ts-brand-soft);
}

.ts-day-today,
.ts-g-today {
    display: inline-block;
    margin-top: 3px;
    padding: 0 8px;
    font-size: .72rem;
    font-weight: 700;
    line-height: 1.6;
    color: #ffffff;
    background: var(--ts-brand);
    border-radius: 999px;
}

:is(html.dark, html.dark-mode, html[data-theme="dark"],
    body.dark-mode, body[data-theme="dark"]) .ts :is(.ts-day-today, .ts-g-today) {
    color: #0b1324;
}

.ts-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.ts-chips li {
    padding: 2px 11px;
    font-size: .86rem;
    font-weight: 600;
    color: var(--ts-ink-2);
    background: var(--ts-paper-alt);
    border: 1px solid var(--ts-line);
    border-radius: 999px;
    font-variant-numeric: tabular-nums;
}

/* ═══════════════════════════════════════════════════════════════════════
   ผังตารางรายสัปดาห์
   ═══════════════════════════════════════════════════════════════════════ */

.ts-sheet-panel {
    margin-top: 16px;
}

.ts-grid-wrap {
    position: relative;
}

/* ★ .sr-only ในตารางต้องมีบรรพบุรุษที่ position ไม่ใช่ static ไม่งั้นหน้าเลื่อนแนวนอนได้ที่จอแคบ */
.ts-grid-scroll {
    position: relative;
    overflow-x: auto;
    border: 1px solid var(--ts-line);
    border-radius: 12px;
}

.ts-grid {
    width: 100%;
    /* ช่องคาบกว้างอย่างน้อยราว 100px ปุ่มเปิดเช็คชื่อและรหัสวิชาจึงไม่ถูกตัด จอที่แคบกว่านี้เลื่อนด้านข้างในกรอบ */
    min-width: 1180px;
    table-layout: fixed;
    border-collapse: separate;
    border-spacing: 0;
    font-size: .86rem;
}

.ts-grid th,
.ts-grid td {
    position: relative;
    border-right: 1px solid var(--ts-line);
    border-bottom: 1px solid var(--ts-line);
}

.ts-grid tr > :last-child {
    border-right: 0;
}

.ts-grid tbody tr:last-child > * {
    border-bottom: 0;
}

.ts-g-corner {
    width: 104px;
}

.ts-grid thead th {
    padding: 8px 6px;
    text-align: center;
    vertical-align: bottom;
    background: var(--ts-paper-alt);
}

.ts-g-h.is-break {
    width: 38px;
    padding-inline: 2px;
}

.ts-g-p {
    display: block;
    font-weight: 700;
    color: var(--ts-ink);
}

.ts-g-t {
    display: block;
    margin-top: 2px;
    font-size: .76rem;
    font-weight: 400;
    color: var(--ts-muted);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* ช่วงพักแคบ เวลาเรียงลงแนวตั้ง */
.ts-g-h.is-break .ts-g-t {
    white-space: normal;
    line-height: 1.25;
}

.ts-g-h.is-break .ts-g-dash {
    display: block;
}

.ts-g-corner,
.ts-g-day {
    position: sticky;
    left: 0;
    z-index: 2;
    background: var(--ts-paper-alt);
}

.ts-g-day {
    padding: 10px 10px 10px 14px;
    text-align: left;
    vertical-align: top;
    font-weight: 400;
}

.ts-g-dn {
    display: block;
    font-family: var(--ts-serif);
    font-size: 1rem;
    font-weight: 600;
    color: var(--ts-ink);
}

.ts-g-dc {
    display: block;
    font-size: .78rem;
    color: var(--ts-muted);
}

.ts-g-row.is-today .ts-g-day {
    box-shadow: inset 5px 0 0 var(--ts-brand);
    background: var(--ts-brand-soft);
}

.ts-g-row.is-today td {
    background: color-mix(in srgb, var(--ts-brand) 3%, var(--ts-paper));
}

.ts-g-c {
    padding: 5px;
    vertical-align: top;
    background: var(--ts-paper);
}

.ts-g-c.is-empty.is-break,
.ts-g-c.is-empty:where(.is-break) {
    background:
        repeating-linear-gradient(135deg, transparent 0 6px, color-mix(in srgb, var(--ts-line-bold) 55%, transparent) 6px 7px),
        var(--ts-paper-alt);
}

/* ★ คาบซ้อนกัน: ทำเครื่องหมายที่ขอบบนของช่อง ไม่ลงพื้นทั้งช่อง ตัวอักษรในช่องจึงยังอ่านออกเท่าเดิม */
.ts-g-c.is-multi {
    box-shadow: inset 0 3px 0 var(--ts-warn);
}

.ts-g-multi {
    margin: 0 0 4px;
    font-size: .74rem;
    font-weight: 700;
    color: var(--ts-warn-fg);
}

/* คาบหนึ่งใบ: พื้นอ่อนตามกลุ่ม เส้นซ้ายสีและลายตามกลุ่ม */
.ts-blk {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 1px;
    height: 100%;
    padding: 6px 8px 7px 10px;
    background: color-mix(in srgb, var(--ts-tone) 8%, var(--ts-paper));
    border-left: 4px solid var(--ts-tone);
    border-radius: 3px 8px 8px 3px;
    overflow-wrap: anywhere;
}

.ts-blk.is-home {
    border-left: 5px double var(--ts-tone);
}

.ts-blk.is-develop {
    border-left-style: dashed;
}

.ts-blk.is-work {
    border-left-style: dotted;
}

.ts-blk + .ts-blk {
    margin-top: 5px;
}

.ts-g-c.is-multi .ts-blk + .ts-blk {
    margin-top: 6px;
    outline: 1px dashed var(--ts-line-bold);
    outline-offset: 2px;
}

.ts-blk-t {
    font-size: .86rem;
    font-weight: 700;
    line-height: 1.35;
    color: var(--ts-ink);
}

.ts-blk-m {
    display: flex;
    flex-wrap: wrap;
    gap: 0 8px;
    font-size: .78rem;
    color: var(--ts-ink-2);
    font-variant-numeric: tabular-nums;
}

.ts-blk-cl {
    font-weight: 700;
}

.ts-blk-k {
    font-size: .76rem;
    font-weight: 600;
    color: var(--ts-tone);
}

.ts-off {
    display: block;
    font-weight: 400;
    color: var(--ts-muted);
}

.ts-blk-time {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: .74rem;
    color: var(--ts-ink-2);
    font-variant-numeric: tabular-nums;
}

.ts-blk-time .ts-icon {
    width: 12px;
    height: 12px;
}

.ts-flag {
    margin-top: 2px;
    font-size: .74rem;
    font-weight: 700;
    color: var(--ts-warn-fg);
}

.ts .ts-act {
    align-self: flex-start;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    min-height: 26px;
    margin-top: 4px;
    padding: 2px 10px 2px 7px;
    font-size: .76rem;
    font-weight: 700;
    color: var(--ts-brand);
    text-decoration: none;
    background: var(--ts-paper);
    border: 1px solid var(--ts-brand-line);
    border-radius: 999px;
}

.ts .ts-act:hover {
    background: var(--ts-brand-soft);
    border-color: var(--ts-brand);
}

.ts-act .ts-icon {
    width: 13px;
    height: 13px;
}

/* รายการรายวัน แสดงแทนผังตารางบนจอแคบ */
.ts-agenda {
    display: none;
}

.ts-ag-day + .ts-ag-day {
    margin-top: 14px;
}

.ts-ag-h {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 10px;
    padding: 6px 0 6px 12px;
    font-family: var(--ts-serif);
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--ts-ink);
    border-left: 4px solid var(--ts-line-bold);
}

.ts-ag-day.is-today .ts-ag-h {
    border-left-color: var(--ts-brand);
}

.ts-ag-h .ts-g-today {
    margin-top: 0;
    font-family: var(--ts-sans);
}

.ts-ag-n {
    margin-left: auto;
    font-family: var(--ts-sans);
    font-size: .82rem;
    font-weight: 400;
    color: var(--ts-muted);
}

.ts-ag-list {
    margin-top: 6px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ts-ag-item {
    display: grid;
    grid-template-columns: 5.6rem minmax(0, 1fr);
    gap: 10px;
    align-items: start;
}

.ts-ag-time {
    display: flex;
    flex-direction: column;
    padding-top: 6px;
    font-size: .8rem;
    color: var(--ts-muted);
    font-variant-numeric: tabular-nums;
}

.ts-ag-time b {
    font-size: .86rem;
    color: var(--ts-ink);
}

.ts-empty-card {
    margin-top: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: clamp(24px, 4vw, 40px) 20px;
    text-align: center;
    background: var(--ts-paper);
    border: 1px dashed var(--ts-line-bold);
    border-radius: var(--ts-r);
}

.ts-empty-card.is-warn {
    background: var(--ts-warn-bg);
    border-color: var(--ts-warn);
}

.ts-empty-ic {
    color: var(--ts-brand);
}

.ts-empty-card.is-warn .ts-empty-ic {
    color: var(--ts-warn-fg);
}

.ts-empty-ic .ts-icon {
    width: 32px;
    height: 32px;
}

.ts-empty-t {
    font-family: var(--ts-serif);
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--ts-ink);
}

.ts-empty-s {
    max-width: 40rem;
    font-size: .92rem;
    color: var(--ts-muted);
}

.ts .ts-empty-card .ts-btn {
    text-decoration: none;
}

/* ครูก่อนหน้า / ถัดไป */
.ts-pager {
    margin-top: 16px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: center;
    gap: 10px;
}

.ts .ts-pager-a {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 52px;
    padding: 8px 14px;
    color: var(--ts-ink);
    text-decoration: none;
    background: var(--ts-paper);
    border: 1px solid var(--ts-line);
    border-radius: 12px;
    transition: border-color .2s var(--ts-ease), background-color .2s var(--ts-ease);
}

.ts .ts-pager-a:hover {
    border-color: var(--ts-brand);
    background: var(--ts-brand-soft);
}

.ts-pager-a.is-next {
    justify-content: flex-end;
    text-align: right;
}

.ts-pager-a span {
    display: flex;
    flex-direction: column;
    min-width: 0;
    font-weight: 600;
    overflow-wrap: anywhere;
}

.ts-pager-a small {
    font-size: .78rem;
    font-weight: 400;
    color: var(--ts-muted);
}

.ts-pager-a .ts-icon {
    flex: none;
    color: var(--ts-brand);
}

.ts .ts-pager-all {
    display: inline-flex;
    align-items: center;
    min-height: 36px;
    padding: 6px 12px;
    font-size: .88rem;
    font-weight: 600;
    color: var(--ts-brand);
    text-align: center;
}

/* ═══════════════════════════════════════════════════════════════════════
   ผังภาระงานรายครู
   ═══════════════════════════════════════════════════════════════════════ */

.ts-find {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 10px;
}

.ts-find-in {
    position: relative;
    display: flex;
    align-items: center;
}

.ts-find-in .ts-icon {
    position: absolute;
    left: 12px;
    width: 18px;
    height: 18px;
    color: var(--ts-muted);
    pointer-events: none;
}

.ts .ts-find input {
    width: min(18rem, 60vw);
    min-height: 40px;
    padding: 6px 14px 6px 38px;
    font: inherit;
    font-size: .92rem;
    color: var(--ts-ink);
    background: var(--ts-paper);
    border: 1px solid var(--ts-line-bold);
    border-radius: 999px;
}

.ts .ts-find input:focus-visible {
    border-color: var(--ts-brand);
}

.ts-kbd {
    display: inline-flex;
    gap: 3px;
    font-size: .76rem;
    color: var(--ts-muted);
}

.ts-kbd kbd {
    padding: 1px 6px;
    font-family: inherit;
    font-size: .76rem;
    color: var(--ts-ink-2);
    background: var(--ts-paper-alt);
    border: 1px solid var(--ts-line-bold);
    border-radius: 5px;
}

.ts-find-meta {
    margin-top: 8px;
    font-size: .9rem;
    font-weight: 600;
    color: var(--ts-brand);
}

.ts-find-empty {
    margin-top: 18px;
    padding: 22px;
    text-align: center;
    color: var(--ts-muted);
    background: var(--ts-paper);
    border: 1px dashed var(--ts-line-bold);
    border-radius: var(--ts-r);
}

/* ★ สองคอลัมน์แบบ columns ไม่ใช่ grid: กลุ่มสาระยาวไม่เท่ากัน (1 ถึง 20 ท่าน) grid จะเหลือช่องว่างใต้กลุ่มสั้น
   ลำดับการอ่านยังเป็นลำดับกลุ่มในทำเนียบ (ลงคอลัมน์ซ้ายก่อน) */
.ts-depts {
    margin-top: 18px;
    columns: 2;
    column-gap: clamp(12px, 1.4vw, 18px);
}

.ts-dept {
    break-inside: avoid;
    margin-bottom: clamp(12px, 1.4vw, 18px);
    scroll-margin-top: var(--ts-stick, 8.5rem);
}

.ts-pnote-warn {
    margin-left: 6px;
    font-weight: 700;
    color: var(--ts-warn-fg);
}

.ts-lrows {
    display: flex;
    flex-direction: column;
}

.ts-lrow {
    display: grid;
    grid-template-columns: 36px minmax(0, 12.5rem) minmax(0, 1fr) 4.4rem;
    align-items: center;
    gap: 12px;
    padding: 7px 8px;
    margin-inline: -8px;
    border-top: 1px solid var(--ts-line);
    border-radius: 10px;
}

.ts-lrow:first-child {
    border-top-color: transparent;
}

.ts-av {
    width: 36px;
    height: 36px;
    object-fit: cover;
    object-position: center top;
    background: var(--ts-paper-alt);
    border-radius: 50%;
    box-shadow: 0 0 0 1px var(--ts-line);
}

.ts-lwho {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.ts .ts-lname {
    display: inline-block;
    align-self: flex-start;
    min-height: 24px;
    padding: 1px 0;
    font-weight: 600;
    line-height: 1.4;
    color: var(--ts-ink);
    overflow-wrap: anywhere;
}

.ts .ts-lwho a.ts-lname {
    color: var(--ts-ink);
    text-decoration: underline;
    text-decoration-color: var(--ts-brand-line);
    text-underline-offset: 3px;
}

.ts .ts-lwho a.ts-lname:hover {
    color: var(--ts-brand);
    text-decoration-color: currentColor;
}

.ts-lsub {
    font-size: .8rem;
    line-height: 1.45;
    color: var(--ts-muted);
}

.ts-lrev {
    font-weight: 700;
    color: var(--ts-warn-fg);
}

.ts-ltrack {
    position: relative;
    display: block;
    height: 12px;
    background: var(--ts-paper-alt);
    border-radius: 999px;
}

.ts-ltrack.is-blank {
    background: repeating-linear-gradient(135deg, transparent 0 5px, var(--ts-line) 5px 6px);
}

.ts-ltrack.is-void {
    background: none;
}

.ts-lbar {
    position: absolute;
    inset: 0 auto 0 0;
    width: var(--w);
    background: linear-gradient(90deg, color-mix(in srgb, var(--ts-brand) 70%, var(--ts-paper)), var(--ts-brand));
    border-radius: 999px;
    transform-origin: left center;
}

/* ขีดค่ากลาง ยาวเลยรางขึ้นลงเล็กน้อย เห็นเป็นแนวเดียวกันทั้งกลุ่ม */
.ts-lmed {
    position: absolute;
    top: -4px;
    bottom: -4px;
    left: var(--m);
    width: 0;
    border-left: 2px dashed var(--ts-ink-2);
}

.ts-lval {
    font-family: var(--ts-serif);
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--ts-ink);
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.ts-lval small {
    font-family: var(--ts-sans);
    font-size: .76rem;
    font-weight: 400;
    color: var(--ts-muted);
}

.ts-lval.is-none {
    color: var(--ts-muted);
}

.ts-lrow.is-current {
    background: var(--ts-brand-soft);
    box-shadow: inset 4px 0 0 var(--ts-brand);
}

.ts-lrow.is-flag .ts-lsub {
    font-weight: 700;
    color: var(--ts-warn-fg);
}

.ts-lrow.is-flag .ts-ltrack.is-blank {
    background: repeating-linear-gradient(135deg, transparent 0 5px, color-mix(in srgb, var(--ts-warn) 55%, transparent) 5px 6px);
}

/* ═══════════════════════════════════════════════════════════════════════
   แผงในหมวดภาพรวม ชนิดคาบ ช่วงเวลา
   ═══════════════════════════════════════════════════════════════════════ */

.ts-grid-2.is-time {
    grid-template-columns: minmax(0, 2.1fr) minmax(0, 1fr);
}

.ts .ts-row-n {
    display: flex;
    align-items: center;
}

.ts a.ts-row-n {
    min-height: 24px;
    color: var(--ts-ink);
    text-decoration: underline;
    text-decoration-color: var(--ts-brand-line);
    text-underline-offset: 3px;
}

.ts a.ts-row-n:hover {
    color: var(--ts-brand);
}

.ts-row-v small {
    margin-left: 4px;
    color: var(--ts-muted);
}

.ts-bars .ts-row {
    grid-template-columns: minmax(0, 11rem) minmax(0, 1fr) minmax(0, 8.5rem);
}

.ts-bar.is-subject,
.ts-bar.is-home,
.ts-bar.is-develop,
.ts-bar.is-work {
    background: var(--ts-tone);
}

.ts-bars .ts-bar:not([class*="is-"]) {
    background: linear-gradient(90deg, color-mix(in srgb, var(--ts-brand) 70%, var(--ts-paper)), var(--ts-brand));
}

.ts-axis {
    margin-top: 6px;
    font-size: .8rem;
    text-align: center;
    color: var(--ts-muted);
}

/* คอลัมน์ (การกระจายภาระงาน และช่วงเวลา) */
.ts-cols,
.ts-tcols {
    display: flex;
    align-items: stretch;
    gap: 8px;
}

.ts-col,
.ts-tcol {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.ts-col-plot {
    position: relative;
    width: 100%;
    height: 190px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    border-bottom: 2px solid var(--ts-line-bold);
}

.ts-col-bar {
    display: block;
    width: min(100%, 64px);
    height: var(--h);
    min-height: 2px;
    background: linear-gradient(180deg, color-mix(in srgb, var(--ts-brand) 55%, var(--ts-paper)), color-mix(in srgb, var(--ts-brand) 75%, var(--ts-paper)));
    border-radius: 8px 8px 0 0;
    transform-origin: center bottom;
}

.ts-col.is-median .ts-col-bar {
    background: linear-gradient(180deg, color-mix(in srgb, var(--ts-brand) 80%, var(--ts-paper)), var(--ts-brand));
}

.ts-col-v {
    order: -1;
    margin-bottom: 4px;
    font-size: .92rem;
    font-weight: 700;
    color: var(--ts-ink);
    font-variant-numeric: tabular-nums;
}

.ts-col-lb {
    margin-top: 6px;
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: .82rem;
    line-height: 1.35;
    color: var(--ts-muted);
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.ts-col-lb b {
    font-weight: 600;
    color: var(--ts-ink-2);
    white-space: nowrap;
}

.ts-col-tag {
    margin-top: 4px;
    padding: 0 8px;
    font-size: .74rem;
    font-weight: 700;
    line-height: 1.6;
    color: var(--ts-brand);
    background: var(--ts-brand-soft);
    border-radius: 999px;
}

.ts-tcols-scroll {
    overflow-x: auto;
    padding-bottom: 4px;
}

.ts-tcols {
    min-width: 620px;
    gap: 6px;
}

.ts-tcol .ts-col-plot {
    height: 170px;
}

.ts-tcol .ts-col-bar {
    width: min(100%, 44px);
}

.ts-tcol.is-break {
    flex: 0 0 38px;
}

.ts-tcol.is-break .ts-col-plot {
    background: repeating-linear-gradient(135deg, transparent 0 6px, color-mix(in srgb, var(--ts-line-bold) 55%, transparent) 6px 7px);
    border-radius: 6px 6px 0 0;
}

.ts-tcol.is-break .ts-col-bar {
    background: var(--ts-neutral);
}

.ts-tcol.is-thin .ts-col-bar {
    background: var(--ts-warn);
}

.ts-tcol.is-thin .ts-col-v {
    color: var(--ts-warn-fg);
}

.ts-tcol .ts-col-lb {
    font-size: .76rem;
}

/* สี่กลุ่มของคาบ */
.ts-glist {
    margin-top: 14px;
    display: flex;
    flex-direction: column;
}

.ts-gl {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 4px 10px;
    padding: 9px 0;
    border-top: 1px solid var(--ts-line);
}

.ts-gl:first-child {
    border-top: 0;
}

.ts-gl .ts-sw {
    width: 14px;
    height: 32px;
    margin: 0;
    border-radius: 4px;
}

.ts-gl-t {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.ts-gl-t b {
    color: var(--ts-ink);
}

.ts-gl-t small {
    font-size: .82rem;
    color: var(--ts-muted);
}

.ts-gl-v {
    text-align: right;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.ts-gl-v b {
    font-family: var(--ts-serif);
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--ts-ink);
}

.ts-gl-v small {
    color: var(--ts-muted);
}

.ts-panel .ts-stack {
    height: 22px;
}

/* ═══════════════════════════════════════════════════════════════════════
   ข้อมูลที่ต้องตรวจ (บุคลากร)
   ═══════════════════════════════════════════════════════════════════════ */

.ts-checks {
    margin-top: 18px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: clamp(12px, 1.4vw, 18px);
    align-items: start;
}

.ts-ck {
    position: relative;
    overflow: hidden;
    padding: 18px 20px 18px 24px;
    background: var(--ts-paper);
    border: 1px solid var(--ts-line);
    border-radius: var(--ts-r);
    box-shadow: var(--ts-shadow);
}

.ts-ck::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 5px;
    background: var(--ts-info);
}

.ts-ck.is-warn::before {
    background: var(--ts-warn);
}

.ts-ck.is-ok::before {
    background: var(--ts-ok);
}

.ts-ck-k {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: .8rem;
    font-weight: 700;
    color: var(--ts-info-fg);
}

.ts-ck.is-warn .ts-ck-k {
    color: var(--ts-warn-fg);
}

.ts-ck.is-ok .ts-ck-k {
    color: var(--ts-ok-fg);
}

.ts-ck-k .ts-icon {
    width: 16px;
    height: 16px;
}

.ts-ck-t {
    margin-top: 4px;
    font-family: var(--ts-serif);
    font-size: 1.05rem;
    font-weight: 600;
    line-height: 1.45;
    color: var(--ts-ink);
}

.ts-ck-n {
    margin-top: 2px;
    font-family: var(--ts-serif);
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--ts-ink);
}

.ts-ck.is-warn .ts-ck-n {
    color: var(--ts-warn-fg);
}

.ts-ck-s {
    margin-top: 4px;
    font-size: .88rem;
    line-height: 1.65;
    color: var(--ts-muted);
}

.ts-ck-list {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
}

.ts-ck-list li {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 2px 10px;
    padding: 6px 0;
    font-size: .9rem;
    border-top: 1px solid var(--ts-line);
}

.ts-ck-list li > span {
    color: var(--ts-muted);
}

.ts-ck-list.is-review li > b {
    margin-left: auto;
    color: var(--ts-warn-fg);
    font-variant-numeric: tabular-nums;
}

.ts-ck-list small {
    color: var(--ts-muted);
}

.ts .ts-ck-list a.ts-link {
    display: inline-block;
    min-height: 24px;
}

.ts-ck-more {
    margin-top: 6px;
    font-size: .86rem;
    color: var(--ts-muted);
}

/* ═══════════════════════════════════════════════════════════════════════
   จอกลางและจอแคบ
   ═══════════════════════════════════════════════════════════════════════ */

@media (max-width: 1199.98px) {
    .ts-figs {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    /* ห้าใบ: สามใบบน สองใบล่างกว้างเต็มแถว */
    .ts-figs.is-5 {
        grid-template-columns: repeat(6, minmax(0, 1fr));
    }

    .ts-figs.is-5 > li {
        grid-column: span 2;
    }

    .ts-figs.is-5 > li:nth-child(4),
    .ts-figs.is-5 > li:nth-child(5) {
        grid-column: span 3;
    }

    .ts-depts {
        columns: 1;
    }

    .ts-pick-card {
        grid-template-columns: auto minmax(0, 1fr);
    }

    .ts-pick-card .ts-pick {
        grid-column: 1 / -1;
    }
}

@media (max-width: 979.98px) {
    .ts-grid-2,
    .ts-grid-2.is-time,
    .ts-checks,
    .ts-who-foot {
        grid-template-columns: minmax(0, 1fr);
    }

    .ts-about-list {
        grid-template-columns: minmax(0, 1fr);
    }

    .ts .ts-pick.is-compact {
        flex: 1 1 100%;
    }
}

@media (max-width: 760px) {
    .ts-panel-note {
        margin-left: 0;
        flex-basis: 100%;
    }

    /* จอแคบ: แถบเครื่องมือไม่ติดหน้าจอ รายการหมวดเลื่อนด้านข้างในแถวเดียว */
    .ts-tools {
        position: static;
        border-radius: var(--ts-r);
        padding: 8px;
    }

    .ts-nav {
        flex-basis: 100%;
        overflow-x: auto;
        scrollbar-width: none;
    }

    .ts-nav::-webkit-scrollbar {
        display: none;
    }

    .ts-nav-list {
        flex-wrap: nowrap;
    }

    .ts-tools-act {
        margin-left: 0;
        padding: 0 6px;
    }

    .ts-kbd {
        display: none;
    }

    .ts-find {
        margin-left: 0;
        flex-basis: 100%;
    }

    .ts .ts-find input {
        width: 100%;
    }

    .ts-find-in {
        flex: 1 1 auto;
    }

    /* ผังตารางกว้างสิบกว่าช่วงเวลา อ่านบนมือถือไม่ได้ จึงแสดงเป็นรายการรายวันแทน */
    .ts-grid-wrap {
        display: none;
    }

    .ts-agenda {
        display: block;
    }

    .ts-who-face {
        width: 72px;
        height: 72px;
    }

    .ts-pager {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    }

    .ts-pager-all {
        grid-column: 1 / -1;
        grid-row: 2;
        justify-self: center;
    }

    .ts-pager > span:empty {
        display: none;
    }
}

@media (max-width: 640px) {
    .ts-hero {
        padding-top: 28px;
    }

    .ts-hero-sub {
        font-size: .95rem;
    }

    .ts-figs,
    .ts-figs.is-5 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .ts-figs.is-5 > li,
    .ts-figs.is-5 > li:nth-child(4) {
        grid-column: auto;
    }

    .ts-figs > li:last-child:nth-child(odd),
    .ts-figs.is-5 > li:last-child:nth-child(odd) {
        grid-column: 1 / -1;
    }

    .ts .ts-fig {
        padding: 16px 14px 14px;
    }

    .ts-fig-ic {
        width: 34px;
        height: 34px;
        border-radius: 9px;
    }

    .ts-panel-head,
    .ts-panel-body {
        padding-inline: 14px;
    }

    .ts-pick-card {
        grid-template-columns: minmax(0, 1fr);
        padding: 18px 16px;
    }

    .ts-pick-ic {
        display: none;
    }

    .ts-lrow {
        grid-template-columns: 32px minmax(0, 1fr) 3.6rem;
        gap: 4px 10px;
    }

    .ts-av {
        width: 32px;
        height: 32px;
    }

    /* แถบย้ายลงไปอยู่ใต้ชื่อ เต็มความกว้าง */
    .ts-ltrack {
        grid-column: 2 / 4;
        grid-row: 2;
    }

    .ts-bars .ts-row {
        grid-template-columns: minmax(0, 1fr) minmax(0, 6.5rem);
        gap: 4px 10px;
    }

    .ts-bars .ts-track {
        grid-column: 1 / -1;
        grid-row: 2;
    }

    .ts-col-plot {
        height: 150px;
    }

    .ts-legend-end {
        margin-left: 0;
    }

    .ts-who-stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* ═══════════════════════════════════════════════════════════════════════
   การเคลื่อนไหว

   ★ ทุกอย่างอยู่ใน prefers-reduced-motion: no-preference
   ★ สถานะ "รอเล่น" มีเฉพาะเมื่อสคริปต์ติดคลาส ts-motion ที่ <main> แล้วเท่านั้น
   ★ ที่รอเล่นได้: แผงเลื่อนลงจากที่เดิม 26px (ยังมองเห็นเต็มตา) แถบที่ยังไม่ยืด คอลัมน์ที่ยังไม่ตั้ง
     และแถววันของผังตารางที่ยังไม่เลื่อนเข้า — ทุกตัวมีตัวเลขหรือข้อความกำกับอยู่เสมอ
   ═══════════════════════════════════════════════════════════════════════ */

@media (prefers-reduced-motion: no-preference) {

    .ts-hero-in > * {
        animation: ts-hero-rise .7s var(--ts-ease) both;
    }

    .ts-hero-in > :nth-child(2) { animation-delay: .06s; }
    .ts-hero-in > :nth-child(3) { animation-delay: .12s; }
    .ts-hero-in > :nth-child(4) { animation-delay: .16s; }
    .ts-hero-in > :nth-child(5) { animation-delay: .2s; }

    .ts-hero::before {
        animation: ts-glow 1.8s var(--ts-ease) both;
    }

    .ts-rise {
        transition-property: translate;
        transition-duration: .75s;
        transition-timing-function: var(--ts-ease);
        transition-delay: var(--ts-d, 0s);
    }

    .ts.ts-motion [data-ts-reveal]:not(.is-in) .ts-rise,
    .ts.ts-motion [data-ts-reveal].ts-rise:not(.is-in) {
        translate: 0 26px;
    }

    .ts-figs > :nth-child(2) { --ts-d: .06s; }
    .ts-figs > :nth-child(3) { --ts-d: .12s; }
    .ts-figs > :nth-child(4) { --ts-d: .18s; }
    .ts-figs > :nth-child(5) { --ts-d: .24s; }
    .ts-figs > :nth-child(6) { --ts-d: .3s; }

    .ts-grid-2 > :nth-child(2),
    .ts-checks > :nth-child(2n) { --ts-d: .08s; }

    .ts-fig::before,
    .ts-who::before {
        transition: transform .9s var(--ts-ease) calc(var(--ts-d, 0s) + .15s);
    }

    .ts.ts-motion .ts-figs:not(.is-in) .ts-fig::before,
    .ts.ts-motion [data-ts-reveal]:not(.is-in) .ts-who::before {
        transform: scaleX(0);
    }

    /* รูปครูขยายขึ้นเล็กน้อยครั้งเดียวเมื่อเปิดตาราง */
    .ts-who-face {
        transition: scale .6s var(--ts-ease) .1s;
    }

    .ts.ts-motion [data-ts-reveal]:not(.is-in) .ts-who-face {
        scale: .88;
    }

    /* แถบ แท่งซ้อน และคอลัมน์ ยืดออกเมื่อแผงเข้าจอ */
    .ts-bar,
    .ts-lbar,
    .ts-seg {
        transition: transform .9s var(--ts-ease) .15s;
    }

    .ts-col-bar {
        transition: transform .8s var(--ts-ease) calc(.12s + var(--ts-c, 0) * .05s);
    }

    .ts-cols > :nth-child(2), .ts-tcols > :nth-child(2) { --ts-c: 1; }
    .ts-cols > :nth-child(3), .ts-tcols > :nth-child(3) { --ts-c: 2; }
    .ts-cols > :nth-child(4), .ts-tcols > :nth-child(4) { --ts-c: 3; }
    .ts-cols > :nth-child(5), .ts-tcols > :nth-child(5) { --ts-c: 4; }
    .ts-cols > :nth-child(6), .ts-tcols > :nth-child(6) { --ts-c: 5; }
    .ts-cols > :nth-child(7), .ts-tcols > :nth-child(7) { --ts-c: 6; }
    .ts-cols > :nth-child(8), .ts-tcols > :nth-child(8) { --ts-c: 7; }
    .ts-cols > :nth-child(n+9), .ts-tcols > :nth-child(n+9) { --ts-c: 8; }

    .ts.ts-motion [data-ts-reveal]:not(.is-in) :is(.ts-bar, .ts-lbar, .ts-seg) {
        transform: scaleX(0);
    }

    .ts.ts-motion [data-ts-reveal]:not(.is-in) .ts-col-bar {
        transform: scaleY(0);
    }

    /* ★ แถววันของผังตารางเลื่อนเข้าทีละแถว (--r คือลำดับแถว) คาบทุกใบมองเห็นตลอด */
    .ts-g-row > td {
        transition: translate .55s var(--ts-ease) calc(.15s + var(--r, 0) * .07s);
    }

    .ts.ts-motion [data-ts-reveal]:not(.is-in) .ts-g-row > td {
        translate: 18px 0;
    }

    .ts-sec-title::before {
        transition: transform .5s var(--ts-ease) .1s;
    }

    .ts.ts-motion .ts-sec:not(.is-in) .ts-sec-title::before {
        transform: scaleY(0);
    }

    /* ★ จังหวะเดียวที่ชี้ไปที่ของจริง: วันนี้ในแถบวันเรืองขึ้นหนึ่งครั้ง */
    .ts.ts-motion [data-ts-reveal].is-in .ts-day.is-today {
        animation: ts-pulse 1.4s var(--ts-ease) .9s 1;
    }

    .ts-lrow,
    .ts-pager-a {
        transition: background-color .2s var(--ts-ease);
    }
}

/* ช่วงติดสถานะรอเล่น (สคริปต์ติดแล้วถอดในเฟรมเดียว) */
.ts.ts-arming *,
.ts.ts-arming *::before {
    transition: none !important;
}

@keyframes ts-hero-rise {
    from {
        transform: translateY(16px);
    }

    to {
        transform: none;
    }
}

@keyframes ts-glow {
    from {
        transform: scale(.9);
        opacity: .2;
    }

    to {
        transform: none;
        opacity: 1;
    }
}

@keyframes ts-pulse {
    0% {
        box-shadow: 0 0 0 0 color-mix(in srgb, var(--ts-brand) 50%, transparent);
    }

    100% {
        box-shadow: 0 0 0 10px color-mix(in srgb, var(--ts-brand) 0%, transparent);
    }
}

@media (prefers-reduced-motion: reduce) {
    .ts *,
    .ts *::before,
    .ts *::after {
        animation: none !important;
        transition: none !important;
    }
}

/* ═══════════════════════════════════════════════════════════════════════
   โหมดคอนทราสต์สูง
   ไฟล์กลาง (css/tb1-navbar.css) บังคับ h1-h6 p li span div b small เป็นสีขาว ลิงก์เป็น #facc15
   ที่นี่เขียนเฉพาะสิ่งที่ไฟล์กลางไม่รู้จัก: การ์ด เส้นขอบ แถบ และความหมายของสี
   กลุ่มคาบเหลือแค่ขาว จึงแยกด้วยลายเส้นซ้าย (ทึบ เส้นคู่ เส้นประ จุด) ซึ่งมีอยู่แล้วทุกโหมด
   ═══════════════════════════════════════════════════════════════════════ */

html.tb1-contrast-high .ts {
    --ts-neutral: #ffffff;
    --ts-warn: #facc15;
    --ts-crit: #facc15;
    --ts-ok: #ffffff;
    --ts-info: #ffffff;
    --ts-brand: #ffffff;
    --ts-g-subject: #ffffff;
    --ts-g-home: #ffffff;
    --ts-g-develop: #ffffff;
    --ts-g-work: #ffffff;
}

html.tb1-contrast-high .ts-hero {
    background: #000000;
}

html.tb1-contrast-high .ts-hero::before,
html.tb1-contrast-high .ts-hero::after {
    display: none;
}

html.tb1-contrast-high .ts-hero-eyebrow,
html.tb1-contrast-high .ts .ts-term {
    background: #000000;
    border-color: #facc15;
}

html.tb1-contrast-high .ts .ts-term[aria-current="page"] {
    color: #000000 !important;
    background: #facc15;
}

html.tb1-contrast-high .ts .ts-fig,
html.tb1-contrast-high .ts-panel,
html.tb1-contrast-high .ts-tools,
html.tb1-contrast-high .ts-about,
html.tb1-contrast-high .ts-callout,
html.tb1-contrast-high .ts-who,
html.tb1-contrast-high .ts-who-stat,
html.tb1-contrast-high .ts-pick-card,
html.tb1-contrast-high .ts-empty-card,
html.tb1-contrast-high .ts-ck,
html.tb1-contrast-high .ts-day,
html.tb1-contrast-high .ts-chips li,
html.tb1-contrast-high .ts-fig-ic,
html.tb1-contrast-high .ts-panel-ic,
html.tb1-contrast-high .ts-pick-ic,
html.tb1-contrast-high .ts .ts-btn,
html.tb1-contrast-high .ts .ts-act,
html.tb1-contrast-high .ts .ts-pager-a,
html.tb1-contrast-high .ts-sec-count,
html.tb1-contrast-high .ts-lock,
html.tb1-contrast-high .ts-audience,
html.tb1-contrast-high .ts-audience-ic,
html.tb1-contrast-high .ts .ts-select,
html.tb1-contrast-high .ts .ts-find input,
html.tb1-contrast-high .ts-kbd kbd,
html.tb1-contrast-high .ts-col-tag,
html.tb1-contrast-high .ts-day-today,
html.tb1-contrast-high .ts-g-today,
html.tb1-contrast-high .ts-find-empty {
    background: #000000;
    border-color: #ffffff;
    box-shadow: none;
}

html.tb1-contrast-high .ts-fig-ic,
html.tb1-contrast-high .ts-panel-ic,
html.tb1-contrast-high .ts-pick-ic,
html.tb1-contrast-high .ts-audience-ic,
html.tb1-contrast-high .ts-sec-count,
html.tb1-contrast-high .ts-lock,
html.tb1-contrast-high .ts-col-tag,
html.tb1-contrast-high .ts-day-today,
html.tb1-contrast-high .ts-g-today {
    color: #ffffff;
    border: 1px solid #ffffff;
}

html.tb1-contrast-high .ts-fig-lock {
    color: #ffffff;
}

html.tb1-contrast-high .ts-panel-head,
html.tb1-contrast-high .ts-grid thead th,
html.tb1-contrast-high .ts-g-corner,
html.tb1-contrast-high .ts-g-day,
html.tb1-contrast-high .ts-g-c,
html.tb1-contrast-high .ts-blk,
html.tb1-contrast-high .ts-g-row.is-today td,
html.tb1-contrast-high .ts-g-row.is-today .ts-g-day,
html.tb1-contrast-high .ts-day.is-today {
    background: #000000;
}

html.tb1-contrast-high .ts-panel-head,
html.tb1-contrast-high .ts-sec-head,
html.tb1-contrast-high .ts-row,
html.tb1-contrast-high .ts-lrow,
html.tb1-contrast-high .ts-gl,
html.tb1-contrast-high .ts-legend,
html.tb1-contrast-high .ts-grid th,
html.tb1-contrast-high .ts-grid td,
html.tb1-contrast-high .ts-grid-scroll,
html.tb1-contrast-high .ts-col-plot,
html.tb1-contrast-high .ts-who-foot,
html.tb1-contrast-high .ts-ck-list li,
html.tb1-contrast-high .ts-foot-note {
    border-color: #ffffff;
}

html.tb1-contrast-high .ts-fig::before,
html.tb1-contrast-high .ts-who::before,
html.tb1-contrast-high .ts-sec-title::before,
html.tb1-contrast-high .ts-ck::before {
    background: #ffffff;
}

html.tb1-contrast-high .ts-ck.is-warn::before {
    background: #facc15;
}

html.tb1-contrast-high .ts-track,
html.tb1-contrast-high .ts-ltrack,
html.tb1-contrast-high .ts-stack {
    background: #000000;
    box-shadow: inset 0 0 0 1px #ffffff;
}

html.tb1-contrast-high .ts-lbar,
html.tb1-contrast-high .ts-bars .ts-bar:not([class*="is-"]),
html.tb1-contrast-high .ts-col-bar,
html.tb1-contrast-high .ts-col.is-median .ts-col-bar {
    background: #ffffff;
}

html.tb1-contrast-high .ts-tcol.is-thin .ts-col-bar {
    background: #facc15;
}

/* สี่กลุ่มในแถบซ้อนและสัญลักษณ์: ขาว ลายเฉียง เหลือง ลายจุด แยกกันได้บนพื้นดำ */
html.tb1-contrast-high .ts-seg.is-subject,
html.tb1-contrast-high .ts-sw.is-subject,
html.tb1-contrast-high .ts-bar.is-subject {
    background: #ffffff;
}

html.tb1-contrast-high .ts-seg.is-home,
html.tb1-contrast-high .ts-sw.is-home,
html.tb1-contrast-high .ts-bar.is-home {
    background: repeating-linear-gradient(135deg, #ffffff 0 3px, #000000 3px 6px);
}

html.tb1-contrast-high .ts-seg.is-develop,
html.tb1-contrast-high .ts-sw.is-develop,
html.tb1-contrast-high .ts-bar.is-develop {
    background: #facc15;
}

html.tb1-contrast-high .ts-seg.is-work,
html.tb1-contrast-high .ts-sw.is-work,
html.tb1-contrast-high .ts-bar.is-work {
    background: radial-gradient(circle, #ffffff 1.2px, #000000 1.6px) 0 0 / 5px 5px;
}

html.tb1-contrast-high .ts-lmed {
    border-left-color: #facc15;
}

html.tb1-contrast-high .ts-g-c.is-multi {
    box-shadow: inset 0 3px 0 #facc15;
}

html.tb1-contrast-high .ts-g-row.is-today .ts-g-day {
    box-shadow: inset 5px 0 0 #facc15;
}

html.tb1-contrast-high .ts-lrow.is-current {
    background: #000000;
    box-shadow: inset 4px 0 0 #facc15;
}

html.tb1-contrast-high .ts .ts-nav-a[aria-current="location"] {
    color: #000000 !important;
    background: #facc15;
}

html.tb1-contrast-high .ts .ts-nav-a:hover,
html.tb1-contrast-high .ts .ts-pager-a:hover,
html.tb1-contrast-high .ts .ts-act:hover {
    background: #000000;
    box-shadow: inset 0 0 0 2px #facc15;
}

/* ปุ่มหลักในโหมดนี้ใช้กติกาปุ่มของไฟล์กลาง (พื้นดำ ตัวขาว ขอบเหลือง ชี้แล้วพื้นเหลือง)
   ★ ห้ามบังคับสีตัวอักษรเอง ไฟล์กลางบังคับพื้นด้วย !important ถ้าตั้งตัวดำจะได้ดำบนดำ */

html.tb1-contrast-high .ts-g-c.is-empty.is-break,
html.tb1-contrast-high .ts-tcol.is-break .ts-col-plot {
    background: repeating-linear-gradient(135deg, #000000 0 6px, #555555 6px 7px);
}

html.tb1-contrast-high .ts-tip {
    color: #ffffff;
    background: #000000;
    border: 1px solid #facc15;
}

html.tb1-contrast-high .ts-kbd kbd {
    color: #ffffff;
}

html.tb1-contrast-high .ts-nav-n {
    color: #facc15;
    background: #000000;
    box-shadow: inset 0 0 0 1px #facc15;
}

html.tb1-contrast-high .ts-who-face {
    box-shadow: 0 0 0 3px #000000, 0 0 0 5px #ffffff;
}

html.tb1-contrast-high .ts :focus-visible {
    outline-color: #facc15;
}

/* ═══════════════════════════════════════════════════════════════════════
   พิมพ์ลงกระดาษ / บันทึก PDF
   ★ เปิดตารางของครูอยู่: พิมพ์เฉพาะใบตารางสอนแนวนอนหนึ่งแผ่น (ใบนี้มักถูกติดหน้าห้องพักครู)
   ★ ไม่ได้เปิดตารางใคร: พิมพ์ภาพรวมทั้งหน้าแนวตั้ง
   ═══════════════════════════════════════════════════════════════════════ */

@page ts-land {
    size: A4 landscape;
    margin: 9mm;
}

@media print {
    body.ts-page {
        background: #ffffff;
    }

    .ts {
        --ts-ink: #0f172a;
        --ts-ink-2: #334155;
        --ts-muted: #475569;
        --ts-paper: #ffffff;
        --ts-paper-alt: #f1f5f9;
        --ts-line: #cbd5e1;
        --ts-line-bold: #94a3b8;
        --ts-neutral: #94a3b8;
        --ts-warn-fg: #9a4508;
        --ts-brand: #1d4ed8;
        --ts-g-subject: #1d4ed8;
        --ts-g-home: #0e7490;
        --ts-g-develop: #9a4508;
        --ts-g-work: #5a697f;
        color-scheme: light;
    }

    .ts *,
    .ts *::before,
    .ts *::after {
        transition: none !important;
        animation: none !important;
    }

    .ts-tools,
    .ts-audience,
    .ts-find,
    .ts-kbd,
    .ts-find-meta,
    .ts-pick,
    .ts-pick-card,
    .ts-pager,
    .ts-act,
    .ts-agenda,
    .ts-fig-ic,
    .ts-panel-ic,
    .ts-hero::before,
    .ts-hero::after,
    .ts-terms,
    .ts-tip {
        display: none !important;
    }

    .ts-grid-wrap {
        display: block !important;
    }

    main.ts {
        padding: 0;
    }

    .ts-hero {
        margin: 0;
        padding: 0 0 8px;
        color: #000000;
        text-align: left;
        background: #ffffff;
        border-bottom: 2px solid #000000;
    }

    .ts-hero-in {
        max-width: none;
        align-items: flex-start;
    }

    .ts-hero-eyebrow {
        padding: 0;
        color: #000000;
        background: none;
        border: 0;
    }

    .ts-hero-eyebrow .ts-icon,
    .ts-hero-sub {
        display: none;
    }

    .ts-hero-title,
    .ts-hero-date {
        color: #000000;
    }

    .ts-hero-title {
        margin-top: 2px;
        font-size: 1.5rem;
    }

    .ts-figs,
    .ts-figs.is-5 {
        margin-top: 12px;
        grid-template-columns: repeat(6, minmax(0, 1fr));
        gap: 8px;
    }

    .ts-figs.is-5 > li,
    .ts-figs.is-5 > li:nth-child(4),
    .ts-figs.is-5 > li:nth-child(5) {
        grid-column: auto;
    }

    .ts .ts-fig {
        padding: 10px 10px 8px;
    }

    .ts .ts-fig,
    .ts-panel,
    .ts-who,
    .ts-ck {
        box-shadow: none !important;
        border-color: #999999;
    }

    .ts [data-ts-reveal],
    .ts .ts-rise,
    .ts .ts-g-row > td {
        translate: none !important;
    }

    .ts .ts-who-face {
        scale: none !important;
    }

    .ts .ts-fig::before,
    .ts .ts-who::before,
    .ts .ts-sec-title::before,
    .ts .ts-bar,
    .ts .ts-lbar,
    .ts .ts-seg,
    .ts .ts-col-bar {
        transform: none !important;
    }

    .ts-fig::before,
    .ts-who::before,
    .ts-sec-title::before,
    .ts-ck::before,
    .ts-bar,
    .ts-lbar,
    .ts-seg,
    .ts-col-bar,
    .ts-sw,
    .ts-blk,
    .ts-g-c,
    .ts-g-day,
    .ts-grid thead th,
    .ts-day,
    .ts-day-today,
    .ts-g-today,
    .ts-ltrack {
        print-color-adjust: exact;
        -webkit-print-color-adjust: exact;
    }

    .ts-sec {
        margin-top: 16px;
    }

    .ts-sec-head {
        break-after: avoid;
    }

    .ts-panel,
    .ts .ts-fig,
    .ts-ck,
    .ts-about,
    .ts-lrow,
    .ts-who {
        break-inside: avoid;
    }

    .ts-dept {
        break-inside: auto;
    }

    .ts-depts {
        columns: 2;
    }

    .ts-grid-2,
    .ts-grid-2.is-time,
    .ts-checks {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    }

    .ts-grid-scroll,
    .ts-tcols-scroll {
        overflow: visible;
    }

    .ts-grid {
        min-width: 0;
        font-size: 7.6pt;
    }

    .ts-g-corner,
    .ts-g-day {
        position: static;
    }

    .ts-g-corner {
        width: 60px;
    }

    .ts-g-h.is-break {
        width: 22px;
    }

    .ts-blk {
        padding: 3px 4px 3px 6px;
    }

    .ts-blk-t {
        font-size: 7.8pt;
    }

    .ts-blk-m,
    .ts-blk-k,
    .ts-blk-time,
    .ts-flag,
    .ts-g-multi {
        font-size: 6.8pt;
    }

    .ts a {
        color: #000000 !important;
        text-decoration: none !important;
    }

    .ts-lock,
    .ts-fig-lock,
    .ts-lrow .ts-av {
        display: none !important;
    }

    .ts-lrow {
        grid-template-columns: minmax(0, 10.5rem) minmax(0, 1fr) 3.4rem;
        gap: 8px;
        padding: 4px 0;
    }

    .ts-grid-2.is-time {
        grid-template-columns: minmax(0, 1fr);
    }

    .ts-tcols {
        min-width: 0;
    }

    /* ช่วงพักบนกระดาษแคบมาก เหลือแค่คำว่า "พัก" */
    .ts-g-h.is-break .ts-g-t {
        display: none;
    }

    /* ── เปิดตารางของครูอยู่: เหลือหัวกระดาษ การ์ดครู และผังตาราง ── */
    body.ts-has-sheet .ts-figs,
    body.ts-has-sheet .ts-callout,
    body.ts-has-sheet .ts-hero-date,
    body.ts-has-sheet .ts-who-foot,
    body.ts-has-sheet #sec-load,
    body.ts-has-sheet #sec-overview,
    body.ts-has-sheet #sec-mix,
    body.ts-has-sheet #sec-time,
    body.ts-has-sheet #sec-check,
    body.ts-has-sheet .ts-about,
    body.ts-has-sheet .ts-sheet-panel .ts-note,
    body.ts-has-sheet .ts-who-links,
    body.ts-has-sheet .tb1-footer,
    body.ts-has-sheet footer {
        display: none !important;
    }

    body.ts-has-sheet .ts-wrap {
        page: ts-land;
    }

    body.ts-has-sheet .ts-sec {
        margin-top: 8px;
    }

    body.ts-has-sheet .ts-who {
        padding: 10px 14px;
    }

    body.ts-has-sheet .ts-who-face {
        width: 46px;
        height: 46px;
    }

    body.ts-has-sheet .ts-who-eyebrow {
        display: none;
    }

    /* ใบตารางต้องจบในแผ่นเดียว ย่อทั้งผังลงเล็กน้อยแทนการตัดแถวข้ามหน้า */
    body.ts-has-sheet .ts-sheet-panel {
        zoom: .8;
        border: 0;
    }

    body.ts-has-sheet .ts-sheet-panel .ts-panel-head {
        display: none;
    }

    body.ts-has-sheet .ts-sheet-panel .ts-legend {
        margin-top: 6px;
        padding-top: 4px;
    }

    body.ts-has-sheet .ts-who-name {
        font-size: 1.3rem;
    }

    body.ts-has-sheet .ts-who-stats {
        margin-top: 8px;
        grid-template-columns: repeat(5, minmax(0, 1fr));
        gap: 6px;
    }

    body.ts-has-sheet .ts-who-stat {
        display: flex;
        align-items: baseline;
        gap: 6px;
        padding: 2px 8px;
    }

    body.ts-has-sheet .ts-who-v b {
        font-size: 1rem;
    }

    body.ts-has-sheet .ts-who-foot {
        margin-top: 8px;
        padding-top: 8px;
        grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) minmax(0, 1fr);
    }

    body.ts-has-sheet .ts-who-classes {
        grid-column: auto;
    }

    body.ts-has-sheet .ts-sheet-panel {
        margin-top: 8px;
    }

    body.ts-has-sheet .ts-sheet-panel .ts-panel-body {
        padding: 0;
    }

    body.ts-has-sheet .ts-hero {
        display: flex;
        padding-bottom: 4px;
    }

    body.ts-has-sheet .ts-hero-title {
        font-size: 1.1rem;
    }

    body.ts-has-sheet .ts-hero-in {
        flex-direction: row-reverse;
        justify-content: flex-end;
        align-items: baseline;
        gap: 12px;
    }

    body.ts-has-sheet .ts-who-top {
        gap: 12px;
    }

    body.ts-has-sheet .ts-g-c {
        padding: 2px;
    }

    body.ts-has-sheet .ts-g-day {
        padding: 4px 6px;
    }

    body.ts-has-sheet .ts-grid thead th {
        padding: 4px 3px;
    }
}
