/* ==========================================================================
   方志揽胜 —— 中国古典风格样式（宣纸底 + 青蓝页头 + 描金点缀）
   设计变量与规格来自 SDD 计划 §9.6；字体全部走系统字体，不依赖外部 CDN。
   ========================================================================== */

:root {
    --primary: #3B6B8A;
    --primary-dark: #2C5066;
    --primary-light: #E8F0F5;
    --accent: #C49A6C;
    --accent-dark: #A67D52;
    --accent-light: #F6EDE0;
    --bg: #FAF7F2;
    --card: #FFFFFF;
    --text: #2C2C2C;
    --text-sub: #777777;
    --border: #E8E0D4;
    --shadow: 0 2px 12px rgba(59, 107, 138, 0.07);
    --shadow-hover: 0 6px 20px rgba(59, 107, 138, 0.14);
    --radius: 6px;
    /* 内容区宽度与左栏宽度：全站唯一来源，响应式断点也复用。
       左栏 288px：保证最长地名「黔东南苗族侗族自治州」与计数同时完整显示 */
    --content-width: 1200px;
    --sidebar-width: 288px;
    --header-height: 56px;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Noto Serif SC', '宋体', 'SimSun', 'Songti SC', serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.7;
    min-height: 100vh;
}

/* Vue 挂载完成前隐藏模板，避免闪现未渲染的 {{ }} */
[v-cloak] {
    display: none !important;
}

#app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

a {
    color: inherit;
    text-decoration: none;
}

button {
    font-family: inherit;
    cursor: pointer;
}

img,
svg,
canvas {
    max-width: 100%;
}

/* ==========================================================================
   顶部页头：青蓝渐变 + 标题 + 三栏目
   ========================================================================== */

.app-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: linear-gradient(135deg, #2C5066 0%, #3B6B8A 52%, #4A7D9E 100%);
    box-shadow: 0 2px 16px rgba(44, 80, 102, 0.25);
}

.header-inner {
    max-width: var(--content-width);
    margin: 0 auto;
    padding: 0 20px;
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.app-logo {
    display: inline-flex;
    align-items: baseline;
    gap: 10px;
    color: #FFFFFF;
    line-height: 1;
    cursor: pointer;
    white-space: nowrap;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
    transition: opacity 0.2s;
}

/* 主标题「方志揽胜」：手写体（优先华文行楷/行楷，回退到楷体与系统手写字体栈） */
.app-logo-main {
    font-family: '华文行楷', 'STXingkai', 'STKaiti', 'KaiTi', '楷体', 'Kaiti SC', cursive;
    font-size: 30px;
    font-weight: 500;
    letter-spacing: 2px;
}

/* 副标题「中国古代方志文献导览」：沿用全站正文字体，小字紧随其后 */
.app-logo-sub {
    font-family: inherit;
    font-size: 13px;
    font-weight: 400;
    letter-spacing: 1px;
    color: rgba(255, 255, 255, 0.86);
}

.app-logo:hover {
    opacity: 0.88;
}

.app-nav {
    display: flex;
    align-items: center;
    gap: 1px;
    flex-shrink: 0;
}

.nav-item {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 32px;
    padding: 0 12px;
    border-radius: 4px;
    color: rgba(255, 255, 255, 0.76);
    font-size: 14px;
    letter-spacing: 1px;
    line-height: 1;
    white-space: nowrap;
    transition: color 0.2s, background 0.2s;
}

.nav-item:hover {
    color: #FFFFFF;
    background: rgba(255, 255, 255, 0.12);
}

.nav-item.active {
    color: #FFFFFF;
    background: rgba(255, 255, 255, 0.2);
    font-weight: 600;
}

/* ==========================================================================
   主体布局
   ========================================================================== */

.app-main {
    flex: 1 0 auto;
    width: 100%;
    max-width: var(--content-width);
    margin: 0 auto;
    /* v1.5：上下内边距略收紧（原 20px），为时代 / 地图页图表多让出约 8px 高度 */
    padding: 18px 20px 14px;
}

.page {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

/* ==========================================================================
   数据概览条
   ========================================================================== */

.summary-strip {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 0;
    margin-bottom: 16px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.summary-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 14px 8px 12px;
    border-left: 1px solid var(--border);
    text-align: center;
}

.summary-item:first-child {
    border-left: none;
}

.summary-num {
    font-size: 24px;
    font-weight: 700;
    line-height: 1.25;
    color: var(--primary-dark);
    font-variant-numeric: tabular-nums;
}

.summary-label {
    margin-top: 2px;
    font-size: 13px;
    letter-spacing: 1px;
    color: var(--text-sub);
}

/* ==========================================================================
   检索条
   ========================================================================== */

.search-bar {
    margin-bottom: 16px;
    padding: 12px 16px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.search-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* v1.2：检索条件合并为「范围五档 + 单一输入框」，原「朝代年号 / 馆藏地」第二行已移除 */

.scope-select {
    flex: 0 0 auto;
    height: 36px;
    padding: 0 8px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: #FFFDF9;
    color: var(--text);
    font-family: inherit;
    font-size: 13px;
    cursor: pointer;
}

.scope-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(59, 107, 138, 0.12);
}

.search-input {
    flex: 1 1 auto;
    min-width: 0;
    height: 36px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: #FFFDF9;
    color: var(--text);
    font-family: inherit;
    font-size: 14px;
}

.search-input::placeholder {
    color: #B3AA9D;
}

.search-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(59, 107, 138, 0.12);
}

.btn-primary {
    flex: 0 0 auto;
    height: 36px;
    padding: 0 20px;
    border: 1px solid var(--primary);
    border-radius: 4px;
    background: var(--primary);
    color: #FFFFFF;
    font-size: 14px;
    letter-spacing: 2px;
    transition: background 0.2s, border-color 0.2s;
}

.btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
}

