@import url("https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@400;500;700&family=Noto+Sans+TC:wght@400;500;700&display=swap");

:root {
    --bg: #edeff3;
    --panel: #ffffff;
    --fg: #1f1f1f;
    --muted: #5f6368;
    --line: #d7dbe5;
    --brand: #5f01d1;
    --brand-dark: #4a00a7;
    --link: #3d38cf;
    --link-hover: #7a1de0;
    --font-sans: "Noto Sans TC", "Noto Sans SC", "Segoe UI", Arial, sans-serif;
    --space: clamp(1rem, 3vw, 1.8rem);
    --wrap: min(1200px, 100% - 2 * var(--space));
}

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

html {
    font-size: 100%;
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    margin: 0;
    font-family: var(--font-sans);
    color: var(--fg);
    background: linear-gradient(180deg, #efe6ff 0, #f1f3f7 180px, var(--bg) 181px);
    line-height: 1.55;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

a {
    color: var(--link);
}

a:hover {
    color: var(--link-hover);
}

.wrap {
    width: var(--wrap);
    margin-inline: auto;
}

.site-header {
    background: #ffffff;
    border-bottom: 1px solid #d5dae5;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.header-row1 {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 0.5rem 1rem;
    padding-block: 0.7rem;
}

.brand {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    text-decoration: none;
}

.site-logo {
    width: 300px;
    max-width: 100%;
    height: auto;
    object-fit: contain;
}

.header-search-wrap {
    flex: 1;
    position: relative;
    min-width: 0;
}

.header-search-form {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0;
    min-width: 0;
    margin: 0;
}

.header-search-input {
    width: 100%;
    height: 2.2rem;
    padding: 0 0.7rem;
    border: 1px solid #c0c4cc;
    border-right: none;
    border-radius: 4px 0 0 4px;
    font-size: 0.88rem;
    background: #f8f9fc;
    color: #2e2e2e;
    min-width: 0;
}

.header-search-input:focus {
    outline: none;
    background: #fff;
    border-color: #5f01d1;
}

.header-search-select {
    height: 2.2rem;
    padding: 0 0.4rem;
    border: 1px solid #c0c4cc;
    border-right: none;
    font-size: 0.85rem;
    background: #f0f1f5;
    color: #2e2e2e;
}

.header-search-btn {
    height: 2.2rem;
    width: 2.2rem;
    border: 1px solid #c0c4cc;
    border-radius: 0 4px 4px 0;
    background: #5f01d1;
    color: #fff;
    font-size: 0.9rem;
    cursor: pointer;
    flex-shrink: 0;
}

.header-search-btn:hover {
    background: #4a00a7;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-shrink: 0;
}

.header-right a {
    display: inline-block;
    padding: 0.28rem 0.6rem;
    font-size: 0.82rem;
    line-height: 1;
    border-radius: 4px;
    color: #2e2e2e;
    text-decoration: none;
    border: 1px solid #c5cad6;
    background: #fff;
}

.header-right a:hover {
    background: #f0ebff;
    color: #5f01d1;
    border-color: #d5b8ff;
}

.header-right a.lang-active {
    color: #fff;
    background: #5f01d1;
    border-color: #5f01d1;
}

.header-row2 {
    border-top: 1px solid #eef0f5;
    background: #f9fafc;
}

.header-subnav {
    display: flex;
    gap: 0;
    padding-block: 0.3rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    flex-wrap: nowrap;
}

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

/* ── Hamburger button ── */
.header-row2-top {
    display: none;
}

.hamburger-btn {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.4rem 0.5rem;
    border-radius: 5px;
    flex-shrink: 0;
    align-self: center;
    transition: background 0.15s;
}

.hamburger-btn:hover {
    background: #f0ebff;
}

.hamburger-icon {
    display: flex;
    flex-direction: column;
    gap: 5px;
    width: 22px;
}

.hamburger-icon span {
    display: block;
    height: 2px;
    background: #4a5568;
    border-radius: 2px;
    transition: transform 0.2s, opacity 0.2s;
}

.hamburger-btn[aria-expanded="true"] .hamburger-icon span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}

.hamburger-btn[aria-expanded="true"] .hamburger-icon span:nth-child(2) {
    opacity: 0;
}

.hamburger-btn[aria-expanded="true"] .hamburger-icon span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

.header-subnav a {
    display: inline-block;
    padding: 0.32rem 0.85rem;
    font-size: 0.88rem;
    color: #3f4659;
    text-decoration: none;
    border-radius: 4px;
    white-space: nowrap;
}

.header-subnav a:hover {
    background: #ede8ff;
    color: #5f01d1;
}

.search-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 200;
    background: #fff;
    border: 1px solid #c5cad6;
    border-top: none;
    border-radius: 0 0 6px 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    overflow: hidden;
    max-height: 260px;
    overflow-y: auto;
}

