/* ──────────────────────────────────────────────────────────────────────────
   news_category.php — รายการข่าว (หน้าสาธารณะ)

   รูปทรง: แฟ้มจดหมายข่าวของโรงเรียน
       กระดาษแผ่นเดียวมีสันน้ำเงินซ้าย 12px ชุดเดียวกับหน้าอ่านข่าว (tb1-news-read.css)
       หัวแฟ้มคือชื่อหมวด บรรทัดสำมะโน และช่องค้นหา ไม่ใช่แถบไล่เฉดกับกล่องตัวเลขลอย
       ข่าวคั่นด้วยหัวเดือน ข่าวแรกของหน้าแรกเป็นข่าวนำกว้างเต็มแถว
       ข้างแฟ้มมีหมวดข่าวและสารบัญรายเดือน (ปีละ 12 ช่อง) ซึ่งเป็นจุดเด่นของหน้า

   สี: alias ที่ชี้ไป --tb1-* ของธีมเท่านั้น

   ความเฉพาะ: หน้านี้แนบ css/tb1-display-scale.css ผ่าน nvabar (โหลดทีหลังไฟล์นี้)
       กฎสีลิงก์ต้องมีคลาสสองชั้น ขนาดตัวอักษรเป็น rem ปุ่มปรับขนาดตัวอักษรของเว็บจึงมีผล
       ธีมบังคับ font-family บน p/span/div/li/dt/dd ตัวเซริฟจึงอยู่ที่ h1–h3 และ b
   ────────────────────────────────────────────────────────────────────────── */