.btn-ghost {
    flex: 0 0 auto;
    height: 36px;
    padding: 0 14px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: transparent;
    color: var(--text-sub);
    font-size: 13px;
    transition: color 0.2s, border-color 0.2s;
}

.btn-ghost:hover {
    color: var(--accent-dark);
    border-color: var(--accent);
}

/* ==========================================================================
   导航页布局：左栏地域树 + 右栏结果
   ========================================================================== */

.nav-layout {
    display: grid;
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
    align-items: start;
    gap: 20px;
}

/* ---- 左栏地域树 ---- */

.sidebar {
    position: sticky;
    top: calc(var(--header-height) + 16px);
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - var(--header-height) - 36px);
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.sidebar-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(180deg, #FCFAF6 0%, #F7F3EC 100%);
}

.sidebar-title {
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 2px;
    color: var(--primary-dark);
}

.tree-toggle-btn {
    display: none;
    padding: 2px 8px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--card);
    color: var(--primary);
    font-size: 12px;
    line-height: 1.6;
}

.sidebar-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 8px 6px 12px;
}

.region-tree {
    list-style: none;
    margin: 0;
    padding: 0;
}

.tree-row {
    display: flex;
    align-items: center;
    min-height: 28px;
    padding-top: 2px;
    padding-bottom: 2px;
    padding-right: 6px;
    border-radius: 4px;
    font-size: 13px;
    line-height: 1.5;
    color: var(--text);
    cursor: pointer;
    transition: background 0.16s, color 0.16s;
}

.tree-row:hover {
    background: #F1F5F8;
    color: var(--primary-dark);
}

.tree-row.active {
    background: var(--primary-light);
    color: var(--primary-dark);
    font-weight: 600;
}

.tree-row.active .tree-count {
    color: var(--primary);
}

/* 通志 / 市辖区伪类目徽标：浅灰底 10px 小字，与真实行政区区分 */
.tree-kind {
    flex: 0 0 auto;
    margin-left: 6px;
    padding: 0 4px;
    border-radius: 2px;
    background: #F0ECE4;
    color: #8C8375;
    font-size: 10px;
    line-height: 16px;
    font-weight: 400;
    letter-spacing: 0;
    white-space: nowrap;
}

.tree-row.active .tree-kind {
    background: #DDE8EF;
    color: var(--primary-dark);
}

.tree-caret {
    flex: 0 0 14px;
    width: 14px;
    margin-right: 2px;
    text-align: center;
    font-size: 11px;
    color: #A79E90;
    cursor: pointer;
    user-select: none;
}

.tree-caret.placeholder {
    cursor: default;
}

.tree-name {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tree-count {
    flex: 0 0 auto;
    padding-left: 6px;
    font-size: 12px;
    color: #9A9184;
    font-variant-numeric: tabular-nums;
}

/* v1.2 全量区划树：count=0 的节点计数灰显「0」（节点仍可点击，列表给「暂无文献」空态） */
.tree-count.zero {
    color: #C3BBB0;
}

.tree-notice,
.tree-loading {
    margin: 8px 6px;
    padding: 8px 10px;
    border-radius: 4px;
    font-size: 12px;
    line-height: 1.6;
    color: var(--text-sub);
}

.tree-notice {
    color: #B4534B;
    background: #FBF2F0;
    border: 1px solid #EBD3CE;
}

/* ---- 右栏结果 ---- */

.result-panel {
    min-width: 0;
}

.result-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 6px 16px;
    margin-bottom: 12px;
    min-width: 0;
}

.breadcrumb {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 1px;
    font-size: 13px;
    color: var(--text-sub);
    min-width: 0;
}

.crumb {
    padding: 1px 4px;
    border-radius: 3px;
    color: var(--primary);
    cursor: pointer;
    transition: background 0.16s;
}

.crumb:hover {
    background: var(--primary-light);
}

.crumb.current {
    color: var(--text);
    font-weight: 600;
    cursor: default;
    background: none;
}

.crumb-sep {
    color: #C6BCAC;
    padding: 0 1px;
}

.result-count {
    font-size: 13px;
    color: var(--text-sub);
    /* 窄屏下「共 X 条」保持单行，检索词可换行，避免长检索词撑出横向滚动 */
    white-space: normal;
    overflow-wrap: anywhere;
    max-width: 100%;
    min-width: 0;
    text-align: right;
}

.result-total {
    white-space: nowrap;
}

.result-count b {
    padding: 0 2px;
    font-size: 16px;
    color: var(--accent-dark);
    font-variant-numeric: tabular-nums;
}

.result-query {
    color: var(--text-sub);
    white-space: normal;
    word-break: break-word;
    overflow-wrap: anywhere;
    min-width: 0;
}

/* 已生效条件 chip：单独一行，带 ✕ 可逐项清除（含时代页跳转带入的特殊口径） */
.result-chips {
    flex: 1 1 100%;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    max-width: 100%;
    padding: 1px 4px 1px 8px;
    border: 1px solid #E4D9C8;
    border-radius: 12px;
    background: #F8F3EA;
    color: #6E6455;
    font-size: 12px;
    line-height: 20px;
}

