/* ===== 全局重置 ===== */
*, *::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;
}

/* ===== 搜索区 ===== */
.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; }

    /* ---- 搜索区竖向排列 ---- */
    .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;
}