.nl {
    --nl-paper: var(--tb1-surface, #ffffff);
    --nl-paper-alt: var(--tb1-surface-alt, #f1f5f9);
    --nl-ink: var(--tb1-ink-1, #0f172a);
    --nl-ink-2: var(--tb1-ink-2, #334155);
    --nl-muted: var(--tb1-ink-3, #5a697f);
    --nl-faint: var(--tb1-ink-4, #94a3b8);
    --nl-line: var(--tb1-border, #e2e8f0);
    --nl-line-bold: var(--tb1-border-bold, #cbd5e1);
    --nl-brand: var(--tb1-brand, #1d4ed8);
    --nl-spine: var(--tb1-brand-strong, #1e3a8a);
    --nl-wash: var(--tb1-brand-50, #eff6ff);
    --nl-on-brand: var(--tb1-on-brand, #ffffff);
    --nl-ok: var(--tb1-text-success, #047857);
    /* โทเคน text-danger โหมดสว่าง (#DC2626) ได้ 4.41:1 บนพื้นรอง ไม่ผ่าน AA */
    --nl-warn: #b91c1c;
    --nl-on-warn: #ffffff;
    --nl-mark: var(--tb1-warning-pale, #fde68a);
    --nl-serif: var(--tb1-font-display, "Noto Serif Thai", serif);
    --nl-sans: var(--tb1-font-body, "Sarabun", system-ui, sans-serif);
    --nl-lift: 0 12px 30px -22px rgba(15, 23, 42, .5);
    --nl-edge: inset 0 1px 0 rgba(255, 255, 255, .6);

    color: var(--nl-ink);
    font-family: var(--nl-sans);
    font-size: 1rem;
    line-height: 1.6;
}

:is(html.dark, html.dark-mode, html[data-theme="dark"],
    body.dark-mode, body[data-theme="dark"]) .nl {
    --nl-warn: var(--tb1-text-danger, #fda4af);
    --nl-on-warn: var(--tb1-page, #0a1120);
    --nl-spine: var(--tb1-banner-4, #2563eb);
    /* warning-pale โหมดมืดเป็นน้ำตาลเข้ม ตัวอักษรสว่างบนพื้นนี้อ่านได้ */
    --nl-lift: 0 16px 36px -24px rgba(0, 0, 0, .9);
    --nl-edge: inset 0 1px 0 rgba(255, 255, 255, .055);
}

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

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

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

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

.nl .nl-sr {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

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

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

.nl .nl-link:hover {
    text-decoration-thickness: 2px;
}

/* ── เปลือกหน้า ─────────────────────────────────────────────────────────── */
body.nl-page {
    margin: 0;
    background: var(--tb1-page, #f8fafc);
    color: var(--tb1-ink-1, #0f172a);
}

html:has(body.nl-page) {
    scroll-padding-top: 4.5rem;
}

.nl-shell {
    box-sizing: border-box;
    display: block;
    width: 100%;
    max-width: var(--tb1-page-max-width, 1440px);
    margin-inline: auto;
    padding: 1.5rem var(--tb1-shell-gutter, 20px) 3rem;
}

body.nl-page a.nl-skip {
    position: absolute;
    top: 8px;
    left: -9999px;
    z-index: 2000;
    padding: 10px 16px;
    color: #ffffff;
    background: var(--tb1-banner-1, #1d4ed8);
    border-radius: 8px;
    font-weight: 600;
    text-decoration: none;
}

body.nl-page a.nl-skip:focus {
    left: 12px;
    outline: 3px solid var(--tb1-brand-300, #93c5fd);
    outline-offset: 2px;
}

/* ── กระดาษ ─────────────────────────────────────────────────────────────── */
.nl-paper {
    padding: 1.4rem 1.75rem 2rem;
    background: var(--nl-paper);
    border: 1px solid var(--nl-line);
    border-left: 12px solid var(--nl-spine);
    border-radius: 14px;
    box-shadow: var(--nl-lift), var(--nl-edge);
}

/* ── หัวแฟ้ม ────────────────────────────────────────────────────────────── */
.nl-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1.25rem 2rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid var(--nl-line);
}

.nl-head-main {
    flex: 1 1 24rem;
    min-width: 0;
}

.nl-head-side {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: .75rem;
    flex: 0 1 26rem;
    min-width: min(100%, 18rem);
}

.nl-crumbs ol {
    display: flex;
    flex-wrap: wrap;
    font-size: .88rem;
}

.nl-crumbs li + li::before {
    content: "";
    display: inline-block;
    width: 1px;
    height: .8em;
    margin: 0 .7rem;
    vertical-align: -.05em;
    background: var(--nl-line-bold);
    transform: skewX(-18deg);
}

.nl .nl-crumbs a {
    display: inline-block;
    min-height: 24px;
    padding-block: .1rem;
}

.nl-title {
    margin-top: .35rem;
    font-family: var(--nl-serif);
    font-size: clamp(1.7rem, 1.3rem + 1.6vw, 2.35rem);
    font-weight: 600;
    line-height: 1.3;
    overflow-wrap: anywhere;
}

/* บรรทัดสำมะโน: grid ที่มีสันซ้ายรายช่อง เส้นจึงไม่ห้อยตอนตัดบรรทัด */
.nl-census {
    display: flex;
    flex-wrap: wrap;
    gap: .6rem 1.6rem;
    margin-top: .9rem;
}

.nl-census > div {
    padding-left: .7rem;
    box-shadow: inset 2px 0 0 var(--nl-line-bold);
}

.nl-census dt {
    font-size: .8rem;
    color: var(--nl-muted);
}

.nl-census dd b {
    font-family: var(--nl-serif);
    font-size: 1.12rem;
    font-weight: 600;
    color: var(--nl-ink);
}

/* ── ค้นหา ─────────────────────────────────────────────────────────────── */
.nl-search {
    width: 100%;
}

.nl-search-label {
    display: block;
    margin-bottom: .3rem;
    font-size: .88rem;
    font-weight: 600;
    color: var(--nl-ink-2);
}

.nl-search-row {
    display: flex;
    gap: .5rem;
}

.nl .nl-search-input {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 2.6rem;
    padding: .4rem .8rem;
    color: var(--nl-ink);
    background: var(--nl-paper);
    border: 1px solid var(--nl-line-bold);
    border-radius: 8px;
    font: inherit;
    font-size: 1rem;
}

.nl .nl-search-input::placeholder {
    color: var(--nl-muted);
    opacity: 1;
}

.nl .nl-search-input:focus-visible {
    outline: 3px solid var(--nl-brand);
    outline-offset: 1px;
    border-color: var(--nl-brand);
}

.nl .nl-search-input[aria-invalid="true"] {
    border-color: var(--nl-warn);
}

.nl-search-note {
    margin-top: .3rem;
    font-size: .86rem;
    font-weight: 600;
    color: var(--nl-warn);
}

/* ── ปุ่ม ───────────────────────────────────────────────────────────────── */
.nl .nl-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2.6rem;
    padding: 0 1.1rem;
    color: var(--nl-brand);
    background: var(--nl-paper);
    border: 1px solid var(--nl-line-bold);
    border-radius: 8px;
    font: inherit;
    font-size: .95rem;
    font-weight: 600;
    line-height: 1.2;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: border-color .16s ease, transform .16s ease;
}

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

.nl .nl-btn:active {
    transform: translateY(1px);
}

.nl .nl-btn-primary {
    color: var(--nl-on-brand);
    background: var(--nl-brand);
    border-color: var(--nl-brand);
}

.nl .nl-btn-warn {
    color: var(--nl-on-warn);
    background: var(--nl-warn);
    border-color: var(--nl-warn);
}

.nl .nl-btn[disabled] {
    opacity: .65;
    cursor: progress;
}

/* ── ข้อความแจ้ง ───────────────────────────────────────────────────────── */
.nl-flash {
    margin-top: 1rem;
    padding: .6rem .9rem;
    background: var(--nl-paper-alt);
    border-radius: 0 8px 8px 0;
    box-shadow: inset 4px 0 0 var(--nl-line-bold);
    font-size: .95rem;
}

.nl-flash.is-ok {
    box-shadow: inset 4px 0 0 var(--nl-ok);
}

/* ── โครงของแฟ้ม ──────────────────────────────────────────────────────
   จอแคบ: หมวด อยู่บนรายการ สารบัญรายเดือนอยู่ท้าย
   จอกว้าง: หมวดกับสารบัญรายเดือนอยู่คอลัมน์ขวา รายการกินสองแถว */
.nl-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
        "cats"
        "main"
        "archive";
    gap: 1.6rem;
    margin-top: 1.5rem;
}

.nl-main {
    grid-area: main;
    min-width: 0;
}

.nl-main:focus {
    outline: none;
}

.nl-cats {
    grid-area: cats;
    min-width: 0;
}

.nl-archive {
    grid-area: archive;
    min-width: 0;
}

@media (min-width: 1024px) {
    .nl-grid {
        grid-template-columns: minmax(0, 1fr) minmax(16rem, 18.5rem);
        grid-template-rows: auto 1fr;
        grid-template-areas:
            "main cats"
            "main archive";
        column-gap: 2.5rem;
        row-gap: 1.6rem;
    }

    .nl-cats,
    .nl-archive {
        padding-left: 1.4rem;
        border-left: 1px solid var(--nl-line);
    }
}

.nl-side-title {
    margin-bottom: .6rem;
    font-family: var(--nl-serif);
    font-size: 1.1rem;
    font-weight: 600;
    line-height: 1.4;
}

.nl-side-sub {
    display: block;
    font-family: var(--nl-sans);
    font-size: .82rem;
    font-weight: 400;
    color: var(--nl-muted);
}

/* ── หมวดข่าว ──────────────────────────────────────────────────────────── */
.nl-cat-list li + li {
    border-top: 1px solid var(--nl-line);
}

.nl .nl-cat {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: .75rem;
    min-height: 2.5rem;
    padding: .5rem .6rem .5rem .7rem;
    color: var(--nl-ink);
    text-decoration: none;
    box-shadow: inset 3px 0 0 transparent;
    transition: box-shadow .16s ease;
}

.nl .nl-cat:hover {
    box-shadow: inset 3px 0 0 var(--nl-line-bold);
}

.nl .nl-cat:hover .nl-cat-name {
    color: var(--nl-brand);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.nl .nl-cat.is-current {
    background: var(--nl-wash);
    box-shadow: inset 3px 0 0 var(--nl-brand);
}

.nl .nl-cat.is-current .nl-cat-name {
    font-weight: 700;
}

.nl-cat-name {
    font-size: .95rem;
    line-height: 1.45;
}

.nl-cat-count {
    font-family: var(--nl-serif);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.nl .nl-cat.is-empty {
    color: var(--nl-muted);
}

.nl .nl-cat.is-empty .nl-cat-count {
    color: var(--nl-muted);
    font-weight: 400;
}

/* จอแคบถึงกลาง: หมวดเป็นแถบปุ่มตัดบรรทัดได้ เหนือรายการ ไม่กินความสูงเต็มจอ */
@media (max-width: 1023.98px) {
    .nl-cats .nl-side-title {
        font-size: 1rem;
        margin-bottom: .45rem;
    }

    .nl-cat-list {
        display: flex;
        flex-wrap: wrap;
        gap: .4rem;
    }

    .nl-cat-list li + li {
        border-top: 0;
    }

    .nl .nl-cat {
        gap: .45rem;
        min-height: 2.25rem;
        padding: .3rem .75rem;
        border: 1px solid var(--nl-line-bold);
        border-radius: 999px;
        box-shadow: none;
    }

    .nl .nl-cat:hover {
        box-shadow: none;
        border-color: var(--nl-brand);
    }

    .nl .nl-cat.is-current {
        border-color: var(--nl-brand);
        box-shadow: inset 0 0 0 1px var(--nl-brand);
    }

    .nl .nl-cat.is-empty {
        border-style: dashed;
    }

    .nl-cat-name {
        font-size: .9rem;
    }
}

/* ── สารบัญรายเดือน ───────────────────────────────────────────────────
   ทุกเดือนของทุกปีมีช่องเสมอ เดือนที่ไม่มีข่าวเป็นช่องเส้นประ เดือนที่ยังไม่ถึงเว้นว่าง
   ความว่างคือข้อมูล: ช่วงที่โรงเรียนไม่ได้ลงข่าวเห็นได้ทันทีโดยไม่ต้องอ่านตัวเลข */
.nl-year + .nl-year {
    margin-top: 1rem;
}

.nl-year-title {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: .5rem;
    margin-bottom: .4rem;
    font-family: var(--nl-serif);
    font-size: .98rem;
    font-weight: 600;
}

.nl-year-title span {
    font-family: var(--nl-sans);
    font-size: .82rem;
    font-weight: 400;
    color: var(--nl-muted);
}

.nl-months {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 4px;
}

.nl .nl-mo {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 3rem;
    padding: .2rem 0;
    color: var(--nl-ink);
    background: var(--nl-paper);
    border: 1px solid var(--nl-line-bold);
    border-radius: 6px;
    text-decoration: none;
    line-height: 1.25;
    transition: border-color .16s ease;
}

.nl .nl-mo > span:first-child {
    font-size: .76rem;
    color: var(--nl-ink-2);
}

.nl .nl-mo b {
    font-family: var(--nl-serif);
    font-size: 1rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.nl a.nl-mo:hover {
    border-color: var(--nl-brand);
}

.nl a.nl-mo:hover b {
    color: var(--nl-brand);
}

.nl .nl-mo.is-current {
    color: var(--nl-on-brand);
    background: var(--nl-brand);
    border-color: var(--nl-brand);
}

.nl .nl-mo.is-current > span:first-child,
.nl .nl-mo.is-current b {
    color: var(--nl-on-brand);
}

.nl .nl-mo.is-empty {
    background: transparent;
    border-style: dashed;
    border-color: var(--nl-line-bold);
}

.nl .nl-mo.is-empty > span:first-child,
.nl .nl-mo.is-empty b {
    color: var(--nl-muted);
    font-weight: 400;
}

.nl .nl-mo.is-future {
    border-color: var(--nl-line);
}

@media (max-width: 1023.98px) {
    .nl-archive {
        padding-top: 1.4rem;
        border-top: 1px solid var(--nl-line);
    }

    .nl-months {
        grid-template-columns: repeat(12, minmax(0, 1fr));
    }
}

@media (max-width: 640px) {
    .nl-months {
        grid-template-columns: repeat(6, minmax(0, 1fr));
    }
}

/* ── บรรทัดสถานะและตัวกรอง ─────────────────────────────────────────────── */
.nl-status {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: .5rem 1.25rem;
    margin-bottom: .4rem;
    font-size: .95rem;
    color: var(--nl-ink-2);
}

.nl-status b {
    font-family: var(--nl-serif);
    font-weight: 600;
    color: var(--nl-ink);
}

.nl-filters {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem .6rem;
}

.nl-filters li {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    min-height: 2rem;
    padding: .1rem .3rem .1rem .75rem;
    font-size: .88rem;
    background: var(--nl-paper-alt);
    border: 1px solid var(--nl-line);
    border-radius: 999px;
}

.nl-filters li:has(> .nl-link) {
    padding-right: .75rem;
    background: transparent;
    border-color: transparent;
}

.nl .nl-filter-x,
.nl .nl-filters .nl-link {
    display: inline-flex;
    align-items: center;
    /* floor of 24px keeps WCAG 2.5.8 when the small font setting shrinks rem */
    min-height: max(1.6rem, 26px);
    padding: 0 .6rem;
    color: var(--nl-brand);
    background: var(--nl-paper);
    border: 1px solid var(--nl-line-bold);
    border-radius: 999px;
    font-size: .82rem;
    font-weight: 600;
    text-decoration: none;
}

.nl .nl-filter-x:hover {
    border-color: var(--nl-brand);
}

/* ── หัวเดือนในรายการ ───────────────────────────────────────────────────── */
.nl-month + .nl-month {
    margin-top: 1.6rem;
}

.nl-month-title {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: .2rem 1rem;
    margin: .9rem 0 .8rem;
    padding-bottom: .35rem;
    border-bottom: 2px solid var(--nl-ink);
    font-family: var(--nl-serif);
    font-size: 1.18rem;
    font-weight: 600;
    line-height: 1.4;
}

.nl .nl-month-all {
    display: inline-block;
    min-height: 24px;
    font-family: var(--nl-sans);
    font-size: .86rem;
    font-weight: 600;
    color: var(--nl-brand);
    text-decoration: underline;
    text-underline-offset: 3px;
}

/* ── การ์ดข่าว ─────────────────────────────────────────────────────────── */
.nl-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(15.5rem, 100%), 1fr));
    gap: 1.6rem 1.4rem;
    align-items: start;
}

.nl-card-in {
    position: relative;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.nl-card-media {
    aspect-ratio: 16 / 10;
    overflow: hidden;
    border-radius: 8px;
    background: var(--nl-paper-alt);
}

.nl-card-media img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform .2s ease;
}

.nl-card-noimg {
    display: grid;
    place-items: center;
    height: 100%;
    font-size: .85rem;
    color: var(--nl-muted);
    border: 1px dashed var(--nl-line-bold);
    border-radius: 8px;
}

.nl-card-body {
    display: flex;
    flex-direction: column;
    gap: .3rem;
    padding-top: .7rem;
}

.nl-card-kicker {
    font-size: .8rem;
    font-weight: 700;
    color: var(--nl-brand);
}

.nl-card-title {
    font-family: var(--nl-serif);
    font-size: 1.05rem;
    font-weight: 600;
    line-height: 1.5;
    overflow-wrap: anywhere;
}

/* ทั้งการ์ดกดได้ผ่านลิงก์หัวข้อ (::after คลุมการ์ด) โดยปุ่มผู้ดูแลยังกดแยกได้ */
.nl .nl-card-link {
    color: var(--nl-ink);
    text-decoration: none;
}

.nl .nl-card-link::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 1;
    border-radius: 8px;
}

.nl .nl-card-link:focus-visible {
    outline: none;
}

.nl .nl-card-link:focus-visible::after {
    outline: 3px solid var(--nl-brand);
    outline-offset: 4px;
}

.nl .nl-card-in:hover .nl-card-link {
    color: var(--nl-brand);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 4px;
}

.nl .nl-card-in:hover .nl-card-media img {
    transform: scale(1.03);
}

.nl-card-text {
    font-size: .95rem;
    line-height: 1.7;
    color: var(--nl-ink-2);
    overflow-wrap: anywhere;
}

/* Pinned to ink: inheriting the hovered link colour dropped to 4.3:1 on the dark mark */
.nl mark,
.nl .nl-card-in:hover mark {
    padding: 0 .1em;
    color: var(--nl-ink);
    background: var(--nl-mark);
    border-radius: 2px;
}

.nl-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: .1rem 1rem;
    font-size: .84rem;
    color: var(--nl-muted);
}

.nl-card-meta time {
    color: var(--nl-ink-2);
    font-weight: 600;
}

.nl-card-tools {
    position: relative;
    z-index: 2;
    display: flex;
    gap: .5rem;
    margin-top: .35rem;
}

.nl .nl-tool {
    display: inline-flex;
    align-items: center;
    min-height: 2rem;
    padding: 0 .75rem;
    color: var(--nl-brand);
    background: var(--nl-paper);
    border: 1px solid var(--nl-line-bold);
    border-radius: 6px;
    font: inherit;
    font-size: .85rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}

.nl .nl-tool:hover {
    border-color: currentColor;
}

.nl .nl-tool.is-warn {
    color: var(--nl-warn);
}

/* ข่าวนำ: กว้างเต็มแถว ภาพซ้ายข้อความขวาบนจอกว้าง */
.nl-card.is-lead {
    grid-column: 1 / -1;
}

.nl-card.is-lead .nl-card-title {
    font-size: clamp(1.25rem, 1.05rem + .8vw, 1.6rem);
    line-height: 1.45;
}

@media (min-width: 760px) {
    .nl-card.is-lead .nl-card-in {
        display: grid;
        grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
        gap: 1.6rem;
        align-items: start;
    }

    .nl-card.is-lead .nl-card-body {
        padding-top: .2rem;
        gap: .55rem;
    }
}

/* จอมือถือ: การ์ดทั่วไปเป็นแถวภาพเล็กซ้ายหัวข้อขวา ข่าว 12 เรื่องจึงไม่ยาวสิบกว่าหน้าจอ
   ข่าวนำยังเป็นภาพใหญ่ */
@media (max-width: 640px) {
    .nl-cards {
        gap: 0;
    }

    .nl-card.is-lead {
        padding-bottom: 1.1rem;
    }

    .nl-card:not(.is-lead) {
        border-top: 1px solid var(--nl-line);
    }

    .nl-card.is-lead + .nl-card,
    .nl-cards > .nl-card:first-child {
        border-top: 0;
    }

    .nl-card:not(.is-lead) .nl-card-in {
        display: grid;
        grid-template-columns: 6.5rem minmax(0, 1fr);
        gap: .85rem;
        padding: .9rem 0;
    }

    .nl-card:not(.is-lead) .nl-card-media {
        aspect-ratio: 1;
        border-radius: 6px;
    }

    .nl-card:not(.is-lead) .nl-card-body {
        padding-top: 0;
        gap: .2rem;
    }

    .nl-card:not(.is-lead) .nl-card-title {
        font-size: 1rem;
    }

    .nl .nl-card:not(.is-lead) .nl-card-link::after {
        inset: .5rem 0;
    }
}

/* ── ว่างและไม่พบ ──────────────────────────────────────────────────────── */
.nl-empty {
    margin-top: .8rem;
    padding: 1rem 1.1rem;
    background: var(--nl-paper-alt);
    border-radius: 0 8px 8px 0;
    box-shadow: inset 4px 0 0 var(--nl-line-bold);
    color: var(--nl-ink-2);
}

.nl-empty p + p {
    margin-top: .4rem;
}

/* ── เลขหน้า ───────────────────────────────────────────────────────────── */
.nl-pages {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    margin-top: 2.2rem;
    padding-top: 1.2rem;
    border-top: 1px solid var(--nl-line);
}

.nl-page-list {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .35rem;
}

.nl .nl-page {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.5rem;
    min-height: 2.5rem;
    padding: 0 .75rem;
    color: var(--nl-brand);
    background: var(--nl-paper);
    border: 1px solid var(--nl-line-bold);
    border-radius: 8px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    text-decoration: none;
}

.nl a.nl-page:hover {
    border-color: var(--nl-brand);
}

.nl .nl-page.is-current {
    color: var(--nl-on-brand);
    background: var(--nl-brand);
    border-color: var(--nl-brand);
}

.nl-page-gap {
    padding: 0 .2rem;
    color: var(--nl-muted);
}

/* ── หน้าต่างยืนยันการลบ ───────────────────────────────────────────────── */
.nl-dialog {
    width: min(30rem, calc(100vw - 32px));
    padding: 1.4rem 1.4rem 1.1rem;
    color: var(--nl-ink);
    background: var(--nl-paper);
    border: 1px solid var(--nl-line-bold);
    border-radius: 14px;
    box-shadow: 0 24px 60px -24px rgba(15, 23, 42, .55);
}

.nl-dialog::backdrop {
    background: rgba(15, 23, 42, .5);
}

.nl-dialog-title {
    font-family: var(--nl-serif);
    font-size: 1.15rem;
    font-weight: 600;
}

.nl-dialog-what {
    margin-top: .7rem;
    padding: .5rem 0 .5rem .8rem;
    font-weight: 600;
    box-shadow: inset 3px 0 0 var(--nl-warn);
    overflow-wrap: anywhere;
}

.nl-dialog-note {
    margin-top: .6rem;
    font-size: .92rem;
    color: var(--nl-ink-2);
}

.nl-dialog-error {
    margin-top: .7rem;
    font-size: .92rem;
    font-weight: 600;
    color: var(--nl-warn);
}

.nl-dialog-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: .5rem;
    margin-top: 1.1rem;
}

/* ── จอแคบ ─────────────────────────────────────────────────────────────── */
@media (max-width: 760px) {
    .nl-shell {
        padding: .9rem 12px 2rem;
    }

    .nl-paper {
        padding: 1rem .95rem 1.4rem;
        border-left-width: 8px;
        border-radius: 12px;
    }

    .nl-head-side {
        flex-basis: 100%;
        align-items: stretch;
    }

    .nl-head-side .nl-btn-primary {
        align-self: flex-start;
    }

    .nl-cards {
        gap: 1.4rem;
    }

    .nl-pages {
        gap: .6rem;
    }

    .nl .nl-page-step {
        flex: 1 1 auto;
    }

    .nl-page-list {
        order: -1;
        flex-basis: 100%;
        justify-content: center;
    }
}

/* ── โหมดคอนทราสต์สูง ──────────────────────────────────────────────────
   ไฟล์กลางบังคับพื้นดำ ตัวอักษรขาว ลิงก์เหลือง ปุ่มขอบเหลืองให้แล้ว
   ที่นี่เขียนเฉพาะสิ่งที่ไฟล์กลางไม่รู้จัก และให้สถานะ "กำลังเลือก" แยกด้วยรูปทรง */
html.tb1-contrast-high body.nl-page {
    background: #000000;
    color: #ffffff;
}

html.tb1-contrast-high .nl {
    --nl-lift: none;
    --nl-edge: none;
}

html.tb1-contrast-high .nl-paper,
html.tb1-contrast-high .nl-dialog,
html.tb1-contrast-high .nl-card-media,
html.tb1-contrast-high .nl-flash,
html.tb1-contrast-high .nl-empty,
html.tb1-contrast-high .nl-filters li,
html.tb1-contrast-high .nl .nl-mo,
html.tb1-contrast-high .nl .nl-cat.is-current {
    background: #000000;
    box-shadow: none;
}

html.tb1-contrast-high .nl-paper {
    border-color: #facc15;
    border-left-color: #facc15;
}

html.tb1-contrast-high .nl-head,
html.tb1-contrast-high .nl-cats,
html.tb1-contrast-high .nl-archive,
html.tb1-contrast-high .nl-cat-list li,
html.tb1-contrast-high .nl-pages,
html.tb1-contrast-high .nl-filters li,
html.tb1-contrast-high .nl-dialog,
html.tb1-contrast-high .nl .nl-mo,
html.tb1-contrast-high .nl .nl-cat {
    border-color: #facc15;
}

html.tb1-contrast-high .nl-month-title {
    border-bottom-color: #ffffff;
}

html.tb1-contrast-high .nl-flash,
html.tb1-contrast-high .nl-empty {
    box-shadow: inset 4px 0 0 #facc15;
}

html.tb1-contrast-high .nl-census > div {
    box-shadow: inset 2px 0 0 #facc15;
}

html.tb1-contrast-high .nl :where(b, dt, dd, time, mark),
html.tb1-contrast-high .nl-search-note,
html.tb1-contrast-high .nl-dialog-error {
    color: #ffffff;
}

html.tb1-contrast-high .nl mark {
    background: #000000;
    text-decoration: underline;
    text-decoration-thickness: 2px;
    text-underline-offset: 3px;
}

html.tb1-contrast-high .nl .nl-btn,
html.tb1-contrast-high .nl .nl-tool,
html.tb1-contrast-high .nl .nl-page,
html.tb1-contrast-high .nl .nl-filter-x,
html.tb1-contrast-high .nl .nl-link,
html.tb1-contrast-high .nl .nl-month-all {
    color: #facc15;
    background: #000000;
    border-color: #facc15;
}

/* สิ่งที่ "กำลังเลือกอยู่" กลับสีเป็นดำบนเหลือง
   ★ ไฟล์กลางบังคับลิงก์และปุ่มด้วย !important ถ้าไม่ !important ด้วยจะเหมือนตัวที่ไม่ได้เลือก */
html.tb1-contrast-high .nl .nl-btn-primary,
html.tb1-contrast-high .nl .nl-btn-warn,
html.tb1-contrast-high .nl .nl-page.is-current,
html.tb1-contrast-high .nl .nl-mo.is-current,
html.tb1-contrast-high .nl .nl-mo.is-current *,
html.tb1-contrast-high .nl .nl-cat.is-current,
html.tb1-contrast-high .nl .nl-cat.is-current * {
    color: #000000 !important;
    -webkit-text-fill-color: #000000 !important;
    background: #facc15 !important;
    border-color: #facc15 !important;
}

html.tb1-contrast-high .nl .nl-mo.is-empty {
    border-style: dashed;
}

html.tb1-contrast-high .nl .nl-cat.is-empty,
html.tb1-contrast-high .nl .nl-mo.is-empty * {
    color: #ffffff;
}

html.tb1-contrast-high .nl-crumbs li + li::before {
    background: #facc15;
}

html.tb1-contrast-high .nl :focus-visible,
html.tb1-contrast-high .nl .nl-card-link:focus-visible::after {
    outline-color: #ffffff;
}

html.tb1-contrast-high body.nl-page a.nl-skip {
    color: #000000;
    background: #facc15;
}

/* ── ฉบับพิมพ์ ─────────────────────────────────────────────────────────── */
@media print {
    body.nl-page {
        background: #ffffff;
    }

    .nl-shell {
        max-width: none;
        padding: 0;
    }

    .nl-paper {
        padding: 0;
        border: 0;
        border-radius: 0;
        box-shadow: none;
        color: #000000;
        background: #ffffff;
    }

    .nl-head-side,
    .nl-cats,
    .nl-archive,
    .nl-pages,
    .nl-card-tools,
    .nl-filter-x,
    .nl-dialog,
    .nl-skip {
        display: none !important;
    }

    .nl-grid {
        display: block;
    }

    .nl-cards {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .nl-card {
        break-inside: avoid;
    }

    .nl-card.is-lead {
        grid-column: auto;
    }

    .nl-card.is-lead .nl-card-in {
        display: flex;
    }

    .nl-card.is-lead .nl-card-text {
        display: none;
    }

    .nl-month-title {
        break-after: avoid;
    }

    .nl .nl-card-link {
        color: #000000;
    }
}

/* ── ลดการเคลื่อนไหว ───────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    .nl *,
    .nl *::before,
    .nl *::after {
        animation: none !important;
        transition: none !important;
    }

    .nl .nl-card-in:hover .nl-card-media img,
    .nl .nl-btn:active {
        transform: none;
    }
}