.chip-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chip-clear {
    flex: 0 0 auto;
    width: 18px;
    height: 18px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: #9A8F7D;
    font-size: 11px;
    line-height: 18px;
    transition: background 0.16s, color 0.16s;
}

.chip-clear:hover {
    background: #EADFCB;
    color: #B4534B;
}

.result-body {
    position: relative;
    min-height: 140px;
}

.loading-mask {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 44px 0;
    font-size: 14px;
    color: var(--text-sub);
}

.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.error-msg {
    margin: 0;
    padding: 24px 16px;
    border: 1px solid #EBD3CE;
    border-radius: var(--radius);
    background: #FBF2F0;
    color: #B4534B;
    font-size: 14px;
    text-align: center;
    word-break: break-word;
}

.empty-msg {
    margin: 0;
    padding: 48px 0;
    font-size: 14px;
    color: var(--text-sub);
    text-align: center;
}

/* ---- 书目卡片 ---- */

.book-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.book-card {
    padding: 14px 18px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.book-card:hover {
    transform: translateY(-2px);
    border-color: #DCCCB3;
    box-shadow: var(--shadow-hover);
}

/* 键盘 Tab 聚焦时给出清晰焦点环（卡片已加 role=button / tabindex=0） */
.book-card:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
    border-color: var(--primary);
}

.book-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
}

.book-title {
    margin: 0;
    font-size: 17px;
    font-weight: 600;
    line-height: 1.5;
    color: var(--text);
    word-break: break-word;
}

.book-type {
    flex: 0 0 auto;
    padding: 1px 8px;
    border: 1px solid transparent;
    border-radius: 10px;
    font-size: 12px;
    line-height: 1.65;
    white-space: nowrap;
}

/* 四类书目类型四色标识（简体数据；繁体值由前端归一） */
.book-type.type-single {
    color: #2F5F7E;
    background: #EAF2F7;
    border-color: #CFE0EA;
}

.book-type.type-combined {
    color: #8A6534;
    background: #F8F0E3;
    border-color: #EAD8BC;
}

.book-type.type-series-sub {
    color: #3F6E5C;
    background: #EAF4EF;
    border-color: #CFE5DA;
}

.book-type.type-series-main {
    color: #7A5560;
    background: #F5ECEF;
    border-color: #E6D2D9;
}

.book-type.type-other {
    color: #6B6B6B;
    background: #F2F0EC;
    border-color: #E2DCD2;
}

.book-agent {
    margin: 4px 0 0;
    font-size: 13px;
    color: #6E665C;
    word-break: break-word;
}

.book-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
    margin: 4px 0 0;
    font-size: 13px;
    color: var(--text-sub);
}

.book-region {
    color: #5B7A90;
}

.meta-dot {
    color: #C6BCAC;
}

.book-counts {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 16px;
    margin-top: 8px;
    font-size: 12px;
    color: var(--text-sub);
}

.book-count b {
    padding-left: 2px;
    color: var(--primary-dark);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   分页
   ========================================================================== */

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 20px;
}

.page-btn {
    min-width: 34px;
    height: 32px;
    padding: 0 10px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--card);
    color: var(--text);
    font-size: 13px;
    line-height: 1.6;
    transition: color 0.16s, border-color 0.16s, background 0.16s;
}

.page-btn:hover:not(:disabled) {
    border-color: var(--primary);
    color: var(--primary);
}

.page-btn.active {
    border-color: var(--primary);
    background: var(--primary);
    color: #FFFFFF;
}

.page-btn:disabled {
    background: #F7F4EF;
    color: #C0B9AE;
    cursor: not-allowed;
}

.page-ellipsis {
    padding: 0 2px;
    color: #A79E90;
    font-size: 13px;
}

.page-jump {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-left: 6px;
    font-size: 13px;
    color: var(--text-sub);
}

.page-jump input {
    width: 52px;
    height: 32px;
    padding: 0 6px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: #FFFDF9;
    color: var(--text);
    font-family: inherit;
    font-size: 13px;
    text-align: center;
}

.page-jump input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(59, 107, 138, 0.12);
}

/* ==========================================================================
   图表空壳页（Task 12 / Task 13 接入 ECharts）
   ========================================================================== */

.chart-box {
    padding: 18px 20px 20px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

/* v1.5：图表区放大（参考 yueju：.chart-box 16px 内边距 + 更大的图表内容区）。
   预留高度 192 → 146px，同时把主体上下内边距与页脚略收紧（56 + 18 + 14 + 10 + 48 = 146），
   1366×768 与 1440×900 下整页仍一屏；min-height 兜底，太矮的视口才允许滚动。 */
#page-era .chart-box,
#page-map .chart-box {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 146px);
    min-height: 540px;
    padding: 16px;
}

/* v1.6：地图页再让出 1px 高度（X 从 146 → 145），给放大的地图更多纵向空间；
   1440×900 / 1366×768 实测整页无纵向滚动（之前 -125 会溢出约 20px）。 */
#page-map .chart-box {
    height: calc(100vh - 145px);
}

.chart-title {
    margin: 0 0 14px;
    padding-left: 10px;
    border-left: 3px solid var(--accent);
    font-size: 16px;
    font-weight: 600;
    letter-spacing: 2px;
    color: var(--primary-dark);
}

.chart-body {
    width: 100%;
    min-height: 500px;
}

/* 时代页图表在 flex 容器里吃掉剩余高度（min-height 兜底，极端矮视口不致压扁） */
#page-era .chart-body {
    flex: 1 1 auto;
    min-height: 340px;
}

