/* 前台：头部 / Hero / 工具区 / 上滑浮动条 + 分类抽屉 / 与头部同宽的网址卡片区 */
:root { --header-h: 64px; }
html { scroll-padding-top: calc(var(--header-h) + 70px); }

.site-header {
    position: sticky;
    top: 0;
    z-index: 20;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: blur(12px);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; height: 64px; }
/* 左侧品牌组：站点名 + 紧随其后的主题按钮，右侧操作组仍整组靠右 */
.site-header-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.header-actions { display: flex; align-items: center; gap: 6px; }
.btn-cta { font-weight: 700; white-space: nowrap; box-shadow: 0 4px 14px var(--accent-soft); }
.btn-cta:hover { transform: translateY(-1px); box-shadow: 0 6px 18px var(--accent-soft); }

/* 首屏只保留站点名称与描述；统计数量统一放进分类抽屉，避免重复占高 */
.hero {
    padding: 40px 0 12px;
    background:
        radial-gradient(700px 240px at 12% 0%, var(--accent-soft), transparent 70%),
        radial-gradient(600px 220px at 88% 10%, rgba(154, 107, 255, .12), transparent 70%);
}
/* 定稿版：标题、描述与下方搜索框共用 .wrap 的中轴 */
.hero .wrap { text-align: center; }
.hero h1 { margin: 0 0 8px; font-size: clamp(26px, 4vw, 40px); letter-spacing: -.5px; }
.hero-sub { margin: 0; color: var(--muted); font-size: 15px; }

/* 工具区独立于 Hero：页面名称与描述留在原地滚动，分类与搜索在这里，
   滚出视口后由 #floatTools 接管，因此往下浏览时仍能随时切换分类 */
.tools { padding: 0 0 24px; }
/* 上滑浮动条里的 ☰全部分类 按钮；首屏不再重复放置同一个入口 */
.ft-cat-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex: none;
    padding: 8px 14px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text);
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    transition: border-color .15s ease, color .15s ease, background .15s ease;
}
.ft-cat-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.ft-cat-count {
    padding: 1px 7px;
    border-radius: 999px;
    background: var(--surface-alt);
    color: var(--muted);
    font-size: 11px;
    font-weight: 600;
}

/* 分类条在居中搜索框「下方」，与标题/描述/搜索框同以 .wrap 中轴居中。
   分类多时逐行换行居中，不再单行横向滚动，避免左端标签被裁掉。
   分类条、搜索框与链接卡片区都位于同一个 .wrap 容器内，左右对齐一致 */
.cat-nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    margin: 16px 0 0;
    padding-bottom: 4px;
    overflow-x: auto;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
}
.cat-nav::-webkit-scrollbar { height: 6px; }
.cat-nav::-webkit-scrollbar-thumb { background: var(--border); border-radius: 999px; }
.cat-chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    flex: none;
    padding: 7px 14px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    white-space: nowrap;
    font-size: 13px;
    color: var(--muted);
    transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.cat-chip:hover, .cat-chip.is-active { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.chip-icon { font-size: 15px; line-height: 1; }

/* 首屏主搜索框：在 .wrap 内水平居中，字号比浮动条更大，作为页面视觉焦点。
   浮动条用 .ft-search，不受这里的规则影响。 */
.search-box {
    display: flex;
    align-items: center;
    gap: 12px;
    width: min(720px, 100%);
    margin: 0 auto;
    padding: 8px 10px 8px 20px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--surface);
    box-shadow: var(--shadow);
    transition: border-color .2s ease, box-shadow .2s ease;
}
.search-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft), var(--shadow); }
.search-icon { font-size: 19px; opacity: .8; }
#search {
    flex: 1;
    min-width: 0;
    padding: 10px 0;
    border: 0 !important;
    box-shadow: none !important;
    background: transparent;
    font-size: 17px;
}
#search::placeholder { color: var(--muted); opacity: .85; font-size: 16px; }
#search::-webkit-search-cancel-button { cursor: pointer; }
.search-kbd { flex: none; }
/* 搜索框快捷键提示：首页与用户单页共用（用户页不加载 hao.css） */
.search-box kbd.search-kbd {
    display: inline-block; padding: 1px 6px; border: 1px solid var(--border);
    border-bottom-width: 2px; border-radius: 6px; background: var(--surface);
    box-shadow: none; color: var(--text); font-size: 12px; font-family: inherit;
}
.search-submit {
    flex: none;
    padding: 11px 20px;
    border: 0;
    border-radius: 12px;
    background: var(--accent);
    color: #fff;
    font-size: 15px;
    font-weight: 600;
}
.search-submit:hover { background: var(--accent-strong); }

