:root {
    --font-sans:
        "Segoe UI", "PingFang SC", "Hiragino Sans GB",
        "Microsoft YaHei", "Noto Sans CJK SC",
        system-ui, -apple-system, BlinkMacSystemFont, sans-serif;

    --color-bg: #f5f5f7;
    --color-surface: #ffffff;
    --color-surface-hover: #f8fafc;

    --color-text: #1f2937;
    --color-link: #4b5563;
    --color-text-secondary: #6b7280;
    --color-text-muted: #9ca3af;

    --color-border: #e5e7eb;
    --color-border-soft: #edf0f3;
    --color-border-hover: #bfdbfe;

    --color-primary: #2563eb;
    --color-primary-hover: #1d4ed8;
    --color-primary-light: #eff6ff;

    --radius-card: 12px;
    --radius-item: 8px;

    --shadow-card:
        0 1px 3px rgba(15, 23, 42, 0.05),
        0 1px 2px rgba(15, 23, 42, 0.03);
    --shadow-card-hover:
        0 8px 24px rgba(15, 23, 42, 0.08);
    --shadow-header:
        0 1px 3px rgba(15, 23, 42, 0.04),
        0 1px 2px rgba(15, 23, 42, 0.02);

    --page-padding: 24px;
    --grid-gap: 20px;
    --card-padding: 19px;
    --item-gap: 7px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
    min-height: 100vh;
    background: var(--color-bg);
    color: var(--color-text);
    font-family: var(--font-sans);
    font-size: 16px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

header {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.7);
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    backdrop-filter: blur(20px) saturate(1.8);
    -webkit-backdrop-filter: blur(20px) saturate(1.8);
}

.header-bar {
    width: 100%;
    max-width: 1500px;
    height: 48px;
    margin: 0 auto;
    padding: 0 var(--page-padding);
    display: flex;
    align-items: center;
    gap: 18px;
}

.brand-link {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
}

.brand-logo {
    display: block;
    width: 22px;
    height: 22px;
    border-radius: 5px;
}

.brand-name {
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0.01em;
    color: var(--color-text);
    white-space: nowrap;
}

.header-nav {
    flex: 1 1 auto;
    min-width: 0;
    height: 100%;
    overflow-x: auto;
    scrollbar-width: none;
}

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

.header-nav-inner {
    height: 100%;
    display: flex;
    align-items: center;
    gap: 2px;
    width: max-content;
}

.header-nav-link {
    padding: 7px 13px;
    font-size: 13.5px;
    font-weight: 500;
    color: var(--color-text-secondary);
    text-decoration: none;
    border-radius: 980px;     white-space: nowrap;
    transition: color 0.15s ease, background-color 0.15s ease;
}

.header-nav-link:hover {
    color: var(--color-primary);
    background: rgba(37, 99, 235, 0.08);
}

.search-toggle {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 50%;
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: color 0.15s ease, background-color 0.15s ease;
}

.search-toggle:hover,
.search-toggle[aria-expanded="true"] {
    color: var(--color-primary);
    background: rgba(37, 99, 235, 0.08);
}

.search-toggle svg { width: 18px; height: 18px; }

.search-panel {
    position: absolute;
    top: 48px;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(20px) saturate(1.8);
    -webkit-backdrop-filter: blur(20px) saturate(1.8);
    border-bottom: 1px solid var(--color-border);
    box-shadow: var(--shadow-header);
}

.search-panel[hidden] { display: none; }

.search-panel-inner {
    max-width: 900px;
    margin: 0 auto;
    padding: 18px var(--page-padding);
    display: flex;
    align-items: center;
    gap: 12px;
}

.search-engine-tabs {
    flex: 0 0 auto;
    display: flex;
    gap: 3px;
}

.search-tab {
    padding: 6px 13px;
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text-muted);
    background: transparent;
    border: none;
    border-radius: 980px;
    cursor: pointer;
    transition: all 0.15s ease;
    font-family: inherit;
    white-space: nowrap;
}

.search-tab:hover { color: var(--color-text-secondary); background: rgba(0, 0, 0, 0.05); }