/* 加载 / 失败态：同样随容器高度伸展，避免一屏内被固定高度顶出滚动条 */
#page-era .chart-state {
    flex: 1 1 auto;
    min-height: 340px;
}

/* 地图页：地图 + 右侧列表吃满标题 / 面包屑 / 提示之外的全部高度 */
#page-map .map-layout {
    flex: 1 1 auto;
    min-height: 0;
}

/* 图表尚未接入时的占位提示；ECharts 注入画布后 :empty 失效，提示自动消失 */
.chart-body:empty {
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px dashed var(--border);
    border-radius: var(--radius);
}

.chart-body:empty::after {
    content: '图表模块建设中…';
    font-size: 14px;
    letter-spacing: 2px;
    color: #B8AFA1;
}

/* ==========================================================================
   编纂时代图（v1.3）：标题行 + 省份筛选 + 年号视图返回 + 交互提示
   ========================================================================== */

/* 标题与右侧操作区同一行，窄屏自动换行；
   v1.4：min-height 固定为返回按钮高度，保证「返回上级 / 全部朝代」出现/隐藏时标题行不跳动 */
.chart-head {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px 12px;
    min-height: 30px;
    margin-bottom: 10px;
}

.chart-head .chart-title {
    margin: 0;
    min-width: 0;
}

/* 标题行右侧操作区：地图页只有返回按钮，时代页是下拉筛选 + 返回按钮 */
.chart-head-actions {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    margin-left: auto;
}

/* 右侧操作区：省份筛选下拉 + 年号视图「◀ 全部朝代」返回按钮。
   v1.4：标签与下拉是同一个 .era-province-field，内部 nowrap，确保始终同一行 */
.era-head-actions {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 12px;
    min-width: 0;
    max-width: 100%;
}

/* 「省份」标签 + 下拉框：包成一组，标签与下拉框基线/高度对齐、永远同一行 */
.era-province-field {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex: 0 0 auto;
    min-width: 0;
    max-width: 100%;
}

/* 「省份」标签：固定 30px 行高与下拉框同高，避免两行错位 */
.era-province-label {
    display: inline-flex;
    align-items: center;
    flex: 0 0 auto;
    height: 30px;
    font-size: 13px;
    letter-spacing: 1px;
    color: #6E665C;
    white-space: nowrap;
}

.era-province-select {
    flex: 0 0 156px;
    min-width: 0;
    max-width: 100%;
    height: 30px;
    padding: 0 8px;
    border: 1px solid #D8CDBC;
    border-radius: 4px;
    background: #FFFDF9;
    color: var(--text);
    font-family: inherit;
    font-size: 13px;
}

.era-province-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(59, 107, 138, 0.12);
}

/* 「◀ 全部朝代」/「◀ 返回上级」共用样式（v1.4）：同一 class 保证位置、字号、间距一致 */
.chart-back-btn {
    flex: 0 0 auto;
    height: 30px;
    padding: 0 12px;
    border-color: #D8CDBC;
    background: #FFFDF9;
    color: var(--primary);
    font-size: 13px;
    letter-spacing: 1px;
    white-space: nowrap;
}

.chart-back-btn:hover {
    border-color: var(--accent);
    color: var(--accent-dark);
}

/* 根视图（全国 / 朝代视图）隐藏返回按钮但保留占位：位置不跳、可聚焦性关闭 */
.chart-back-btn.is-hidden {
    visibility: hidden;
    pointer-events: none;
}

/* 图表下方交互提示：居中细字说明（点击柱子的跳转口径）；v1.4 收紧行距与上边距省高度 */
.chart-hint {
    margin: 8px 0 0;
    font-size: 12px;
    line-height: 1.5;
    color: #A79E90;
    text-align: center;
}

/* 年号视图数据异常空态（该朝年号与「年号不确定」都为 0）：仅留中文提示 */
.era-view-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 120px;
    color: #8C8276;
}

/* 加载 / 失败态：与图表等高，避免页面高度跳动 */
.chart-state {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 500px;
    font-size: 14px;
    color: var(--text-sub);
}

.chart-state-error {
    flex-direction: column;
    gap: 12px;
    padding: 20px;
    border: 1px solid #EBD3CE;
    border-radius: var(--radius);
    background: #FBF2F0;
    color: #B4534B;
    text-align: center;
}

.chart-state-text {
    margin: 0;
    font-size: 14px;
    line-height: 1.7;
    word-break: break-word;
}

/* ==========================================================================
   页脚（文案固定，不可改动）
   ========================================================================== */

.global-footer {
    flex: 0 0 auto;
    /* v1.5：上边距与上下内边距收紧（原 28px / 22px），给时代 / 地图页图表腾出高度 */
    margin-top: 10px;
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    background: #F5F1EA;
    color: #9A9184;
    font-size: 13px;
    letter-spacing: 0.5px;
    text-align: center;
}

/* ==========================================================================
   响应式：≤900px 左栏折叠为顶部可展开面板
   ========================================================================== */

@media (max-width: 900px) {
    .app-main {
        padding: 14px;
    }

    .summary-strip {
        grid-template-columns: repeat(auto-fit, minmax(92px, 1fr));
    }

    .summary-item:nth-child(n) {
        border-left: none;
        border-top: 1px solid var(--border);
    }

    .summary-item:first-child,
    .summary-item:nth-child(2),
    .summary-item:nth-child(3) {
        border-top: none;
    }

    .nav-layout {
        grid-template-columns: minmax(0, 1fr);
        gap: 14px;
    }

    .sidebar {
        position: static;
        max-height: none;
    }

    .tree-toggle-btn {
        display: inline-block;
    }

    .sidebar-body {
        display: none;
        max-height: 60vh;
        border-top: 1px solid var(--border);
    }

    .sidebar-body.open {
        display: block;
    }

    .chart-body {
        min-height: 380px;
    }
}

