:root {
    --primary-color: #3f8f5f;
    /* 修正为6位HEX */
    --secondary-color: #fff;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
}

a {
    text-decoration: none;
    color: unset;
}

/* ========== 顶部导航 ==========
   DOM 顺序：logo → 汉堡 → 搜索 → nav（nav 桌面 flex order，移动 absolute 下拉）
   桌面：Logo | 导航 | 搜索 一行
   移动：行1 Logo + 汉堡 | 行2 全宽搜索；汉堡展开下方菜单 + 遮罩 */
.site-header {
    position: fixed;
    left: 0;
    top: 0;
    width: 100%;
    z-index: 1000;
    background: var(--primary-color);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.header-inner {
    position: relative;
    z-index: 1002;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0.65rem 1rem;
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 1rem 1.5rem;
}

.logo {
    color: #fff;
    font-weight: 600;
    font-size: 1.15rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-shrink: 1;
    min-width: 0;
    max-width: 280px;
}

.nav-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    padding: 0;
    margin: 0;
    border: none;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    cursor: pointer;
    transition: background 0.2s ease;
}

.nav-toggle:hover {
    background: rgba(255, 255, 255, 0.25);
}

.nav-toggle:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

.nav-toggle-icon {
    position: relative;
    display: block;
    width: 20px;
    height: 2px;
    background: currentColor;
    border-radius: 1px;
    box-shadow: 0 -7px 0 currentColor, 0 7px 0 currentColor;
}

.site-header.nav-open .nav-toggle-icon {
    background: transparent;
    box-shadow: none;
}

.site-header.nav-open .nav-toggle-icon::before,
.site-header.nav-open .nav-toggle-icon::after {
    content: "";
    position: absolute;
    left: 0;
    top: 50%;
    width: 20px;
    height: 2px;
    margin-top: -1px;
    background: #fff;
    border-radius: 1px;
}

.site-header.nav-open .nav-toggle-icon::before {
    transform: rotate(45deg);
}

.site-header.nav-open .nav-toggle-icon::after {
    transform: rotate(-45deg);
}

.header-search {
    flex-shrink: 0;
}

.search-bar {
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 999px;
    padding: 6px 12px 6px 16px;
    width: min(260px, 36vw);
    max-width: 100%;
}

.search-bar input {
    flex: 1;
    min-width: 0;
    background: transparent;
    border: none;
    color: white;
    padding: 6px 8px;
    outline: none;
    font-size: 0.95rem;
}

.search-bar input::placeholder {
    color: rgba(255, 255, 255, 0.72);
}

.search-bar button {
    flex-shrink: 0;
    background: transparent;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 1.1rem;
    padding: 4px;
    line-height: 1;
}

.nav {
    flex: 1;
    display: flex;
    justify-content: center;
    min-width: 0;
}

.nav-list {
    display: flex;
    flex-wrap: wrap;
    list-style: none;
    margin: 0;
    padding: 0;
    gap: 0.35rem 0.5rem;
    justify-content: center;
    align-items: center;
}

.nav-list li {
    margin: 0;
}

.nav a {
    display: block;
    color: var(--secondary-color);
    text-decoration: none;
    padding: 0.45rem 0.85rem;
    border-radius: 6px;
    transition: background 0.2s ease;
    font-size: 0.95rem;
}

.nav a:hover,
.nav a.active {
    background: rgba(255, 255, 255, 0.2);
}

.nav-backdrop {
    position: fixed;
    inset: 0;
    /* 低于顶栏，避免挡住汉堡与菜单 */
    z-index: 999;
    background: rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(2px);
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* 桌面：视觉顺序 Logo → 导航 → 搜索 */
@media (min-width: 769px) {
    .logo {
        order: 1;
    }

    .nav-toggle {
        display: none !important;
    }

    .header-search {
        order: 3;
    }

    .nav {
        order: 2;
        flex: 1;
    }
}

@media (max-width: 768px) {
    .header-inner {
        display: grid;
        grid-template-columns: 1fr auto;
        grid-template-rows: auto auto;
        gap: 0.65rem 0.75rem;
        align-items: center;
        padding: 0.55rem 0.85rem;
    }

    .logo {
        grid-column: 1;
        grid-row: 1;
        max-width: none;
        font-size: clamp(0.95rem, 3.8vw, 1.1rem);
    }

    .nav-toggle {
        display: inline-flex;
        grid-column: 2;
        grid-row: 1;
        justify-self: end;
    }

    .header-search {
        grid-column: 1 / -1;
        grid-row: 2;
        width: 100%;
    }

    .search-bar {
        width: 100%;
        border-radius: 10px;
        padding: 8px 12px;
    }

    .nav {
        position: absolute;
        left: 0;
        right: 0;
        top: 100%;
        flex: unset;
        justify-content: stretch;
        max-height: 0;
        overflow: hidden;
        visibility: hidden;
        opacity: 0;
        transition: max-height 0.35s ease, opacity 0.25s ease, visibility 0.25s;
        background: #2f7a52;
        box-shadow: 0 12px 28px rgba(0, 0, 0, 0.18);
        border-radius: 0 0 12px 12px;
    }

    .site-header.nav-open .nav {
        max-height: min(70vh, 420px);
        overflow-y: auto;
        overflow-x: hidden;
        visibility: visible;
        opacity: 1;
        -webkit-overflow-scrolling: touch;
    }

    .nav-list {
        flex-direction: column;
        flex-wrap: nowrap;
        align-items: stretch;
        gap: 0;
        padding: 0.35rem 0;
    }

    .nav-list li {
        border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    }

    .nav-list li:last-child {
        border-bottom: none;
    }

    .nav a {
        padding: 0.85rem 1.1rem;
        border-radius: 0;
        font-size: 1rem;
    }

    .nav a:hover,
    .nav a.active {
        background: rgba(0, 0, 0, 0.12);
    }
}

.breadcrumb-line {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 1.25rem;
}

.breadcrumb-line a {
    color: var(--primary-color);
}

.breadcrumb-line span {
    color: #666;
}

.breadcrumb-line a:hover {
    text-decoration: underline;
}

.breadcrumb-line span.sep {
    margin: unset;
    padding: unset;
    color: #bbb;
}

footer {
    background: var(--primary-color);
    color: var(--secondary-color);
    padding: 2rem;
    text-align: center;
    margin-top: auto;
}

.main-content {
    margin-top: 84px;
    min-height: calc(100vh - 160px);
    padding: 20px;
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
}

@media (max-width: 768px) {
    .main-content {
        /* 移动端：两行顶栏（Logo/汉堡 + 全宽搜索）略高 */
        margin-top: 118px;
        padding: 16px 14px;
    }
}

/* 返回顶部按钮 */
.back-to-top {
    position: fixed;
    bottom: 40px;
    right: 40px;
    width: 50px;
    height: 50px;
    padding: 0;
    margin: 0;
    border: none;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
    background: var(--primary-color);
    color: var(--secondary-color);
    font: inherit;
    line-height: 1;
    border-radius: 50%;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    z-index: 1005;
    touch-action: manipulation;
    /* 防止双击缩放 */
}

.back-to-top:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 3px;
}

.back-to-top.show {
    opacity: 0.8;
    visibility: visible;
}

.back-to-top:hover {
    opacity: 1;
    transform: translateY(-3px);
}

@media (max-width: 768px) {
    .back-to-top {
        bottom: 20px;
        right: 20px;
        width: 40px;
        height: 40px;
        font-size: 0.8em;
    }
}