.btn-theme:focus-visible {
    outline: 3px solid var(--theme-accent);
    outline-offset: 3px;
}

body,
h1,
h2,
h3,
h4,
h5,
h6,
.navbar-brand,
.nav-link,
.btn,
.badge,
.stat-number,
.dropdown-item {
    font-family: 'Sarabun', sans-serif !important;
}

body {
    color: var(--theme-dark);
    background-color: #f8fafc;
    overflow-x: hidden;
}

/* ==========================================================================
   2. Sticky Navbar (โทนสีไล่เฉดสดใสตามการตั้งค่าระบบ เหมือนภาพตัวอย่างระบบเก่า)
   ========================================================================== */
.school-navbar {
    background: linear-gradient(90deg, var(--theme-secondary) 0%, color-mix(in srgb, var(--theme-secondary) 50%, var(--theme-primary) 50%) 50%, var(--theme-primary) 100%);
    box-shadow: 0 4px 20px rgba(15, 23, 42, 0.14);
    border-bottom: none;
    transition: all 0.3s ease;
    z-index: 1030;
}

.brand-logo-box {
    background: rgba(255, 255, 255, 0.78);
    padding: 5px;
    border-radius: 16px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease, background 0.3s ease;
}

.navbar-brand:hover .brand-logo-box {
    transform: scale(1.05);
    background: #ffffff;
}

.brand-logo-img {
    width: 48px;
    height: 48px;
    object-fit: contain;
    border-radius: 50%;
    background: #ffffff;
    padding: 2px;
}

.school-title-th {
    font-size: 1.3rem;
    font-weight: 700;
    color: #ffffff;
    line-height: 1.2;
    text-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}

.school-title-en {
    font-size: 0.85rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.95);
    line-height: 1.2;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.28);
}

@media (max-width: 575.98px) {
    .brand-logo-img {
        width: 40px;
        height: 40px;
    }

    .school-title-th {
        font-size: 1.05rem;
    }

    .school-title-en {
        font-size: 0.72rem;
    }
}

.school-navbar .nav-link {
    font-weight: 700;
    font-size: 0.96rem;
    color: #ffffff !important;
    padding: 0.55rem 0.9rem !important;
    border-radius: 0.65rem;
    transition: all 0.25s ease;
    margin: 0 2px;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.28);
}

.school-navbar .nav-link:hover,
.school-navbar .nav-link.active,
.school-navbar .nav-link.show {
    color: #ffffff !important;
    background-color: rgba(255, 255, 255, 0.22);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.school-navbar .dropdown-menu {
    border: none;
    border-radius: 1rem;
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.16);
    padding: 0.6rem;
    border-top: 3px solid var(--theme-secondary);
    animation: fadeInDropdown 0.2s ease-out;
}

@keyframes fadeInDropdown {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.school-navbar .dropdown-item {
    font-size: 0.9rem;
    padding: 0.55rem 0.9rem;
    border-radius: 0.6rem;
    color: var(--theme-dark);
    transition: all 0.2s ease;
}

.school-navbar .dropdown-item i {
    width: 22px;
    color: var(--theme-secondary);
    transition: transform 0.2s ease;
}

.school-navbar .dropdown-item:hover,
.school-navbar .dropdown-item.active {
    background: var(--theme-soft-gradient);
    color: var(--theme-primary);
    font-weight: 600;
}

.school-navbar .dropdown-item:hover i,
.school-navbar .dropdown-item.active i {
    transform: translateX(3px);
    color: var(--theme-primary);
}

.custom-toggler {
    border: 2px solid rgba(255, 255, 255, 0.75);
    border-radius: 0.65rem;
    padding: 0.4rem 0.65rem;
    color: #ffffff;
    background-color: rgba(255, 255, 255, 0.18);
}

/* ==========================================================================
   3. ส่วนบนสุด: โลโก้ ชื่อโรงเรียนไทย-อังกฤษ และสังกัดสำนักงานเขต
   ========================================================================== */
.top-identity-banner {
    background: var(--theme-soft-gradient);
    position: relative;
    overflow: hidden;
    border-bottom: 1px solid rgba(14, 165, 233, 0.15);
}

.hero-school-logo {
    width: 96px;
    height: 96px;
    object-fit: contain;
    background: var(--theme-white);
    border-radius: 50%;
    padding: 6px;
    box-shadow: var(--theme-shadow);
    border: 3px solid var(--theme-primary);
}

.gradient-text {
    background: var(--theme-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.affiliation-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(14, 165, 233, 0.3);
    padding: 0.45rem 1.25rem;
    border-radius: 50rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
    font-weight: 600;
    color: var(--theme-dark);
}

/* ==========================================================================
   4. ภาพสไลด์หลัก (Main Carousel)
   ========================================================================== */
.main-slider-wrapper {
    border-radius: var(--card-radius);
    overflow: hidden;
    box-shadow: var(--theme-shadow);
    border: 3px solid var(--theme-white);
}

.main-carousel-item {
    height: 440px;
    position: relative;
}

.main-carousel-item img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: var(--theme-primary-light);
}

.carousel-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(0deg, rgba(15, 23, 42, 0.82) 0%, rgba(15, 23, 42, 0.25) 55%, rgba(15, 23, 42, 0.05) 100%);
}