/* ==========================================================================
   响应式：≤600px（含 375px 小屏，保证无横向滚动）
   ========================================================================== */

@media (max-width: 600px) {
    :root {
        --header-height: 52px;
    }

    .header-inner {
        padding: 0 12px;
        gap: 6px;
    }

    .app-logo {
        gap: 6px;
    }

    /* 手机屏宽有限：保留手写体主标题，隐藏副标题（浏览器标签页仍显示完整站名） */
    .app-logo-main {
        font-size: 22px;
        letter-spacing: 1px;
    }

    .app-logo-sub {
        display: none;
    }

    .nav-item {
        height: 30px;
        padding: 0 7px;
        font-size: 12px;
        letter-spacing: 0;
    }

    .app-main {
        padding: 12px;
    }

    .summary-item {
        padding: 10px 4px 9px;
    }

    .summary-num {
        font-size: 20px;
    }

    .summary-label {
        font-size: 12px;
        letter-spacing: 0;
    }

    .search-bar {
        padding: 10px 12px;
    }

    .search-row {
        flex-wrap: wrap;
        gap: 8px;
    }

    .scope-select {
        flex: 1 1 100%;
        width: 100%;
    }

    .search-input {
        flex: 1 1 140px;
    }

    .btn-primary {
        padding: 0 14px;
        letter-spacing: 1px;
    }

    .result-bar {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }

    .book-card {
        padding: 12px 14px;
    }

    .book-title {
        font-size: 16px;
    }

    .book-type {
        font-size: 11px;
    }

    .book-counts {
        gap: 4px 12px;
    }

    .pagination {
        gap: 4px;
    }

    .page-btn {
        min-width: 30px;
        padding: 0 8px;
        font-size: 12px;
    }

    .page-jump {
        margin-left: 0;
        flex: 1 1 100%;
        justify-content: center;
        margin-top: 4px;
    }

    .chart-box {
        padding: 14px;
    }

    .chart-title {
        font-size: 15px;
    }

    .chart-body {
        min-height: 300px;
    }

    .global-footer {
        margin-top: 20px;
        padding: 18px 12px;
        font-size: 12px;
    }
}

/* ==========================================================================
   详情抽屉（Task 11）：遮罩 + 右侧 640px 面板，≤900px 全屏
   ========================================================================== */

/* 抽屉打开时锁定背景滚动，避免遮罩下方页面跟着滚 */
body.detail-locked {
    overflow: hidden;
}

.detail-overlay {
    position: fixed;
    inset: 0;
    z-index: 200;
    background: rgba(30, 38, 44, 0.42);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.24s ease, visibility 0.24s;
}

.detail-overlay.open {
    opacity: 1;
    visibility: visible;
}

.detail-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 201;
    display: flex;
    flex-direction: column;
    width: 640px;
    max-width: 100%;
    background: var(--bg);
    border-left: 1px solid var(--border);
    box-shadow: -8px 0 32px rgba(44, 80, 102, 0.18);
    transform: translateX(102%);
    visibility: hidden;
    transition: transform 0.28s ease, visibility 0.28s;
    outline: none;
}

.detail-panel.open {
    transform: translateX(0);
    visibility: visible;
}

/* ---- 标题行 ---- */

.detail-head {
    flex: 0 0 auto;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px 56px 14px 22px;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(180deg, #FCFAF6 0%, #F7F3EC 100%);
    position: relative;
}

.detail-head-main {
    display: flex;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 4px 10px;
    min-width: 0;
}

.detail-title {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
    line-height: 1.5;
    letter-spacing: 1px;
    color: var(--primary-dark);
    word-break: break-word;
}

.detail-head-main .book-type {
    margin-top: 4px;
}

.detail-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: #FFFDF9;
    color: var(--text-sub);
    font-size: 15px;
    line-height: 1;
    transition: color 0.16s, border-color 0.16s, background 0.16s;
}

.detail-close:hover {
    color: #B4534B;
    border-color: #E3C4BF;
    background: #FBF2F0;
}

/* 抽屉内「返回上级书目」：丛书本点开子目后的独立返回，与 ✕ 关闭语义分离 */
.detail-back-btn {
    align-self: flex-start;
    margin-top: 3px;
    height: 30px;
    padding: 0 10px;
    font-size: 12px;
    white-space: nowrap;
}

/* ---- 滚动内容区 ---- */

.detail-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 14px 22px 32px;
}

.detail-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 56px 0;
    font-size: 14px;
    color: var(--text-sub);
}

.detail-error {
    margin: 12px 0;
    padding: 22px 16px;
    border: 1px solid #EBD3CE;
    border-radius: var(--radius);
    background: #FBF2F0;
    color: #B4534B;
    font-size: 14px;
    text-align: center;
    word-break: break-word;
}

.detail-section {
    padding: 13px 0;
    border-bottom: 1px dashed var(--border);
}

.detail-section:last-child {
    border-bottom: none;
}