.search-suggestions a {
    display: block;
    padding: 0.55rem 0.85rem;
    font-size: 0.88rem;
    color: #2e2e2e;
    text-decoration: none;
    border-bottom: 1px solid #f0f1f5;
}

.search-suggestions a:hover {
    background: #f6f3ff;
    color: #5f01d1;
}

.search-suggestions a:last-child {
    border-bottom: none;
}

@media (max-width: 700px) {
    .header-row1 {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .header-search-form {
        order: 3;
        width: 100%;
        min-width: 0;
    }

    .header-search-input {
        border-right: 1px solid #c0c4cc;
        border-radius: 4px;
        flex: 1;
        min-width: 0;
    }

    .header-search-select {
        display: none;
    }

    .header-search-btn {
        border-radius: 4px;
        flex-shrink: 0;
    }

    .header-right {
        gap: 0.25rem;
    }

    .header-right a {
        padding: 0.22rem 0.45rem;
        font-size: 0.78rem;
    }

    /* ── Mobile nav: hamburger + drawer ── */
    .header-row2-top {
        display: flex;
        justify-content: flex-end;
        align-items: center;
        padding-block: 0.4rem;
        width: 100%;
    }

    .hamburger-btn {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .header-row2 {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        padding-inline: 0;
        max-width: none;
    }

    #header-row2.wrap {
        padding-inline: var(--space);
        max-width: none;
    }

    .header-subnav {
        display: none;
        flex-direction: column;
        flex-wrap: nowrap;
        overflow: visible;
        padding: 0;
        gap: 0;
        background: #fff;
        border-top: 1px solid #eef0f5;
        box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    }

    .header-subnav.open {
        display: flex;
    }

    .header-subnav a {
        display: block;
        padding: 0.75rem 1rem;
        border-bottom: 1px solid #f0f0f5;
        font-size: 0.95rem;
        color: #2e2e2e;
        white-space: nowrap;
    }

    .header-subnav a:hover {
        background: #f6f3ff;
        color: #5f01d1;
    }
}

@media (max-width: 480px) {
    .site-logo {
        width: 200px;
        height: auto;
    }
}

.nav-main a:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.16);
}

.lang-switch {
    display: flex;
    gap: 0.35rem;
}

.lang-switch a {
    display: inline-block;
    padding: 0.26rem 0.52rem;
    font-size: 0.78rem;
    line-height: 1;
    border-radius: 4px;
    color: #fff;
    text-decoration: none;
    border: 1px solid rgba(255, 255, 255, 0.35);
    background: rgba(255, 255, 255, 0.08);
}

.lang-switch a:hover {
    background: rgba(255, 255, 255, 0.25);
}

.lang-switch a.lang-active {
    color: var(--brand-dark);
    background: #fff;
    border-color: #fff;
    font-weight: 700;
}

.main-content {
    flex: 1;
    margin-top: 1rem;
    margin-bottom: 2rem;
    padding: 1.2rem 1.35rem 2rem;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(31, 31, 31, 0.05);
}

.home-search-block {
    margin-bottom: 0.9rem;
    padding: 0.9rem;
    border: 1px solid #d8ddef;
    border-radius: 8px;
    background: #f8f9ff;
    overflow-x: auto;
}

.home-search-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 160px auto;
    gap: 0.55rem;
}

.search-input,
.search-select,
.search-btn {
    border: 1px solid #bec6df;
    border-radius: 6px;
    font: inherit;
    height: 2.35rem;
}

.search-input,
.search-select {
    background: #fff;
    color: #2b2b2b;
    padding: 0 0.75rem;
}

.search-btn {
    border-color: #5f01d1;
    background: #5f01d1;
    color: #fff;
    font-weight: 700;
    padding: 0 1rem;
    cursor: pointer;
}

.search-btn:hover {
    background: #4a00a7;
}

.search-result-block {
    margin-top: 0.75rem;
}

.search-list {
    margin-top: 0.55rem;
}

