.root-tools-search {
    margin: 0 0 16px;
}

.root-tools-search .form-control {
    height: 42px;
    font-size: 15px;
    border-radius: 8px;
}

html[data-theme="dark"] .root-tools-search .form-control,
html[data-theme="dark"] .root-tools-search .input-group-text {
    background: #0c1320 !important;
    border-color: rgba(148, 163, 184, 0.18) !important;
    color: #e2e8f0;
}

html[data-theme="dark"] .root-tools-search .form-control::placeholder {
    color: #7f8aa3;
}

/* 快捷分类胶囊栏 */
.category-nav-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
}

.category-pill {
    display: inline-flex;
    align-items: center;
    padding: 6px 14px;
    border-radius: 20px;
    background: #f1f5f9;
    color: #475569;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid rgba(0, 0, 0, 0.06);
    transition: all 0.15s ease;
    user-select: none;
}

.category-pill:hover, .category-pill.active {
    background: #3b82f6;
    color: #ffffff;
    border-color: #2563eb;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.25);
}

.category-pill .badge {
    margin-left: 6px;
    font-size: 11px;
    color: #64748b;
    background: rgba(0, 0, 0, 0.06);
    padding: 2px 6px;
    border-radius: 10px;
    font-weight: 500;
}

.category-pill:hover .badge, .category-pill.active .badge {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.25);
}

html[data-theme="dark"] .category-pill {
    background: #1e293b;
    color: #cbd5e1;
    border-color: rgba(255, 255, 255, 0.08);
}

html[data-theme="dark"] .category-pill .badge {
    color: #94a3b8;
    background: rgba(255, 255, 255, 0.08);
}

html[data-theme="dark"] .category-pill:hover, html[data-theme="dark"] .category-pill.active {
    background: #2563eb;
    color: #ffffff;
    border-color: #3b82f6;
}

html[data-theme="dark"] .category-pill:hover .badge,
html[data-theme="dark"] .category-pill.active .badge {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.25);
}

/* 移动端分类筛选下拉框 */
.category-select-wrapper {
    display: none;
    margin: 0 0 16px;
}

.category-select-wrapper .form-select {
    height: 42px;
    font-size: 14px;
    border-radius: 8px;
    cursor: pointer;
}

html[data-theme="dark"] .category-select-wrapper .form-select {
    background-color: #0c1320 !important;
    border-color: rgba(148, 163, 184, 0.18) !important;
    color: #e2e8f0 !important;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%2394a3b8' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e") !important;
}

html[data-theme="dark"] .category-select-wrapper .input-group-text {
    background: #0c1320 !important;
    border-color: rgba(148, 163, 184, 0.18) !important;
    color: #e2e8f0;
}

html[data-theme="dark"] .category-select-wrapper .form-select option {
    background-color: #0c1320;
    color: #e2e8f0;
}

/* 二级子分类筛选药丸容器 */
.sub-category-nav-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: -10px;
    margin-bottom: 20px;
    padding: 8px 12px;
    background: #f8fafc;
    border-radius: 12px;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.sub-category-pill {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: 14px;
    background: #ffffff;
    color: #64748b;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid rgba(0, 0, 0, 0.08);
    transition: all 0.15s ease;
    user-select: none;
}

.sub-category-pill:hover, .sub-category-pill.active {
    background: #0284c7;
    color: #ffffff;
    border-color: #0369a1;
}

.sub-category-pill .badge {
    margin-left: 5px;
    font-size: 10px;
    color: #94a3b8;
    background: rgba(0, 0, 0, 0.05);
    padding: 1px 5px;
    border-radius: 8px;
}

.sub-category-pill:hover .badge, .sub-category-pill.active .badge {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.25);
}

html[data-theme="dark"] .sub-category-nav-bar {
    background: #0f172a;
    border-color: rgba(255, 255, 255, 0.06);
}

html[data-theme="dark"] .sub-category-pill {
    background: #1e293b;
    color: #94a3b8;
    border-color: rgba(255, 255, 255, 0.08);
}