/* 地域 / 责任者：双行事实表 */
.detail-profile {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.detail-fact {
    display: flex;
    align-items: baseline;
    gap: 10px;
    font-size: 14px;
    line-height: 1.7;
}

.detail-fact-label {
    flex: 0 0 42px;
    font-size: 12px;
    letter-spacing: 2px;
    color: var(--text-sub);
}

.detail-fact-value {
    flex: 1 1 auto;
    min-width: 0;
    color: #4A4238;
    word-break: break-word;
}

.detail-fact-value.unknown {
    color: #A79E90;
}

.detail-agents .detail-agent + .detail-agent::before {
    content: '；';
    margin: 0 2px;
    color: #C6BCAC;
}

.detail-section-title {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin: 0 0 10px;
    padding-left: 9px;
    border-left: 3px solid var(--accent);
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 1px;
    color: var(--primary-dark);
}

.section-count {
    font-size: 12px;
    font-weight: 400;
    letter-spacing: 0;
    color: var(--text-sub);
}

.detail-empty {
    margin: 0;
    font-size: 13px;
    color: #A79E90;
}

/* ---- 著录信息 ---- */

.detail-meta {
    margin: 0;
}

.meta-row {
    display: flex;
    align-items: baseline;
    gap: 10px;
    padding: 2px 0;
    font-size: 14px;
    line-height: 1.7;
}

.meta-row dt {
    flex: 0 0 72px;
    font-size: 12px;
    letter-spacing: 1px;
    color: var(--text-sub);
}

.meta-row dd {
    flex: 1 1 auto;
    min-width: 0;
    margin: 0;
    color: var(--text);
    word-break: break-word;
}

/* ---- 版本卡与复本 ---- */

.edition-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.edition-card {
    padding: 10px 14px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.edition-version {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.6;
    color: #3F4A52;
    word-break: break-word;
}

.edition-note {
    margin: 2px 0 0;
    font-size: 12.5px;
    line-height: 1.6;
    color: var(--text-sub);
    word-break: break-word;
}

.copy-list {
    list-style: none;
    margin: 8px 0 0;
    padding: 8px 0 0;
    border-top: 1px dashed var(--border);
}

.copy-row {
    display: flex;
    align-items: baseline;
    gap: 8px;
    padding: 2px 0;
    font-size: 13px;
    line-height: 1.6;
}

.copy-holder {
    flex: 0 1 auto;
    min-width: 0;
    color: var(--text);
    word-break: break-word;
}

.copy-holder.unknown {
    color: #A79E90;
}

.copy-tag {
    flex: 0 0 auto;
    padding: 0 6px;
    border: 1px solid #E3C4BF;
    border-radius: 9px;
    background: #FBF2F0;
    color: #B4534B;
    font-size: 11px;
    line-height: 1.7;
}

.copy-note {
    flex: 0 1 auto;
    margin-left: auto;
    font-size: 12.5px;
    color: var(--text-sub);
    text-align: right;
    word-break: break-word;
}

.copy-empty {
    margin: 8px 0 0;
    padding-top: 8px;
    border-top: 1px dashed var(--border);
    font-size: 12.5px;
    line-height: 1.6;
    color: #A79E90;
}

/* ---- 所属丛书 ---- */

.series-card {
    padding: 12px 14px;
    background: var(--card);
    border: 1px solid #EAD8BC;
    border-radius: var(--radius);
}

.series-head {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 4px 8px;
    margin: 0;
}

.series-no {
    font-size: 12px;
    padding: 0 6px;
    border-radius: 3px;
    background: var(--accent-light);
    color: #8A6534;
    line-height: 1.8;
    font-variant-numeric: tabular-nums;
}

.series-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--primary-dark);
    word-break: break-word;
}

.series-orig {
    margin: 2px 0 0;
    font-size: 12.5px;
    line-height: 1.6;
    color: var(--text-sub);
    word-break: break-word;
}

.series-card .edition-list {
    margin-top: 10px;
}

.expand-btn {
    display: block;
    width: 100%;
    height: 32px;
    margin-top: 10px;
    border-color: #EAD8BC;
    background: #FCF7EF;
    color: #8A6534;
    letter-spacing: 1px;
}

.expand-btn:hover {
    color: var(--accent-dark);
    border-color: var(--accent);
}

/* ---- 丛书子目 ---- */

.subitem-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.subitem-row {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 2px 8px;
    padding: 7px 8px;
    border-radius: 4px;
    font-size: 13.5px;
    line-height: 1.65;
    cursor: pointer;
    transition: background 0.16s;
}

.subitem-row + .subitem-row {
    border-top: 1px dashed var(--border);
}

.subitem-row:hover {
    background: var(--primary-light);
}

.subitem-title {
    color: var(--primary-dark);
    font-weight: 600;
    word-break: break-word;
}

.subitem-era {
    font-size: 12.5px;
    color: var(--accent-dark);
}

.subitem-agent {
    font-size: 12.5px;
    color: var(--text-sub);
    word-break: break-word;
}

/* ---- 详情抽屉响应式：≤900px 全屏 ---- */

@media (max-width: 900px) {
    .detail-panel {
        width: 100%;
        border-left: none;
        box-shadow: none;
    }

    .detail-head {
        padding: 14px 52px 12px 16px;
    }

    .detail-title {
        font-size: 18px;
    }

    .detail-body {
        padding: 12px 16px 28px;
    }
}

@media (max-width: 600px) {
    .detail-title {
        font-size: 17px;
        letter-spacing: 0;
    }

    .detail-fact-label {
        flex-basis: 40px;
    }

    .meta-row dt {
        flex-basis: 64px;
    }

    .subitem-row {
        gap: 1px 6px;
        font-size: 13px;
    }

    .copy-row {
        flex-wrap: wrap;
    }

    .copy-note {
        flex: 1 1 100%;
        margin-left: 0;
        text-align: left;
    }
}

