/* 暗黑模式样式 */
body.dark-mode {
    background-color: #1a1a2e !important;
    color: #e0e0e0 !important;
}
body.dark-mode .navbar-default {
    background-color: #16213e !important;
    border-color: #0f3460 !important;
}
body.dark-mode .navbar-default .navbar-brand,
body.dark-mode .navbar-default .navbar-nav > li > a {
    color: #e0e0e0 !important;
}
body.dark-mode .navbar-default .navbar-nav > li > a:hover {
    color: #4fc3f7 !important;
}
body.dark-mode .panel {
    background-color: #16213e !important;
    border-color: #0f3460 !important;
}
body.dark-mode .panel-heading {
    background-color: #0f3460 !important;
    border-color: #0f3460 !important;
    color: #e0e0e0 !important;
}
body.dark-mode .panel-body {
    background-color: #1a1a2e !important;
    color: #e0e0e0 !important;
}
body.dark-mode .btn-default {
    background-color: #16213e !important;
    border-color: #0f3460 !important;
    color: #e0e0e0 !important;
}
body.dark-mode .btn-default:hover {
    background-color: #0f3460 !important;
    color: #4fc3f7 !important;
}
body.dark-mode .btn-primary {
    background-color: #0f3460 !important;
    border-color: #4fc3f7 !important;
}
body.dark-mode .btn-success {
    background-color: #1b5e20 !important;
}
body.dark-mode .form-control {
    background-color: #16213e !important;
    border-color: #0f3460 !important;
    color: #e0e0e0 !important;
}
body.dark-mode textarea,
body.dark-mode input[type="text"],
body.dark-mode select {
    background-color: #16213e !important;
    border-color: #0f3460 !important;
    color: #e0e0e0 !important;
}
body.dark-mode .breadcrumb {
    background-color: #16213e !important;
}
body.dark-mode .breadcrumb > li > a {
    color: #4fc3f7 !important;
}
body.dark-mode .table {
    color: #e0e0e0 !important;
}
body.dark-mode .table > thead > th {
    background-color: #0f3460 !important;
    border-color: #1a3a5c !important;
}
body.dark-mode .table td {
    border-color: #1a3a5c !important;
}
body.dark-mode .alert {
    border-color: #0f3460 !important;
}
body.dark-mode .alert-info {
    background-color: #16213e !important;
    color: #4fc3f7 !important;
}
body.dark-mode .modal-content {
    background-color: #1a1a2e !important;
    color: #e0e0e0 !important;
}
body.dark-mode .modal-header {
    border-color: #0f3460 !important;
}
body.dark-mode hr {
    border-color: #0f3460 !important;
}
body.dark-mode .footer,
body.dark-mode .footer a {
    color: #9e9e9e !important;
}
body.dark-mode .list-group-item {
    background-color: #16213e !important;
    border-color: #0f3460 !important;
    color: #e0e0e0 !important;
}
body.dark-mode .list-group-item:hover {
    background-color: #0f3460 !important;
}
body.dark-mode .dropdown-menu {
    background-color: #16213e !important;
}
body.dark-mode .dropdown-menu > li > a {
    color: #e0e0e0 !important;
}
body.dark-mode .dropdown-menu > li > a:hover {
    background-color: #0f3460 !important;
    color: #4fc3f7 !important;
}
body.dark-mode .dropdown-menu .dropdown-header {
    color: #9e9e9e !important;
}
body.dark-mode .dropdown-menu .divider {
    background-color: #0f3460 !important;
}
body.dark-mode .well {
    background-color: #16213e !important;
    border-color: #0f3460 !important;
    color: #e0e0e0 !important;
}
body.dark-mode .nav-tabs > li > a {
    color: #e0e0e0 !important;
}
body.dark-mode .nav-tabs > li.active > a {
    background-color: #1a1a2e !important;
    border-color: #0f3460 !important;
    color: #4fc3f7 !important;
}
body.dark-mode .tab-content {
    color: #e0e0e0 !important;
}
body.dark-mode pre {
    background-color: #0d1117 !important;
    color: #e0e0e0 !important;
    border-color: #0f3460 !important;
}
body.dark-mode code {
    background-color: #0d1117 !important;
    color: #4fc3f7 !important;
}
body.dark-mode .panel-success > .panel-heading {
    background-color: #1b5e20 !important;
    border-color: #2e7d32 !important;
}
body.dark-mode .panel-info > .panel-heading {
    background-color: #0d47a1 !important;
    border-color: #1565c0 !important;
}
body.dark-mode .panel-warning > .panel-heading {
    background-color: #e65100 !important;
    border-color: #f57c00 !important;
}
body.dark-mode .panel-danger > .panel-heading {
    background-color: #b71c1c !important;
    border-color: #c62828 !important;
}
body.dark-mode canvas {
    background-color: #16213e !important;
}
/* 移动端适配优化 */
@media (max-width: 768px) {
    .panel-body .row > div[class*="col-"] {
        margin-bottom: 8px;
    }
    .btn-block {
        font-size: 14px;
        padding: 8px 10px;
    }
    /* 游戏画布适配 */
    canvas {
        max-width: 100% !important;
        height: auto !important;
        touch-action: none;
    }
    /* 编辑器区域 */
    textarea {
        font-size: 16px !important; /* 防止 iOS 自动缩放 */
    }
    /* 搜索框 */
    .input-group-lg > .form-control {
        font-size: 16px;
    }
    /* 比较工具 */
    .d2h-file-side-diff {
        width: 100% !important;
        display: block !important;
    }
    /* 面板间距 */
    .panel {
        margin-bottom: 12px;
    }
    .panel-heading {
        font-size: 14px;
    }
    /* 面包屑 */
    .breadcrumb {
        padding: 6px 10px;
        font-size: 12px;
    }

    /* 新增纯前端工具批次：手机端统一从双栏改为单栏，避免左右编辑器被挤成窄条。 */
    .j3-grid.cols-2,
    .tg-grid,
    .td-grid,
    .env-grid,
    .in-grid,
    .sp-grid,
    .lo-grid,
    .ex-grid,
    .rg-grid,
    .wm-form,
    .pdf-form,
    .fav-form,
    .anki-form,
    .preview-wrap,
    div[style*="grid-template-columns:1fr 1fr"],
    div[style*="grid-template-columns:1fr 1.2fr"],
    div[style*="grid-template-columns:1fr 1.4fr"],
    div[style*="grid-template-columns:1.3fr 1fr"],
    div[style*="grid-template-columns:200px 1fr"] {
        grid-template-columns: 1fr !important;
    }

    /* 顶部说明块在手机端减少占屏，先让用户看到工具主体。 */
    .container > div[style*="linear-gradient"] {
        padding: 16px 14px !important;
        margin-bottom: 12px !important;
        border-radius: 10px !important;
    }
    .container > div[style*="linear-gradient"] h1 {
        font-size: 19px !important;
        line-height: 1.35 !important;
    }
    .container > div[style*="linear-gradient"] p {
        font-size: 13px !important;
        line-height: 1.6 !important;
    }

    /* JSON / 代码 / PDF 等工具的按钮区：移动端两列或单列排列，避免横向溢出。 */
    .j3-toolbar,
    .webp-form,
    .fc-toolbar,
    .rx-input-row {
        align-items: stretch !important;
    }
    .j3-toolbar .btn,
    .webp-form .btn,
    .fc-toolbar .btn,
    .rx-input-row .btn {
        flex: 1 1 calc(50% - 8px);
        min-width: 0;
    }
    .j3-toolbar label,
    .webp-form label,
    .fc-toolbar label {
        flex: 0 0 100%;
        margin-left: 0 !important;
    }
    .j3-toolbar select,
    .j3-toolbar input,
    .webp-form select,
    .webp-form input,
    .fc-toolbar select,
    .fc-toolbar input,
    .rx-input-row input,
    .rx-input-row select {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
    }

    /* 编辑区/结果区：手机端降低首屏高度，输入输出上下排列更顺手。 */
    .j3-wrap,
    .fav-wrap,
    .webp-wrap,
    .wm-wrap,
    .pdf-wrap,
    .ext-wrap,
    .fc-wrap,
    .anki-wrap {
        padding: 12px !important;
        border-radius: 10px !important;
    }
    .j3-pane textarea,
    .j3-pane pre,
    .rx-test,
    .md-preview,
    .ext-result {
        min-height: 220px !important;
        max-height: 360px !important;
        font-size: 13px !important;
    }

    /* 结果表格/代码块允许横向滚动，不撑破页面。 */
    .j3-diff-pre,
    .rx-highlight,
    .rx-match-list,
    .tg-out-content,
    .ext-result,
    pre,
    table.top-table {
        max-width: 100%;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
    }
    .rx-match-list table,
    table.top-table {
        min-width: 520px;
    }

    /* 正则预设按钮和卡片类工具：手指点击面积足够，但别把页面撑得太长。 */
    .rx-presets {
        gap: 8px !important;
    }
    .rx-presets button {
        flex: 1 1 calc(50% - 8px);
        white-space: normal;
    }
    .fc-card,
    .anki-card {
        min-height: 210px !important;
        padding: 34px 16px !important;
    }
    .fc-word {
        font-size: 34px !important;
        word-break: break-word;
    }
    .anki-card .front {
        font-size: 21px !important;
    }
    .anki-card .back {
        font-size: 16px !important;
    }

    /* 图片工具：预览区域和多尺寸网格在小屏下更紧凑。 */
    .fav-preview-grid,
    .ppt-preview,
    .ext-imggrid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 10px !important;
    }
    .wm-preview,
    .fav-drop,
    .webp-drop,
    .pdf-drop,
    .ext-drop {
        padding: 18px 12px !important;
    }
    .wm-preview canvas,
    .fav-preview canvas,
    .ext-imggrid canvas {
        max-width: 100% !important;
        height: auto !important;
    }
}