html[data-theme="dark"] .sub-category-pill:hover,
html[data-theme="dark"] .sub-category-pill.active {
    background: #0284c7;
    color: #ffffff;
    border-color: #38bdf8;
}

.tool-sub-badge {
    display: inline-block;
    font-weight: normal;
    font-size: 11px;
    line-height: 1.4;
    padding: 2px 8px;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.04) !important;
    color: #64748b !important;
}

.root-tool-item .card-header {
    padding-bottom: 8px;
}

.tool-sub-row {
    margin-bottom: 8px;
    line-height: 1;
}

html[data-theme="dark"] .tool-sub-badge {
    background: rgba(255, 255, 255, 0.08) !important;
    color: #94a3b8 !important;
}

@media (max-width: 767.98px) {
    .category-nav-bar {
        display: none;
    }
    .category-select-wrapper {
        display: block;
    }

    /*
     * 手机端工具列表很长，搜索框吸顶，滚过分类和工具卡片时仍可直接输入。
     * 仅窄屏生效；桌面保持文档流。
     * top 用 --rh-nav-offset（脚本按固定顶栏第一行实测），缺省 56px，与折叠菜单的 100dvh - 56px 一致，
     * 使搜索框落在顶栏下方而不是被顶栏挡住。顶栏 .fixed-top 的 z-index 是 1030，这里用 1020
     * （与 Bootstrap .sticky-top 相同），展开的导航菜单仍盖在搜索框之上。
     * 吸顶包含块是主栏：侧栏广告在主栏之后的兄弟列里，滚到广告时搜索框随主栏离开，不会压住广告。
     * 不用 position:fixed，也不抬到广告浮层（锚点 / 插屏）之上，避免遮挡广告。
     */
    .root-tools-search {
        position: sticky;
        top: var(--rh-nav-offset, 56px);
        z-index: 1020;
        margin-top: 0;
        margin-bottom: 0;
        /*
         * 搜索条默认只占列的内容盒，左右各空出 --mdb-gutter-x 的一半。
         * 卡片阴影和色边会从这道透明缝里滚出来。负外边距把背景铺满所在列
         * （手机上列本身就是视口宽），对称内边距把输入框留在和卡片对齐的位置。
         * 上内边距把输入框让到顶栏阴影下面；背景仍从顶栏下沿开始。
         */
        margin-left: calc(var(--mdb-gutter-x, 1.5rem) / -2);
        margin-right: calc(var(--mdb-gutter-x, 1.5rem) / -2);
        padding: 8px calc(var(--mdb-gutter-x, 1.5rem) / 2) 12px;
        background: #fff;
        box-shadow: 0 1px 0 rgba(15, 23, 42, 0.08);
    }

    html[data-theme="dark"] .root-tools-search {
        background: #0b1220;
        box-shadow: 0 1px 0 rgba(255, 255, 255, 0.08);
    }
}

.history-tool-chip {
    display: inline-flex;
    align-items: center;
    padding: 6px 12px;
    border-radius: 20px;
    background: #f1f5f9;
    color: #334155;
    text-decoration: none;
    margin: 0 8px 8px 0;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.15s ease;
    border: 1px solid rgba(0,0,0,0.06);
}
.history-tool-chip:hover {
    background: #3b82f6;
    color: #ffffff;
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(59, 130, 246, 0.3);
}
html[data-theme="dark"] .history-tool-chip {
    background: #1e293b;
    color: #e2e8f0;
    border-color: rgba(255, 255, 255, 0.08);
}
html[data-theme="dark"] .history-tool-chip:hover {
    background: #2563eb;
    color: #ffffff;
}

.section-header-box {
    display: flex;
    align-items: baseline;
    margin: 28px 0 14px;
    border-bottom: 2px solid rgba(0, 0, 0, 0.04);
    padding-bottom: 8px;
}
html[data-theme="dark"] .section-header-box {
    border-bottom-color: rgba(255, 255, 255, 0.06);
}

.card-header .tool-name-text {
    margin-right: 8px;
}