/* ---- 编纂时代图响应式（Task 12）：与 .chart-body 高度断点保持一致 ---- */

@media (max-width: 900px) {
    .chart-state {
        min-height: 380px;
    }
}

@media (max-width: 600px) {
    .chart-state {
        min-height: 300px;
    }

    /* 窄屏：操作区整行，省份标签 + 下拉仍同一行，下拉可压缩、返回按钮不换行 */
    .era-head-actions {
        width: 100%;
        flex-wrap: wrap;
        gap: 8px;
    }

    .era-province-field {
        flex: 1 1 auto;
        min-width: 0;
    }

    .era-province-label {
        height: 28px;
        font-size: 12px;
    }

    .era-province-select {
        flex: 1 1 120px;
        height: 28px;
        font-size: 12px;
    }

    .chart-hint {
        font-size: 12px;
        text-align: left;
    }

    .era-view-empty {
        min-height: 100px;
    }
}

/* ==========================================================================
   地区分布地图（Task 13）：标题行 + 面包屑 + 地图/右侧列表 + 底部说明
   ========================================================================== */

/* 「◀ 返回上级」与时代页「◀ 全部朝代」共用上方 .chart-back-btn，样式完全一致，
   HTML 里保留 .map-back-btn / .era-back-btn 仅作语义别名与响应式钩子。 */

/* 地图面包屑：复用 .crumb / .crumb-sep 的交互样式，仅调整行距；
   v1.4 始终渲染（全国层就是「全国」一项），下钻时下面地图/列表不上下跳动。 */
.map-crumbs {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 1px;
    min-width: 0;
    min-height: 24px;
    margin: 0 0 10px;
    font-size: 13px;
    color: var(--text-sub);
}

/* 下钻请求进行中的小提示（保留当前地图，不清空画布） */
.map-loading-tip {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 12px;
    font-size: 13px;
    color: var(--text-sub);
}

/* 地图 + 右侧层级列表（v1.4）：列表固定收窄到 252px（原 7:3 约 331px），
   折叠后列表整列隐藏、地图占满整行；≤900px 列表移到地图下方（见文末媒体查询）。 */
.map-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 252px;
    gap: 14px;
    align-items: stretch;
    min-width: 0;
    position: relative;
}

.map-layout.is-list-collapsed {
    grid-template-columns: minmax(0, 1fr);
}

/* 地图画布高度：桌面吃满 .chart-box 的剩余高度（见上方 #page-map .chart-box），
   ≤900px 交给下方媒体查询用 60vh，避免小视口把提示挤出首屏。
   v1.6：ECharts layoutSize 改为按容器宽高与底图 bbox 动态计算的像素值（见 app.js
   computeMapLayout），容器越大图形越大，宽高两个方向都会铺满。 */
.map-body {
    height: 100%;
    min-height: 0;
}

/* 地图容器在 ECharts 注入画布前不显示「建设中…」占位（有独立加载态） */
.map-body:empty {
    border: none;
}

.map-body:empty::after {
    content: none;
}

/* 右侧层级列表：头（当前层名称 + 收起按钮）固定置顶，行区域独立滚动，脚注固定底部 */
.map-list {
    display: flex;
    flex-direction: column;
    min-width: 0;
    height: 100%;
    min-height: 0;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #FCFAF6;
    overflow: hidden;
}

.map-list-head {
    flex: 0 0 auto;
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 6px;
    padding-bottom: 8px;
    margin-bottom: 4px;
    border-bottom: 1px solid var(--border);
}

.map-list-title {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 1px;
    color: var(--primary-dark);
    word-break: break-word;
}

.map-list-summary {
    flex: 0 0 auto;
    color: var(--text-sub);
    font-size: 12px;
    font-variant-numeric: tabular-nums;
}

/* v1.4 折叠按钮：列表头部右侧的「›」，收起后在地图右上角出现「‹ 列表」展开 */
.map-list-toggle {
    flex: 0 0 auto;
    align-self: center;
    width: 22px;
    height: 22px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: #FFFDF9;
    color: var(--primary);
    font-size: 15px;
    line-height: 1;
    cursor: pointer;
}

.map-list-toggle:hover {
    border-color: var(--accent);
    color: var(--accent-dark);
}

.map-list-expand {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 6;
    height: 26px;
    padding: 0 10px;
    border: 1px solid #D8CDBC;
    border-radius: 4px;
    background: #FFFDF9;
    color: var(--primary);
    font-size: 12px;
    letter-spacing: 1px;
    box-shadow: var(--shadow);
    cursor: pointer;
}

.map-list-expand:hover {
    border-color: var(--accent);
    color: var(--accent-dark);
}

.map-list-rows {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    list-style: none;
    margin: 0;
    padding: 0;
    overscroll-behavior: contain;
}

.map-list-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    padding: 6px 2px;
    border-top: 1px dashed var(--border);
    font-size: 13.5px;
}

.map-list-row:first-child {
    border-top: none;
}

/* 可点击条目：在文献导航（新页面）中打开对应地域 */
.map-list-link {
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.18s;
}

.map-list-link:hover,
.map-list-link:focus-visible {
    background: #F3EDE3;
}

.map-list-link:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
}

.map-list-name {
    min-width: 0;
    color: var(--text);
    word-break: break-word;
}

