:root {
    --bg: #f5f7fb;
    --surface: #ffffff;
    --surface-soft: #f8f9fd;
    --text: #172033;
    --muted: #7a859b;
    --border: rgba(23, 32, 51, 0.08);
    --accent: #695cff;
    --accent-2: #8f78ff;
    --accent-soft: rgba(105, 92, 255, 0.10);
    --shadow-sm: 0 7px 22px rgba(25, 35, 58, 0.055);
    --content-width: 1240px;
    --header-height: 82px;
}

[data-theme="dark"] {
    --bg: #0c1120;
    --surface: #151c2e;
    --surface-soft: #1b2438;
    --text: #eef2ff;
    --muted: #98a3ba;
    --border: rgba(255, 255, 255, 0.08);
    --accent: #9187ff;
    --accent-2: #b09cff;
    --accent-soft: rgba(143, 133, 255, 0.13);
    --shadow-sm: 0 8px 24px rgba(0, 0, 0, 0.16);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    margin: 0;
    min-height: 100vh;
    font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}
body.sidebar-open { overflow: hidden; }
a { color: inherit; }
button { font: inherit; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

/* 顶部 Logo 栏：唯一吸顶区域 */
.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    height: var(--header-height);
    padding: 10px 20px;
    background: color-mix(in srgb, var(--surface) 96%, transparent);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 4px 18px rgba(24, 31, 50, .045);
}
.topbar {
    max-width: var(--content-width);
    height: 100%;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
}
.topbar-button,
.contact-button,
.float-btn,
.plain-icon {
    border: 1px solid var(--border);
    color: var(--text);
    background: var(--surface);
    cursor: pointer;
}
.topbar-button {
    justify-self: start;
    width: 43px;
    height: 43px;
    display: grid;
    place-items: center;
    border-radius: 13px;
}
.menu-glyph { font-size: 21px; line-height: 1; }
.brand {
    justify-self: center;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 70px;
    min-height: 58px;
    text-decoration: none;
}
.brand-logo {
    display: block;
    width: auto;
    height: 56px;
    max-width: min(220px, 35vw);
    object-fit: contain;
}
.brand-placeholder {
    width: 42px;
    height: 42px;
    display: inline-grid;
    place-items: center;
    border-radius: 13px;
    color: #fff;
    font-weight: 800;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
}
.brand-placeholder-main { width: 56px; height: 56px; border-radius: 17px; font-size: 20px; }
.contact-button {
    justify-self: end;
    width: 43px;
    height: 43px;
    display: grid;
    place-items: center;
    padding: 0;
    border-radius: 13px;
    text-decoration: none;
    font-size: 12px;
    font-weight: 750;
    letter-spacing: .02em;
    white-space: nowrap;
}
.topbar-button:hover,
.contact-button:hover { border-color: rgba(105,92,255,.32); color: var(--accent); }

/* 分类栏正常随页面滚动，不吸顶 */
.category-nav {
    position: static;
    padding: 12px 16px 8px;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
}
.nav-scroll {
    max-width: var(--content-width);
    margin: 0 auto;
    display: flex;
    gap: 8px;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}
.nav-scroll::-webkit-scrollbar { display: none; }
.nav-tab {
    flex: 0 0 auto;
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 12px 7px 14px;
    border-radius: 999px;
    border: 1px solid transparent;
    color: var(--muted);
    text-decoration: none;
    font-size: 13px;
    font-weight: 650;
    transition: .16s ease;
}
.nav-tab:hover { color: var(--text); background: var(--surface); border-color: var(--border); }
.nav-tab.active { color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent-2)); box-shadow: 0 6px 18px rgba(105,92,255,.20); }
.nav-tab b { padding: 2px 6px; border-radius: 999px; font-size: 10px; background: var(--surface-soft); color: var(--muted); }
.nav-tab.active b { color: var(--accent); background: rgba(255,255,255,.92); }

/* 内容 */
.link-area {
    max-width: var(--content-width);
    margin: 0 auto;
    padding: 18px 20px 28px;
    scroll-margin-top: calc(var(--header-height) + 12px);
}
.category-block {
    margin-bottom: 18px;
    content-visibility: auto;
    contain-intrinsic-size: 280px;
    padding: 18px;
    border-radius: 24px;
    border: 1px solid var(--border);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}