.search-tab.active {
    color: #fff;
    background: var(--color-primary);
    font-weight: 600;
}

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

.header-search svg {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: var(--color-text-muted);
    pointer-events: none;
}

.header-search input {
    width: 100%;
    height: 40px;
    padding: 0 14px 0 36px;
    font-family: inherit;
    font-size: 16px;
    color: var(--color-text);
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 10px;
    outline: none;
    transition: background-color 0.16s ease, border-color 0.16s ease;
}

.header-search input::placeholder { color: var(--color-text-muted); }

.header-search input:focus {
    background: #fff;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3.5px rgba(37, 99, 235, 0.1);
}

.search-close {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 50%;
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: color 0.15s ease, background-color 0.15s ease;
}

.search-close:hover { color: var(--color-primary); background: rgba(37, 99, 235, 0.08); }
.search-close svg { width: 17px; height: 17px; }

main {
    width: 100%;
    padding: 26px var(--page-padding) 12px;
}

.grid-container {
    width: 100%;
    max-width: 1500px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--grid-gap);
}

.grid-item {
    min-width: 0;
    display: flex;
    flex-direction: column;
    padding: var(--card-padding);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-card);
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
    scroll-margin-top: 68px;
}

.grid-item:hover {
    transform: translateY(-2px);
    border-color: #dbe3ee;
    box-shadow: var(--shadow-card-hover);
}

.grid-item h2 {
    position: relative;
    display: flex;
    align-items: center;
    margin: 0 0 15px;
    padding: 0 0 12px;
    color: var(--color-text);
    font-size: 20px;
    font-weight: 600;
    line-height: 1.45;
    letter-spacing: 0.01em;
    border-bottom: 1px solid var(--color-border-soft);
}

.grid-item h2::before {
    content: "";
    flex: 0 0 auto;
    width: 4px;
    height: 17px;
    margin-right: 9px;
    background: var(--color-primary);
    border-radius: 3px;
}

.grid-item h2::after {
    content: "";
    position: absolute;
    left: 0;
    bottom: -1px;
    width: 28px;
    height: 1px;
    background: rgba(37, 99, 235, 0.28);
}

.link-container {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--item-gap);
    align-items: stretch;
}

.link-block {
    min-width: 0;
    display: flex;
    align-items: stretch;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-item);
    transition: background-color 0.16s ease, border-color 0.16s ease, transform 0.16s ease;
}

.link-block:hover {
    background: var(--color-primary-light);
    border-color: var(--color-border-hover);
    transform: translateY(-1px);
}

.link-block a {
    display: flex;
    align-items: center;
    width: 100%;
    min-height: 42px;
    padding: 8px 9px;
    color: var(--color-link);
    font-size: 16px;
    font-weight: 400;
    line-height: 1.45;
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    border-radius: var(--radius-item);
    transition: color 0.16s ease;
}

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

.link-block img {
    flex: 0 0 auto;
    width: 19px;
    height: 19px;
    margin-right: 9px;
    object-fit: contain;
    border-radius: 3px;
    display: block;
}

.back-to-top {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 999;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    box-shadow: var(--shadow-card-hover);
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    color: var(--color-text-secondary);
}

.back-to-top.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.back-to-top:hover {
    color: var(--color-primary);
    border-color: var(--color-border-hover);
    transform: translateY(-2px);
}

.back-to-top svg { width: 20px; height: 20px; }

footer {
    width: 100%;
    margin-top: 60px;
    padding: 28px var(--page-padding) 20px;
    background: #f5f5f7;
    border-top: 1px solid var(--color-border-soft);
    color: rgba(29, 29, 31, 0.62);
    font-size: 14px;
    line-height: 1.5;
    letter-spacing: 0.001em;
}

.footer-container {
    max-width: 1500px;
    margin: 0 auto;
}

.footer-top {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 16px;
    padding-bottom: 20px;
}

.footer-stats-primary,
.footer-stats-secondary {
    font-variant-numeric: tabular-nums;
}

.footer-stats-primary {
    justify-self: start;
    font-size: 15px;
    font-weight: 500;
    color: rgba(29, 29, 31, 0.88);
}