.home-banner {
    margin-bottom: 1rem;
    border: 1px solid #ceb8ff;
    border-left: 5px solid #7a25e8;
    border-radius: 8px;
    padding: 0.85rem 1rem;
    background: linear-gradient(90deg, #f5efff, #fbf9ff);
}

.banner-title {
    margin: 0 0 0.2rem;
    font-size: 1rem;
    font-weight: 700;
    color: #4a00a7;
}

.banner-text {
    margin: 0;
    color: #4e5564;
    font-size: 0.93rem;
}

.home-layout {
    display: grid;
    gap: 1rem;
}

.portal-shell {
    display: grid;
    grid-template-columns: 190px minmax(0, 1fr) 280px;
    gap: 1rem;
    align-items: start;
}

.portal-left,
.portal-right {
    position: sticky;
    top: 0.8rem;
}

.portal-menu {
    margin: 0;
    padding: 0;
    list-style: none;
    border: 1px solid #d5daea;
    border-radius: 10px;
    background: #fff;
    overflow: hidden;
}

.portal-menu li + li {
    border-top: 1px solid #edf0f7;
}

.portal-menu a {
    display: block;
    padding: 0.68rem 0.8rem;
    text-decoration: none;
    color: #2e2e2e;
    font-size: 0.92rem;
}

.portal-menu a:hover {
    background: #f6f3ff;
    color: #4b2cd1;
}

.portal-search {
    margin-bottom: 0.8rem;
}

.portal-top-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.8rem;
    flex-wrap: wrap;
}

.portal-tab {
    text-decoration: none;
    padding: 0.35rem 0.8rem;
    border-radius: 999px;
    border: 1px solid #d5daea;
    color: #3f4659;
    background: #fff;
    font-size: 0.86rem;
}

.portal-tab-active,
.portal-tab:hover {
    background: #5f01d1;
    color: #fff;
    border-color: #5f01d1;
}

/* ── Homepage Explore Featured (Magazine Style) ── */
.explore-featured {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 0.8rem;
    margin-bottom: 0.8rem;
}

.explore-featured-main {
    display: flex;
    flex-direction: column;
    background: #fff;
    border: 1px solid #e6e9f2;
    border-radius: 10px;
    overflow: hidden;
}

.explore-featured-img-link {
    display: block;
    overflow: hidden;
}

.explore-featured-img {
    display: block;
    width: 100%;
    height: 220px;
    object-fit: cover;
    background: #f7f8fb;
}

.explore-featured-img-placeholder {
    width: 100%;
    height: 220px;
    background: #f0f3f8;
}

.explore-featured-img-placeholder--sm {
    height: 80px;
}

.explore-featured-main-body {
    padding: 0.85rem 1rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.explore-featured-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: #1e2538;
    text-decoration: none;
    line-height: 1.4;
    display: block;
}

.explore-featured-title:hover {
    color: #7b04c4;
}

.explore-featured-meta {
    font-size: 0.78rem;
    color: #888;
}

