/* ═══════════════════════════════════════════════════════════════════════
   css/tb1-history.css — หน้า "ประวัติโรงเรียน" (history.php) · v4 · 3 ต.ค. 2569
   ธีมเดียวกับหน้า "ข้อมูลงบประมาณ" และ "ติดต่อโรงเรียน" (tb1-budget.css / tb1-contact.css):
   ส่วนหัวน้ำเงินเต็มจอ การ์ดซ้อนขอบส่วนหัว แถบข้อมูลปัจจุบันจากระบบ เมนูหัวข้อติดใต้แถบเมนูหลัก
   หัวข้อกลางหน้าพร้อมป้าย การ์ดมุมโค้ง 18px
   มือถือก่อน โหมดมืด ([data-theme=dark] / html.dark-mode) ความคมชัดสูง (html.tb1-contrast-high) พิมพ์
   สีการ์ดตัวเลข: ชุดที่ตรวจตาบอดสีแล้วของหน้างบประมาณ
   แอนิเมชันทำงานเฉพาะเมื่อมี JavaScript (html.hi-js) และผู้ใช้ไม่ได้ตั้งลดการเคลื่อนไหว
   ═══════════════════════════════════════════════════════════════════════ */

:root {
    --hi-ink1: #0F172A;
    --hi-ink2: #334155;
    --hi-ink3: #56657A;
    --hi-page: #F4F7FB;
    --hi-card: #FFFFFF;
    --hi-alt: #F1F5F9;
    --hi-line: #E2E8F0;
    --hi-line2: #CBD5E1;
    --hi-navy: #1E3A8A;
    --hi-brand: #1D4ED8;
    --hi-link: #1D4ED8;
    --hi-gold: #B45309;
    --hi-gold-dot: #F59E0B;
    --hi-inc: #2a78d6;
    --hi-c-age: #2a78d6;
    --hi-c-name: #4a3aa7;
    --hi-c-sec: #1baf7a;
    --hi-c-cur: #eb6834;
    --hi-ok: #1baf7a;
    --hi-sh: var(--tb1-shadow-card, 0 0 16px rgba(15, 23, 42, .05));
    --hi-sh2: var(--tb1-shadow-raise, 0 14px 28px -14px rgba(15, 23, 42, .22));
    --hi-r: var(--tb1-radius-md, 16px);
    --hi-rs: var(--tb1-radius-sm, 10px);
    --hi-mw: var(--tb1-page-max-width, 1280px);
    --hi-gut: 16px;
    --hi-fd: var(--tb1-font-display, 'Noto Sans Thai Looped', sans-serif);
    --hi-fbody: var(--tb1-font-body, 'Sarabun', system-ui, -apple-system, 'Segoe UI', sans-serif);
    --hi-ease: cubic-bezier(.22, .8, .24, 1);
}

[data-theme="dark"],
html.dark,
html.dark-mode,
body.dark-mode {
    --hi-ink1: #F1F5F9;
    --hi-ink2: #CBD5E1;
    --hi-ink3: #9FB0C6;
    --hi-page: #0A1322;
    --hi-card: #111C2E;
    --hi-alt: #16233A;
    --hi-line: #22324A;
    --hi-line2: #34465F;
    --hi-link: #93C5FD;
    --hi-gold: #FBBF24;
    --hi-inc: #3987e5;
    --hi-c-age: #3987e5;
    --hi-c-name: #9085e9;
    --hi-c-sec: #199e70;
    --hi-c-cur: #d95926;
    --hi-ok: #199e70;
    --hi-sh: var(--tb1-shadow-card, none);
    --hi-sh2: var(--tb1-shadow-raise, 0 14px 28px -14px rgba(0, 0, 0, .6));
}

@media (min-width: 640px) {
    :root {
        --hi-gut: 24px;
    }
}

/* ═══ พื้นฐาน ═══ */
.hi-page,
.hi-page *,
.hi-page *::before,
.hi-page *::after {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    scroll-padding-top: 132px;
}