@media (max-width: 480px) {
    .j3-toolbar .btn,
    .webp-form .btn,
    .fc-toolbar .btn,
    .rx-input-row .btn,
    .rx-presets button {
        flex-basis: 100%;
    }
    .fav-preview-grid,
    .ppt-preview,
    .ext-imggrid {
        grid-template-columns: 1fr !important;
    }
    .fc-word {
        font-size: 30px !important;
    }
}

/* 首页标题栏最终兜底：该文件加载晚于 modern-ui，避免旧渐变标题栏把深色文字压暗。 */
body.home-modern .panel > .panel-heading,
body.home-modern .tool-panel > .panel-heading {
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%) !important;
    color: #0f172a !important;
    border-bottom: 1px solid rgba(226, 232, 240, .92) !important;
    text-shadow: none !important;
}

body.home-modern .panel > .panel-heading small,
body.home-modern .tool-panel > .panel-heading small {
    color: #64748b !important;
    opacity: 1 !important;
}

body.home-modern.dark-mode .panel > .panel-heading,
body.home-modern.dark-mode .tool-panel > .panel-heading {
    background: rgba(15, 23, 42, .94) !important;
    color: #f8fafc !important;
    border-bottom-color: rgba(51, 65, 85, .88) !important;
}
/* =====================================================
   移动端底部 Tab Bar + 移动端通用体验优化
   只在 ≤ 768px 生效，PC 端不可见 / 不影响布局
   ===================================================== */

