/* ===== 全局重置 ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg: #f4f1eb;
    --sidebar-bg: #2c2416;
    --sidebar-text: #d4c5a0;
    --sidebar-active: rgba(255,255,255,0.12);
    --gold: #c8b87a;
    --gold-light: #f5e09a;
    --brown: #5a3e1b;
    --brown-dark: #3d2b0a;
    --border: #e8dfc8;
    --hover: #fef9ee;
    --white: #fff;
    --text: #2c2416;
    --muted: #8c7755;
    --tag-bg: #f0e8c8;
    --input-bg: #faf7f0;
}

html { font-size: 16px; }

body {
    font-family: "Microsoft YaHei", "PingFang SC", "SimSun", serif;
    background: var(--bg);
    color: var(--text);
    height: 100dvh;
    overflow: hidden;
}

/* ===== 布局 ===== */
.layout {
    display: flex;
    height: 100dvh;
    position: relative;
}

/* ===== 侧边栏（桌面端） ===== */
.sidebar {
    width: 220px;
    min-width: 180px;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex-shrink: 0;
    transition: transform 0.28s cubic-bezier(.4,0,.2,1);
    z-index: 200;
}

.sidebar-title {
    padding: 18px 16px 12px;
    font-size: 15px;
    font-weight: bold;
    color: #f0e6c8;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    letter-spacing: 1px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* 侧边栏关闭按钮（仅移动端显示） */
.sidebar-close {
    display: none;
    background: none;
    border: none;
    color: #a89b6f;
    font-size: 22px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}

.category-tree {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
    -webkit-overflow-scrolling: touch;
}

.cat-item { cursor: pointer; }

.cat-header {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    font-size: 14px;
    color: var(--gold);
    transition: background 0.15s;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}
.cat-header:hover, .cat-header:active { background: rgba(255,255,255,0.07); }
.cat-header.active { background: var(--sidebar-active); color: var(--gold-light); }

.cat-arrow {
    margin-right: 6px;
    font-size: 10px;
    transition: transform 0.2s;
    display: inline-block;
    flex-shrink: 0;
}
.cat-arrow.open { transform: rotate(90deg); }

.cat-count {
    margin-left: auto;
    font-size: 11px;
    background: rgba(255,255,255,0.12);
    border-radius: 10px;
    padding: 1px 7px;
    flex-shrink: 0;
}

.sub-list { display: none; padding-left: 8px; }
.sub-list.open { display: block; }

.sub-item {
    padding: 8px 16px 8px 28px;
    font-size: 13px;
    color: #a89b6f;
    cursor: pointer;
    transition: background 0.15s;
    -webkit-tap-highlight-color: transparent;
}
.sub-item:hover, .sub-item:active { background: rgba(255,255,255,0.06); color: var(--sidebar-text); }
.sub-item.active { color: #f0d882; }

.sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid rgba(255,255,255,0.08);
}

.btn-rebuild {
    width: 100%;
    padding: 8px;
    background: rgba(255,255,255,0.08);
    color: #a89b6f;
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.15s;
    -webkit-tap-highlight-color: transparent;
}
.btn-rebuild:hover { background: rgba(255,255,255,0.14); }

/* 遮罩层（移动端展开侧边栏时） */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 190;
}
.sidebar-overlay.visible { display: block; }

/* ===== 主内容区 ===== */
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