body.hi-page {
    margin: 0;
    font-family: var(--hi-fbody);
    font-size: 16px;
    line-height: 1.65;
    color: var(--hi-ink1);
    background: var(--hi-page);
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

/* รีเซ็ตแบบน้ำหนักศูนย์ (:where) คลาสของหน้าจึงกำหนดระยะทับได้เสมอ */
:where(.hi-main, .hi-hero) :where(h1, h2, h3, h4, p, ul, ol, dl, dd, dt) {
    margin: 0;
    padding: 0;
}

:where(.hi-main, .hi-hero) :where(ul, ol) {
    list-style: none;
}

.hi [hidden] {
    display: none !important;
}

.hi-nw {
    white-space: nowrap;
}

.hi-num {
    font-variant-numeric: tabular-nums;
    font-feature-settings: 'tnum';
    white-space: nowrap;
}

.hi .sr-only {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

body.hi-page a.hi-skip {
    position: absolute;
    left: 12px;
    top: -60px;
    z-index: 10000;
    padding: .7rem 1.2rem;
    border-radius: 0 0 12px 12px;
    background: var(--hi-navy);
    color: #fff;
    font-weight: 700;
    text-decoration: none;
    transition: top .2s;
}

body.hi-page a.hi-skip:focus {
    top: 0;
}

.hi :focus-visible {
    outline: 3px solid #F59E0B;
    outline-offset: 2px;
    border-radius: 6px;
}

.hi-main {
    max-width: var(--hi-mw);
    margin: 0 auto;
    padding: 0 var(--hi-gut) 3rem;
    outline: none;
}

.hi-main a {
    color: var(--hi-link);
}

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

/* ═══ ส่วนหัว ═══ */
.hi-hero {
    position: relative;
    overflow: hidden;
    color: #fff;
    background:
        radial-gradient(120% 90% at 0% 0%, #2563EB 0%, transparent 55%),
        /* ฟ้าเข้มกว่าหน้างบประมาณเล็กน้อย: ข้อความขาวและเหลืองบนมุมขวาต้องได้ 4.5:1 ทุกจุด (หน้าจอแคบข้อความยาวถึงมุมนี้) */
        radial-gradient(90% 90% at 100% 20%, #0B78C2 0%, transparent 50%),
        linear-gradient(135deg, #172554 0%, #1E3A8A 45%, #1D4ED8 100%);
    padding: 2.25rem var(--hi-gut) 6.5rem;
    isolation: isolate;
}

[data-theme="dark"] .hi-hero,
html.dark-mode .hi-hero {
    background:
        radial-gradient(110% 90% at 0% 0%, rgba(37, 99, 235, .45) 0%, transparent 55%),
        radial-gradient(90% 90% at 100% 20%, rgba(14, 165, 233, .28) 0%, transparent 50%),
        linear-gradient(135deg, #060D1A 0%, #0B1A33 50%, #0F2447 100%);
}

.hi-hero-deco {
    position: absolute;
    inset: 0;
    z-index: -1;
    pointer-events: none;
}

.hi-hero-deco .orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(2px);
    opacity: .5;
    background: radial-gradient(circle at 35% 35%, rgba(255, 255, 255, .28), rgba(255, 255, 255, 0) 70%);
}

.hi-hero-deco .o1 {
    width: 340px;
    height: 340px;
    left: -90px;
    top: -120px;
}

.hi-hero-deco .o2 {
    width: 220px;
    height: 220px;
    right: 12%;
    top: -60px;
}

.hi-hero-deco .o3 {
    width: 160px;
    height: 160px;
    left: 38%;
    bottom: -70px;
}

/* วงปีของต้นไม้ (ตำแหน่งเดียวกับหมุดแผนที่ของหน้าติดต่อ) */
.hi-hero-rings {
    position: absolute;
    right: 2%;
    bottom: 2.6rem;
    width: min(270px, 40vw);
    height: auto;
    opacity: .2;
    overflow: visible;
}

.hi-hero-rings .ring {
    fill: none;
    stroke: #fff;
    stroke-width: 3;
}

.hi-hero-rings .r1 {
    fill: rgba(255, 255, 255, .55);
    stroke-width: 0;
}

.hi-hero-in {
    position: relative;
    max-width: var(--hi-mw);
    margin: 0 auto;
    text-align: center;
}

.hi-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    max-width: 100%;
    padding: .35rem .95rem;
    border: 1px solid rgba(255, 255, 255, .28);
    border-radius: 999px;
    background: rgba(15, 23, 42, .24);
    font-size: var(--tb1-fs-xs, .875rem);
    font-weight: 600;
    letter-spacing: .01em;
    backdrop-filter: blur(6px);
}

.hi-hero h1 {
    margin: .9rem 0 .35rem;
    font-family: var(--hi-fd);
    font-weight: 800;
    font-size: var(--tb1-fs-3xl, clamp(1.875rem, 1.4rem + 1.6vw, 2.5rem));
    line-height: 1.25;
    letter-spacing: -.01em;
    color: #fff;
    text-shadow: 0 2px 18px rgba(15, 23, 42, .35);
}

.hi-lead {
    font-size: var(--tb1-fs-md, 1.125rem);
    color: #fff;
}

.hi-lead strong {
    margin: 0 .3rem;
    color: #FDE68A;
    font-weight: 700;
}

.hi-hero-meta {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: .45rem .6rem;
    margin-top: 1rem !important;
}

.hi-hero-meta li {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    padding: .3rem .8rem;
    border-radius: 999px;
    background: rgba(15, 23, 42, .28);
    font-size: var(--tb1-fs-xs, .875rem);
    color: rgba(255, 255, 255, .95);
}

/* วันคล้ายวันก่อตั้ง: การ์ดขาวกลางส่วนหัว (ตำแหน่งเดียวกับการ์ดสถานะของหน้าติดต่อ) */
.hi-anniv {
    display: inline-flex;
    align-items: center;
    gap: .75rem;
    width: min(100%, 30rem);
    margin-top: 1.35rem;
    padding: .75rem 1.1rem;
    text-align: left;
    color: var(--hi-ink1);
    background: var(--hi-card);
    border: 1px solid rgba(255, 255, 255, .5);
    border-radius: var(--tb1-radius-md, 16px);
    box-shadow: 0 10px 30px rgba(15, 23, 42, .28);
}

.hi-anniv-ic {
    flex: none;
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    border-radius: 12px;
    color: var(--hi-gold);
    background: color-mix(in srgb, var(--hi-gold-dot) 16%, var(--hi-card));
}

.hi-anniv-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
    line-height: 1.45;
}

.hi-anniv-text b {
    font-family: var(--hi-fd);
    font-size: var(--tb1-fs-lg, 1.25rem);
    font-weight: 700;
}

.hi-anniv-text span {
    font-size: var(--tb1-fs-xs, .875rem);
    color: var(--hi-ink2);
}

.hi-anniv.is-today {
    border-color: var(--hi-gold-dot);
    box-shadow: 0 0 0 3px rgba(245, 158, 11, .35), 0 10px 30px rgba(15, 23, 42, .28);
}

/* แถบยุค: ความกว้างแต่ละช่วงเป็นสัดส่วนของจำนวนปีจริง จุดสีทอง = เหตุการณ์สำคัญ */
.hi-ribbon {
    max-width: 920px;
    margin: 1.6rem auto 0;
    text-align: left;
}

.hi-ribbon-bar {
    display: flex;
    gap: 3px;
}

.hi-ribbon-seg {
    flex: 0 0 auto;
    width: calc(var(--w) - 3px);
    min-width: 0;
}

.hi .hi-ribbon-seg a {
    display: flex;
    flex-direction: column;
    gap: .1rem;
    min-height: 44px;
    padding: .4rem .55rem;
    border-radius: var(--tb1-radius-sm, 10px);
    color: #fff;
    text-decoration: none;
    /* พื้นกระจกสีเข้ม ยิ่งใกล้ปัจจุบันยิ่งทึบ ตัวเลขปีสีเหลืองจึงอ่านได้แม้อยู่บนมุมฟ้าของส่วนหัว */
    background: rgba(15, 23, 42, var(--a, .3));
    border: 1px solid rgba(255, 255, 255, .22);
    overflow: hidden;
    transition: background-color .2s ease;
}

.hi-ribbon-seg.s0 {
    --a: .26;
}

.hi-ribbon-seg.s1 {
    --a: .3;
}

.hi-ribbon-seg.s2 {
    --a: .34;
}

.hi-ribbon-seg.s3 {
    --a: .4;
}

.hi-ribbon-seg.s4 {
    --a: .46;
}

.hi .hi-ribbon-seg a:hover {
    background: rgba(15, 23, 42, .62);
    border-color: rgba(255, 255, 255, .55);
}

.hi-ribbon-y {
    font-size: var(--tb1-fs-xs, .875rem);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: #FDE68A;
}

.hi-ribbon-l {
    font-size: var(--tb1-fs-xs, .875rem);
    font-weight: 600;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.hi-ribbon-dots {
    position: relative;
    height: 12px;
    margin: .35rem 0 0;
    border-top: 2px solid rgba(255, 255, 255, .35);
}

.hi-ribbon-dots i {
    position: absolute;
    top: -6px;
    left: var(--x);
    width: 10px;
    height: 10px;
    margin-left: -5px;
    border-radius: 50%;
    background: #FBBF24;
    box-shadow: 0 0 0 2px rgba(15, 23, 42, .35);
}

.hi-ribbon-ends {
    display: flex;
    justify-content: space-between;
    font-size: var(--tb1-fs-xs, .875rem);
    color: rgba(255, 255, 255, .85);
    font-variant-numeric: tabular-nums;
}

/* ═══ การ์ดตัวเลข: ซ้อนขอบส่วนหัว ═══ */
.hi-kpis {
    position: relative;
    z-index: 2;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .75rem;
    margin-top: -4.5rem !important;
}

@media (min-width: 980px) {
    .hi-kpis {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 1rem;
    }
}

.hi-kpis > li {
    display: flex;
    min-width: 0;
}

.hi .hi-kpi {
    position: relative;
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-width: 0;
    padding: 1rem 1rem 1.05rem;
    border-radius: var(--hi-r);
    background: var(--hi-card);
    border: 1px solid var(--hi-line);
    box-shadow: var(--hi-sh);
    overflow: hidden;
    color: var(--hi-ink1);
    text-decoration: none;
}

.hi-kpi::before {
    content: '';
    position: absolute;
    inset: 0 0 auto 0;
    height: 4px;
    background: var(--k, var(--hi-inc));
}

.hi-kpi.k-age {
    --k: var(--hi-c-age);
}

.hi-kpi.k-name {
    --k: var(--hi-c-name);
}

.hi-kpi.k-sec {
    --k: var(--hi-c-sec);
}

.hi-kpi.k-cur {
    --k: var(--hi-c-cur);
}

.hi-kpi-top {
    display: flex;
    align-items: center;
    gap: .55rem;
}

.hi-kpi-k {
    font-size: var(--tb1-fs-sm, 1rem);
    font-weight: 600;
    color: var(--hi-ink2);
    line-height: 1.35;
}

.hi-kpi-ic {
    flex: none;
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border-radius: 10px;
    color: #fff;
    background: var(--k);
    font-size: .9rem;
}

.hi-kpi-v {
    margin-top: .55rem;
    line-height: 1.2;
    color: var(--hi-ink1);
}

.hi-kpi-v b {
    font-size: clamp(1.6rem, 6vw, 2.2rem);
    font-weight: 700;
}

.hi-kpi-v small {
    font-size: var(--tb1-fs-xs, .875rem);
    color: var(--hi-ink3);
    font-weight: 600;
}

.hi-kpi-f {
    margin-top: auto;
    padding-top: .45rem;
    font-size: var(--tb1-fs-xs, .875rem);
    color: var(--hi-ink3);
    line-height: 1.45;
}

.hi .hi-kpi:hover .hi-kpi-k {
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 4px;
}

/* ═══ เมนูหัวข้อ ═══ */
.hi-subnav {
    position: sticky;
    top: var(--hi-top, 56px);
    z-index: 20;
    display: flex;
    gap: .4rem;
    margin: 1.25rem calc(var(--hi-gut) * -1) 0;
    padding: .6rem var(--hi-gut);
    overflow-x: auto;
    scrollbar-width: none;
    background: color-mix(in srgb, var(--hi-page) 88%, transparent);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--hi-line);
}

.hi-subnav::-webkit-scrollbar {
    display: none;
}

.hi .hi-subnav a {
    flex: none;
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    padding: .3rem .9rem;
    border-radius: 999px;
    border: 1px solid var(--hi-line2);
    background: var(--hi-card);
    color: var(--hi-ink2);
    font-size: var(--tb1-fs-xs, .875rem);
    font-weight: 600;
    text-decoration: none;
    transition: background .2s, color .2s, border-color .2s;
}

.hi .hi-subnav a:hover {
    border-color: var(--hi-brand);
}

.hi .hi-subnav a.is-on {
    background: var(--hi-navy);
    border-color: var(--hi-navy);
    color: #fff;
}

[data-theme="dark"] .hi .hi-subnav a.is-on,
html.dark-mode .hi .hi-subnav a.is-on {
    background: #93C5FD;
    border-color: #93C5FD;
    color: #0A1322;
}

/* ═══ หัวข้อส่วน ═══ */
.hi-sec {
    margin-top: 3rem;
    scroll-margin-top: 132px;
}

.hi-sec-h {
    text-align: center;
    margin-bottom: 1.4rem;
}

.hi-badge {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .25rem .8rem;
    border-radius: 999px;
    background: color-mix(in srgb, var(--hi-inc) 12%, transparent);
    color: var(--hi-ink1);
    font-size: var(--tb1-fs-xs, .875rem);
    font-weight: 700;
}

.hi-badge i {
    color: var(--hi-inc);
}

.hi-sec-h h2 {
    margin-top: .5rem !important;
    font-family: var(--hi-fd);
    font-size: var(--tb1-fs-2xl, clamp(1.5rem, 1.2rem + 1vw, 1.875rem));
    font-weight: 800;
    line-height: 1.3;
    color: var(--tb1-heading, var(--hi-ink1));
}

.hi-sec-h p {
    max-width: 720px;
    margin: .35rem auto 0 !important;
    color: var(--hi-ink3);
    font-size: var(--tb1-fs-sm, 1rem);
}

/* ═══ การ์ด ═══ */
.hi-card {
    border-radius: var(--hi-r);
    background: var(--hi-card);
    border: 1px solid var(--hi-line);
    box-shadow: var(--hi-sh);
    padding: 1.1rem;
    min-width: 0;
}

.hi-card-h {
    display: flex;
    align-items: flex-start;
    gap: .75rem;
    margin-bottom: .85rem;
}

.hi-card-h h3 {
    font-family: var(--hi-fbody);
    font-size: var(--tb1-fs-md, 1.125rem);
    font-weight: 700;
    color: var(--tb1-heading, var(--hi-ink1));
    line-height: 1.4;
}

.hi-card-h p {
    font-size: var(--tb1-fs-xs, .875rem);
    color: var(--hi-ink3);
}

.hi-card-ic {
    flex: none;
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    border-radius: 12px;
    background: color-mix(in srgb, var(--hi-inc) 12%, transparent);
    color: var(--hi-inc);
}

.hi-card-ic.is-gold {
    background: color-mix(in srgb, var(--hi-gold-dot) 16%, transparent);
    color: var(--hi-gold);
}

.hi-card-f {
    margin-top: .9rem !important;
}

.hi .hi-pill {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    min-height: 38px;
    padding: .2rem .9rem;
    color: var(--hi-link);
    background: var(--hi-card);
    border: 1px solid var(--hi-line2);
    border-radius: 999px;
    font-size: var(--tb1-fs-xs, .875rem);
    font-weight: 600;
    text-decoration: none;
    transition: border-color .16s ease, background-color .16s ease;
}

.hi .hi-pill:hover {
    border-color: var(--hi-brand);
    background: color-mix(in srgb, var(--hi-inc) 8%, var(--hi-card));
}

.hi-src {
    display: flex;
    align-items: baseline;
    gap: .4rem;
    margin-top: .8rem !important;
    font-size: var(--tb1-fs-xs, .875rem);
    color: var(--hi-ink3);
}

/* ═══ จุดเริ่มต้น ═══ */
.hi-start {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

@media (min-width: 900px) {
    .hi-start {
        grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
    }
}

.hi-start-text {
    padding: 1.3rem 1.3rem 1.2rem;
}

.hi-start-p {
    font-size: var(--tb1-fs-md, 1.125rem);
    line-height: 1.85;
    color: var(--hi-ink2);
}

.hi-start-p + .hi-start-p {
    margin-top: .8rem !important;
}

.hi-start-p:first-child::first-letter {
    font-family: var(--hi-fd);
    font-weight: 800;
    color: var(--hi-navy);
}

[data-theme="dark"] .hi-start-p:first-child::first-letter,
html.dark-mode .hi-start-p:first-child::first-letter {
    color: #93C5FD;
}

.hi-context {
    margin-top: 1.1rem;
    padding: .8rem 1rem;
    border-radius: var(--hi-rs);
    background: var(--hi-alt);
    border-left: 4px solid var(--hi-gold-dot);
}

.hi-context p {
    font-size: var(--tb1-fs-sm, 1rem);
    color: var(--hi-ink2);
}

.hi-context .hi-context-k {
    margin-bottom: .2rem !important;
    font-weight: 700;
    color: var(--hi-ink1);
}

.hi-context-k i {
    color: var(--hi-gold);
}

.hi-first {
    position: relative;
    overflow: hidden;
    background:
        radial-gradient(120% 120% at 100% 0%, color-mix(in srgb, var(--hi-gold-dot) 14%, transparent) 0%, transparent 55%),
        var(--hi-card);
}

.hi-first-y {
    display: flex;
    align-items: baseline;
    gap: .4rem;
    font-family: var(--hi-fd);
    color: var(--hi-navy);
    line-height: 1;
}

[data-theme="dark"] .hi-first-y,
html.dark-mode .hi-first-y {
    color: #93C5FD;
}

.hi-first-y span {
    font-size: var(--tb1-fs-md, 1.125rem);
    font-weight: 700;
}

.hi-first-y b {
    font-size: clamp(2.6rem, 9vw, 3.6rem);
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.hi-first-dl {
    margin-top: .9rem !important;
    display: grid;
    gap: .1rem;
}

.hi-first-dl > div {
    display: grid;
    grid-template-columns: 6.2rem minmax(0, 1fr);
    gap: .75rem;
    padding: .5rem 0;
    border-top: 1px solid var(--hi-line);
}

.hi-first-dl > div:first-child {
    border-top: 0;
}

.hi-first-dl dt {
    font-size: var(--tb1-fs-xs, .875rem);
    font-weight: 700;
    color: var(--hi-ink3);
}

.hi-first-dl dd {
    font-size: var(--tb1-fs-sm, 1rem);
    color: var(--hi-ink1);
}

/* ═══ ชื่อโรงเรียน ═══ */
.hi-names {
    position: relative;
    display: grid;
    gap: .6rem;
}

.hi-names::before {
    content: '';
    position: absolute;
    left: 1.45rem;
    top: 1.2rem;
    bottom: 1.2rem;
    width: 2px;
    background: var(--hi-line2);
}

.hi-name {
    position: relative;
}

.hi .hi-name a {
    display: grid;
    grid-template-columns: 2.9rem minmax(0, 1fr);
    grid-template-areas: "n y" "n t" "n g";
    column-gap: .7rem;
    align-items: center;
    padding: .55rem .9rem .6rem .1rem;
    border-radius: var(--hi-rs);
    color: var(--tb1-heading, var(--hi-ink1));
    text-decoration: none;
    transition: background-color .18s ease;
}

.hi .hi-name a:hover {
    background: color-mix(in srgb, var(--hi-inc) 8%, transparent);
}

.hi-name-n {
    grid-area: n;
    position: relative;
    z-index: 1;
    justify-self: center;
    width: 2.25rem;
    height: 2.25rem;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--hi-card);
    border: 2px solid var(--hi-c-name);
    color: var(--hi-c-name);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.hi-name-y {
    grid-area: y;
    font-size: var(--tb1-fs-xs, .875rem);
    font-weight: 700;
    color: var(--hi-ink3);
    font-variant-numeric: tabular-nums;
}

.hi-name-t {
    grid-area: t;
    font-family: var(--hi-fd);
    font-size: var(--tb1-fs-md, 1.125rem);
    font-weight: 700;
    line-height: 1.45;
}

.hi-name-tag {
    grid-area: g;
    justify-self: start;
    margin-top: .2rem;
    padding: 0 .6rem;
    border-radius: 999px;
    font-size: var(--tb1-fs-xs, .875rem);
    font-weight: 700;
    color: var(--hi-gold);
    border: 1px solid currentColor;
}

.hi-name.is-current .hi-name-n {
    background: var(--hi-gold-dot);
    border-color: var(--hi-gold-dot);
    color: #1F1300;
}

.hi-name.is-current a {
    background: color-mix(in srgb, var(--hi-gold-dot) 10%, var(--hi-card));
    border: 1px solid color-mix(in srgb, var(--hi-gold-dot) 45%, var(--hi-line));
}

@media (min-width: 1000px) {
    .hi-names {
        grid-template-columns: repeat(7, minmax(0, 1fr));
        gap: .5rem;
    }

    .hi-names::before {
        left: 7%;
        right: 7%;
        top: 1.55rem;
        bottom: auto;
        width: auto;
        height: 2px;
    }

    .hi .hi-name a {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: .3rem;
        height: 100%;
        padding: .3rem .4rem .8rem;
        text-align: center;
    }

    .hi-name-n {
        width: 2.5rem;
        height: 2.5rem;
    }

    .hi-name-t {
        font-size: var(--tb1-fs-sm, 1rem);
    }

    .hi-name-tag {
        align-self: center;
    }
}

/* ═══ เส้นเวลา ═══ */
.hi-filter {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: .45rem;
    margin: 0 0 1.4rem;
}

.hi .hi-chip {
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .3rem .95rem;
    border-radius: 999px;
    border: 1px solid var(--hi-line2);
    background: var(--hi-card);
    color: var(--hi-ink2);
    font: inherit;
    font-size: var(--tb1-fs-xs, .875rem);
    font-weight: 600;
    cursor: pointer;
    transition: background .2s, color .2s, border-color .2s;
}

.hi .hi-chip:hover {
    border-color: var(--hi-brand);
}

.hi .hi-chip[aria-pressed="true"] {
    background: var(--hi-navy);
    border-color: var(--hi-navy);
    color: #fff;
}

.hi .hi-chip.is-key i {
    color: var(--hi-gold-dot);
}

[data-theme="dark"] .hi .hi-chip[aria-pressed="true"],
html.dark-mode .hi .hi-chip[aria-pressed="true"] {
    background: #93C5FD;
    border-color: #93C5FD;
    color: #0A1322;
}

.hi-era {
    scroll-margin-top: 132px;
}

.hi-era + .hi-era {
    margin-top: 2rem;
}

.hi-era-h {
    max-width: 1100px;
    margin: 0 auto;
}

.hi-era-h {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: .85rem;
    align-items: start;
    padding: 1rem 1.1rem;
    border-radius: var(--hi-r);
    color: #fff;
    background: linear-gradient(135deg, #172554 0%, #1E3A8A 55%, #1D4ED8 100%);
    box-shadow: var(--hi-sh);
}

[data-theme="dark"] .hi-era-h,
html.dark-mode .hi-era-h {
    background: linear-gradient(135deg, #0B1A33 0%, #0F2447 60%, #173A73 100%);
    border: 1px solid #22324A;
}

.hi-era-ic {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border-radius: 12px;
    background: rgba(255, 255, 255, .14);
    color: #FDE68A;
    font-size: 1.1rem;
}

.hi-era-k {
    display: flex;
    flex-wrap: wrap;
    gap: .2rem .6rem;
    font-size: var(--tb1-fs-xs, .875rem);
    font-weight: 700;
    color: rgba(255, 255, 255, .85);
}

.hi-era-range {
    color: #FDE68A;
    font-variant-numeric: tabular-nums;
}

.hi-era-h h3 {
    font-family: var(--hi-fd);
    font-size: var(--tb1-fs-xl, 1.5rem);
    font-weight: 800;
    line-height: 1.35;
    color: #fff;
}

.hi-era-lead {
    font-size: var(--tb1-fs-sm, 1rem);
    color: rgba(255, 255, 255, .9);
}

.hi-era-n {
    grid-column: 2;
    justify-self: start;
    padding: .1rem .7rem;
    border-radius: 999px;
    background: rgba(15, 23, 42, .3);
    font-size: var(--tb1-fs-xs, .875rem);
    font-weight: 700;
    color: #fff;
}

@media (min-width: 760px) {
    .hi-era-h {
        grid-template-columns: auto minmax(0, 1fr) auto;
        align-items: center;
    }

    .hi-era-n {
        grid-column: 3;
        justify-self: end;
    }
}

.hi-tl {
    position: relative;
    max-width: 1100px;
    margin: 1rem auto 0 !important;
}

/* เส้นแกน: กลางคอลัมน์จุด */
.hi-tl::before {
    content: '';
    position: absolute;
    top: .5rem;
    bottom: .5rem;
    left: 1.3rem;
    width: 2px;
    background: var(--hi-line2);
}

.hi-ev {
    position: relative;
    display: grid;
    grid-template-columns: 2.6rem minmax(0, 1fr);
    column-gap: .75rem;
    align-items: start;
    scroll-margin-top: 140px;
}

.hi-ev + .hi-ev {
    margin-top: .85rem;
}

.hi-ev-y {
    display: none;
}

.hi-ev-dot {
    grid-column: 1;
    grid-row: 1;
    position: relative;
    z-index: 1;
    justify-self: center;
    width: 2.6rem;
    height: 2.6rem;
    display: grid;
    place-items: center;
    margin-top: .55rem;
    border-radius: 50%;
    background: var(--hi-card);
    border: 2px solid var(--hi-inc);
    color: var(--hi-inc);
    font-size: var(--tb1-fs-sm, 1rem);
}

.hi-ev.is-key .hi-ev-dot {
    background: var(--hi-gold-dot);
    border-color: var(--hi-gold-dot);
    color: #1F1300;
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--hi-gold-dot) 25%, transparent);
}

.hi-ev-card {
    grid-column: 2;
    grid-row: 1;
    min-width: 0;
    padding: .95rem 1.05rem 1rem;
    border-radius: var(--hi-r);
    background: var(--hi-card);
    border: 1px solid var(--hi-line);
    box-shadow: var(--hi-sh);
}

.hi-ev.is-key .hi-ev-card {
    border-color: color-mix(in srgb, var(--hi-gold-dot) 45%, var(--hi-line));
}

.hi-ev-when {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .25rem .7rem;
}

.hi-ev-y2 {
    font-family: var(--hi-fd);
    font-size: var(--tb1-fs-lg, 1.25rem);
    font-weight: 800;
    color: var(--hi-navy);
    font-variant-numeric: tabular-nums;
}

[data-theme="dark"] .hi-ev-y2,
html.dark-mode .hi-ev-y2,
[data-theme="dark"] .hi-ev-y,
html.dark-mode .hi-ev-y {
    color: #93C5FD;
}

.hi-ev-date {
    font-size: var(--tb1-fs-xs, .875rem);
    color: var(--hi-ink3);
}

.hi-ev-star {
    font-size: var(--tb1-fs-xs, .875rem);
    font-weight: 700;
    color: var(--hi-gold);
}

.hi-ev-t {
    margin-top: .25rem !important;
    font-family: var(--hi-fbody);
    font-size: var(--tb1-fs-md, 1.125rem);
    font-weight: 700;
    line-height: 1.45;
    color: var(--tb1-heading, var(--hi-ink1));
}

.hi-ev-d {
    margin-top: .35rem !important;
    font-size: var(--tb1-fs-sm, 1rem);
    line-height: 1.75;
    color: var(--hi-ink2);
}

.hi-ev-d.is-more {
    padding-left: .75rem;
    border-left: 3px solid var(--hi-line2);
    color: var(--hi-ink3);
}

.hi-ev-tags {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem .45rem;
    margin-top: .7rem !important;
}

.hi-ev-tags li {
    display: inline-flex;
    align-items: baseline;
    gap: .35rem;
    max-width: 100%;
    padding: .12rem .6rem;
    border-radius: 999px;
    font-size: var(--tb1-fs-xs, .875rem);
    line-height: 1.5;
    color: var(--hi-ink2);
    background: var(--hi-alt);
}

.hi-ev-tags .t-name {
    color: var(--hi-ink1);
    background: color-mix(in srgb, var(--hi-c-name) 12%, var(--hi-card));
}

.hi-ev-tags .t-name i {
    color: var(--hi-c-name);
}

.hi-ev-tags .t-level i {
    color: var(--hi-c-sec);
}

.hi-ev-tags .t-src {
    color: var(--hi-ink3);
    background: transparent;
    border: 1px dashed var(--hi-line2);
}

.hi-ev-tags .t-src.is-school {
    border-style: solid;
    border-color: color-mix(in srgb, var(--hi-c-cur) 55%, var(--hi-line2));
}

@media (min-width: 820px) {
    .hi-tl::before {
        left: calc(8.5rem + .75rem + 1.5rem - 1px);
    }

    .hi-ev {
        grid-template-columns: 8.5rem 3rem minmax(0, 1fr);
    }

    .hi-ev-y {
        display: block;
        grid-column: 1;
        grid-row: 1;
        padding-top: .85rem;
        text-align: right;
        font-family: var(--hi-fd);
        font-size: var(--tb1-fs-lg, 1.25rem);
        font-weight: 800;
        line-height: 1.3;
        color: var(--hi-navy);
        font-variant-numeric: tabular-nums;
    }

    .hi-ev-y.is-range {
        font-size: var(--tb1-fs-md, 1.125rem);
    }

    .hi-ev-dot {
        grid-column: 2;
        width: 3rem;
        height: 3rem;
    }

    .hi-ev-card {
        grid-column: 3;
    }

    .hi-ev-y2 {
        display: none;
    }
}

/* ตัวกรองยุค: สถานะ "ไม่ตรงตัวกรอง" ซ่อนด้วยคลาส (สคริปต์ใส่) */
.hi-era.is-out,
.hi-ev.is-out {
    display: none;
}

/* ═══ ที่ตั้งและชุมชน ═══ */
.hi-places {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    counter-reset: hi-place;
}

@media (min-width: 900px) {
    .hi-places {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

.hi-place {
    position: relative;
    counter-increment: hi-place;
    padding-top: 1.2rem;
}

.hi-place::after {
    content: counter(hi-place);
    position: absolute;
    top: .8rem;
    right: 1rem;
    font-family: var(--hi-fd);
    font-size: 2.4rem;
    font-weight: 800;
    line-height: 1;
    color: color-mix(in srgb, var(--hi-inc) 18%, transparent);
}

.hi-place-ic {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border-radius: 12px;
    background: color-mix(in srgb, var(--hi-inc) 12%, transparent);
    color: var(--hi-inc);
    font-size: 1.1rem;
}

.hi-place-when {
    margin-top: .7rem !important;
    font-size: var(--tb1-fs-xs, .875rem);
    font-weight: 700;
    color: var(--hi-gold);
    font-variant-numeric: tabular-nums;
}

.hi-place h3 {
    font-family: var(--hi-fd);
    font-size: var(--tb1-fs-lg, 1.25rem);
    font-weight: 800;
    line-height: 1.4;
    color: var(--tb1-heading, var(--hi-ink1));
}

.hi-place-t {
    margin-top: .35rem !important;
    font-size: var(--tb1-fs-sm, 1rem);
    line-height: 1.75;
    color: var(--hi-ink2);
}

.hi-place-more {
    margin-top: 1rem !important;
    padding: .8rem 1rem;
    border-radius: var(--hi-rs);
    background: var(--hi-alt);
    font-size: var(--tb1-fs-sm, 1rem);
    color: var(--hi-ink2);
}

.hi-place-more i {
    margin-right: .35rem;
    color: var(--hi-inc);
}

.hi-next {
    display: grid;
    grid-template-columns: 1fr;
    gap: .75rem;
    margin-top: 2.5rem;
}

@media (min-width: 640px) {
    .hi-next {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (min-width: 1000px) {
    .hi-next {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

.hi .hi-next a {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: .7rem;
    align-items: center;
    min-height: 64px;
    padding: .8rem .95rem;
    border-radius: var(--hi-r);
    background: var(--hi-card);
    border: 1px solid var(--hi-line);
    box-shadow: var(--hi-sh);
    color: var(--hi-ink1);
    text-decoration: none;
}

.hi-next a > i {
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    border-radius: 12px;
    background: color-mix(in srgb, var(--hi-inc) 12%, transparent);
    color: var(--hi-inc);
}

.hi-next span {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.hi-next b {
    font-size: var(--tb1-fs-sm, 1rem);
    line-height: 1.4;
}

.hi-next small {
    font-size: var(--tb1-fs-xs, .875rem);
    color: var(--hi-ink3);
}

.hi .hi-next a:hover b {
    text-decoration: underline;
    text-underline-offset: 3px;
}

/* ═══ ที่มาของข้อมูล ═══ */
.hi-about h2 {
    font-family: var(--hi-fd);
    font-size: var(--tb1-fs-lg, 1.25rem);
    font-weight: 700;
    color: var(--tb1-heading, var(--hi-ink1));
    margin-bottom: .6rem !important;
}

.hi-about h2 i {
    color: var(--hi-inc);
}

.hi-about > ul li {
    position: relative;
    padding: .45rem 0 .45rem 1.1rem;
    font-size: var(--tb1-fs-sm, 1rem);
    color: var(--hi-ink2);
    border-top: 1px solid var(--hi-line);
}

.hi-about > ul li:first-child {
    border-top: 0;
}

.hi-about > ul li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 1.05rem;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--hi-inc);
}

.hi-about > ul b {
    color: var(--hi-ink1);
    margin-right: .3rem;
}

.hi-about-f {
    margin-top: .7rem !important;
    font-size: var(--tb1-fs-xs, .875rem);
    color: var(--hi-ink3);
}

.hi-audit {
    margin-top: 1.1rem;
    padding: .9rem 1rem;
    border-radius: var(--hi-rs);
    background: color-mix(in srgb, var(--hi-gold-dot) 9%, var(--hi-card));
    border: 1px dashed color-mix(in srgb, var(--hi-gold-dot) 60%, var(--hi-line2));
}

.hi-audit h3 {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: .2rem .6rem;
    font-size: var(--tb1-fs-sm, 1rem);
    font-weight: 700;
    color: var(--tb1-heading, var(--hi-ink1));
}

.hi-audit h3 i {
    color: var(--hi-gold);
}

.hi-audit h3 span {
    font-size: var(--tb1-fs-xs, .875rem);
    font-weight: 600;
    color: var(--hi-ink3);
}

.hi-audit ol {
    margin: .5rem 0 0 !important;
    padding-left: 1.3rem !important;
    list-style: decimal;
}

.hi-audit li {
    padding: .2rem 0;
    font-size: var(--tb1-fs-xs, .875rem);
    color: var(--hi-ink2);
}

.hi-audit > p {
    margin-top: .5rem !important;
    font-size: var(--tb1-fs-xs, .875rem);
    color: var(--hi-ink3);
}

.hi-audit code {
    font-size: var(--tb1-fs-xs, .875rem);
}

/* ═══ จอแคบ ═══ */
@media (max-width: 640px) {
    .hi-hero {
        padding-top: 1.75rem;
    }

    .hi .hi-kpi {
        padding: .85rem .85rem .9rem;
    }

    /* วงปีบนจอแคบ: ขึ้นไปมุมบนขวา ไม่ทับแถบยุค */
    .hi-hero-rings {
        top: -30px;
        right: -50px;
        bottom: auto;
        width: 190px;
        opacity: .14;
    }

    .hi-kpi-k {
        font-size: var(--tb1-fs-xs, .875rem);
    }

    /* แถบยุคบนจอแคบ: เหลือแค่ปีเริ่มของยุค ชื่อยุคยังอยู่ในลิงก์ให้โปรแกรมอ่านหน้าจออ่าน */
    .hi-ribbon-l {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
    }

    .hi .hi-ribbon-seg a {
        align-items: center;
        justify-content: center;
        padding: .3rem .1rem;
    }

    .hi-ribbon-y {
        font-size: var(--tb1-fs-xs, .875rem);
    }

    .hi-start-text {
        padding: 1.05rem;
    }

    .hi-first-dl > div {
        grid-template-columns: 5.2rem minmax(0, 1fr);
    }
}

@media (max-width: 380px) {
    .hi-kpis {
        grid-template-columns: 1fr;
    }
}

/* ═══ แอนิเมชัน (เฉพาะเมื่อมี JS และไม่ได้ตั้งลดการเคลื่อนไหว) ═══ */
@media (prefers-reduced-motion: no-preference) {

    .hi-hero-deco .o1 {
        animation: hiFloat 16s ease-in-out infinite alternate;
    }

    .hi-hero-deco .o2 {
        animation: hiFloat 20s ease-in-out -6s infinite alternate-reverse;
    }

    .hi-hero-deco .o3 {
        animation: hiFloat 24s ease-in-out -3s infinite alternate;
    }

    /* วงปีงอกออกทีละวงจากแกนกลาง */
    .hi-js .hi-hero-rings .ring {
        transform-box: fill-box;
        transform-origin: 50% 50%;
        animation: hiGrow 1.1s var(--hi-ease) both;
    }

    .hi-js .hi-hero-rings .r2 {
        animation-delay: .15s;
    }

    .hi-js .hi-hero-rings .r3 {
        animation-delay: .3s;
    }

    .hi-js .hi-hero-rings .r4 {
        animation-delay: .45s;
    }

    .hi-js .hi-hero-rings .r5 {
        animation-delay: .6s;
    }

    .hi-js .hi-hero-in > * {
        animation: hiUp .8s var(--hi-ease) both;
    }

    .hi-js .hi-hero-in > *:nth-child(2) {
        animation-delay: .08s;
    }

    .hi-js .hi-hero-in > *:nth-child(3) {
        animation-delay: .16s;
    }

    .hi-js .hi-hero-in > *:nth-child(4) {
        animation-delay: .24s;
    }

    .hi-js .hi-hero-in > *:nth-child(5) {
        animation-delay: .32s;
    }

    .hi-js .hi-hero-in > *:nth-child(6) {
        animation-delay: .4s;
    }

    /* แถบยุคยืดจากซ้ายไปขวาตามลำดับเวลา */
    .hi-js .hi-ribbon-seg {
        animation: hiSeg .6s var(--hi-ease) both;
        transform-origin: 0 50%;
    }

    .hi-js .hi-ribbon-seg.s0 {
        animation-delay: .5s;
    }

    .hi-js .hi-ribbon-seg.s1 {
        animation-delay: .62s;
    }

    .hi-js .hi-ribbon-seg.s2 {
        animation-delay: .74s;
    }

    .hi-js .hi-ribbon-seg.s3 {
        animation-delay: .86s;
    }

    .hi-js .hi-ribbon-seg.s4 {
        animation-delay: .98s;
    }

    .hi-js .hi-ribbon-dots i {
        animation: hiPop .5s var(--hi-ease) 1.15s both;
    }

    .hi-anniv.is-today .hi-anniv-ic {
        animation: hiWiggle 1.4s ease-in-out .8s 2;
    }

    /* เผยทีละส่วนเมื่อเลื่อนถึง */
    .hi-js .hi-rv {
        opacity: 0;
        transform: translateY(22px);
        transition: opacity .7s var(--hi-ease), transform .7s var(--hi-ease);
        transition-delay: calc(var(--i, 0) * 90ms);
    }

    .hi-js .hi-rv.is-in,
    .hi-js.hi-ready .hi-rv {
        opacity: 1;
        transform: none;
    }

    /* จุดบนเส้นเวลา: เด้งเข้ามาหลังการ์ดเผย */
    .hi-js .hi-ev .hi-ev-dot {
        transform: scale(.4);
        transition: transform .55s var(--hi-ease) .15s;
    }

    .hi-js .hi-ev.is-in .hi-ev-dot,
    .hi-js.hi-ready .hi-ev .hi-ev-dot {
        transform: none;
    }

    /* ชื่อโรงเรียน: วงตัวเลขขึ้นทีละวง */
    .hi-js .hi-names .hi-name {
        opacity: 0;
        transform: translateY(12px);
        transition: opacity .5s var(--hi-ease), transform .5s var(--hi-ease);
    }

    .hi-js .hi-names.is-in .hi-name,
    .hi-js.hi-ready .hi-names .hi-name {
        opacity: 1;
        transform: none;
    }

    .hi-js .hi-names.is-in .hi-name:nth-child(2) {
        transition-delay: .08s;
    }

    .hi-js .hi-names.is-in .hi-name:nth-child(3) {
        transition-delay: .16s;
    }

    .hi-js .hi-names.is-in .hi-name:nth-child(4) {
        transition-delay: .24s;
    }

    .hi-js .hi-names.is-in .hi-name:nth-child(5) {
        transition-delay: .32s;
    }

    .hi-js .hi-names.is-in .hi-name:nth-child(6) {
        transition-delay: .4s;
    }

    .hi-js .hi-names.is-in .hi-name:nth-child(n+7) {
        transition-delay: .48s;
    }

    .hi-kpi,
    .hi-card,
    .hi-ev-card,
    .hi-next a {
        transition: box-shadow .25s ease, transform .25s var(--hi-ease), opacity .7s var(--hi-ease), border-color .2s ease;
    }

    .hi-kpi:hover,
    .hi-ev-card:hover,
    .hi-next a:hover {
        box-shadow: var(--hi-sh2);
    }

    .hi .hi-kpi:hover,
    .hi .hi-next a:hover {
        transform: translateY(-2px);
    }

    /* มาจากลิงก์ตรง (#hi-y2537 ฯลฯ): วงเน้นกะพริบสองครั้งให้เห็นว่าอยู่ตรงไหน */
    .hi-ev:target .hi-ev-card {
        animation: hiFlash 1.1s ease-out .3s 2;
    }
}

@keyframes hiFloat {
    from {
        transform: translate3d(0, 0, 0) scale(1);
    }

    to {
        transform: translate3d(40px, 26px, 0) scale(1.12);
    }
}

@keyframes hiUp {
    from {
        opacity: 0;
        transform: translateY(16px);
    }

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

@keyframes hiGrow {
    from {
        opacity: 0;
        transform: scale(.3);
    }

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

@keyframes hiSeg {
    from {
        opacity: 0;
        transform: scaleX(.2);
    }

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

@keyframes hiPop {
    from {
        opacity: 0;
        transform: scale(0);
    }

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

@keyframes hiWiggle {
    0%,
    100% {
        transform: rotate(0);
    }

    25% {
        transform: rotate(-10deg);
    }

    75% {
        transform: rotate(10deg);
    }
}

@keyframes hiFlash {
    0%,
    100% {
        box-shadow: 0 0 0 3px color-mix(in srgb, var(--hi-inc) 30%, transparent), var(--hi-sh2);
    }

    40% {
        box-shadow: 0 0 0 8px color-mix(in srgb, var(--hi-inc) 18%, transparent), var(--hi-sh2);
    }
}

/* ═══ ความคมชัดสูง ═══
   ไฟล์กลาง (css/tb1-display-scale.css) บังคับตัวอักษรขาว ลิงก์เหลือง พื้นดำ ด้วย !important
   ที่นี่จึงเปลี่ยนพื้นการ์ดทุกชั้นเป็นดำ เส้นขาว/เหลือง ตัวอักษรจะอ่านได้ทุกจุด */
html.tb1-contrast-high {
    --hi-ink1: #fff;
    --hi-ink2: #fff;
    --hi-ink3: #fff;
    --hi-page: #000;
    --hi-card: #000;
    --hi-alt: #000;
    --hi-line: #fff;
    --hi-line2: #facc15;
    --hi-link: #facc15;
    --hi-gold: #facc15;
    --hi-sh: none;
    --hi-sh2: none;
}

html.tb1-contrast-high .hi-hero,
html.tb1-contrast-high .hi-era-h {
    background: #000;
    border: 0;
    border-bottom: 2px solid #facc15;
}

html.tb1-contrast-high .hi-era-h {
    border: 2px solid #fff;
}

html.tb1-contrast-high .hi-hero-deco {
    display: none;
}

html.tb1-contrast-high .hi :is(.hi-anniv, .hi-kpi, .hi-card, .hi-ev-card, .hi-eyebrow, .hi-hero-meta li, .hi-subnav a, .hi-pill, .hi-chip, .hi-ev-tags li, .hi-next a, .hi-context, .hi-audit, .hi-badge, .hi-era-n, .hi-name a, .hi-name-tag, .hi-ribbon-seg a) {
    background: #000 !important;
    border: 2px solid #fff;
    box-shadow: none !important;
}

html.tb1-contrast-high .hi :is(.hi-kpi, .hi-pill, .hi-chip, .hi-subnav a, .hi-next a, .hi-ribbon-seg a) {
    border-color: #facc15 !important;
}

html.tb1-contrast-high .hi :is(.hi-kpi-ic, .hi-card-ic, .hi-place-ic, .hi-era-ic, .hi-anniv-ic, .hi-next a > i, .hi-name-n, .hi-ev-dot) {
    background: #000 !important;
    border: 1px solid #fff;
    color: #fff !important;
    box-shadow: none !important;
}

html.tb1-contrast-high .hi :is(.hi-ev.is-key .hi-ev-dot, .hi-name.is-current .hi-name-n, .hi-ribbon-dots i) {
    background: #facc15 !important;
    color: #000 !important;
    border-color: #facc15;
}

html.tb1-contrast-high .hi .hi-kpi::before {
    background: #facc15;
}

html.tb1-contrast-high .hi :is(.hi-subnav a.is-on, .hi-chip[aria-pressed="true"]) {
    background: #facc15 !important;
}

html.tb1-contrast-high .hi :is(.hi-subnav a.is-on, .hi-subnav a.is-on *, .hi-chip[aria-pressed="true"], .hi-chip[aria-pressed="true"] *) {
    color: #000 !important;
}

/* <button> ตอนชี้/โฟกัส: ไฟล์กลางกลับสีเป็นดำบนเหลือง (ตัวอักษรดำ) พื้นต้องเหลืองตาม */
html.tb1-contrast-high .hi button.hi-chip:is(:hover, :focus-visible) {
    background: #facc15 !important;
}

html.tb1-contrast-high .hi .hi-tl::before,
html.tb1-contrast-high .hi .hi-names::before {
    background: #fff;
}

html.tb1-contrast-high .hi .hi-subnav {
    background: #000;
}

html.tb1-contrast-high .hi .hi-place::after {
    color: #fff;
    opacity: .35;
}

/* ═══ พิมพ์ ═══ */
@media print {

    .hi-skip,
    .hi-subnav,
    .hi-hero-deco,
    .hi-filter,
    .hi-ribbon,
    .hi-next,
    .hi-card-f,
    .tb1-navbar,
    nav.navbar,
    header.tb1-header,
    footer {
        display: none !important;
    }

    body.hi-page {
        background: #fff;
        font-size: 12px;
    }

    .hi-hero {
        padding: 1rem 0 1rem;
        color: #000;
        background: none !important;
    }

    .hi-hero h1 {
        color: #000;
        text-shadow: none;
    }

    .hi-hero-meta li,
    .hi-eyebrow {
        background: none;
        color: #000;
        border: 1px solid #999;
    }

    .hi-lead,
    .hi-lead strong {
        color: #000;
    }

    .hi-kpis {
        margin-top: 0 !important;
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .hi-rv,
    .hi-js .hi-rv,
    .hi-js .hi-names .hi-name,
    .hi-js .hi-ev .hi-ev-dot {
        opacity: 1 !important;
        transform: none !important;
    }

    .hi-era.is-out,
    .hi-ev.is-out {
        display: block !important;
    }

    .hi-ev.is-out {
        display: grid !important;
    }

    .hi-era-h {
        color: #000;
        background: none !important;
        border: 1px solid #999;
    }

    .hi-era-h h3,
    .hi-era-k,
    .hi-era-range,
    .hi-era-lead,
    .hi-era-n,
    .hi-era-ic {
        color: #000 !important;
        background: none !important;
    }

    .hi-kpi,
    .hi-card,
    .hi-ev-card {
        box-shadow: none;
        break-inside: avoid;
    }

    .hi-page * {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .hi-start,
    .hi-places {
        grid-template-columns: 1fr;
    }

    .hi-sec {
        margin-top: 1.5rem;
    }

    .hi-sec-h {
        break-after: avoid;
        page-break-after: avoid;
    }
}