/* 顶部搜索条：百度 / 必应 外部搜索按钮（紧凑图标，不改变搜索条格局） */
.search-engine-btn {
    flex: none;
    width: 32px; height: 32px;
    display: inline-flex; align-items: center; justify-content: center;
    padding: 0; margin-left: -4px;
    border: 1px solid transparent; border-radius: 9px;
    color: #fff; font-size: 13px; font-weight: 700; line-height: 1;
    cursor: pointer;
    transition: transform .12s ease, box-shadow .12s ease, filter .12s ease;
}
.search-engine-btn.engine-baidu { background: #4e6ef2; }
.search-engine-btn.engine-bing  { background: #0f7dc2; }
.search-engine-btn:hover { transform: translateY(-1px); filter: brightness(1.06); box-shadow: var(--shadow-sm); }
.search-engine-btn:active { transform: translateY(0); }
/* 当前默认引擎：底部小圆点标记 + 轻微外圈，格局不变 */
.search-engine-btn.is-default { box-shadow: 0 0 0 2px var(--surface), 0 0 0 3.5px currentColor; }
.search-engine-btn.is-default::after {
    content: ''; position: absolute; bottom: 3px; left: 50%;
    width: 4px; height: 4px; margin-left: -2px; border-radius: 50%;
    background: #fff; opacity: .95;
}
.search-engine-btn { position: relative; }

/* 链接区与头部、Hero、footer 共用 .wrap 容器（1180px 居中，两侧留白）。
   注意：这里绝不能再声明 width:100%。site.css 在 base.css 之后加载，
   同为单类选择器时会覆盖 .wrap 的宽度，导致卡片区铺满视口而头部仍有留白。
   单栏布局指的是「不再有 214px 侧栏」，不是「占满视口」。 */
.site-content { padding-bottom: 48px; }
.side-link { display: inline-block; margin-top: 10px; }

.result-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 2px 0 18px;
    color: var(--muted);
    font-size: 13px;
}
.clear-link { color: var(--accent); }
.cat-section { margin-bottom: 34px; scroll-margin-top: calc(var(--header-h) + 70px); }
.cat-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.cat-heading h2 { display: flex; align-items: center; gap: 9px; margin: 0; font-size: 18px; }
.cat-emoji { font-size: 20px; }
.cat-count { color: var(--muted); font-size: 12px; }
/* 卡片网格：显式断点阶梯，>=1440 视口 8 列，随宽度逐级递减，最小 2 列。
   容器上限 1380px（见 base.css），8 列时卡宽约 160px */
.card-grid { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 14px; }
@media (max-width: 1439px) { .card-grid { grid-template-columns: repeat(7, minmax(0, 1fr)); } }
@media (max-width: 1279px) { .card-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
@media (max-width: 1099px) { .card-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
@media (max-width: 899px)  { .card-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (max-width: 679px)  { .card-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 519px)  { .card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* 紧凑卡片：大图标在上、标题在下、整卡居中；描述与域名不再常驻显示 */
.card-grid .link-card {
    display: flex;
    position: relative;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 11px;
    min-height: 128px;
    padding: 16px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    text-align: center;
    transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.card-grid .link-card:hover {
    transform: translateY(-3px);
    border-color: var(--accent);
    box-shadow: var(--shadow);
}
/* 主链接占满卡片内容区；子链接下拉是它的兄弟节点，叠在右上角 */
.card-grid .link-card .card-hit {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 11px;
    width: 100%;
    min-width: 0;
    color: inherit;
}
.card-grid .link-card .tile { width: 64px; height: 64px; border-radius: 16px; font-size: 28px; }
.card-grid .link-card .tile-img { padding: 10px; border-radius: 16px; }
.card-grid .link-card .card-main { display: flex; flex-direction: column; min-width: 0; width: 100%; flex: 0 1 auto; align-items: center; gap: 0; }
.card-grid .link-card .card-title { font-size: 13.5px; font-weight: 700; line-height: 1.4; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 描述改为鼠标停留 / 键盘聚焦时显示的气泡，配色跟随明暗主题 */
.card-grid .link-card[data-tip]::after {
    content: attr(data-tip);
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%) translateY(-4px);
    z-index: 30;
    width: max-content;
    min-width: 140px;
    max-width: min(220px, 80vw);
    padding: 8px 11px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow);
    font-size: 12px;
    font-weight: 400;
    line-height: 1.55;
    text-align: left;
    white-space: normal;
    word-break: break-word;
    opacity: 0;
    pointer-events: none;
    transition: opacity .16s ease, transform .16s ease;
}
/* 显示气泡 / 展开子链接时把整卡抬到兄弟卡片之上，避免菜单被相邻卡片盖住 */
.card-grid .link-card[data-tip]:hover,
.card-grid .link-card.has-sub:hover,
.card-grid .link-card.has-sub:focus-within { z-index: 25; }
.card-grid .link-card[data-tip]:hover::after,
.card-grid .link-card[data-tip]:focus-within::after {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}
/* 触屏没有 hover，避免气泡误触发 */
@media (hover: none) { .card-grid .link-card[data-tip]::after { display: none; } }

/* ---------- 卡片右上角的子链接下拉 ----------
   用原生 <details>：静态 HTML 不依赖 JS 即可展开，键盘可聚焦，触屏可点。
   只有存在子链接时前端模板才输出 .sub-menu。 */
.card-grid .link-card .sub-menu {
    position: absolute;
    top: 5px;
    right: 5px;
    z-index: 5;
}
.card-grid .link-card .sub-menu > summary {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: var(--surface-alt);
    color: var(--muted);
    font-size: 12px;
    line-height: 1;
    list-style: none;
    cursor: pointer;
    transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.card-grid .link-card .sub-menu > summary::-webkit-details-marker { display: none; }
.card-grid .link-card .sub-menu > summary::marker { content: ''; }
.card-grid .link-card .sub-menu > summary:hover,
.card-grid .link-card .sub-menu[open] > summary {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: var(--accent);
}
.card-grid .link-card .sub-menu-list {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    z-index: 40;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 150px;
    max-width: min(240px, 78vw);
    max-height: 260px;
    overflow-y: auto;
    padding: 6px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    box-shadow: var(--shadow);
}
.card-grid .link-card .sub-menu-list a {
    padding: 7px 10px;
    border-radius: 8px;
    color: var(--text);
    font-size: 12.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.card-grid .link-card .sub-menu-list a:hover,
.card-grid .link-card .sub-menu-list a:focus-visible {
    background: var(--accent-soft);
    color: var(--accent);
}

.empty-state { padding: 64px 20px; text-align: center; border: 1px dashed var(--border); border-radius: var(--radius); background: var(--surface); }
.empty-emoji { display: block; font-size: 36px; margin-bottom: 10px; }
.empty-state h2 { margin: 0 0 6px; font-size: 18px; }
.empty-state p { margin: 0; color: var(--muted); font-size: 14px; }
.noscript-tip { margin-top: 18px; color: var(--muted); font-size: 13px; }
.site-footer { border-top: 1px solid var(--border); padding: 22px 0; color: var(--muted); font-size: 13px; }
.site-footer .wrap { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.site-footer a:hover { color: var(--accent); }

/* 首页 / 公共单页页脚：三行全居中。只给这两类页面加 .has-beian，
   用户单页不带该类，仍走上面的左右分布布局，也不显示备案信息。 */
.site-footer.has-beian .wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    text-align: center;
}
.site-footer.has-beian .wrap > span {
    max-width: 100%;
    line-height: 1.7;
    text-align: center;
    white-space: normal;
}
.site-footer .beian-icon { height: 14px; vertical-align: middle; margin-right: 4px; }

/* 首页 <-> 公共单页切换：details 原生展开，静态页无需 JS 即可用 */
.page-switch { position: relative; flex: none; }
.page-switch > summary {
    list-style: none;
    cursor: pointer;
    padding: 8px 13px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text);
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
}
.page-switch > summary::-webkit-details-marker { display: none; }
.page-switch > summary::after { content: " ▾"; color: var(--muted); }
.page-switch[open] > summary { border-color: var(--accent); color: var(--accent); }
.page-switch-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 30;
    min-width: 170px;
    max-width: 260px;
    padding: 6px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.page-switch-menu a {
    padding: 8px 10px;
    border-radius: 8px;
    color: var(--text);
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.page-switch-menu a:hover { background: var(--accent-soft); color: var(--accent); }
.page-switch-menu a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 700; }

/* ---------- 上滑自现的浮动工具条 ----------
   紧贴 sticky 头部下方；默认隐藏，滚过工具区后「上滑出现 / 下滑收起」，
   由 site.js 根据滚动方向切换 .is-visible。visibility + pointer-events
   一起切换，避免隐藏状态下仍可点击或遮挡内容。 */
.float-tools {
    position: fixed;
    top: var(--header-h);
    left: 0;
    right: 0;
    z-index: 30;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
    background: color-mix(in srgb, var(--bg) 90%, transparent);
    backdrop-filter: blur(12px);
    box-shadow: var(--shadow-sm);
    transform: translateY(-12px);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: transform .22s ease, opacity .22s ease, visibility .22s ease;
}
.float-tools.is-visible {
    transform: translateY(0);
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}
.float-tools-inner { display: flex; align-items: center; gap: 10px; height: 54px; }
.ft-cat-btn { padding: 6px 12px; font-size: 12.5px; }
#floatCatLabel { max-width: 118px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ft-search {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
    padding: 3px 14px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    transition: border-color .18s ease, box-shadow .18s ease;
}
.ft-search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.ft-search .search-icon { font-size: 14px; }
#floatSearch {
    flex: 1;
    min-width: 0;
    padding: 6px 0;
    border: 0 !important;
    box-shadow: none !important;
    background: transparent;
    font-size: 14px;
}
.ft-top {
    flex: none;
    width: 36px;
    height: 36px;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: var(--surface);
    color: var(--muted);
    font-size: 17px;
    line-height: 1;
}
.ft-top:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- 分类抽屉（分类标签抽离文档流后以菜单形式出现） ---------- */
.cat-overlay {
    position: fixed;
    inset: 0;
    z-index: 50;
    background: rgba(9, 14, 26, .45);
    opacity: 0;
    transition: opacity .24s ease;
}
.cat-overlay.is-open { opacity: 1; }
.cat-drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 60;
    display: flex;
    flex-direction: column;
    width: min(340px, 88vw);
    border-left: 1px solid var(--border);
    background: var(--surface);
    box-shadow: -12px 0 36px rgba(9, 14, 26, .18);
    transform: translateX(102%);
    transition: transform .26s cubic-bezier(.22, .61, .36, 1);
}
.cat-drawer.is-open { transform: translateX(0); }
.cat-drawer-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 20px 14px;
    border-bottom: 1px solid var(--border);
}
.cat-drawer-head strong { font-size: 15px; }
.cat-drawer-head .muted { font-size: 12px; font-weight: 400; }
.cat-drawer-close {
    width: 32px;
    height: 32px;
    border: 0;
    border-radius: 9px;
    background: var(--surface-alt);
    color: var(--muted);
    font-size: 20px;
    line-height: 1;
}
.cat-drawer-close:hover { color: var(--text); }
.cat-drawer-search { padding: 14px 20px 6px; }
.cat-drawer-search input { width: 100%; }
.cat-drawer-list { flex: 1; overflow-y: auto; padding: 6px 12px 12px; }
.cat-drawer-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    transition: background .15s ease, color .15s ease;
}
.cat-drawer-item:hover { background: var(--surface-alt); }
.cat-drawer-item.is-active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.dc-icon { flex: none; width: 24px; text-align: center; font-size: 17px; line-height: 1; }
.dc-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dc-count { flex: none; color: var(--muted); font-size: 12px; font-weight: 400; }
.cat-drawer-foot { padding: 12px 20px 18px; border-top: 1px solid var(--border); }
.cat-drawer-foot button { width: 100%; }

@media (prefers-reduced-motion: reduce) {
    .float-tools, .cat-overlay, .cat-drawer { transition: none; }
}

@media (max-width: 900px) {
    .header-actions .btn-ghost { display: none; }
    .cat-chip { padding: 6px 12px; }
    #floatCatLabel { max-width: 84px; }
}
@media (max-width: 560px) {
    :root { --header-h: 58px; }
    .header-inner { height: 58px; }
    .btn-cta { font-size: 12px; padding: 7px 10px; }
    .page-switch > summary { padding: 6px 10px; font-size: 12px; }
    .page-switch-menu { right: auto; left: 0; }
    .hero { padding: 28px 0 10px; }
    .tools { padding-bottom: 18px; }
    .search-box { padding: 6px 8px 6px 14px; border-radius: 14px; }
    #search { font-size: 16px; }
    .search-submit { padding: 10px 14px; font-size: 14px; }
    .search-kbd { display: none; }
    .float-tools-inner { height: 50px; gap: 8px; }
    .ft-cat-btn { padding: 6px 10px; }
    .ft-cat-count { display: none; }
    .ft-search { padding: 2px 10px; }
    .ft-top { width: 32px; height: 32px; }
    .cat-drawer { width: 88vw; }
}