/* 默认 PC 端隐藏 */
.m-tabbar { display: none; }

@media (max-width: 768px) {
    /* 1. 把 Tab Bar 固定到屏幕底部 */
    .m-tabbar {
        display: flex;
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 1080;
        height: 56px;
        background: rgba(255, 255, 255, .92);
        border-top: 1px solid rgba(226, 232, 240, .92);
        box-shadow: 0 -12px 30px rgba(15, 23, 42, .08);
        backdrop-filter: blur(16px);
        /* 兼容 iPhone 底部安全区 */
        padding-bottom: env(safe-area-inset-bottom);
    }

    .m-tab {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        padding: 6px 2px;
        text-decoration: none !important;
        color: #64748b;
        font-size: 11px;
        line-height: 1.2;
        position: relative;
        transition: color .15s;
        /* 关闭手机长按高亮 */
        -webkit-tap-highlight-color: transparent;
    }

    .m-tab:active { background: rgba(0, 0, 0, .03); }
    .m-tab:visited { color: #7a8090; }

    .m-tab-icon {
        font-size: 20px;
        line-height: 1;
        margin-bottom: 2px;
    }

    .m-tab-label {
        font-size: 11px;
        font-weight: 500;
        white-space: nowrap;
    }

    /* 当前页高亮 */
    .m-tab.active {
        color: #2563eb;
    }
    .m-tab.active .m-tab-label {
        font-weight: 700;
    }
    .m-tab.active::before {
        content: '';
        position: absolute;
        top: 0;
        left: 30%;
        right: 30%;
        height: 3px;
        background: #2563eb;
        border-radius: 0 0 3px 3px;
    }

    /* 2. 给 body 加底部内边距，避免被 fixed tabbar 遮挡内容尾部 */
    body {
        padding-bottom: calc(56px + env(safe-area-inset-bottom));
    }

    /* 3. 头部 hamburger 点击区放大 + 间距优化 */
    .navbar-default .navbar-toggle {
        margin-top: 12px;
        margin-right: 8px;
        padding: 10px 12px;
        border-color: #d6dde6;
    }
    .navbar-default .navbar-toggle .icon-bar {
        background-color: #5b6573;
        height: 3px;
        width: 24px;
    }
    .navbar-default .navbar-toggle:focus,
    .navbar-default .navbar-toggle:hover {
        background-color: #f5f7fa;
    }
    .navbar-brand {
        padding: 12px 14px !important;
    }
    .navbar-brand span {
        font-size: 1.1rem !important;
    }
    /* hamburger 展开后的菜单项更高，方便手指点击 */
    .navbar-default .navbar-collapse .navbar-nav > li > a {
        padding-top: 14px;
        padding-bottom: 14px;
        font-size: 15px;
    }

    /* 4. 全站可点击元素最小 44px 高度（Apple HIG 标准），改善误触 */
    .btn, .btn-default, .btn-primary, .btn-success, .btn-warning, .btn-danger,
    .form-control {
        min-height: 38px;
    }

    /* 5. 容器边距收紧，让内容区域更宽 */
    .container {
        padding-left: 12px !important;
        padding-right: 12px !important;
    }
}

/* 暗色模式 Tab Bar */
body.dark-mode .m-tabbar {
    background: #1c2228;
    border-top-color: #2e3640;
}
body.dark-mode .m-tab { color: #9aa3ad; }
body.dark-mode .m-tab.active { color: #60a5fa; }
body.dark-mode .m-tab:active { background: rgba(255,255,255,.04); }

/* ============= 悬浮 CTA（右下角， 滚动 ≥ 一屏才出现） ============= */
.float-cta {
    position: fixed;
    right: 18px;
    bottom: 22px;
    z-index: 998;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 6px 0 0;
    background: #0f172a;
    color: #fff;
    border-radius: 30px;
    box-shadow: 0 18px 40px rgba(15, 23, 42, .24);
    transform: translateY(120%);
    opacity: 0;
    transition: transform .35s cubic-bezier(.2,.8,.3,1.2), opacity .25s;
    pointer-events: none;
    font-size: 14px;
    max-width: calc(100% - 36px);
}
.float-cta.show {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
}
.float-cta-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 6px 12px 18px;
    color: #fff;
    text-decoration: none;
    font-weight: 600;
    line-height: 1;
}
.float-cta-link:hover, .float-cta-link:focus {
    color: #fff;
    text-decoration: none;
}
.float-cta-emoji { font-size: 18px; }
.float-cta-close {
    flex-shrink: 0;
    background: transparent;
    border: none;
    color: rgba(255,255,255,.85);
    font-size: 18px;
    width: 28px; height: 28px;
    line-height: 1;
    border-radius: 50%;
    cursor: pointer;
    margin-right: 4px;
}
.float-cta-close:hover {
    background: rgba(255,255,255,.18);
    color: #fff;
}

/* 移动端：避开底部 Tab Bar 占位 */
@media (max-width: 768px) {
    .float-cta {
        bottom: calc(70px + env(safe-area-inset-bottom));
        right: 12px;
        font-size: 13px;
    }
    .float-cta-link { padding: 10px 6px 10px 14px; }
    .float-cta-emoji { font-size: 16px; }
}

/* 联系页 / 案例页本身就是目的地，不再展示悬浮 CTA */
body[data-cta-suppress="1"] .float-cta { display: none !important; }
/* share-dock.css
 *
 * 移动端底部固定分享条（"Mobile Share Dock"）。
 * 用法：在工具/模板/场景详情页通过 commonSections :: mobileShareDock 注入。
 * 设计原则：
 *   - 仅在窄屏（≤ 768px）显示，PC 端隐藏（PC 端用现有的 .tool-share-bar 行内组件）
 *   - 底部固定，给底部 tabbar 让 50px 空间（结合 mobile-tabbar.css 总高度 ≈ 116px）
 *   - 半透明毛玻璃 + 圆角顶边，避免与页面内容割裂
 *   - 4 按钮等宽：💬 分享 / 📷 长图 / 🔗 二维码 / 📋 复制
 *   - 隐藏在 admin 后台、首页等不需要分享的页面（由 JS 判断后加 body[data-share-dock="off"]）
 */

.m-share-dock {
    display: none;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 56px;
    z-index: 1040;
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: saturate(180%) blur(12px);
    -webkit-backdrop-filter: saturate(180%) blur(12px);
    border-top: 1px solid rgba(226, 232, 240, 0.92);
    box-shadow: 0 -8px 24px rgba(15, 23, 42, 0.06);
    padding: 6px 4px 8px;
    transition: transform 0.25s ease;
    transform: translateY(0);
}

.m-share-dock.is-hidden {
    transform: translateY(150%);
}

.m-share-dock-row {
    display: flex;
    align-items: stretch;
    justify-content: space-around;
    gap: 4px;
}

.m-share-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 0;
    color: #334155;
    padding: 6px 4px;
    border-radius: 10px;
    -webkit-tap-highlight-color: transparent;
    cursor: pointer;
    min-height: 50px;
    transition: background 0.15s, transform 0.1s;
}

.m-share-btn:active {
    background: rgba(99, 102, 241, 0.08);
    transform: scale(0.96);
}

.m-share-btn .m-share-icon {
    font-size: 22px;
    line-height: 1;
    margin-bottom: 3px;
}

.m-share-btn .m-share-label {
    font-size: 11px;
    color: #64748b;
    line-height: 1.2;
    font-weight: 600;
}

.m-share-btn.is-primary {
    color: #1d4ed8;
}

.m-share-btn.is-primary .m-share-label {
    color: #1d4ed8;
}

.m-share-toast {
    position: fixed;
    left: 50%;
    bottom: 178px;
    transform: translateX(-50%);
    background: rgba(15, 23, 42, 0.88);
    color: #fff;
    font-size: 13px;
    padding: 8px 14px;
    border-radius: 999px;
    z-index: 1050;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s, transform 0.2s;
}

.m-share-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(-4px);
}