.footer-stats-secondary {
    justify-self: end;
    font-size: 13.5px;
    font-weight: 400;
}

.footer-divider {
    width: 100%;
    height: 1px;
    background: rgba(0, 0, 0, 0.07);
}

.footer-bottom {
    padding-top: 16px;
    text-align: center;
}

.footer-copyright {
    font-size: 12.5px;
    font-weight: 400;
}

.footer-legal-links {
    justify-self: center;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0;
    list-style: none;
}

.footer-legal-links li {
    padding: 0 12px;
    border-left: 1px solid rgba(0, 0, 0, 0.5);
    line-height: 1;
}

.footer-legal-links li:first-child { border-left: none; padding-left: 0; }

.footer-legal-links a {
    font-size: 14px;
    font-weight: 500;
    color: inherit;
    text-decoration: none;
}

.footer-legal-links a:hover { color: var(--color-primary); text-decoration: underline; }

a:focus-visible, button:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

@media (max-width: 1199px) {
    :root {
        --page-padding: 20px;
        --grid-gap: 16px;
        --card-padding: 17px;
    }

    .grid-container { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .link-container { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 768px) {
    :root {
        --page-padding: 14px;
        --grid-gap: 12px;
        --card-padding: 15px;
        --item-gap: 6px;
    }

    .header-bar { gap: 10px; }
    .header-nav-link { padding: 6px 11px; font-size: 12.5px; }

    .search-panel-inner { padding: 14px var(--page-padding); gap: 8px; }
    .search-tab { padding: 5px 10px; font-size: 12px; }
    .header-search input { height: 38px; font-size: 15px; }

    main { padding: 16px var(--page-padding) 5px; }

    .grid-container { grid-template-columns: 1fr; }
    .grid-item { border-radius: 10px; scroll-margin-top: 60px; }

    .grid-item h2 {
        margin-bottom: 12px;
        padding-bottom: 10px;
        font-size: 18px;
    }

    .grid-item h2::before { width: 4px; height: 15px; margin-right: 7px; }
    .grid-item h2::after { width: 24px; }

    .link-container { grid-template-columns: repeat(2, minmax(0, 1fr)); }

    .link-block a {
        min-height: 40px;
        padding: 7px 8px;
        font-size: 15px;
    }

    .link-block img { width: 18px; height: 18px; margin-right: 7px; }

    .back-to-top {
        right: 14px;
        bottom: 14px;
        width: 40px;
        height: 40px;
    }

    footer { margin-top: 36px; padding: 20px var(--page-padding); }

        .footer-top {
        grid-template-columns: 1fr;
        row-gap: 14px;
    }

    .footer-stats-primary,
    .footer-stats-secondary,
    .footer-legal-links {
        justify-self: center;
        text-align: center;
    }
}

@media (max-width: 480px) {
    :root {
        --page-padding: 10px;
        --grid-gap: 10px;
        --card-padding: 13px;
        --item-gap: 5px;
    }

    main { padding-top: 10px; }

    .grid-item { padding: var(--card-padding); }

    .grid-item h2 {
        margin-bottom: 11px;
        padding-bottom: 10px;
        font-size: 18px;
    }

    .link-block a {
        min-height: 40px;
        padding: 7px 8px;
        font-size: 15px;
    }

    .link-block img { width: 18px; height: 18px; margin-right: 7px; }
}

@media (max-width: 360px) {
    :root {
        --page-padding: 8px;
        --card-padding: 11px;
    }

    .search-tab { padding: 4px 8px; font-size: 11.5px; }

    .link-block a {
        min-height: 38px;
        padding: 6px;
        font-size: 14px;
    }

    .link-block img { width: 17px; height: 17px; margin-right: 6px; }
}

@media (orientation: landscape) and (max-height: 500px) {
        .search-panel-inner { padding: 10px var(--page-padding); }
    .header-search input { height: 32px; font-size: 13px; }

    main { padding: 8px var(--page-padding) 4px; }

    .grid-item { padding: 12px; }
    .grid-item h2 { margin-bottom: 8px; padding-bottom: 6px; }
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }

    *, *::before, *::after {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }
}