.explore-featured-side {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.explore-featured-side-item {
    display: flex;
    gap: 0.6rem;
    background: #fff;
    border: 1px solid #e6e9f2;
    border-radius: 8px;
    padding: 0.6rem;
    flex: 1;
}

.explore-featured-side-img-link {
    flex-shrink: 0;
    display: block;
    overflow: hidden;
    border-radius: 6px;
}

.explore-featured-side-img {
    width: 80px;
    height: 80px;
    object-fit: cover;
    display: block;
    background: #f7f8fb;
}

.explore-featured-side-body {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    min-width: 0;
}

.explore-featured-side-title {
    font-size: 0.88rem;
    font-weight: 600;
    color: #1e2538;
    text-decoration: none;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.explore-featured-side-title:hover {
    color: #7b04c4;
}

.explore-featured-side-meta {
    font-size: 0.75rem;
    color: #888;
}

.tier-districts-grid {
    display: grid;
    gap: 0.8rem;
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.tier-district-col {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.district-list-box {
    border: 1px solid #d0d7e2;
    border-top: 2px solid #1a5fb4;
    background: #fff;
}

.district-dl {
    margin: 0;
    padding: 0.3rem 0;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0 0.4rem;
    font-size: 0.82rem;
}

.district-item {
    margin: 0;
    padding: 0.2rem 0;
}

.district-item a {
    font-size: 16px;
    color: #1a5fb4;
    text-decoration: none;
}

.district-item a:hover {
    text-decoration: underline;
    color: #0d47a1;
}

.portal-tier-card {
    min-height: 88px;
    display: flex;
    align-items: center;
}

.portal-right-card + .portal-right-card {
    margin-top: 0.8rem;
}

@media (min-width: 940px) {
    .home-layout {
        grid-template-columns: minmax(0, 1fr) 300px;
        align-items: start;
    }
}

@media (min-width: 700px) and (max-width: 939px) {
    .home-layout {
        grid-template-columns: 1fr 260px;
        align-items: start;
    }

    .home-sidebar {
        grid-template-columns: 1fr;
    }

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

.home-sidebar {
    display: grid;
    gap: 0.9rem;
    grid-template-columns: 1fr;
}

.sidebar-card {
    border: 1px solid #d5daea;
    border-radius: 8px;
    background: #fff;
}

.sidebar-title {
    margin: 0;
    padding: 0.7rem 0.85rem;
    font-size: 0.9rem;
    font-weight: 700;
    color: #434b5d;
    border-bottom: 1px solid #e8ebf3;
    background: #f8f9fc;
}

.sidebar-list {
    margin: 0;
    padding: 0.3rem 0.85rem 0.55rem;
    list-style: none;
}

.sidebar-list li {
    padding: 0.45rem 0;
    border-bottom: 1px solid #eef0f6;
    color: #545b6c;
    font-size: 0.9rem;
}

.sidebar-list li:last-child {
    border-bottom: none;
}

.sidebar-list a {
    text-decoration: none;
}

.page-title {
    margin: 0 0 0.35rem;
    font-size: clamp(1.35rem, 2.8vw, 1.85rem);
    font-weight: 700;
    color: #272727;
}

.school-net-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: linear-gradient(135deg, #f8e8ff 0%, #f0d4ff 100%);
    border: 1px solid #d9a3f0;
    border-radius: 25px;
    padding: 0.4rem 1rem 0.4rem 0.75rem;
    margin-bottom: 1rem;
}
.school-net-label {
    font-size: 0.85rem;
    color: #5f01d1;
    font-weight: 600;
}
.school-net-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #5f01d1;
    color: #fff;
    font-size: 1rem;
    font-weight: 700;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    text-decoration: none;
    transition: background 0.2s;
}
.school-net-num:hover {
    background: #3a0091;
}

.lead {
    margin: 0 0 1.25rem;
    color: #494d58;
    max-width: 46rem;
    font-size: 1rem;
    padding: 0.85rem 1rem;
    background: #f6f8ff;
    border-left: 4px solid #7a25e8;
    border-radius: 0 6px 6px 0;
}

.muted {
    color: var(--muted);
    font-size: 0.92rem;
}

.section-heading {
    margin: 0 0 0.7rem;
    color: #4f5562;
    font-size: 0.84rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.breadcrumb ol {
    margin: 0 0 1rem;
    padding: 0;
    list-style: none;
    display: flex;
    gap: 0.3rem 0.45rem;
    flex-wrap: wrap;
    font-size: 0.82rem;
    color: #6a7080;
}

.breadcrumb li:not(:last-child)::after {
    content: ">";
    margin-left: 0.45rem;
    color: #a8afbf;
}

.breadcrumb a {
    color: #5a47bd;
    text-decoration: none;
}

.breadcrumb a:hover {
    text-decoration: underline;
}

.tier-cards {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 0.8rem;
}

@media (min-width: 700px) {
    .tier-cards {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

.tier-card {
    display: block;
    text-decoration: none;
    color: #282828;
    padding: 1rem 1.1rem;
    border: 1px solid #ccd2df;
    border-top: 4px solid #7a25e8;
    border-radius: 8px;
    background: linear-gradient(180deg, #ffffff, #f8faff);
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.tier-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(66, 56, 177, 0.12);
}

.tier-card-title {
    font-size: 1.05rem;
    font-weight: 700;
}

.district-list,
.school-list {
    margin: 1rem 0 0;
    padding: 0;
    list-style: none;
    border: 1px solid #d5daea;
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
}

.district-region + .district-region {
    margin-top: 1rem;
}

.district-region-title {
    margin-bottom: 0.45rem;
    color: #4a00a7;
}

/* explore.php: tab navigation - Yahoo style */
.explore-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 0;
    padding: 0;
    border: 1px solid #ccc;
    border-bottom: none;
    background: #f0f0f0;
    border-radius: 8px 8px 0 0;
    overflow: hidden;
}

.explore-tab {
    background: #f0f0f0;
    border: none;
    border-right: 1px solid #ccc;
    padding: 0.75rem 1.5rem;
    font-size: 0.95rem;
    font-weight: 700;
    color: #666;
    cursor: pointer;
    transition: background 0.2s ease;
    flex: 1;
    text-align: center;
}

.explore-tab:last-child {
    border-right: none;
}

.explore-tab:hover {
    background: #e8e8e8;
}

.explore-tab.active {
    background: #fff;
    color: #7b04c4;
    border-bottom: 2px solid #fff;
    margin-bottom: -1px;
}

.explore-tab .tab-count {
    font-weight: 400;
    color: #999;
    margin-left: 4px;
}

.explore-tab.active .tab-count {
    color: #7b04c4;
}

.explore-content {
    border: 1px solid #ccc;
    background: #fff;
    padding: 1rem;
    border-radius: 0 0 8px 8px;
    animation: fadeIn 0.3s ease;
}

.explore-tab-content {
    display: flex;
    flex-direction: column;
}

.explore-tab-content[style="display:none"] {
    display: none !important;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.district-list li + li,
.school-list li + li {
    border-top: 1px solid #e6e9f2;
}

.district-list li > a,
.school-list > li > a {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.25rem 0.75rem;
    align-items: baseline;
    padding: 0.78rem 0.95rem;
    color: #2e2e2e;
    text-decoration: none;
}

.article-title {
    flex: 1 1 0%;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* explore.php: one row — title left (ellipsis), meta right */
.explore-list > li.explore-item .explore-item__row {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem 1rem;
    padding: 0.78rem 0.95rem;
}

.explore-list .explore-item__title {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #2e2e2e;
    text-decoration: none;
}

.explore-list .explore-item__meta {
    flex: 0 0 auto;
    max-width: 48%;
    text-align: right;
    font-size: 0.84rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.d-count {
    flex: 0 0 auto;
    text-align: right;
    color: #697083;
    font-size: 0.84rem;
    white-space: nowrap;
    overflow: hidden;
    max-width: 40%;
    gap: 0.3rem;
}

.district-list li > a:hover,
.school-list > li > a:hover {
    background: #f6f3ff;
}

.district-list li > a:hover .d-name,
.school-list > li > a:hover {
    color: #4b2cd1;
}

.explore-list .explore-item:hover {
    background: #f6f3ff;
}

.explore-list .explore-item:hover .explore-item__title {
    color: #4b2cd1;
}

.school-link-inline {
    color: inherit;
    text-decoration: none;
}
.school-link-inline:hover {
    text-decoration: underline;
}

.primary-school-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
    border: 1px solid #d5daea;
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
    font-size: 0.93rem;
}

.primary-school-table th,
.primary-school-table td {
    padding: 0.62rem 0.75rem;
    border-bottom: 1px solid #e6e9f2;
    text-align: left;
    vertical-align: top;
}

.primary-school-table thead th {
    background: #f4f6fc;
    color: #4a5262;
    font-weight: 700;
}

.primary-school-table tbody tr:hover {
    background: #f8f5ff;
}

.primary-school-table tbody tr:last-child td {
    border-bottom: none;
}

.primary-school-table td a {
    text-decoration: none;
    color: #3d38cf;
}

.primary-school-table td a:hover {
    text-decoration: underline;
}

.back-link {
    margin: 0 0 0.75rem;
    font-size: 0.9rem;
}

.back-link a {
    text-decoration: none;
    color: #5a47bd;
}

.back-link a:hover {
    text-decoration: underline;
}

.detail-block {
    margin-top: 1rem;
}

.school-logo-block {
    margin: 0.8rem 0 1rem;
}

.school-logo-img {
    max-width: 140px;
    max-height: 140px;
    width: auto;
    height: auto;
    border: 1px solid #d5daea;
    border-radius: 10px;
    background: #fff;
    padding: 0.35rem;
}

.article-hero {
    margin-top: 0.8rem;
}

.article-hero-img {
    width: min(100%, 860px);
    display: block;
    margin: 0 auto;
    border: 1px solid #d5daea;
    border-radius: 10px;
    background: #fff;
    padding: 0.35rem;
}

.article-hero-caption {
    margin: 0.45rem 0 0;
    text-align: center;
    color: var(--muted);
    font-size: 0.92rem;
}

.article-gallery {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.85rem;
    margin-top: 1rem;
}

.article-gallery-item {
    margin: 0;
    text-align: center;
}

.article-gallery-img {
    width: 100%;
    max-width: 220px;
    border: 1px solid #d5daea;
    border-radius: 10px;
    background: #fff;
    padding: 0.3rem;
}

.article-gallery-caption {
    margin-top: 0.4rem;
    font-size: 0.9rem;
    color: var(--muted);
}

.article-school-link {
    color: #3d38cf;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.article-school-link:hover {
    color: #7a1de0;
}

@media (min-width: 560px) {
    .article-gallery {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (min-width: 860px) {
    .article-gallery {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

.lightbox-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0, 0, 0, 0.86);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem 3rem;
}

.lightbox-overlay[hidden] {
    display: none !important;
}

.lightbox-content {
    max-width: min(1100px, 100%);
    max-height: 100%;
    text-align: center;
}

.lightbox-content img {
    max-width: 100%;
    max-height: min(78vh, 860px);
    border-radius: 8px;
    background: #111;
}

.lightbox-caption {
    margin-top: 0.55rem;
    color: #fff;
    font-size: 0.95rem;
}

.lightbox-close,
.lightbox-nav {
    position: absolute;
    border: none;
    color: #fff;
    background: rgba(20, 20, 20, 0.6);
    cursor: pointer;
    border-radius: 999px;
}

.lightbox-close {
    top: 1rem;
    right: 1rem;
    width: 40px;
    height: 40px;
    font-size: 1.6rem;
    line-height: 1;
}

.lightbox-nav {
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    font-size: 2rem;
    line-height: 1;
}

.lightbox-prev {
    left: 1rem;
}

.lightbox-next {
    right: 1rem;
}

.kv {
    width: 100%;
    border-collapse: collapse;
    border: 1px solid #d5daea;
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
    font-size: 0.94rem;
}

.kv th,
.kv td {
    text-align: left;
    vertical-align: top;
    padding: 0.64rem 0.9rem;
    border-bottom: 1px solid #e6e9f2;
}

.kv tr:last-child th,
.kv tr:last-child td {
    border-bottom: none;
}

.kv th {
    width: 11rem;
    max-width: 35%;
    color: #565d6e;
    font-weight: 600;
    background: #f7f8fb;
}

.kv a {
    color: #3d38cf;
    word-break: break-all;
}

.detail-more {
    margin-top: 1rem;
    background: #fbfbff;
    border: 1px solid #d5daea;
    border-radius: 8px;
    padding: 0.7rem 0.95rem;
}

.detail-more summary {
    cursor: pointer;
    color: #4f5562;
    font-weight: 700;
}

.detail-more .kv {
    margin-top: 0.7rem;
}

@media (max-width: 560px) {
    .home-search-form {
        grid-template-columns: 1fr;
    }

    .search-btn {
        width: 100%;
    }

    .main-content {
        padding: 1rem 0.85rem 1.5rem;
    }

    .kv th,
    .kv td {
        display: block;
        width: 100%;
        max-width: none;
    }

    .kv th {
        padding-bottom: 0.2rem;
    }

    .kv td {
        padding-top: 0;
    }

    .primary-school-table {
        font-size: 0.88rem;
    }

    .primary-school-table th,
    .primary-school-table td {
        padding: 0.52rem 0.55rem;
    }

    .portal-shell {
        grid-template-columns: 1fr;
    }

    .portal-left,
    .portal-right {
        position: static;
    }

    .explore-featured {
        grid-template-columns: 1fr;
    }

    .tier-districts-grid {
        grid-template-columns: 1fr;
    }

    /* ── Advanced search mobile ── */
    .adv-search-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        gap: 0.2rem;
        flex-wrap: nowrap;
        padding-bottom: 2px;
    }

    .adv-search-tabs::-webkit-scrollbar {
        display: none;
    }

    .adv-search-tab {
        white-space: nowrap;
        flex-shrink: 0;
        padding: 0.3rem 0.75rem;
        font-size: 0.85rem;
    }

    .adv-search-form {
        padding: 0.7rem;
    }

    .adv-search-kw-row .search-input {
        width: 100%;
        display: block;
    }

    .adv-filter-row {
        flex-direction: column;
        gap: 0.55rem;
    }

    .adv-filter-group {
        min-width: 0;
        width: 100%;
    }

    .adv-filter-checkboxes {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        gap: 0.2rem 0.6rem;
        max-height: none;
        padding-bottom: 2px;
    }

    .adv-filter-checkboxes::-webkit-scrollbar {
        display: none;
    }

    .adv-checkbox-label {
        white-space: nowrap;
        flex-shrink: 0;
    }

    .adv-search-actions {
        margin-top: 0.7rem;
    }

    .adv-search-actions .search-btn {
        width: 100%;
    }

    /* ── Homepage layout mobile ── */
    .home-layout {
        grid-template-columns: 1fr !important;
    }

    .home-sidebar {
        grid-template-columns: 1fr 1fr;
    }

    /* ── Browse table mobile ── */
    .primary-school-table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .primary-school-table th,
    .primary-school-table td {
        white-space: nowrap;
    }

    /* ── View cards/magazine mobile ── */
    .view-cards {
        grid-template-columns: 1fr 1fr;
    }

    .view-magazine {
        grid-template-columns: 1fr;
    }

    .mag-feature {
        grid-template-columns: 1fr;
    }

    .mag-feature__img {
        height: 180px;
    }

    .mag-feature__body {
        padding: 0.85rem;
    }

    .mag-item {
        flex-direction: column;
    }

    .mag-item__img {
        width: 100%;
        height: 120px;
    }
}

.site-footer {
    margin-top: auto;
    padding-block: 0.8rem 1.8rem;
}

.site-footer .muted {
    margin: 0;
    font-size: 0.79rem;
    color: #7a8091;
}

.footer-copy {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    margin: 0 0 0.3rem;
    font-size: 0.82rem;
    color: #555;
}

.footer-links a {
    color: #7b04c4;
    text-decoration: none;
}

.footer-links a:hover {
    text-decoration: underline;
}

/* ── About page ── */
.about-hero {
    background: linear-gradient(135deg, #7b04c4 0%, #4f32a0 100%);
    color: #fff;
    border-radius: 12px;
    padding: 2.5rem 2rem;
    margin-bottom: 2rem;
}

.about-hero h1 {
    margin: 0 0 0.5rem;
    font-size: 2rem;
    font-weight: 700;
}

.about-hero .lead {
    margin: 0;
    font-size: 1.1rem;
    opacity: 0.9;
}

.about-content {
    width: 100%;
    max-width: 100%;
}

.main-content > .about-content > .wrap,
.main-content > .about-hero > .wrap {
    width: 100%;
    max-width: 100%;
    padding-inline: 0;
}

.about-content h2 {
    font-size: 1.2rem;
    color: #4f5562;
    margin: 1.8rem 0 0.6rem;
    padding-bottom: 0.3rem;
    border-bottom: 2px solid #ede8f5;
}

.about-content h2:first-child {
    margin-top: 0;
}

.about-content p {
    margin: 0.6rem 0;
    line-height: 1.75;
    color: #3a3f4b;
}

.about-content ul {
    margin: 0.6rem 0;
    padding-left: 1.4rem;
}

.about-content li {
    margin: 0.35rem 0;
    line-height: 1.65;
    color: #3a3f4b;
}

/* ── Explore view switcher ── */
.explore-viewbar {
    display: flex;
    gap: 4px;
    margin-bottom: 0.8rem;
    padding: 4px;
    background: #f0f0f0;
    border-radius: 8px;
    width: fit-content;
    margin-left: auto;
}

.view-btn {
    padding: 0.4rem 1rem;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    color: #666;
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
}

.view-btn:hover {
    background: #e4e4e4;
    color: #333;
}

.view-btn.active {
    background: #fff;
    color: #7b04c4;
    box-shadow: 0 1px 3px rgba(0,0,0,0.12);
}

/* ── CARD view ── */
.view-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1.2rem;
    padding: 0.5rem 0;
}

.article-card {
    background: #fff;
    border: 1px solid #e6e9f2;
    border-radius: 10px;
    overflow: hidden;
    transition: box-shadow 0.2s, transform 0.2s;
    display: flex;
    flex-direction: column;
}

.article-card:hover {
    box-shadow: 0 4px 16px rgba(123,4,196,0.12);
    transform: translateY(-2px);
}

.article-card__img {
    display: block;
    width: 100%;
    height: 160px;
    object-fit: cover;
    background: #f7f8fb;
}

.article-card__img--placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f0eeff;
}

.card-placeholder-icon {
    font-size: 2.5rem;
}

.article-card__body {
    padding: 0.9rem;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.article-card__title {
    font-size: 0.95rem;
    font-weight: 700;
    color: #222;
    text-decoration: none;
    line-height: 1.4;
    margin-bottom: 0.4rem;
    display: block;
}

.article-card__title:hover {
    color: #7b04c4;
}

.article-card__meta {
    font-size: 0.78rem;
    color: #888;
    margin-bottom: 0.5rem;
    line-height: 1.5;
}

.article-card__excerpt {
    font-size: 0.82rem;
    color: #555;
    line-height: 1.6;
    margin: 0;
    flex: 1;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ── MAGAZINE view ── */
.view-magazine {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    padding: 0.5rem 0;
}

.mag-feature {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 1.4fr 1fr;
    gap: 1rem;
    background: #fff;
    border: 1px solid #e6e9f2;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.mag-feature__img {
    display: block;
    width: 100%;
    height: 280px;
    object-fit: cover;
    background: #f7f8fb;
}

.mag-feature__img-link {
    display: block;
    overflow: hidden;
    border-radius: 8px 8px 0 0;
}

.mag-feature__body {
    padding: 1.2rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.mag-feature__title {
    font-size: 1.25rem;
    font-weight: 700;
    color: #222;
    text-decoration: none;
    line-height: 1.35;
    margin-bottom: 0.5rem;
    display: block;
}

.mag-feature__title:hover {
    color: #7b04c4;
}

.mag-feature__meta {
    font-size: 0.8rem;
    color: #888;
    margin-bottom: 0.7rem;
    line-height: 1.5;
}

.mag-feature__excerpt {
    font-size: 0.88rem;
    color: #555;
    line-height: 1.7;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.mag-item {
    display: flex;
    gap: 0.7rem;
    background: #fff;
    border: 1px solid #e6e9f2;
    border-radius: 8px;
    padding: 0.7rem;
    align-items: flex-start;
}

.mag-item__img {
    flex-shrink: 0;
    width: 90px;
    height: 68px;
    object-fit: cover;
    border-radius: 6px;
    background: #f7f8fb;
    display: block;
}

.mag-item__body {
    flex: 1;
    min-width: 0;
}

.mag-item__title {
    font-size: 0.88rem;
    font-weight: 700;
    color: #222;
    text-decoration: none;
    line-height: 1.4;
    display: block;
    margin-bottom: 0.25rem;
}

.mag-item__title:hover {
    color: #7b04c4;
}

.mag-item__meta {
    font-size: 0.76rem;
    color: #888;
    line-height: 1.5;
}

/* ── THUMB view ── */
.view-thumb-list {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    padding: 0.5rem 0;
}

/* ── Explore image helpers ── */
.explore-thumb-img {
    height: 160px;
    object-fit: cover;
    display: block;
}

.mag-feature__img-link {
    display: block;
    overflow: hidden;
    border-radius: 8px 8px 0 0;
}

.mag-item__img-link {
    display: block;
    flex-shrink: 0;
}

/* ── District Quick Links on Homepage ── */
.district-quick-section {
    padding: 1.2rem 0 0.4rem;
    border-top: 1px solid #e8e4f0;
}

.district-quick-heading {
    font-size: 1rem;
    font-weight: 600;
    color: #2d3748;
    margin: 0 0 0.6rem;
}

.district-quick-region {
    display: flex;
    align-items: baseline;
    gap: 0.6rem;
    margin-bottom: 0.4rem;
    flex-wrap: wrap;
}

.district-quick-region-label {
    font-size: 0.78rem;
    color: #718096;
    min-width: 52px;
    flex-shrink: 0;
}

.district-quick-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 0.15rem 0.3rem;
}

.district-pill {
    font-size: 0.8rem;
    color: #2b6cb0;
    text-decoration: none;
    white-space: nowrap;
    padding: 0.05rem 0.25rem;
    border-radius: 3px;
    transition: background 0.15s, color 0.15s;
}

.district-pill:hover {
    background: #ebf4ff;
    color: #2c5282;
    text-decoration: underline;
}

/* ── Advanced search form ──────────────────────────────────────────────── */
.adv-search-tabs {
    display: flex;
    gap: 0.35rem;
    margin-bottom: 0.85rem;
}

.adv-search-tab {
    padding: 0.35rem 1.1rem;
    border: 1px solid #bec6df;
    border-radius: 6px 6px 0 0;
    background: #eef1f8;
    color: #4a5568;
    font: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    margin-bottom: -1px;
}

.adv-search-tab:hover {
    background: #e2e8f0;
    color: #2d3748;
}

.adv-search-tab.active {
    background: #f8f9ff;
    color: #5f01d1;
    border-bottom-color: #f8f9ff;
}

.adv-search-form {
    border: 1px solid #bec6df;
    border-radius: 0 8px 8px 8px;
    background: #f8f9ff;
    padding: 0.9rem;
    overflow-x: hidden;
}

.adv-search-kw-row {
    margin-bottom: 0.75rem;
}

.adv-search-kw-row .search-input {
    width: 100%;
    display: block;
    box-sizing: border-box;
}

.adv-search-panel {
    display: none;
}

.adv-search-panel.active {
    display: block;
}

.adv-filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1.5rem;
    margin-bottom: 0.75rem;
}

.adv-filter-group {
    min-width: 140px;
}

.adv-filter-label {
    display: block;
    font-size: 0.78rem;
    font-weight: 700;
    color: #4a5568;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.3rem;
}

.adv-filter-checkboxes {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 0.75rem;
    max-height: 120px;
    overflow-y: auto;
}

.adv-checkbox-label {
    font-size: 0.82rem;
    color: #2d3748;
    cursor: pointer;
    white-space: nowrap;
}

.adv-checkbox-label input {
    margin-right: 0.2rem;
    accent-color: #5f01d1;
}

.adv-loading-hint {
    font-size: 0.8rem;
}

.adv-search-actions {
    margin-top: 0.85rem;
    padding-top: 0.75rem;
    border-top: 1px solid #dde3f0;
}

.adv-search-actions .search-btn {
    min-width: 120px;
}

/* ── Search results page ───────────────────────────────────────────────── */
.search-page-header {
    margin-bottom: 1.2rem;
}

.search-page-header .page-title {
    margin-bottom: 0.25rem;
}

.search-page-header .muted {
    font-size: 0.88rem;
}