/* 暗色模式 */
body.dark-mode .m-share-dock {
    background: rgba(15, 23, 42, 0.94);
    border-top-color: rgba(51, 65, 85, 0.88);
}

body.dark-mode .m-share-btn {
    color: #cbd5e1;
}

body.dark-mode .m-share-btn .m-share-label {
    color: #94a3b8;
}

body.dark-mode .m-share-btn.is-primary {
    color: #60a5fa;
}

body.dark-mode .m-share-btn.is-primary .m-share-label {
    color: #60a5fa;
}

/* 只在 ≤768px 移动端显示；同时 body 必须没有 data-share-dock="off" */
@media (max-width: 768px) {
    body[data-share-dock="on"] .m-share-dock {
        display: block;
    }
    /* 出现分享条时，给页面底部留够空间避免 tab bar + 分享条遮挡 footer 内容 */
    body[data-share-dock="on"] .footer,
    body[data-share-dock="on"] .footer-inner {
        padding-bottom: 90px;
    }
}

/* 二维码弹层（点击 🔗 二维码按钮触发） */
.m-share-qr-mask {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.66);
    z-index: 99998;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.m-share-qr-box {
    background: #fff;
    border-radius: 16px;
    padding: 22px 24px;
    max-width: 320px;
    width: 100%;
    text-align: center;
    box-shadow: 0 16px 40px rgba(15, 23, 42, 0.25);
}