.seo-guide-card {
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.08) !important;
    border-radius: 12px;
}
.seo-step-box {
    background: #f8fafc;
    border: 1px solid rgba(0, 0, 0, 0.05);
}
.seo-faq-item {
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}
.seo-faq-item:last-child {
    border-bottom: none;
}
.seo-faq-item summary {
    list-style: none;
    outline: none;
    user-select: none;
    padding: 14px 0;
    min-height: 48px;
    line-height: 1.5;
    transition: color 0.15s ease;
}
.seo-faq-item summary:hover {
    color: var(--primary, #0d6efd);
}
.seo-faq-item summary::-webkit-details-marker {
    display: none;
}
.seo-faq-item[open] summary {
    padding-bottom: 8px;
}
.seo-faq-item[open] summary i {
    transform: rotate(180deg);
}
.seo-faq-item summary i {
    transition: transform 0.2s ease;
}
.seo-faq-answer {
    padding-bottom: 14px;
    line-height: 1.6;
}
html[data-theme="dark"] .seo-guide-card {
    background: #111827;
    border-color: rgba(255, 255, 255, 0.08) !important;
}
html[data-theme="dark"] .seo-guide-card .text-dark {
    color: #f3f4f6 !important;
}
html[data-theme="dark"] .seo-step-box {
    background: #1f2937;
    border-color: rgba(255, 255, 255, 0.06);
}
html[data-theme="dark"] .seo-faq-item {
    border-bottom-color: rgba(255, 255, 255, 0.08) !important;
}
html[data-theme="dark"] .seo-faq-item summary:hover {
    color: #60a5fa !important;
}

/*
 * 列表卡片由 root-tools.js 在加载时构造。构造完成前（#rootToolsList 还没有 .is-ready），
 * 按每个分类默认要显示的卡片数（行上的 data-n）预留大致高度，让下面的内容（含广告位）不在卡片出现时整体下跳。
 * 列数与卡片的 col-12 / col-sm-6 / col-lg-4（无侧栏广告时 xl 为 col-xl-3）一致；
 * 每行高度取各断点下卡片实测值的整数，只是估算：构造完成后以真实高度为准。
 * 只在脚本可用时预留（scripting: enabled）：没有 JS 时卡片不会出现，也就不留空白，页面显示 <noscript> 提示。
 */
@media (scripting: enabled) {
    .root-tools-list:not(.is-ready) [data-n="1"] { min-height: 150px; }
    .root-tools-list:not(.is-ready) [data-n="2"] { min-height: 300px; }
    .root-tools-list:not(.is-ready) [data-n="3"] { min-height: 450px; }
    .root-tools-list:not(.is-ready) [data-n="4"] { min-height: 600px; }
    .root-tools-list:not(.is-ready) [data-n="5"] { min-height: 750px; }
    .root-tools-list:not(.is-ready) [data-n="6"] { min-height: 900px; }
    .root-tools-list:not(.is-ready) [data-n="7"] { min-height: 1050px; }
    .root-tools-list:not(.is-ready) [data-n="8"] { min-height: 1200px; }
    .root-tools-list:not(.is-ready) [data-n="9"] { min-height: 1350px; }
    .root-tools-list:not(.is-ready) [data-n="10"] { min-height: 1500px; }
    .root-tools-list:not(.is-ready) [data-n="11"] { min-height: 1650px; }
    .root-tools-list:not(.is-ready) [data-n="12"] { min-height: 1800px; }
    .root-tools-list:not(.is-ready) [data-n="13"] { min-height: 1950px; }
    .root-tools-list:not(.is-ready) [data-n="14"] { min-height: 2100px; }
}
@media (scripting: enabled) and (min-width: 576px) {
    .root-tools-list:not(.is-ready) [data-n="1"],.root-tools-list:not(.is-ready) [data-n="2"] { min-height: 175px; }
    .root-tools-list:not(.is-ready) [data-n="3"],.root-tools-list:not(.is-ready) [data-n="4"] { min-height: 350px; }
    .root-tools-list:not(.is-ready) [data-n="5"],.root-tools-list:not(.is-ready) [data-n="6"] { min-height: 525px; }
    .root-tools-list:not(.is-ready) [data-n="7"],.root-tools-list:not(.is-ready) [data-n="8"] { min-height: 700px; }
    .root-tools-list:not(.is-ready) [data-n="9"],.root-tools-list:not(.is-ready) [data-n="10"] { min-height: 875px; }
    .root-tools-list:not(.is-ready) [data-n="11"],.root-tools-list:not(.is-ready) [data-n="12"] { min-height: 1050px; }
    .root-tools-list:not(.is-ready) [data-n="13"],.root-tools-list:not(.is-ready) [data-n="14"] { min-height: 1225px; }
}
@media (scripting: enabled) and (min-width: 992px) {
    .root-tools-list:not(.is-ready) [data-n="1"],.root-tools-list:not(.is-ready) [data-n="2"],.root-tools-list:not(.is-ready) [data-n="3"] { min-height: 230px; }
    .root-tools-list:not(.is-ready) [data-n="4"],.root-tools-list:not(.is-ready) [data-n="5"],.root-tools-list:not(.is-ready) [data-n="6"] { min-height: 460px; }
    .root-tools-list:not(.is-ready) [data-n="7"],.root-tools-list:not(.is-ready) [data-n="8"],.root-tools-list:not(.is-ready) [data-n="9"] { min-height: 690px; }
    .root-tools-list:not(.is-ready) [data-n="10"],.root-tools-list:not(.is-ready) [data-n="11"],.root-tools-list:not(.is-ready) [data-n="12"] { min-height: 920px; }
    .root-tools-list:not(.is-ready) [data-n="13"],.root-tools-list:not(.is-ready) [data-n="14"] { min-height: 1150px; }
}
@media (scripting: enabled) and (min-width: 1200px) {
    .root-tools-list:not(.is-ready) [data-n="1"],.root-tools-list:not(.is-ready) [data-n="2"],.root-tools-list:not(.is-ready) [data-n="3"] { min-height: 190px; }
    .root-tools-list:not(.is-ready) [data-n="4"],.root-tools-list:not(.is-ready) [data-n="5"],.root-tools-list:not(.is-ready) [data-n="6"] { min-height: 380px; }
    .root-tools-list:not(.is-ready) [data-n="7"],.root-tools-list:not(.is-ready) [data-n="8"],.root-tools-list:not(.is-ready) [data-n="9"] { min-height: 570px; }
    .root-tools-list:not(.is-ready) [data-n="10"],.root-tools-list:not(.is-ready) [data-n="11"],.root-tools-list:not(.is-ready) [data-n="12"] { min-height: 760px; }
    .root-tools-list:not(.is-ready) [data-n="13"],.root-tools-list:not(.is-ready) [data-n="14"] { min-height: 950px; }
    .root-tools-list-wide:not(.is-ready) [data-n="1"],.root-tools-list-wide:not(.is-ready) [data-n="2"],.root-tools-list-wide:not(.is-ready) [data-n="3"],.root-tools-list-wide:not(.is-ready) [data-n="4"] { min-height: 190px; }
    .root-tools-list-wide:not(.is-ready) [data-n="5"],.root-tools-list-wide:not(.is-ready) [data-n="6"],.root-tools-list-wide:not(.is-ready) [data-n="7"],.root-tools-list-wide:not(.is-ready) [data-n="8"] { min-height: 380px; }
    .root-tools-list-wide:not(.is-ready) [data-n="9"],.root-tools-list-wide:not(.is-ready) [data-n="10"],.root-tools-list-wide:not(.is-ready) [data-n="11"],.root-tools-list-wide:not(.is-ready) [data-n="12"] { min-height: 570px; }
    .root-tools-list-wide:not(.is-ready) [data-n="13"],.root-tools-list-wide:not(.is-ready) [data-n="14"] { min-height: 760px; }
}

.root-tools-noscript {
    margin: 0 0 16px;
    font-size: 14px;
}

/* 没有 JS 时分类下面没有卡片，只剩空标题：整块收起，由 <noscript> 提示和顶部菜单代替 */
@media (scripting: none) {
    .root-tools-section {
        display: none;
    }
}