.block-header { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 14px; }
.block-title-wrap { display: flex; align-items: center; gap: 10px; min-width: 0; }
.block-icon { width: 38px; height: 38px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 12px; background: var(--accent-soft); font-size: 18px; }
.block-title { margin: 0; font-size: 16px; line-height: 1.3; }
.block-count { flex: 0 0 auto; min-width: 30px; text-align: center; padding: 5px 8px; border-radius: 999px; background: var(--surface-soft); color: var(--muted); font-size: 11px; font-weight: 700; }

.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(225px, 1fr)); gap: 9px; }
.card-item {
    min-width: 0;
    min-height: 68px;
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border-radius: 15px;
    border: 1px solid var(--border);
    background: var(--surface-soft);
    text-decoration: none;
    transition: transform .15s ease, border-color .15s ease, background .15s ease;
}
.card-item:hover { transform: translateY(-1px); border-color: rgba(105,92,255,.34); background: var(--surface); }
.card-icon { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); overflow: hidden; }
.card-icon img { width: 34px; height: 34px; object-fit: contain; border-radius: 6px; }
.default-icon { font-size: 20px; }
.card-content { min-width: 0; }
.card-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); font-size: 13px; font-weight: 700; line-height: 1.4; }
.card-desc { margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 11px; line-height: 1.35; }
.card-arrow { opacity: .35; color: var(--muted); font-size: 12px; }
.card-item:hover .card-arrow { opacity: 1; color: var(--accent); }
.empty-tip { grid-column: 1 / -1; padding: 26px; text-align: center; color: var(--muted); font-size: 13px; }

/* 侧边栏 */
.sidebar-overlay {
    position: fixed;
    inset: 0;
    z-index: 990;
    background: rgba(7, 11, 22, .46);
    opacity: 0;
    visibility: hidden;
    transition: .2s ease;
}
.sidebar-overlay.open { opacity: 1; visibility: visible; }
.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 1000;
    width: min(310px, 86vw);
    background: var(--surface);
    border-right: 1px solid var(--border);
    box-shadow: 24px 0 60px rgba(0,0,0,.14);
    transform: translateX(-102%);
    transition: transform .24s cubic-bezier(.2,.8,.2,1);
    display: flex;
    flex-direction: column;
}
.sidebar.open { transform: translateX(0); }
.sidebar-header { min-height: 76px; padding: 12px 14px 12px 18px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border); }
.sidebar-brand { display: inline-flex; align-items: center; text-decoration: none; }
.sidebar-logo { width: auto; height: 46px; max-width: 170px; object-fit: contain; }
.plain-icon { width: 39px; height: 39px; border-radius: 12px; font-size: 25px; line-height: 1; }
.sidebar-nav { padding: 12px 10px 24px; overflow-y: auto; }
.sidebar-link { display: grid; grid-template-columns: 24px 1fr auto; align-items: center; gap: 10px; min-height: 45px; margin: 3px 0; padding: 8px 12px; border-radius: 12px; color: var(--muted); text-decoration: none; }
.sidebar-link:hover, .sidebar-link.active { color: var(--accent); background: var(--accent-soft); }
.sidebar-link b { font-size: 10px; min-width: 24px; text-align: center; padding: 3px 6px; border-radius: 999px; background: var(--surface-soft); color: var(--muted); }
.sidebar-emoji { text-align: center; }
.sidebar-divider { height: 1px; background: var(--border); margin: 12px 10px; }

/* 悬浮工具 */
.float-buttons { position: fixed; right: 18px; bottom: 20px; z-index: 80; display: flex; flex-direction: column; gap: 8px; }
.float-btn { width: 43px; height: 43px; border-radius: 13px; box-shadow: var(--shadow-sm); font-size: 16px; }
.float-btn:hover { border-color: rgba(105,92,255,.35); color: var(--accent); }
.back-to-top { opacity: 0; transform: translateY(7px); pointer-events: none; transition: .15s ease; }
.back-to-top.visible { opacity: 1; transform: translateY(0); pointer-events: auto; }