body.dark-mode .m-share-qr-box {
    background: #1e293b;
    color: #f1f5f9;
}

.m-share-qr-box h4 {
    margin: 0 0 6px;
    font-size: 16px;
    color: inherit;
}

.m-share-qr-box .m-share-qr-hint {
    color: #64748b;
    font-size: 12px;
    margin-bottom: 12px;
}

body.dark-mode .m-share-qr-box .m-share-qr-hint {
    color: #94a3b8;
}

.m-share-qr-box .m-share-qr-canvas {
    display: inline-block;
    padding: 8px;
    background: #fff;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
}

.m-share-qr-box .m-share-qr-url {
    margin-top: 12px;
    font-size: 12px;
    color: #64748b;
    word-break: break-all;
    line-height: 1.5;
}

.m-share-qr-box .m-share-qr-actions {
    margin-top: 14px;
    display: flex;
    gap: 8px;
    justify-content: center;
}

/* P6：当 ToolResult.publish 触发时，给"长图/分享"按钮加引导脉冲 —— 提示用户
 * 此刻分享会带个性化结果卡片 + _r 快照参数，扩散效果最好。 */
.m-share-btn.is-pulse {
    position: relative;
}

.m-share-btn.is-pulse::before {
    content: "";
    position: absolute;
    inset: 4px;
    border-radius: 12px;
    box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.55);
    animation: m-share-pulse 1.4s ease-out infinite;
    pointer-events: none;
}

@keyframes m-share-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.55); }
    70%  { box-shadow: 0 0 0 14px rgba(99, 102, 241, 0); }
    100% { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0); }
}

body.dark-mode .m-share-btn.is-pulse::before {
    animation: m-share-pulse-dark 1.4s ease-out infinite;
}

@keyframes m-share-pulse-dark {
    0%   { box-shadow: 0 0 0 0 rgba(165, 180, 252, 0.6); }
    70%  { box-shadow: 0 0 0 14px rgba(165, 180, 252, 0); }
    100% { box-shadow: 0 0 0 0 rgba(165, 180, 252, 0); }
}
/* tool-result.css
 *
 * P6（分享 + 回访闭环）专属样式：
 *   1) 顶部"上次结果"历史 banner   .tr-history-banner
 *   2) 顶部"朋友分享了一份结果"banner   .tr-restore-banner
 *   3) 顶部"通过分享进来"推荐 banner   .tr-recommend-banner
 *   4) 成就卡片（长图分享专用）   .tr-achievement-card
 *
 * 设计原则：
 *   - 与 modern-ui.css 的色调保持一致（蓝紫渐变 + 浅卡片）
 *   - 移动端首位响应，但 PC 端也能用
 *   - 顶部 banner 区域统一放在 #toolResultBanners，便于多个 banner 排版
 */

#toolResultBanners {
    margin: 12px 0 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* ============== 共用基础 ============== */
.tr-history-banner,
.tr-restore-banner,
.tr-recommend-banner {
    position: relative;
    border-radius: 12px;
    padding: 14px 16px;
    box-shadow: 0 6px 16px rgba(15, 23, 42, 0.06);
    font-size: 14px;
    line-height: 1.5;
    color: #1f2937;
}