/* ===== 顶部栏 ===== */
.top-bar {
    background: var(--white);
    padding: 12px 16px 10px;
    border-bottom: 2px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

/* 汉堡菜单按钮（仅移动端） */
.menu-btn {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px 8px 4px 0;
    color: var(--brown);
    font-size: 22px;
    line-height: 1;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
}

.top-bar h1 {
    font-size: 18px;
    color: var(--brown-dark);
    white-space: nowrap;
    letter-spacing: 1px;
}

.stats-bar {
    font-size: 12px;
    color: var(--muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    min-width: 0;
}

/* 帮助入口（指向 /help.html 的操作手册；窄屏只留图标） */
.help-btn {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 12px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--hover);
    color: var(--brown);
    font-size: 13px;
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.18s, border-color 0.18s;
}
.help-btn:hover { background: var(--tag-bg); border-color: var(--gold); }
.help-btn-ico { font-size: 13px; line-height: 1; }

/* ===== 搜索区 ===== */
.search-wrap {
    background: var(--white);
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.search-warning {
    margin-top: 6px;
    padding: 6px 10px;
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 4px;
    color: #856404;
    font-size: 13px;
}

.search-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.search-row input[type="text"] {
    flex: 1;
    min-width: 0;
    padding: 10px 14px;
    border: 1.5px solid #d5c9a8;
    border-radius: 8px;
    font-size: 15px;
    background: var(--input-bg);
    transition: border-color 0.2s;
    -webkit-appearance: none;
}
.search-row input[type="text"]:focus {
    outline: none;
    border-color: #8b6914;
}

.toggle-label {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    color: var(--brown);
    white-space: nowrap;
    cursor: pointer;
    flex-shrink: 0;
}
.toggle-label input { accent-color: var(--brown); width: 15px; height: 15px; cursor: pointer; }

.btn-search {
    padding: 10px 18px;
    background: var(--brown);
    color: #f5e6c8;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.2s;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}
.btn-search:hover { background: #7a5628; }
.btn-search:active { background: #7a5628; }

.btn-clear {
    padding: 10px 12px;
    background: none;
    color: var(--muted);
    border: 1.5px solid #d5c9a8;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.15s;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}
.btn-clear:hover { background: #f0e8d0; color: var(--brown); }

.active-filter {
    margin-top: 6px;
    font-size: 12px;
    color: var(--muted);
    min-height: 14px;
}

.filter-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--tag-bg);
    border: 1px solid #d5c080;
    border-radius: 12px;
    padding: 2px 10px;
    margin-right: 6px;
    font-size: 12px;
    color: var(--brown);
}
.filter-tag span { cursor: pointer; color: var(--muted); }
.filter-tag span:hover { color: #c0392b; }

/* ===== 反馈列表（首页） ===== */
.feedback-list-wrap {
    margin: 16px;
    background: var(--white);
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0,0,0,.08);
    border: 1px solid var(--border);
    overflow: hidden;
}
.feedback-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: linear-gradient(135deg, #8B4513 0%, #A0522D 100%);
    color: #fff;
    font-size: 15px;
    font-weight: bold;
}
.btn-feedback-write {
    background: rgba(255,255,255,.2);
    border: 1px solid rgba(255,255,255,.4);
    color: #fff;
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    transition: background .15s;
}
.btn-feedback-write:hover {
    background: rgba(255,255,255,.3);
}
.feedback-list {
    padding: 12px;
    max-height: 400px;
    overflow-y: auto;
}
.feedback-empty {
    text-align: center;
    color: var(--muted);
    padding: 24px;
    font-size: 14px;
}
.feedback-item {
    padding: 12px;
    margin-bottom: 10px;
    background: var(--hover);
    border-radius: 8px;
    border: 1px solid var(--border);
}
.feedback-item:last-child { margin-bottom: 0; }
.feedback-item-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    font-size: 12px;
}
.feedback-type {
    background: var(--gold);
    color: var(--brown-dark);
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: bold;
}
.feedback-book {
    color: var(--brown);
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.feedback-item-content {
    font-size: 14px;
    line-height: 1.6;
    color: var(--text);
    margin-bottom: 8px;
}
.feedback-item-footer {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--muted);
}

/* ===== 体质测试入口 ===== */
.constitution-banner {
    margin: 16px;
}
.constitution-link {
    display: flex;
    align-items: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 12px;
    padding: 16px;
    text-decoration: none;
    color: white;
}
.constitution-icon {
    font-size: 32px;
    margin-right: 12px;
}
.constitution-text {
    flex: 1;
    display: flex;
    flex-direction: column;
}
.constitution-title {
    font-size: 16px;
    font-weight: bold;
    margin-bottom: 4px;
}
.constitution-desc {
    font-size: 12px;
    opacity: 0.9;
}
.constitution-arrow {
    font-size: 20px;
    opacity: 0.8;
}

/* ===== 热搜榜 ===== */
.hotkeywords-wrap {
    margin: 0 16px 12px;
    padding: 12px;
    background: linear-gradient(to right, #fff8e1, #fff);
    border-radius: 10px;
    border: 1px solid #ffe0b2;
}
.hotkeywords-title {
    font-size: 13px;
    color: #e65100;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 4px;
}
.hotkeywords-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.hotkeyword-tag {
    display: inline-block;
    padding: 4px 12px;
    background: #fff;
    border: 1px solid #ffcc80;
    border-radius: 16px;
    font-size: 13px;
    color: #e65100;
    cursor: pointer;
    transition: all .2s;
}
.hotkeyword-tag:hover {
    background: #fff3e0;
    transform: scale(1.05);
}
.hotkeyword-tag .count {
    font-size: 11px;
    color: #999;
    margin-left: 4px;
}

/* ===== 结果区 ===== */
.results-wrap {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 9px 16px;
    font-size: 13px;
    color: var(--muted);
    background: var(--input-bg);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
}

/* 排序按钮组 */
.sort-btns {
    display: flex;
    gap: 4px;
}
.sort-btn {
    padding: 3px 12px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: var(--white);
    font-size: 12px;
    cursor: pointer;
    color: var(--brown);
    transition: all .15s;
    line-height: 1.6;
}
.sort-btn.active {
    background: var(--brown);
    color: var(--white);
    border-color: var(--brown);
}
.sort-btn:hover:not(.active) { background: var(--hover); }

/* 阅读量徽章 */
.read-badge {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    font-size: 11px;
    color: var(--muted);
    background: var(--hover);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1px 7px;
    white-space: nowrap;
}
.read-badge.hot {
    color: #c0392b;
    background: #fff3f0;
    border-color: #f5c6c0;
    font-weight: bold;
}



.result-item {
    padding: 13px 16px;
    border-bottom: 1px solid #ede4cc;
    cursor: pointer;
    transition: background 0.15s;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}
.result-item:hover { background: var(--hover); }
.result-item:active { background: #f5edd5; }

.result-icon {
    font-size: 22px;
    flex-shrink: 0;
    margin-top: 2px;
}

.result-body { flex: 1; min-width: 0; }

.result-title {
    font-size: 16px;
    font-weight: bold;
    color: var(--brown-dark);
    margin-bottom: 4px;
    word-break: break-word;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.title-read-count {
    font-size: 12px;
    font-weight: normal;
    color: #c0392b;
    background: #fff3f0;
    padding: 2px 8px;
    border-radius: 10px;
    white-space: nowrap;
}
.result-title mark {
    background: #fff176;
    color: inherit;
    border-radius: 2px;
    padding: 0 2px;
}

.result-meta {
    font-size: 12px;
    color: var(--muted);
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 4px;
}

.result-excerpt {
    font-size: 13px;
    color: #5a4a2a;
    line-height: 1.6;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.result-excerpt mark {
    background: #fff176;
    color: inherit;
    border-radius: 2px;
    padding: 0 2px;
}

/* ===== 分页 ===== */
.pagination {
    display: flex;
    justify-content: center;
    gap: 6px;
    padding: 14px 12px;
    flex-wrap: wrap;
}
.pagination button {
    padding: 7px 13px;
    border: 1px solid #d5c9a8;
    background: var(--white);
    color: var(--brown);
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.15s;
    min-width: 40px;
    touch-action: manipulation;
}
.pagination button:hover { background: #f0e8d0; }
.pagination button.active { background: var(--brown); color: #f5e6c8; border-color: var(--brown); }
.pagination button:disabled { opacity: 0.4; cursor: not-allowed; }

/* ===== 空/加载状态 ===== */
.empty-tip {
    text-align: center;
    padding: 60px 20px;
    color: #a09070;
    font-size: 15px;
}
.empty-tip .big { font-size: 40px; margin-bottom: 12px; }
.loading-sm { padding: 16px; color: #a09070; font-size: 13px; text-align: center; }

/* ===== 模态框 ===== */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    z-index: 1000;
    align-items: flex-start;
    justify-content: center;
    padding: 20px 12px;
}
.modal.open { display: flex; }

.modal-box {
    background: #fffdf5;
    border-radius: 12px;
    width: 100%;
    max-width: 820px;
    max-height: 92vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    overflow: hidden;
}

.modal-header {
    padding: 16px 18px 10px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.modal-header h2 {
    font-size: 17px;
    color: var(--brown-dark);
    margin-bottom: 4px;
    word-break: break-word;
    line-height: 1.4;
}
.modal-meta {
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 8px;
}
.modal-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.modal-actions button, .modal-actions a {
    padding: 7px 14px;
    border: 1px solid #d5c9a8;
    background: var(--white);
    color: var(--brown);
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    text-decoration: none;
    transition: background 0.15s;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}
.modal-actions button:hover, .modal-actions a:hover { background: #f0e8d0; }
.btn-dl { background: var(--brown) !important; color: #f5e6c8 !important; border-color: var(--brown) !important; }
.btn-dl:hover { background: #7a5628 !important; }

/* 模态框内嵌搜索框 */
.modal-inline-search {
    flex: 1;
    min-width: 120px;
}
.modal-inline-search input {
    width: 100%;
    padding: 7px 10px;
    border: 1px solid #d5c9a8;
    border-radius: 6px;
    font-size: 13px;
    background: #fff;
    color: var(--brown);
    outline: none;
}
.modal-inline-search input:focus {
    border-color: var(--gold);
    box-shadow: 0 0 0 2px rgba(200,184,122,0.2);
}

/* 翻页控制 */
.reader-pager {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}
.reader-btn {
    padding: 6px 12px;
    border: 1px solid #d5c9a8;
    background: var(--white);
    color: var(--brown);
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-family: inherit;
    transition: background 0.15s;
}
.reader-btn:hover:not(:disabled) {
    background: #f0e8d0;
}
.reader-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
.reader-page-info {
    font-size: 12px;
    color: var(--muted);
    white-space: nowrap;
    min-width: 70px;
    text-align: center;
}

/* 移动端调整 */


.modal-search {
    padding: 8px 18px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.modal-search input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #d5c9a8;
    border-radius: 6px;
    font-size: 14px;
    background: var(--input-bg);
    -webkit-appearance: none;
}
.modal-search input:focus { outline: none; border-color: #8b6914; }

.modal-content {
    flex: 1;
    overflow-y: auto;
    padding: 18px;
    font-family: "Microsoft YaHei", "SimSun", serif;
    font-size: 15px;
    line-height: 2;
    color: var(--text);
    white-space: pre-wrap;
    word-break: break-all;
    -webkit-overflow-scrolling: touch;
}

/* 阅读进度恢复提示条 */
.resume-tip {
    position: sticky;
    top: 0;
    z-index: 10;
    background: #f5e6a0;
    border-bottom: 1px solid #c9a84c;
    color: #5a3e00;
    font-size: 13px;
    padding: 7px 14px;
    text-align: center;
    border-radius: 0;
    transition: opacity .3s;
}

.modal-footer {
    padding: 7px 18px;
    border-top: 1px solid var(--border);
    font-size: 12px;
    color: #a09070;
    flex-shrink: 0;
}


/* ============================================================
   移动端响应式 (≤ 768px)
   ============================================================ */
@media (max-width: 768px) {

    /* 让 body 可以滚动（移动端不锁overflow） */
    body { overflow: auto; height: auto; }
    .layout { height: auto; min-height: 100dvh; flex-direction: column; overflow: visible; }

    /* 主内容不再固定高度 */
    .main { overflow: visible; flex: none; }
    .results-wrap { overflow: visible; }

    /* ---- 侧边栏变为左侧抽屉 ---- */
    .sidebar {
        position: fixed;
        left: 0; top: 0; bottom: 0;
        width: 80vw;
        max-width: 300px;
        min-width: 0;
        transform: translateX(-100%);
        z-index: 200;
        border-radius: 0 16px 16px 0;
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .sidebar-close { display: block; }

    /* ---- 顶部栏 ---- */
    .menu-btn { display: block; }
    .top-bar {
        padding: 10px 14px;
        gap: 8px;
    }
    .top-bar h1 { font-size: 16px; }
    .stats-bar { font-size: 11px; }
    /* 顶栏此时已经很挤：帮助只留圆形图标 */
    .help-btn { padding: 5px 9px; }
    .help-btn-txt { display: none; }

    /* ---- 搜索区竖向排列 ---- */
    .search-wrap { padding: 10px 12px; }
    .search-row {
        flex-wrap: wrap;
        gap: 8px;
    }
    .search-row input[type="text"] {
        width: 100%;
        flex: none;
        font-size: 16px; /* 防止iOS自动缩放 */
    }
    .toggle-label { font-size: 13px; }
    .btn-search {
        flex: 1;
        padding: 11px;
        font-size: 15px;
        text-align: center;
    }
    .btn-clear {
        padding: 11px 14px;
        font-size: 15px;
    }

    /* ---- 结果列表更紧凑 ---- */
    .results-header { padding: 8px 12px; font-size: 12px; }
    .result-item { padding: 12px 12px; gap: 10px; }
    .result-icon { font-size: 20px; }
    .result-title { font-size: 15px; }
    .result-meta { font-size: 11px; gap: 8px; }
    .result-excerpt { font-size: 12px; }

    /* ---- 分页按钮更大 ---- */
    .pagination { padding: 12px 8px; gap: 5px; }
    .pagination button { padding: 8px 12px; font-size: 13px; min-width: 44px; }

    /* ---- 模态框全屏 ---- */
    .modal { padding: 0; align-items: flex-end; }
    .modal-box {
        border-radius: 16px 16px 0 0;
        max-width: 100%;
        max-height: 95dvh;
    }
    .modal-header { padding: 14px 14px 10px; }
    .modal-header h2 { font-size: 16px; }
    .modal-actions button, .modal-actions a {
        padding: 8px 12px;
        font-size: 13px;
    }
    .modal-content { font-size: 15px; line-height: 1.9; padding: 14px; }
    .modal-search { padding: 7px 14px; }
    .modal-search input { font-size: 15px; }
    .modal-footer { padding: 6px 14px; font-size: 11px; }
}

/* 更小屏幕（≤ 390px，iPhone SE等） */
@media (max-width: 390px) {
    .top-bar h1 { font-size: 14px; }
    .result-title { font-size: 14px; }
    .btn-search { font-size: 14px; }
}

/* ===== 页脚 ===== */
.site-footer {
    padding: 12px 16px;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    text-align: center;
    font-size: 12px;
    flex-shrink: 0;
}

.footer-links {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    flex-wrap: wrap;
}

.footer-links a {
    color: var(--gold);
    text-decoration: none;
}

.footer-links a:hover {
    text-decoration: underline;
}

.footer-links .divider {
    color: rgba(255,255,255,0.3);
}

.footer-links .contact,
.footer-links .icp {
    color: rgba(255,255,255,0.6);
}

.copyright {
    color: rgba(255,255,255,0.4);
    font-size: 11px;
}

/* 移动端页脚适配 */
@media (max-width: 480px) {
    .site-footer {
        padding: 10px 12px;
        font-size: 11px;
    }
    .footer-links {
        flex-direction: column;
        gap: 4px;
    }
    .footer-links .divider {
        display: none;
    }
}

/* ===== 隐私政策模态框 ===== */
.privacy-box {
    max-width: 600px;
    max-height: 80vh;
}

.privacy-box .modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.privacy-box .modal-header h2 {
    margin: 0;
    font-size: 18px;
}

.privacy-box .close-btn {
    background: none;
    border: none;
    color: var(--muted);
    cursor: pointer;
    padding: 6px 12px;
    font-size: 14px;
}

.privacy-box .close-btn:hover {
    color: var(--text);
}

.privacy-content {
    padding: 20px;
    max-height: calc(80vh - 60px);
    overflow-y: auto;
    text-align: left;
}

.privacy-content h3 {
    color: var(--brown);
    font-size: 15px;
    margin: 16px 0 8px;
}

.privacy-content h3:first-child {
    margin-top: 0;
}

.privacy-content p {
    color: var(--text);
    font-size: 14px;
    line-height: 1.7;
    margin: 6px 0;
}

@media (max-width: 480px) {
    .privacy-box {
        max-width: 100%;
        max-height: 90vh;
        border-radius: 16px 16px 0 0;
    }
    .privacy-content {
        padding: 14px;
        max-height: calc(90vh - 60px);
    }
    .privacy-content h3 {
        font-size: 14px;
    }
    .privacy-content p {
        font-size: 13px;
    }
}

/* ============================================================
   AI 智能助手组件样式
   ============================================================ */

/* ----- 悬浮按钮 FAB ----- */
.ai-fab {
    position: fixed;
    right: 24px;
    bottom: 30px;
    width: 54px;
    height: 54px;
    background: linear-gradient(135deg, #8b5e2a, #c8922a);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 18px rgba(139,94,42,0.45);
    z-index: 1200;
    transition: transform 0.2s, box-shadow 0.2s;
    user-select: none;
}
.ai-fab:hover { transform: scale(1.1); box-shadow: 0 6px 24px rgba(139,94,42,0.6); }
.ai-fab.active { transform: scale(0.95); }
.ai-fab-icon { font-size: 26px; line-height: 1; }
.ai-fab-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    background: #e53e3e;
    color: #fff;
    font-size: 11px;
    font-weight: bold;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
}

/* ----- AI 对话面板 ----- */
.ai-panel {
    position: fixed;
    right: 24px;
    bottom: 96px;
    width: 360px;
    max-height: 520px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.22);
    display: flex;
    flex-direction: column;
    z-index: 1200;
    overflow: hidden;
    transform: scale(0.92) translateY(20px);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.22s cubic-bezier(.4,0,.2,1), opacity 0.22s;
}
.ai-panel.open {
    transform: scale(1) translateY(0);
    opacity: 1;
    pointer-events: auto;
}

/* 面板头部 */
.ai-panel-header {
    background: linear-gradient(135deg, #2c2416, #5a3e1b);
    padding: 12px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}
.ai-panel-title {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #fff;
    font-size: 16px;
}
.ai-name { font-weight: bold; font-size: 14px; color: #f5e09a; }
.ai-status { font-size: 11px; color: rgba(255,255,255,0.65); }
.ai-panel-actions { display: flex; gap: 6px; }
.ai-panel-actions button {
    background: rgba(255,255,255,0.15);
    border: none;
    color: #fff;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}
.ai-panel-actions button:hover { background: rgba(255,255,255,0.3); }

/* 消息区 */
.ai-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px 12px 4px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
}
.ai-msg { display: flex; max-width: 88%; }
.ai-msg-user { align-self: flex-end; justify-content: flex-end; }
.ai-msg-bot  { align-self: flex-start; }
.ai-bubble {
    padding: 9px 13px;
    border-radius: 14px;
    font-size: 13.5px;
    line-height: 1.65;
    word-break: break-word;
}
.ai-msg-bot .ai-bubble {
    background: #f4f1eb;
    color: #2c2416;
    border-bottom-left-radius: 4px;
}
.ai-msg-user .ai-bubble {
    background: linear-gradient(135deg, #8b5e2a, #c8922a);
    color: #fff;
    border-bottom-right-radius: 4px;
}

/* 打字动画 */
.ai-typing { display: flex; align-items: center; gap: 5px; padding: 12px 14px; }
.ai-typing span {
    width: 7px; height: 7px;
    background: #8c7755;
    border-radius: 50%;
    animation: aiDot 1.2s infinite;
}
.ai-typing span:nth-child(2) { animation-delay: 0.2s; }
.ai-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes aiDot {
    0%, 80%, 100% { transform: scale(0.7); opacity: 0.5; }
    40%           { transform: scale(1);   opacity: 1; }
}

/* 快捷按钮 */
.ai-quick-btns {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 6px 12px;
    flex-shrink: 0;
}
.ai-quick-btns button {
    background: #f4f1eb;
    border: 1px solid #d5c9a8;
    border-radius: 20px;
    padding: 5px 12px;
    font-size: 12px;
    color: #5a3e1b;
    cursor: pointer;
    transition: background 0.15s;
    font-family: inherit;
}
.ai-quick-btns button:hover { background: #e8dfc8; }

/* 输入框区 */
.ai-input-row {
    display: flex;
    padding: 10px 12px;
    gap: 8px;
    border-top: 1px solid #f0e8c8;
    flex-shrink: 0;
    background: #fffdf5;
}
.ai-input-row input {
    flex: 1;
    border: 1.5px solid #d5c9a8;
    border-radius: 22px;
    padding: 8px 14px;
    font-size: 13px;
    background: #faf7f0;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}
.ai-input-row input:focus { border-color: #8b6914; }
.ai-input-row button {
    background: linear-gradient(135deg, #8b5e2a, #c8922a);
    color: #fff;
    border: none;
    border-radius: 22px;
    padding: 8px 18px;
    font-size: 13px;
    cursor: pointer;
    font-family: inherit;
    transition: opacity 0.15s;
    white-space: nowrap;
}
.ai-input-row button:hover:not(:disabled) { opacity: 0.88; }
.ai-input-row button:disabled { opacity: 0.5; cursor: not-allowed; }

/* ----- 阅读页 AI 分析面板（折叠版，详见文件末尾样式区） ----- */

/* ----- 移动端适配 ----- */
@media (max-width: 480px) {
    .ai-panel {
        right: 0;
        bottom: 0;
        width: 100%;
        max-height: 85dvh;
        border-radius: 20px 20px 0 0;
    }
    .ai-fab {
        right: 16px;
        bottom: 20px;
        width: 48px;
        height: 48px;
    }
    .ai-fab-icon { font-size: 22px; }
}

/* ============================================================
   阅读器工具栏（注音 / 翻译开关）
   ============================================================ */
.modal-search {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 20px;
    background: var(--hover);
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}
.modal-search input[type="text"] {
    flex: 1;
    min-width: 120px;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    background: var(--white);
}
/* ============================================================
   内嵌评论区（评论按钮下方展开）
   ============================================================ */
.inline-comment-box {
    margin-top: 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fffdf5;
    overflow: hidden;
    animation: slideDown .2s ease;
}
@keyframes slideDown {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}
.inline-comment-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: linear-gradient(135deg, var(--brown) 0%, #8B4513 100%);
    color: #fff;
    font-size: 14px;
    font-weight: bold;
}
.inline-comment-title { color: #fff; }
.btn-comment-add {
    background: var(--gold);
    color: var(--brown-dark);
    border: none;
    border-radius: 6px;
    padding: 5px 10px;
    font-size: 13px;
    cursor: pointer;
    font-weight: bold;
}
.btn-comment-add:hover { background: var(--gold-light); }

/* 评论按钮激活态 */
#btnComment.active {
    background: var(--brown);
    color: #fff;
    border-color: var(--brown);
}

.comment-list {
    max-height: 340px;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.comment-item {
    background: var(--hover);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 14px;
}
.comment-book {
    font-size: 13px;
    font-weight: bold;
    color: var(--brown);
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px dashed var(--border);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.comment-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 6px;
    font-size: 12px;
    color: var(--muted);
}
.comment-author { font-weight: bold; color: var(--brown); }
.comment-content { font-size: 14px; line-height: 1.7; color: var(--text); }
.comment-empty, .comment-loading {
    text-align: center;
    color: var(--muted);
    padding: 30px 0;
    font-size: 14px;
}
.comment-more {
    padding: 10px;
    text-align: center;
}
.comment-more button {
    background: none;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 6px 20px;
    cursor: pointer;
    font-size: 13px;
    color: var(--brown);
}
.comment-more button:hover { background: var(--hover); }



/* ============================================================
   反馈表单模态框
   ============================================================ */
.feedback-box {
    max-width: 520px;
    width: 92%;
}
.feedback-form { padding: 16px 20px 20px; }
.fb-row {
    margin-bottom: 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.fb-row label {
    font-size: 13px;
    color: var(--muted);
    font-weight: bold;
}
.required { color: #e53935; }
.fb-type-tabs {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.fb-tab {
    padding: 6px 14px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: var(--white);
    font-size: 13px;
    cursor: pointer;
    color: var(--brown);
    transition: all .15s;
}
.fb-tab.active {
    background: var(--brown);
    color: var(--white);
    border-color: var(--brown);
}
.fb-row input[type="text"],
.fb-row textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    background: var(--input-bg);
    color: var(--text);
    resize: vertical;
    transition: border-color .15s;
}
.fb-row input:focus,
.fb-row textarea:focus {
    outline: none;
    border-color: var(--gold);
}
.fb-char-count {
    font-size: 11px;
    color: var(--muted);
    text-align: right;
}
.fb-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 4px;
}
.btn-cancel {
    padding: 8px 18px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--white);
    cursor: pointer;
    font-size: 14px;
    color: var(--muted);
}
.btn-submit {
    padding: 8px 22px;
    border: none;
    border-radius: 8px;
    background: var(--brown);
    color: var(--white);
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    transition: background .15s;
}
.btn-submit:hover { background: var(--brown-dark); }
.btn-submit:disabled { opacity: .6; cursor: not-allowed; }

/* 页脚反馈链接 */
.footer-link {
    color: var(--muted);
    text-decoration: none;
    font-size: 12px;
    transition: color .15s;
}
.footer-link:hover { color: var(--brown); }

/* Toast 提示 */
.toast-msg {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: rgba(44,36,22,.88);
    color: #fff;
    padding: 10px 22px;
    border-radius: 24px;
    font-size: 14px;
    opacity: 0;
    transition: all .35s;
    z-index: 9999;
    pointer-events: none;
    white-space: nowrap;
}
.toast-msg.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* 移动端适配 */
@media (max-width: 600px) {
    .feedback-box { max-width: 100%; width: 96%; }
    .modal-search { gap: 6px; }
    .comment-list { max-height: 260px; }
}

/* ============================================================
   快捷功能入口栏（热搜榜 / 最新反馈 / 体质测试）
   ============================================================ */
.quick-entry-bar {
    display: flex;
    gap: 8px;
    padding: 10px 16px;
    background: var(--white);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.quick-entry-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 8px 10px;
    background: var(--bg);
    border: 1.5px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    font-size: 13px;
    color: var(--brown);
    font-family: inherit;
    transition: all 0.18s;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    white-space: nowrap;
    overflow: hidden;
}
.quick-entry-btn:hover { background: var(--hover); border-color: var(--gold); }
.quick-entry-btn.active {
    background: var(--brown);
    color: #f5e6c8;
    border-color: var(--brown);
}
.quick-entry-btn.active .qe-arrow { color: #f5e6c8; }
.quick-entry-btn.has-data .qe-icon::after {
    content: '';
    display: inline-block;
    width: 6px; height: 6px;
    background: #e53935;
    border-radius: 50%;
    vertical-align: top;
    margin-left: -4px;
    margin-top: -1px;
}

.qe-icon { font-size: 16px; flex-shrink: 0; }
.qe-label { font-size: 13px; font-weight: 500; }
.qe-count {
    font-size: 11px;
    color: var(--muted);
    background: var(--tag-bg);
    border-radius: 8px;
    padding: 1px 5px;
    line-height: 1.4;
    flex-shrink: 0;
}
.quick-entry-btn.active .qe-count { background: rgba(255,255,255,0.2); color: #f5e6c8; }
.qe-arrow {
    font-size: 12px;
    color: var(--muted);
    margin-left: auto;
    flex-shrink: 0;
    transition: color 0.15s;
}

/* 展开面板 */
.quick-panel {
    background: var(--white);
    border-bottom: 1px solid var(--border);
    padding: 12px 16px;
    animation: qpSlideDown 0.18s ease;
    flex-shrink: 0;
}
@keyframes qpSlideDown {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* 热搜榜面板 */
.quick-panel .hotkeywords-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

/* 反馈面板工具栏 */
.qp-feedback-toolbar {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 10px;
}

/* 反馈面板列表 */
.quick-panel .feedback-list {
    max-height: 320px;
    overflow-y: auto;
    padding: 0;
}

/* 体质测试面板 */
.quick-panel-const { padding: 10px 16px; }
.quick-panel-const .constitution-link {
    display: flex;
    align-items: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 10px;
    padding: 14px 16px;
    text-decoration: none;
    color: white;
    gap: 12px;
}
.quick-panel-const .constitution-icon { font-size: 28px; flex-shrink: 0; }
.quick-panel-const .constitution-text { flex: 1; display: flex; flex-direction: column; gap: 3px; }
.quick-panel-const .constitution-title { font-size: 15px; font-weight: bold; }
.quick-panel-const .constitution-desc { font-size: 12px; opacity: 0.9; }

/* 移动端快捷栏自适应 */
@media (max-width: 480px) {
    .quick-entry-bar { gap: 6px; padding: 8px 12px; }
    .quick-entry-btn { padding: 7px 6px; font-size: 12px; gap: 3px; }
    .qe-label { font-size: 12px; }
    .qe-icon { font-size: 15px; }
    .qe-arrow { display: none; }
}

/* ============================================================
   AI 分析面板 — 折叠版
   ============================================================ */
.ai-analysis-panel {
    background: linear-gradient(135deg, #fefcf4, #fdf6e3);
    border-bottom: 1px solid #e8dfc8;
    font-size: 13px;
    flex-shrink: 0;
    display: none;
}

/* 折叠标题行（始终显示） */
.ai-analysis-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 9px 16px;
    cursor: pointer;
    user-select: none;
    font-weight: bold;
    color: #5a3e1b;
    font-size: 13.5px;
    -webkit-tap-highlight-color: transparent;
}
.ai-analysis-toggle:hover { background: rgba(200,184,122,0.12); }
.ai-analysis-toggle-arrow {
    font-size: 12px;
    color: #8c7755;
    transition: transform 0.2s;
    flex-shrink: 0;
}
.ai-analysis-panel.expanded .ai-analysis-toggle-arrow {
    transform: rotate(180deg);
}

/* 折叠内容区 */
.ai-analysis-body {
    display: none;
    padding: 0 16px 12px;
    border-top: 1px dashed #e8dfc8;
}
.ai-analysis-panel.expanded .ai-analysis-body {
    display: block;
}

.ai-analysis-summary { color: #3d2b0a; line-height: 1.6; margin-bottom: 7px; }
.ai-analysis-tags    { margin-bottom: 7px; }
.ai-analysis-rec     { margin-bottom: 7px; }
.ai-analysis-tips {
    color: #6b5530;
    font-size: 12px;
    line-height: 1.55;
    border-top: 1px dashed #e8dfc8;
    padding-top: 7px;
    margin-top: 4px;
}
.ai-analysis-loading {
    color: #8c7755;
    font-size: 13px;
    padding: 4px 0;
    display: flex;
    align-items: center;
    gap: 6px;
}
.ai-tag {
    display: inline-block;
    background: #f0e8c8;
    color: #5a3e1b;
    border-radius: 12px;
    padding: 2px 9px;
    font-size: 11.5px;
    margin: 2px 3px 2px 0;
}
.ai-rec-item {
    display: inline-block;
    background: #fff3cd;
    color: #8b5e2a;
    border: 1px solid #c8922a;
    border-radius: 12px;
    padding: 3px 10px;
    font-size: 12px;
    margin: 2px 4px 2px 0;
    cursor: pointer;
    transition: background 0.15s;
}
.ai-rec-item:hover { background: #ffe69c; }


/* AI 分析按钮激活态 */
#btnToggleAI.active {
    background: #5a3e1b !important;
    color: #f5e6c8 !important;
    border-color: #5a3e1b !important;
}

/* ===== v2.0 语义搜索 ===== */
.btn-semantic {
    padding: 8px 12px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    white-space: nowrap;
    transition: opacity 0.2s, transform 0.15s;
}
.btn-semantic:hover { opacity: 0.88; transform: translateY(-1px); }
.btn-semantic:active { transform: translateY(0); }

.semantic-badge {
    text-align: center;
    color: #667eea;
    font-size: 13px;
    font-weight: 600;
    padding: 8px 0 4px;
    letter-spacing: 1px;
}

.semantic-item {
    position: relative;
    animation: fadeInUp 0.3s ease forwards;
    opacity: 0;
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.semantic-score {
    position: absolute;
    top: 12px;
    right: 12px;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
    white-space: nowrap;
}

.semantic-label {
    font-size: 12px;
    font-weight: 600;
}

/* ===== 智能检索（✨）===== */

/* 旧版语义按钮：故意做得不起眼。它保留的唯一目的是当场演示
   「改造前点了报 Qdrant 未启动」，不是给日常用的。 */
.btn-legacy {
    padding: 8px 10px;
    background: transparent;
    color: #9a8f7a;
    border: 1px dashed #c9bda2;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    white-space: nowrap;
}
.btn-legacy:hover { color: #6b604d; border-color: #9a8f7a; }

.smart-head {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    padding: 6px 2px 8px;
}
.route-chip {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 12px;
    white-space: nowrap;
}
.degraded-chip {
    background: #fff4e0;
    color: #b26a00;
    border: 1px solid #f0c98a;
    font-size: 12px;
    padding: 3px 10px;
    border-radius: 12px;
}
.smart-time { font-size: 12px; color: #999; }

.smart-notice {
    background: #fdf8ec;
    border-left: 3px solid #e0b96b;
    color: #7a6a4a;
    font-size: 13px;
    line-height: 1.6;
    padding: 8px 12px;
    border-radius: 4px;
    margin-bottom: 10px;
}

.smart-item .result-title {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.match-tag {
    font-size: 11px;
    font-weight: 600;
    padding: 1px 7px;
    border-radius: 9px;
    white-space: nowrap;
}
/* 四类命中用四套颜色，**措辞与颜色都必须严格对应**：
   只有 m-hit / m-literal 是真的命中了原文，其余三种都不是。 */
.match-tag.m-hit     { background: #e6f4ea; color: #1e7e34; }
.match-tag.m-literal { background: #e8ecfb; color: #3b4fa8; }
.match-tag.m-mention { background: #eaf3fb; color: #1a6fa8; }
.match-tag.m-weak    { background: #f2f2f2; color: #888; }
.match-tag.m-book    { background: #f7f1fb; color: #7b5ea7; }

.smart-score { margin-left: auto; font-size: 12px; font-weight: 700; color: #667eea; }

/* 「仅片段」「语义相近」整条压灰：它们没有位置信息，不该与真命中同权重呈现 */
.smart-item.m-weak, .smart-item.m-book { opacity: 0.82; }

.cite-label {
    font-size: 12px;
    color: #8a6d3b;
    background: #fbf6e9;
    border-left: 2px solid #e0c78a;
    padding: 3px 8px;
    margin: 6px 0;
    border-radius: 3px;
    word-break: break-all;
}

.score-bar {
    position: relative;
    display: flex;
    height: 6px;
    border-radius: 3px;
    overflow: hidden;
    margin: 8px 0 20px;
    background: #eee;
}
.sb-seg { display: block; height: 100%; }
.sb-sem { background: #667eea; }
.sb-lex { background: #4caf50; }
.sb-pri { background: #ffb74d; }
.sb-legend {
    position: absolute;
    top: 8px;
    left: 0;
    font-size: 11px;
    color: #aaa;
    white-space: nowrap;
}
.smart-note { font-size: 11px; color: #aaa; margin: 6px 0; }

.exhaustive-cta {
    background: #f6f8ff;
    border: 1px solid #ccd6f6;
    border-radius: 8px;
    padding: 14px 16px;
    margin-top: 14px;
}
.ec-title { font-size: 14px; color: #2f3f74; margin-bottom: 6px; }
.ec-body { font-size: 12px; color: #5c678f; line-height: 1.7; margin-bottom: 10px; }
.btn-exhaustive {
    padding: 8px 14px;
    background: linear-gradient(135deg, #4a5fc1 0%, #6b46a8 100%);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
}
.btn-exhaustive:hover { opacity: 0.9; }

/* ===== AI 归纳卡（P3）。刻意排在原文结果之后：原文优先 = 防幻觉的产品层表达 ===== */
.btn-ai-answer {
    margin-left: auto;          /* 推到 .smart-head 最右，与检索元信息分开 */
    padding: 6px 12px;
    background: linear-gradient(135deg, #6b46a8 0%, #4a5fc1 100%);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    white-space: nowrap;
}
.btn-ai-answer:hover { opacity: 0.9; }
.btn-ai-answer:disabled { opacity: 0.55; cursor: default; }

.ai-card {
    margin: 14px 0 20px;
    padding: 14px 16px;
    background: #faf9fd;
    border: 1px solid #ddd6ee;
    border-left: 4px solid #6b46a8;
    border-radius: 8px;
}
.ai-card-loading { color: #6b46a8; font-size: 13px; }
.ai-card-err { background: #fff8f6; border-color: #f0d6cc; border-left-color: #c0563a; }

.ai-head { font-size: 14px; font-weight: 600; color: #3d2f5c; margin-bottom: 8px; }
.ai-note { font-size: 11px; font-weight: 400; color: #9a91ac; }

.ai-body {
    font-size: 14px;
    line-height: 1.9;
    color: #3a3a3a;
    white-space: pre-wrap;      /* 模型爱用换行分段，保留它，别把段落挤成一坨 */
    word-break: break-word;
}

/* 引用角标：可点的跳原文，核不过的灰掉且不可点 */
.cite-mark {
    color: #6b46a8;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    padding: 0 1px;
    vertical-align: super;
    line-height: 0;
}
.cite-mark:hover { text-decoration: underline; }
.cite-mark.unverified {
    color: #b8b2c4;
    cursor: help;
    text-decoration: line-through;
}

.ai-warn {
    margin-top: 10px; padding: 8px 10px;
    background: #fff6e8; border-radius: 6px;
    font-size: 12px; color: #8a6a2f; line-height: 1.6;
}
.ai-ok { margin-top: 10px; font-size: 12px; color: #4a8a5c; }
.ai-err-body { font-size: 13px; line-height: 1.8; color: #8a4a34; }
.ai-err-note { font-size: 12px; color: #a08a80; }

.semantic-snippet {
    font-size: 13px;
    line-height: 1.7;
    color: #555;
    border-left: 3px solid #667eea;
    padding-left: 10px;
    margin-top: 4px;
}

.btn-read-semantic {
    margin-top: 6px;
    padding: 4px 12px;
    background: var(--gold-light);
    border: 1px solid var(--gold);
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    color: var(--brown);
    transition: background 0.15s;
}
.btn-read-semantic:hover { background: var(--gold); color: #fff; }

/* ===== v2.0 深度分析面板 ===== */
#btnDeepAnalyze {
    padding: 6px 12px;
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    white-space: nowrap;
    transition: opacity 0.2s;
}
#btnDeepAnalyze:hover { opacity: 0.88; }

.deep-analysis-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.6);
    z-index: 2000;
    backdrop-filter: blur(4px);
}
.deep-analysis-overlay.open { display: flex; justify-content: center; align-items: center; }

.deep-analysis-box {
    background: var(--white);
    border-radius: 16px;
    width: 90%;
    max-width: 800px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    animation: modalIn 0.25s ease;
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.deep-analysis-header {
    padding: 16px 20px 12px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.deep-analysis-header h2 {
    font-size: 18px;
    color: var(--brown);
    margin-bottom: 4px;
}
.deep-analysis-meta {
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 8px;
}
.deep-analysis-actions {
    display: flex;
    gap: 8px;
}

.btn-deep-run {
    padding: 6px 16px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    font-weight: 600;
}
.btn-deep-run:hover { opacity: 0.9; }
.btn-deep-run:disabled { opacity: 0.5; cursor: wait; }

.btn-deep-note {
    padding: 6px 14px;
    background: #e8f5e9;
    color: #2e7d32;
    border: 1px solid #a5d6a7;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
}

.btn-deep-close {
    margin-left: auto;
    padding: 6px 12px;
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
}

.deep-analysis-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    padding: 0 16px;
    flex-shrink: 0;
}

.deep-tab {
    padding: 10px 16px;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    font-size: 14px;
    color: var(--muted);
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}
.deep-tab:hover { color: var(--text); }
.deep-tab.active {
    color: #667eea;
    border-bottom-color: #667eea;
    font-weight: 600;
}

.deep-analysis-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
}

.deep-analysis-placeholder {
    text-align: center;
    color: var(--muted);
    padding: 40px 20px;
}
.deep-placeholder-icon {
    font-size: 48px;
    margin-bottom: 12px;
}
.deep-analysis-placeholder textarea {
    width: 100%;
    margin-top: 16px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    line-height: 1.7;
    resize: vertical;
    font-family: "SimSun", "Microsoft YaHei", serif;
    background: var(--input-bg);
}

.deep-options {
    display: flex;
    gap: 16px;
    justify-content: center;
    margin-top: 12px;
    font-size: 13px;
}
.deep-option {
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
}

/* 加载动画 */
.deep-analysis-loading-box {
    text-align: center;
    padding: 60px 20px;
    color: var(--muted);
}
.deep-loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #eee;
    border-top-color: #667eea;
    border-radius: 50%;
    margin: 0 auto 16px;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.deep-loading-text { font-size: 16px; margin-bottom: 12px; }
/* 首次分析要先做一次全库精查（约 1 分钟）。不写清楚的话，用户盯着转圈
   一分钟只会以为死机了，然后去刷新——刷新等于把已经跑完的分析丢掉。 */
.deep-loading-hint { font-size: 13px; color: #888; margin-bottom: 12px; }
.deep-loading-agents { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.deep-agent-badge {
    background: #f0e8c8;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
}

/* Agent 结果卡片 */
.deep-agent-result {
    margin-bottom: 20px;
}
.deep-agent-title {
    font-size: 16px;
    color: var(--brown);
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 2px solid var(--gold-light);
}

.deep-thinking {
    margin-bottom: 12px;
}
.deep-thinking summary {
    cursor: pointer;
    color: var(--muted);
    font-size: 13px;
    padding: 6px 10px;
    background: #f9f7f2;
    border-radius: 6px;
}
.deep-thinking pre {
    margin-top: 8px;
    padding: 12px;
    background: #1e1e2e;
    color: #cdd6f4;
    border-radius: 8px;
    font-size: 12px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 300px;
    overflow-y: auto;
}

.deep-result-text {
    font-size: 14px;
    line-height: 1.8;
    color: #333;
}
.deep-result-text p { margin-bottom: 8px; }
.deep-result-text strong { color: var(--brown); }

.deep-section {
    margin-bottom: 14px;
}
.deep-section h4 {
    font-size: 14px;
    color: var(--brown);
    margin-bottom: 6px;
}
.deep-section p {
    font-size: 14px;
    line-height: 1.7;
}
.deep-section ul {
    padding-left: 20px;
    font-size: 14px;
    line-height: 1.8;
}

.deep-glossary {
    margin-bottom: 14px;
}
.deep-glossary h4 { margin-bottom: 8px; }
.deep-glossary table {
    width: 100%;
    border-collapse: collapse;
}
.deep-glossary td {
    padding: 6px 10px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
    vertical-align: top;
}
.gloss-term {
    font-weight: 600;
    color: var(--brown);
    width: 100px;
    white-space: nowrap;
}

.deep-verdict {
    font-size: 15px;
    margin-bottom: 6px;
}
.deep-refs {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
}
.deep-refs ul {
    padding-left: 18px;
    font-size: 13px;
    color: var(--muted);
}

.deep-error-item {
    background: #fff5f5;
    border: 1px solid #ffd7d7;
    border-radius: 6px;
    padding: 10px 12px;
    margin-bottom: 10px;
    font-size: 14px;
    line-height: 1.7;
}
.deep-error-header {
    margin-bottom: 4px;
}
.deep-error-content {
    color: #555;
}
.deep-error-correction {
    color: #2e7d32;
    font-weight: 500;
    margin-top: 2px;
}
.deep-evidence {
    color: var(--muted);
    font-size: 13px;
    margin-top: 2px;
}

/* 参考来源（三个 Agent 的 I*/C*/H* 引用） */
.deep-cites {
    margin-top: 14px;
    border-top: 1px dashed #e0d6b8;
    padding-top: 10px;
}
.deep-cites h4 {
    font-size: 14px;
    color: var(--brown);
    margin-bottom: 6px;
}
.deep-cites ul { list-style: none; padding-left: 0; }
.deep-cites li { margin-bottom: 5px; font-size: 13px; line-height: 1.5; }
.deep-cites a { color: #2f5d8a; text-decoration: none; }
.deep-cites a:hover { text-decoration: underline; }
.cite-no {
    display: inline-block;
    min-width: 26px;
    margin-right: 6px;
    padding: 0 5px;
    border-radius: 3px;
    background: #f0e8c8;
    color: #7a5c1e;
    font-size: 12px;
    text-align: center;
}

/* 逐句解析 / 已知人物明细 */
.deep-sent { list-style: none; padding-left: 0; }
.deep-sent li { margin-bottom: 8px; }
.deep-sent-src { color: var(--brown); }
.deep-sent-mean { color: #444; font-size: 13px; margin-top: 2px; }
.deep-known { list-style: none; padding-left: 0; }
.deep-known li { margin-bottom: 8px; }
.deep-known-detail { color: var(--muted); font-size: 13px; margin-top: 2px; }
.gloss-src { color: var(--muted); font-size: 12px; }

/* 综合摘要 */
.deep-summary-box h3 {
    font-size: 16px;
    color: var(--brown);
    margin-bottom: 12px;
}
.summary-item {
    display: flex;
    justify-content: space-between;
    padding: 10px 14px;
    background: #f9f7f2;
    border-radius: 8px;
    margin-bottom: 6px;
    cursor: pointer;
    transition: background 0.15s;
    font-size: 14px;
}
.summary-item:hover { background: var(--hover); }

.summary-excerpt {
    margin-top: 14px;
    padding: 12px;
    background: #faf7f0;
    border-radius: 8px;
    border-left: 4px solid var(--gold);
    font-size: 14px;
    line-height: 1.7;
}
.summary-warn { border-left-color: #f5576c; }

/* 底部状态栏 */
.deep-analysis-footer {
    display: flex;
    justify-content: space-between;
    padding: 8px 20px;
    border-top: 1px solid var(--border);
    font-size: 12px;
    color: var(--muted);
    flex-shrink: 0;
}
.deep-cache-tag {
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
}
.cache-hit { background: #e8f5e9; color: #2e7d32; }
.cache-fresh { background: #e3f2fd; color: #1565c0; }

/* 手机端适配 */
@media (max-width: 768px) {
    .deep-analysis-box {
        width: 96%;
        max-height: 90vh;
        border-radius: 12px 12px 0 0;
        align-self: flex-end;
    }
    .deep-analysis-overlay.open {
        align-items: flex-end;
    }
    .deep-analysis-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .deep-tab { padding: 8px 12px; font-size: 13px; }
    .btn-semantic { padding: 6px 8px; font-size: 12px; }
    /* 旧版对照按钮在窄屏收成纯图标，免得把搜索行挤到换行 */
    .btn-legacy { padding: 6px 7px; font-size: 12px; }
    .route-chip, .degraded-chip { font-size: 11px; padding: 2px 8px; }
    #btnDeepAnalyze { padding: 4px 8px; font-size: 12px; }
}