.footer { padding: 16px 20px 32px; color: var(--muted); }
.footer-inner { max-width: var(--content-width); margin: 0 auto; text-align: center; font-size: 12px; }

/* 联系页 */
.contact-topbar { max-width: 760px; margin: 0 auto; padding: 18px 20px 0; display: flex; justify-content: space-between; }
.contact-page { max-width: 760px; margin: 0 auto; padding: 28px 20px 50px; }
.contact-shell { border: 1px solid var(--border); border-radius: 28px; background: var(--surface); box-shadow: var(--shadow-sm); padding: 28px; }
.contact-head { text-align: center; margin-bottom: 24px; }
.contact-head .brand-logo { margin: 0 auto 12px; height: 58px; max-width: 220px; }
.contact-head .brand-placeholder { margin: 0 auto 12px; }
.contact-head h1 { margin: 0 0 7px; font-size: 28px; }
.contact-head p { margin: 0; color: var(--muted); font-size: 13px; }
.contact-list { display: grid; gap: 12px; }
.contact-item { display: grid; grid-template-columns: 56px 1fr auto; gap: 14px; align-items: center; min-height: 76px; padding: 10px 14px; border: 1px solid var(--border); border-radius: 18px; background: var(--surface-soft); text-decoration: none; transition: .15s ease; }
.contact-item[href]:hover { transform: translateY(-1px); border-color: rgba(105,92,255,.35); }
.contact-thumb { width: 56px; height: 56px; display: grid; place-items: center; overflow: hidden; border-radius: 14px; background: var(--surface); color: var(--accent); }
.contact-thumb img { width: 100%; height: 100%; object-fit: cover; }
.contact-label { font-weight: 700; font-size: 14px; }
.contact-note { margin-top: 3px; color: var(--muted); font-size: 11px; }
.contact-arrow { color: var(--muted); font-size: 14px; }
.contact-empty { padding: 32px; text-align: center; color: var(--muted); }
.back-home { display: inline-flex; align-items: center; gap: 7px; margin-top: 18px; color: var(--muted); text-decoration: none; font-size: 12px; }
.back-home:hover { color: var(--accent); }
.contact-action { width: 42px; height: 42px; display: grid; place-items: center; border: 1px solid var(--border); border-radius: 13px; background: var(--surface); color: var(--text); text-decoration: none; cursor: pointer; }

@media (max-width: 600px) {
    :root { --header-height: 70px; }
    .site-header { padding: 8px 10px; }
    .topbar-button { width: 39px; height: 39px; border-radius: 12px; }
    .brand { min-width: 58px; min-height: 50px; }
    .brand-logo { height: 48px; max-width: 36vw; }
    .brand-placeholder-main { width: 48px; height: 48px; border-radius: 15px; }
   .contact-button { width: 39px; height: 39px; padding: 0; font-size: 11px; }
    .category-nav { padding: 9px 10px 6px; }
    .nav-tab { min-height: 35px; padding: 6px 10px 6px 11px; font-size: 12px; }
    .link-area { padding: 14px 10px 18px; }
    .category-block { padding: 13px; border-radius: 20px; }
    .block-header { margin-bottom: 11px; }
    .block-icon { width: 34px; height: 34px; border-radius: 11px; }
    .block-title { font-size: 14px; }
    .card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
    .card-item { min-height: 56px; grid-template-columns: 36px minmax(0,1fr); gap: 7px; padding: 7px; border-radius: 13px; }
    .card-icon { width: 36px; height: 36px; border-radius: 10px; }
    .card-icon img { width: 29px; height: 29px; }
    .default-icon { font-size: 16px; }
    .card-name { font-size: 11px; }
    .card-desc, .card-arrow { display: none; }
    .float-buttons { right: 11px; bottom: 13px; }
    .float-btn { width: 39px; height: 39px; border-radius: 12px; }
    .footer { padding-bottom: 70px; }
    .contact-shell { padding: 20px 14px; border-radius: 23px; }
    .contact-item { grid-template-columns: 48px 1fr auto; padding: 9px 10px; }
    .contact-thumb { width: 48px; height: 48px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