.map-list-count {
    flex: 0 0 auto;
    color: var(--accent-dark);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

/* count=0 的行灰显：有区划但暂无方志，仍可点击进导航看空结果 */
.map-list-row.is-zero .map-list-name,
.map-list-row.is-zero .map-list-count {
    color: #B3AA9B;
}

.map-list-empty {
    flex: 1 1 auto;
    margin: 12px 0 0;
    color: #A79E90;
    font-size: 13px;
}

.map-list-note {
    flex: 0 0 auto;
    margin: 8px 0 0;
    font-size: 12px;
    line-height: 1.6;
    color: #A79E90;
}

/* 地图响应式：≤900px 列表移到地图下方；≤600px 地图约 60vh。
   v1.4：窄屏下时代 / 地图页恢复自然高度（桌面的一屏定高只用于 ≥901px），
   列表仍可折叠（默认展开，折叠按钮可用）。 */
@media (max-width: 900px) {
    #page-era .chart-box,
    #page-map .chart-box {
        display: block;
        height: auto;
        min-height: 0;
        padding: 14px;
    }

    #page-era .chart-body {
        flex: none;
        height: 420px;
        min-height: 380px;
    }

    #page-era .chart-state {
        flex: none;
        min-height: 380px;
    }

    .map-body {
        height: 60vh;
        min-height: 380px;
    }

    .map-layout {
        grid-template-columns: minmax(0, 1fr);
    }

    /* 列表下移后不再与地图等高，限高并内部滚动，避免把提示挤出首屏 */
    .map-list {
        height: auto;
        min-height: 0;
        max-height: 40vh;
    }
}

@media (max-width: 600px) {
    #page-era .chart-body {
        height: 320px;
        min-height: 300px;
    }

    #page-era .chart-state {
        min-height: 300px;
    }

    .map-body {
        height: 60vh;
        min-height: 300px;
    }

    .map-list {
        max-height: 34vh;
    }

    .chart-back-btn {
        height: 28px;
        padding: 0 10px;
        font-size: 12px;
        letter-spacing: 0;
    }

    .map-crumbs {
        margin-bottom: 8px;
        font-size: 12px;
    }
}

/* ==========================================================================
   页面右下角浮层提示（toast）：无下级数据 / 底图缺失 / 加载失败等
   固定定位、pointer-events:none 不遮挡交互，显示 2.5 秒后淡出（由 JS 控制显隐）
   ========================================================================== */

.toast {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 300;
    max-width: min(320px, calc(100vw - 40px));
    padding: 10px 16px;
    border: 1px solid rgba(196, 154, 108, 0.55);
    border-radius: var(--radius);
    background: rgba(44, 80, 102, 0.95);
    color: #FFFDF9;
    font-size: 13.5px;
    line-height: 1.6;
    letter-spacing: 0.5px;
    box-shadow: 0 6px 22px rgba(44, 80, 102, 0.28);
    opacity: 0;
    visibility: hidden;
    transform: translateY(8px);
    transition: opacity 0.22s ease, transform 0.22s ease, visibility 0.22s;
    pointer-events: none;   /* 不遮挡地图点击 / 悬停 */
    word-break: break-word;
}

.toast.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* 文本节点：JS 每次 showToast 用 :key 重建 span，使同一文案重复触发时也重放入场动画 */
.toast-text {
    display: inline-block;
}

.toast.show .toast-text {
    animation: toast-pop 0.26s ease-out;
}

/* 轻微入场反馈：淡入 + 5px 上移回位；不影响 2.5s 后由 .show 移除触发的淡出 */
@keyframes toast-pop {
    from {
        opacity: 0.25;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 尊重系统「减少动态效果」设置：仍保留文字与显隐，只去掉位移动画 */
@media (prefers-reduced-motion: reduce) {
    .toast.show .toast-text {
        animation: none;
    }
}

@media (max-width: 600px) {
    .toast {
        right: 12px;
        bottom: 12px;
        max-width: calc(100vw - 24px);
        padding: 9px 12px;
        font-size: 12.5px;
    }
}

/* ==========================================================================
   文献导航页「返回顶部」浮动按钮（v1.5）：参考 yueju 的 .back-to-top 规格
   固定右下角、圆形主色 #3B6B8A、白字 ▲；导航页滚动超过 400px 淡入。
   z-index 高于卡片，低于详情抽屉（200）与 toast（300）。默认不可见也不拦截点击。
   ========================================================================== */

.back-to-top {
    position: fixed;
    right: 30px;
    bottom: 50px;
    z-index: 150;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: #3B6B8A;
    color: #FFFFFF;
    font-size: 18px;
    line-height: 1;
    box-shadow: 0 2px 10px rgba(59, 107, 138, 0.4);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s;
}

.back-to-top.show {
    opacity: 0.9;
    visibility: visible;
    pointer-events: auto;
}

.back-to-top:hover,
.back-to-top:focus-visible {
    background: #2C5066;
    opacity: 1;
    transform: translateY(-2px);
}

/* 375px 小屏：缩小到 36px 并贴边，避免遮挡卡片 / 分页按钮 */
@media (max-width: 600px) {
    .back-to-top {
        right: 16px;
        bottom: 24px;
        width: 36px;
        height: 36px;
        font-size: 16px;
    }
}

/* 尊重系统「减少动态效果」设置：只保留显隐，不做位移动画 */
@media (prefers-reduced-motion: reduce) {
    .back-to-top {
        transition: none;
    }

    .back-to-top:hover,
    .back-to-top:focus-visible {
        transform: none;
    }
}