/* ============== 历史 banner ============== */
.tr-history-banner {
    background: linear-gradient(135deg, #f0f7ff 0%, #f4f3ff 100%);
    border: 1px solid #dbeafe;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.tr-history-icon {
    font-size: 20px;
    flex-shrink: 0;
}

.tr-history-text {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tr-history-text strong {
    color: #1d4ed8;
    margin-right: 4px;
}

.tr-history-text small {
    color: #64748b;
}

.tr-history-action {
    flex-shrink: 0;
    background: #1d4ed8;
    color: #fff;
    border: 0;
    padding: 6px 14px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.15s ease, background 0.15s ease;
}

.tr-history-action:hover {
    background: #1e40af;
    transform: translateY(-1px);
}

.tr-history-close {
    background: transparent;
    border: 0;
    color: #94a3b8;
    font-size: 20px;
    line-height: 1;
    padding: 0 4px;
    cursor: pointer;
    flex-shrink: 0;
}

.tr-history-close:hover {
    color: #475569;
}

/* ============== 回看 banner（带 _r 参数进来） ============== */
.tr-restore-banner {
    background: linear-gradient(135deg, #eff6ff 0%, #ede9fe 100%);
    border: 1px solid #c7d2fe;
    padding: 16px 18px 18px;
}

.tr-restore-head {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.tr-restore-emoji {
    font-size: 22px;
}

.tr-restore-title {
    font-weight: 600;
    color: #4338ca;
    font-size: 15px;
}

.tr-restore-summary {
    font-size: 18px;
    font-weight: 700;
    color: #0f172a;
    margin-bottom: 12px;
    line-height: 1.45;
}

.tr-restore-summary small {
    font-weight: 400;
    font-size: 13px;
    color: #64748b;
}

.tr-restore-metrics {
    display: flex;
    gap: 12px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.tr-metric {
    flex: 1 1 30%;
    min-width: 100px;
    background: rgba(255, 255, 255, 0.7);
    border-radius: 10px;
    padding: 8px 12px;
    text-align: center;
}

.tr-metric-label {
    display: block;
    font-size: 12px;
    color: #64748b;
    margin-bottom: 2px;
}

.tr-metric-value {
    display: block;
    font-size: 16px;
    font-weight: 700;
    color: #0f172a;
}

.tr-metric-value.is-accent {
    color: #c026d3;
}

.tr-restore-cta {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.tr-restore-btn-primary,
.tr-restore-btn-secondary {
    border: 0;
    padding: 9px 16px;
    border-radius: 999px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.15s ease;
}

.tr-restore-btn-primary {
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    color: #fff;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.32);
}

.tr-restore-btn-secondary {
    background: #fff;
    color: #4338ca;
    border: 1px solid #c7d2fe;
}

.tr-restore-btn-primary:hover,
.tr-restore-btn-secondary:hover {
    transform: translateY(-1px);
}

/* ============== 推荐 banner（来自 utm_source=share-*） ============== */
.tr-recommend-banner {
    background: linear-gradient(135deg, #fff7ed 0%, #fef3c7 100%);
    border: 1px solid #fde68a;
    display: flex;
    align-items: center;
    gap: 12px;
}

.tr-recommend-emoji {
    font-size: 22px;
    flex-shrink: 0;
}

.tr-recommend-body {
    flex: 1 1 auto;
    min-width: 0;
}

.tr-recommend-title {
    font-weight: 600;
    color: #92400e;
    font-size: 14px;
}

.tr-recommend-sub {
    color: #b45309;
    font-size: 12px;
    margin-top: 2px;
}

.tr-recommend-action {
    flex-shrink: 0;
    background: #f59e0b;
    color: #fff;
    border: 0;
    padding: 7px 14px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.tr-recommend-action:hover {
    background: #d97706;
}

.tr-recommend-close {
    background: transparent;
    border: 0;
    color: #b45309;
    font-size: 20px;
    line-height: 1;
    padding: 0 4px;
    cursor: pointer;
    flex-shrink: 0;
}

/* ============== 暗色模式 ============== */
body.dark-mode .tr-history-banner,
html.dark-mode .tr-history-banner {
    background: linear-gradient(135deg, #1e293b 0%, #1e1b4b 100%);
    border-color: #312e81;
    color: #e2e8f0;
}

body.dark-mode .tr-history-text strong,
html.dark-mode .tr-history-text strong {
    color: #93c5fd;
}

body.dark-mode .tr-history-text small,
html.dark-mode .tr-history-text small {
    color: #94a3b8;
}

body.dark-mode .tr-restore-banner,
html.dark-mode .tr-restore-banner {
    background: linear-gradient(135deg, #1e1b4b 0%, #2e1065 100%);
    border-color: #4338ca;
    color: #e2e8f0;
}

body.dark-mode .tr-restore-title,
html.dark-mode .tr-restore-title {
    color: #a5b4fc;
}

body.dark-mode .tr-restore-summary,
html.dark-mode .tr-restore-summary {
    color: #f1f5f9;
}

body.dark-mode .tr-metric,
html.dark-mode .tr-metric {
    background: rgba(15, 23, 42, 0.5);
}

body.dark-mode .tr-metric-value,
html.dark-mode .tr-metric-value {
    color: #f1f5f9;
}

body.dark-mode .tr-metric-value.is-accent,
html.dark-mode .tr-metric-value.is-accent {
    color: #f472b6;
}

body.dark-mode .tr-recommend-banner,
html.dark-mode .tr-recommend-banner {
    background: linear-gradient(135deg, #422006 0%, #451a03 100%);
    border-color: #78350f;
}

body.dark-mode .tr-recommend-title,
html.dark-mode .tr-recommend-title {
    color: #fcd34d;
}

body.dark-mode .tr-recommend-sub,
html.dark-mode .tr-recommend-sub {
    color: #fde68a;
}

/* ============== 移动端优化 ============== */
@media (max-width: 640px) {
    #toolResultBanners {
        margin: 8px 0 12px;
        gap: 8px;
    }

    .tr-history-banner,
    .tr-restore-banner,
    .tr-recommend-banner {
        padding: 12px 14px;
        font-size: 13px;
        border-radius: 10px;
    }

    .tr-restore-summary {
        font-size: 16px;
    }

    .tr-metric {
        flex: 1 1 calc(50% - 8px);
        padding: 6px 8px;
    }
}
/* tool-related.css
 *
 * R1 工具页底部"相关工具"组件样式。
 *
 * 设计原则：
 *   - PC ≥ 768px：CSS Grid 自适应列数（auto-fit, minmax(240px, 1fr)），密集时 3-4 列
 *   - 移动 < 768px：横向滚动 + scroll-snap，节省纵向高度（手机滑屏更轻松）
 *   - 卡片与 modern-ui 主色调一致（蓝紫渐变 + 暖色 tag 提示）
 *   - 暗色模式整体反色
 */

.related-tools {
    margin: 40px 0 24px;
    padding: 24px 22px;
    background: linear-gradient(135deg, #fafbff 0%, #f4f7ff 100%);
    border: 1px solid #e3eaff;
    border-radius: 14px;
    box-shadow: 0 6px 20px rgba(15, 23, 42, 0.04);
}

.related-tools-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.related-tools-title {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    color: #1e293b;
    line-height: 1.3;
}

.related-tools-emoji {
    font-size: 22px;
}

.related-tools-more {
    font-size: 13px;
    color: #4f46e5;
    text-decoration: none;
    font-weight: 500;
    flex-shrink: 0;
}

.related-tools-more:hover {
    color: #3730a3;
    text-decoration: underline;
}

/* ---------------- 卡片网格（PC） ---------------- */
.related-tools-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 12px;
}

.related-tool-card {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 14px 14px 12px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    text-decoration: none !important;
    color: #1e293b;
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
    min-height: 76px;
}

.related-tool-card:hover {
    transform: translateY(-2px);
    border-color: #c7d2fe;
    box-shadow: 0 8px 22px rgba(79, 70, 229, 0.12);
    text-decoration: none !important;
    color: #1e293b;
}

.related-tool-card:focus {
    outline: 2px solid #4f46e5;
    outline-offset: 2px;
}

.related-tool-icon {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    background: linear-gradient(135deg, #eef2ff 0%, #e0e7ff 100%);
    border-radius: 10px;
}

.related-tool-body {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.related-tool-title {
    font-size: 14px;
    font-weight: 600;
    color: #0f172a;
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.related-tool-desc {
    font-size: 12px;
    color: #64748b;
    line-height: 1.45;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.related-tool-tag {
    position: absolute;
    top: 8px;
    right: 8px;
    font-size: 11px;
    line-height: 1;
    padding: 3px 6px;
    border-radius: 999px;
    color: #b45309;
    background: #fef3c7;
    font-weight: 600;
    white-space: nowrap;
}

.related-tool-card[data-reason="seo"] .related-tool-tag {
    color: #4338ca;
    background: #e0e7ff;
}

.related-tool-card[data-reason="same-category"] .related-tool-tag {
    color: #64748b;
    background: #f1f5f9;
}

/* ---------------- 移动端：横向滚动 ---------------- */
@media (max-width: 767px) {
    .related-tools {
        margin: 28px -10px 18px;     /* 让左右 negative margin 顶到屏幕边 */
        padding: 18px 12px 16px;
        border-radius: 12px;
    }

    .related-tools-head {
        padding: 0 4px;
        margin-bottom: 12px;
    }

    .related-tools-title {
        font-size: 16px;
    }

    .related-tools-list {
        display: flex;
        grid-template-columns: none;
        gap: 10px;
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        -webkit-overflow-scrolling: touch;
        padding: 4px 4px 12px;
        /* 隐藏滚动条但保留可滚动性 */
        scrollbar-width: thin;
    }

    .related-tools-list::-webkit-scrollbar {
        height: 4px;
    }

    .related-tools-list::-webkit-scrollbar-thumb {
        background: rgba(99, 102, 241, 0.25);
        border-radius: 2px;
    }

    .related-tool-card {
        flex: 0 0 78%;
        max-width: 280px;
        scroll-snap-align: start;
        min-height: 72px;
    }

    .related-tool-icon {
        width: 36px;
        height: 36px;
        font-size: 20px;
    }
}

/* ---------------- 暗色模式 ---------------- */
body.dark-mode .related-tools,
html.dark-mode .related-tools {
    background: linear-gradient(135deg, #1e293b 0%, #1e1b4b 100%);
    border-color: #312e81;
}

body.dark-mode .related-tools-title,
html.dark-mode .related-tools-title {
    color: #e2e8f0;
}

body.dark-mode .related-tools-more,
html.dark-mode .related-tools-more {
    color: #a5b4fc;
}

body.dark-mode .related-tool-card,
html.dark-mode .related-tool-card {
    background: #0f172a;
    border-color: #1e293b;
    color: #e2e8f0;
}

body.dark-mode .related-tool-card:hover,
html.dark-mode .related-tool-card:hover {
    border-color: #4338ca;
    box-shadow: 0 8px 22px rgba(99, 102, 241, 0.25);
    color: #f8fafc;
}

body.dark-mode .related-tool-icon,
html.dark-mode .related-tool-icon {
    background: linear-gradient(135deg, #312e81 0%, #1e1b4b 100%);
}

body.dark-mode .related-tool-title,
html.dark-mode .related-tool-title {
    color: #f1f5f9;
}

body.dark-mode .related-tool-desc,
html.dark-mode .related-tool-desc {
    color: #94a3b8;
}

body.dark-mode .related-tool-tag,
html.dark-mode .related-tool-tag {
    color: #fcd34d;
    background: rgba(252, 211, 77, 0.12);
}

body.dark-mode .related-tool-card[data-reason="seo"] .related-tool-tag,
html.dark-mode .related-tool-card[data-reason="seo"] .related-tool-tag {
    color: #a5b4fc;
    background: rgba(165, 180, 252, 0.12);
}

body.dark-mode .related-tool-card[data-reason="same-category"] .related-tool-tag,
html.dark-mode .related-tool-card[data-reason="same-category"] .related-tool-tag {
    color: #94a3b8;
    background: rgba(148, 163, 184, 0.12);
}
/* usage-badge.css
 *
 * R2 工具页"今日已用 X 次 · 累计 X"角标。
 *
 * 两端适配：
 *   - PC ≥ 768px：内联在 h1 右侧，正常字号
 *   - 移动 < 768px：自动换行成独立一行，更紧凑
 */

.usage-badge {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin-left: 14px;
    padding: 4px 10px;
    background: rgba(16, 185, 129, 0.08);
    color: #047857;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 500;
    vertical-align: middle;
    line-height: 1.6;
    opacity: 0;
    transform: translateY(-2px);
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.usage-badge.is-shown {
    opacity: 1;
    transform: translateY(0);
}

.usage-badge strong {
    color: #047857;
    font-weight: 700;
    margin: 0 1px;
}

.usage-badge-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}

.usage-badge-item-muted {
    color: #64748b;
    border-left: 1px solid rgba(100, 116, 139, 0.25);
    padding-left: 10px;
}

.usage-badge-item-muted strong {
    color: #475569;
}

.usage-badge-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #10b981;
    box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.15);
    animation: usage-badge-pulse 2s ease-in-out infinite;
}

@keyframes usage-badge-pulse {
    0%, 100% { box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.15); }
    50%      { box-shadow: 0 0 0 6px rgba(16, 185, 129, 0.05); }
}

/* ---------------- 移动端：自动换行成独立一行 ---------------- */
@media (max-width: 767px) {
    .usage-badge {
        display: flex;
        margin: 8px 0 0;
        font-size: 12px;
        padding: 3px 9px;
        max-width: max-content;
    }
}

/* ---------------- 暗色模式 ---------------- */
body.dark-mode .usage-badge,
html.dark-mode .usage-badge {
    background: rgba(52, 211, 153, 0.12);
    color: #6ee7b7;
}

body.dark-mode .usage-badge strong,
html.dark-mode .usage-badge strong {
    color: #a7f3d0;
}

body.dark-mode .usage-badge-item-muted,
html.dark-mode .usage-badge-item-muted {
    color: #94a3b8;
    border-left-color: rgba(148, 163, 184, 0.3);
}

body.dark-mode .usage-badge-item-muted strong,
html.dark-mode .usage-badge-item-muted strong {
    color: #cbd5e1;
}

body.dark-mode .usage-badge-dot,
html.dark-mode .usage-badge-dot {
    background: #34d399;
    box-shadow: 0 0 0 4px rgba(52, 211, 153, 0.2);
}