.custom-carousel-caption {
    bottom: 1.75rem;
    left: 6%;
    right: 6%;
    text-align: left;
    z-index: 3;
}

@media (max-width: 767.98px) {
    .main-carousel-item {
        height: 270px;
    }

    .custom-carousel-caption h3 {
        font-size: 1.15rem;
    }

    .custom-carousel-caption p {
        font-size: 0.82rem;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }
}

/* ==========================================================================
   5. การ์ดวิสัยทัศน์ ปรัชญา และ ป้ายประชาสัมพันธ์
   ========================================================================== */
.section-heading {
    position: relative;
    display: inline-block;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.section-divider {
    width: 70px;
    height: 4px;
    background: var(--theme-gradient);
    border-radius: 2px;
    margin-top: 0.4rem;
}

.modern-card {
    background: var(--theme-white);
    border-radius: var(--card-radius);
    border: 1px solid rgba(14, 165, 233, 0.14);
    box-shadow: var(--theme-shadow);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.modern-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 16px 35px -5px rgba(14, 165, 233, 0.18), 0 8px 20px -5px rgba(236, 72, 153, 0.12);
}

.motto-box {
    border-left: 5px solid var(--theme-primary);
    background: linear-gradient(to right, var(--theme-primary-light), #ffffff);
}

.philosophy-box {
    border-left: 5px solid var(--theme-secondary);
    background: linear-gradient(to right, var(--theme-secondary-light), #ffffff);
}

.icon-circle {
    width: 54px;
    height: 54px;
    border-radius: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    color: var(--theme-white);
    background: var(--theme-gradient);
    box-shadow: 0 6px 15px rgba(236, 72, 153, 0.25);
    flex-shrink: 0;
}

.pr-carousel-img {
    height: auto;
    object-fit: contain;
    border-radius: 0.9rem;
}

/* ==========================================================================
   6. ส่วนผู้อำนวยการโรงเรียน (Director Showcase)
   ========================================================================== */
.director-section-card {
    background: var(--theme-soft-gradient);
    border-radius: calc(var(--card-radius) + 0.25rem);
    border: 2px solid var(--theme-white);
    box-shadow: var(--theme-shadow);
    position: relative;
    overflow: hidden;
}

.director-frame {
    position: relative;
    display: inline-block;
    padding: 8px;
    border-radius: 50%;
    background: var(--theme-gradient);
    box-shadow: 0 12px 28px rgba(236, 72, 153, 0.28);
}

.director-img {
    width: 210px;
    height: 210px;
    object-fit: cover;
    border-radius: 50%;
    border: 5px solid var(--theme-white);
    background-color: var(--theme-white);
}

/* ==========================================================================
   7. ข่าวสารและกิจกรรม & ภาพกิจกรรม (รูปแบบ Card จากไฟล์ตั้งค่า)
   ========================================================================== */
.news-card-img-wrapper {
    height: 200px;
    overflow: hidden;
    border-top-left-radius: var(--card-radius);
    border-top-right-radius: var(--card-radius);
    position: relative;
    background-color: #f1f5f9;
}

.news-card-img-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.modern-card:hover .news-card-img-wrapper img {
    transform: scale(1.08);
}

.news-badge {
    position: absolute;
    top: 12px;
    left: 12px;
    background: var(--theme-gradient);
    color: var(--theme-white);
    font-size: 0.76rem;
    padding: 0.35rem 0.8rem;
    border-radius: 50rem;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
    z-index: 2;
}

.photo-count-pill {
    position: absolute;
    bottom: 12px;
    right: 12px;
    background: rgba(15, 23, 42, 0.75);
    color: #fff;
    font-size: 0.75rem;
    padding: 0.28rem 0.7rem;
    border-radius: 50rem;
    backdrop-filter: blur(4px);
    z-index: 2;
}

.line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.line-clamp-3 {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ==========================================================================
   8. จำนวนนักเรียนและครูบุคลากร (Statistics Section - 2 Cards)
   ========================================================================== */
.stats-section {
    background: var(--theme-gradient);
    color: var(--theme-white);
    border-radius: calc(var(--card-radius) + 0.25rem);
    box-shadow: var(--theme-shadow);
    position: relative;
    overflow: hidden;
}

.stat-box {
    background: rgba(255, 255, 255, 0.16);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 1.1rem;
    padding: 1.8rem 1.25rem;
    transition: transform 0.3s ease, background 0.3s ease;
}

.stat-box:hover {
    transform: translateY(-5px);
    background: rgba(255, 255, 255, 0.24);
}

/* ==========================================================================
   9. Footer (โทนสีไล่เฉดสดใสตามการตั้งค่าระบบ ไม่ใช้สีทึบ เหมือนภาพตัวอย่าง)
   ========================================================================== */
.school-footer {
    background: linear-gradient(90deg, var(--theme-secondary) 0%, color-mix(in srgb, var(--theme-secondary) 50%, var(--theme-primary) 50%) 50%, var(--theme-primary) 100%);
    color: #ffffff;
    position: relative;
    overflow: hidden;
}

/* แถบสีด้านบนสุดของ Footer เหมือนในภาพตัวอย่าง */
.school-footer::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 6px;
    background: linear-gradient(90deg, #84cc16 0%, var(--theme-secondary) 45%, var(--theme-primary) 75%, var(--theme-accent) 100%);
}

.footer-logo-img {
    width: 76px;
    height: 76px;
    object-fit: contain;
    border-radius: 50%;
    padding: 6px;
    background: #ffffff;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.15);
}

/* เส้นขีดสีเหลือง/สีเน้นใต้หัวข้อใน Footer */
.footer-title-underline {
    width: 46px;
    height: 3.5px;
    background-color: var(--theme-accent);
    border-radius: 2px;
    margin-top: 8px;
    margin-bottom: 16px;
}

.footer-text-light {
    color: rgba(255, 255, 255, 0.92);
}

.footer-nav-link {
    color: rgba(255, 255, 255, 0.92);
    text-decoration: none;
    display: inline-block;
    transition: all 0.2s ease;
}

.footer-nav-link:hover {
    color: #ffffff;
    transform: translateX(4px);
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}

.btn-theme {
    background: var(--theme-gradient);
    color: var(--theme-white);
    border: none;
    font-weight: 600;
    border-radius: 50rem;
    padding: 0.55rem 1.4rem;
    box-shadow: 0 4px 14px rgba(236, 72, 153, 0.3);
    transition: all 0.25s ease;
}

.btn-theme:hover {
    color: var(--theme-white);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(14, 165, 233, 0.4);
    filter: brightness(1.05);
}

.btn-outline-theme {
    border: 2px solid var(--theme-secondary);
    color: var(--theme-secondary);
    background: var(--theme-white);
    font-weight: 600;
    border-radius: 50rem;
    padding: 0.5rem 1.3rem;
    transition: all 0.25s ease;
}

.btn-outline-theme:hover {
    background: var(--theme-secondary);
    color: var(--theme-white);
}

/* ปุ่มลอยควบคุมเพลงมาร์ชโรงเรียน */
.march-floating-player {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 1045;
}

/* ป๊อปอัพประชาสัมพันธ์ รองรับทุกขนาดหน้าจอ */
.web-popup-modal .modal-content {
    border: none;
    border-radius: 1.35rem;
    overflow: hidden;
    box-shadow: 0 25px 60px rgba(15, 23, 42, 0.35);
    max-height: 94dvh;
    overflow-y: auto;
}

.web-popup-close-btn {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(15, 23, 42, 0.65);
    color: #ffffff;
    border: 2px solid rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    cursor: pointer;
    transition: all 0.2s ease;
}

.web-popup-close-btn:hover {
    background: var(--theme-primary);
    transform: scale(1.08);
}

.web-popup-img {
    width: 100%;
    max-height: 75dvh;
    object-fit: contain;
    background: #0f172a;
}

/* Reference cards: data remains dynamic; no screenshot content is hard-coded. */
.director-profile-card {
    max-width: 404px;
    overflow: hidden;
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 8px 26px rgba(15, 23, 42, .1);
}

.director-profile-heading {
    margin: 0;
    padding: 16px 12px;
    min-height: 68px;
    color: white;
    font-size: 1.65rem;
    font-weight: 700;
    background: linear-gradient(110deg, #3b82f6, #8855fa);
}

.director-profile-body {
    min-height: 480px;
    padding: 30px 20px 44px;
}

.director-portrait {
    display: block;
    width: 200px;
    height: 290px;
    max-width: 100%;
    margin: 0 auto 48px;
    border: 5px solid white;
    border-radius: 50%;
    object-fit: cover;
    object-position: center top;
    box-shadow: 0 7px 12px rgba(0, 0, 0, .14);
}

.director-profile-name {
    font-size: 1.4rem;
    font-weight: 700;
    color: #0753ef;
    margin-bottom: 8px;
}

.director-profile-rank {
    color: #ff3294;
    margin: 0;
    font-size: .95rem;
}

.poster-news-card,
.activity-reference-card {
    overflow: hidden;
    border-radius: 20px;
    background: white;
    border: 1px solid #e8eaed;
    box-shadow: 0 6px 16px rgba(15, 23, 42, .09);
}

.poster-news-date {
    text-align: right;
    padding: 10px 16px;
    font-size: .9rem;
    background: #f8f8f8;
    border-bottom: 1px solid #dedede;
    color: #334155;
}

.poster-news-image {
    display: block;
    padding: 16px;
}

.poster-news-image img {
    display: block;
    width: 100%;
    aspect-ratio: 210/297;
    height: auto;
    object-fit: contain;
    background: #fff;
    border-radius: 4px;
}

.poster-news-body {
    padding: 22px 16px 20px;
}

.poster-news-title {
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.5;
    color: #006cdb;
    margin-bottom: 6px;
}

.poster-news-footer {
    padding: 9px 16px 12px;
    border-top: 1px solid #dedede;
}

.reference-detail-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 22px;
    border-radius: 50px;
    color: white;
    font-size: .85rem;
    font-weight: 700;
    text-decoration: none;
    background: linear-gradient(110deg, #189aff, #0068ce);
    box-shadow: 0 4px 9px rgba(0, 105, 210, .2);
}

.reference-detail-btn:hover {
    color: white;
    filter: brightness(.92);
}

.reference-detail-btn:focus-visible,
.poster-news-image:focus-visible {
    outline: 3px solid var(--theme-accent);
    outline-offset: 3px;
}

.activity-reference-cover {
    display: block;
    width: 100%;
    aspect-ratio: 2.08/1;
    object-fit: cover;
    object-position: center;
}

.activity-reference-body {
    padding: 18px 16px 14px;
    min-height: 285px;
}

.activity-reference-category {
    align-self: flex-start;
    background: #ffc107;
    color: #171717;
    font-size: .75rem;
    padding: 3px 8px;
    border-radius: 6px;
    font-weight: 700;
    margin-bottom: 8px;
}

.activity-reference-title {
    font-size: 1.15rem;
    color: #10116e;
    font-weight: 700;
    line-height: 1.35;
    margin-bottom: 8px;
}

#stats-section .compact-school-stats {
    max-width: 960px;
    padding: 20px 24px;
    border-radius: 18px;
}

#stats-section .stat-box {
    padding: 14px 12px;
    border-radius: 14px;
}

#stats-section .stat-number {
    font-size: 2rem;
    line-height: 1.15;
}

#stats-section .small {
    font-size: .8rem;
}

#stats-section .stat-box .mb-2 {
    margin-bottom: 6px !important;
}

@media(max-width:575.98px) {
    .director-profile-card {
        max-width: 360px;
    }

    .director-profile-heading {
        font-size: 1.4rem;
    }

    .director-portrait {
        width: 180px;
        height: 260px;
        margin-bottom: 30px;
    }

    #stats-section .compact-school-stats {
        padding: 18px 14px;
    }

    #stats-section .stat-box {
        padding: 12px;
    }

    .activity-reference-body {
        min-height: 250px;
    }
}