/* 心典古籍数字馆 —— 宣纸 / 朱印风格（浅色主题，无外部依赖） */
:root {
    --paper: #f6f2e7;
    --paper-deep: #efe7d5;
    --card: #fffdf7;
    --ink: #2b2823;
    --ink-soft: #6c6557;
    --red: #9b2f2f;
    --red-dark: #7d2424;
    --gold: #b08a4a;
    --line: #e0d7c2;
    --green: #3f6b4a;
    --shadow: 0 2px 12px rgba(74, 58, 34, .09);
    --radius: 10px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: "Songti SC", "SimSun", "Noto Serif CJK SC", "Source Han Serif SC", "STSong", Georgia, serif;
    font-size: 15px;
    line-height: 1.65;
}

a { color: var(--red); text-decoration: none; }
a:hover { color: var(--red-dark); text-decoration: underline; }

.wrap { width: min(1320px, 94vw); margin: 0 auto; }

.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

.skip-link {
    position: absolute; left: -9999px; top: 0; z-index: 100;
    background: var(--red); color: #fff; padding: 10px 16px;
}
.skip-link:focus { left: 12px; top: 12px; }

:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

/* ---------- 页头 ---------- */
.site-header {
    background: linear-gradient(180deg, #fffdf6, #f3ecd9);
    border-bottom: 3px double var(--line);
}
.header-inner {
    display: flex; align-items: center; gap: 24px;
    min-height: 84px; padding: 12px 0; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 12px; color: var(--ink); flex: 0 0 auto; }
.brand:hover { text-decoration: none; color: var(--ink); }
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text strong { font-size: 22px; letter-spacing: 2px; }
.brand-text small { font-size: 16px; color: var(--ink-soft); letter-spacing: 3px; }

.search-form { display: flex; flex: 1 1 340px; max-width: 560px; gap: 8px; }
.search-form .search-field {
    flex: 0 0 auto; padding: 10px 8px; font-size: 14px; font-family: inherit;
    color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 6px;
}
.search-form input[type="search"] {
    flex: 1; min-width: 120px; padding: 10px 14px; font-size: 15px;
    font-family: inherit; color: var(--ink); background: #fff;
    border: 1px solid var(--line); border-radius: 6px;
}
.search-form input[type="search"]:focus { border-color: var(--gold); }
.search-form button,
.primary-link,
.add-btn {
    font-family: inherit; cursor: pointer; border-radius: 6px;
}
.search-form button {
    padding: 10px 22px; background: var(--red); color: #fff;
    border: 1px solid var(--red); font-size: 15px; letter-spacing: 2px;
}
.search-form button:hover { background: var(--red-dark); }

.cart-link {
    flex: 0 0 auto; display: inline-flex; align-items: center; gap: 6px;
    padding: 9px 16px; border: 1px solid var(--line); border-radius: 6px;
    background: var(--card); color: var(--ink); font-size: 15px;
}
.cart-link:hover { border-color: var(--red); color: var(--red); text-decoration: none; }
.badge {
    display: inline-grid; place-items: center; min-width: 22px; height: 22px;
    padding: 0 6px; border-radius: 11px; background: var(--red);
    color: #fff; font-size: 12px; font-family: Arial, sans-serif;
}

/* ---------- 分类导航 ---------- */
.cat-nav {
    background: #fffdf7; border-bottom: 1px solid var(--line);
    position: sticky; top: 0; z-index: 20;
}
.nav-inner { display: flex; gap: 4px; overflow-x: auto; padding: 6px 0; scrollbar-width: thin; }
.cat-link {
    flex: 0 0 auto; padding: 8px 14px; border-radius: 5px; white-space: nowrap;
    color: var(--ink); font-size: 14.5px;
}
.cat-link em {
    font-style: normal; font-size: 11px; color: var(--ink-soft);
    margin-left: 4px; font-family: Arial, sans-serif;
}
.cat-link:hover { background: var(--paper-deep); text-decoration: none; }
.cat-link.active { background: var(--red); color: #fff; }
.cat-link.active em { color: #f3ddd5; }

/* ---------- 错误提示 ---------- */
.alert {
    width: min(1320px, 94vw); margin: 16px auto 0; padding: 12px 18px;
    background: #fff3f0; border: 1px solid #e0b4a8; border-left: 5px solid var(--red);
    color: #7d2424; border-radius: 4px;
}

.main-content { min-height: 55vh; padding-top: 24px; padding-bottom: 48px; }

/* ---------- 首屏 ---------- */
.hero {
    background:
        radial-gradient(circle at 88% 20%, rgba(176,138,74,.13), transparent 42%),
        linear-gradient(120deg, #f1e9d6, #fbf7ec 60%, #f0e6d2);
    border: 1px solid var(--line); border-radius: var(--radius);
    padding: 30px 34px; margin-bottom: 28px; box-shadow: var(--shadow);
}
.hero-inner { max-width: 900px; }
.eyebrow { margin: 0 0 6px; color: var(--red); letter-spacing: 6px; font-size: 12px; }
.hero h1 { margin: 0 0 10px; font-size: 34px; letter-spacing: 6px; font-weight: 600; }
.hero-sub { margin: 0; color: var(--ink-soft); font-size: 14.5px; max-width: 780px; }
.hero-rule { margin-top: 20px; width: 120px; height: 3px; background: var(--red); opacity: .75; }

/* ---------- 工具条 ---------- */
.toolbar {
    display: flex; justify-content: space-between; align-items: flex-end;
    gap: 16px; flex-wrap: wrap; margin-bottom: 16px;
    border-bottom: 1px solid var(--line); padding-bottom: 10px;
}
.section-title { margin: 0; font-size: 22px; font-weight: 600; letter-spacing: 2px; }
.section-meta { margin: 2px 0 0; color: var(--ink-soft); font-size: 13px; }
.keyword { margin: 0; color: var(--ink-soft); font-size: 14px; }
.keyword a { margin-left: 8px; font-size: 13px; }

/* ---------- 书目卡片 ---------- */
.book-grid {
    display: grid; gap: 16px;
    grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
}
.book-card {
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 16px 16px 18px; box-shadow: var(--shadow);
    display: flex; flex-direction: column;
    transition: transform .15s ease, box-shadow .15s ease;
}
.book-card:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(74,58,34,.14); }
.card-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.cat-tag {
    display: inline-block; padding: 2px 9px; font-size: 12px;
    color: var(--red); border: 1px solid #e2c8bd; background: #fdf5f1; border-radius: 3px;
}
.cat-tag:hover { text-decoration: none; background: #f7e9e2; }
.size { font-size: 11.5px; color: var(--ink-soft); font-family: Arial, sans-serif; }
.book-title {
    margin: 10px 0 8px; font-size: 18px; line-height: 1.4; font-weight: 600;
    min-height: 2.8em;
}
.book-title a { color: var(--ink); }
.book-title a:hover { color: var(--red); }
.book-price { margin: 0 0 12px; font-size: 13px; color: var(--ink-soft); }
.book-price strong { font-size: 21px; color: var(--red); font-family: Arial, sans-serif; margin: 0 6px 0 2px; }
.book-price span { font-size: 12px; margin-left: 4px; }
.fmt-hint { margin: auto 0 8px; font-size: 12px; color: var(--ink-soft); letter-spacing: 1px; }

.fmt-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
.fmt-btn {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 2px; min-height: 52px; padding: 5px 4px; cursor: pointer;
    background: #fff; border: 1px solid var(--line); border-radius: 6px;
    font-family: Arial, "Microsoft YaHei", sans-serif; color: var(--ink);
    transition: background .12s ease, border-color .12s ease;
}
.fmt-btn:hover:not(:disabled) { border-color: var(--red); background: #fdf6f2; }
.fmt-btn.is-txt { background: #fbf4e9; border-color: #dcc9a3; }
.fmt-btn:disabled { opacity: .6; cursor: not-allowed; background: #f1eee5; }
.fmt-name { font-size: 12px; font-weight: 700; letter-spacing: .5px; }
.fmt-price { font-size: 11px; color: var(--red); }
.fmt-btn:disabled .fmt-price { color: var(--green); }

/* ---------- 分页 ---------- */
.pager { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 26px; }
.pager-top { margin-top: 0; margin-bottom: 18px; }
.page-btn {
    display: inline-block; padding: 6px 14px; background: var(--card);
    border: 1px solid var(--line); border-radius: 5px; color: var(--ink); font-size: 14px;
}
.page-btn:hover { border-color: var(--red); text-decoration: none; }
.page-btn.current { background: var(--red); border-color: var(--red); color: #fff; }
.page-btn.disabled { opacity: .45; pointer-events: none; }
.page-total { margin-left: 8px; color: var(--ink-soft); font-size: 13px; }

/* 前台书目/检索分页：参照中药100网全文检索的「首页 前页 页码信息 后页 末页 + 跳页」 */
.pager-list {
    justify-content: center; gap: 6px;
    margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line);
}
.pager-list.pager-top {
    margin-top: 4px; margin-bottom: 14px;
    padding-top: 0; padding-bottom: 12px;
    border-top: 0; border-bottom: 1px solid var(--line);
}
.pager-list .page-btn {
    padding: 5px 10px; font-size: 13px; white-space: nowrap;
    color: var(--ink); background: var(--paper); border-radius: 3px;
}
.pager-list a.page-btn:hover {
    background: var(--card); border-color: var(--gold); color: var(--red); text-decoration: none;
}
.pager-list .page-btn.disabled {
    opacity: 1; color: #b8a88c; background: transparent; border-style: dashed;
}
.page-info {
    padding: 5px 8px; font-size: 12.5px; white-space: nowrap; color: var(--ink-soft);
}
.page-goto {
    display: inline-flex; align-items: center; gap: 5px;
    margin-left: 4px; font-size: 13px; white-space: nowrap; color: var(--ink-soft);
}
.page-goto label { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.page-goto .page-input {
    width: 74px; padding: 4px 6px; font-size: 13px; font-family: inherit;
    font-variant-numeric: tabular-nums; color: var(--ink); text-align: center;
    background: #fff; border: 1px solid var(--line); border-radius: 3px;
}
.page-goto .page-input:focus {
    outline: none; border-color: var(--gold); box-shadow: 0 0 0 2px rgba(176, 138, 74, .18);
}
.page-go {
    padding: 5px 10px; font-size: 13px; font-family: inherit; white-space: nowrap;
    color: #fff; background: var(--red); border: 1px solid var(--red);
    border-radius: 3px; cursor: pointer;
}
.page-go:hover { background: var(--red-dark); border-color: var(--red-dark); }
@media (max-width: 720px) {
    .pager { gap: 6px; }
    .pager .page-btn { padding: 6px 10px; font-size: 13px; }
    .pager-list { gap: 5px; }
    .pager-list .page-btn { padding: 5px 8px; }
    .pager-list .page-goto { margin-left: 0; }
    .pager-list .page-input { width: 64px; }
    .page-info { font-size: 12px; }
}

/* ---------- 详情页 ---------- */
.breadcrumb { font-size: 13px; color: var(--ink-soft); margin-bottom: 16px; }
.breadcrumb span { margin: 0 6px; }
.detail-card {
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 28px 30px; box-shadow: var(--shadow);
}
.detail-head { border-bottom: 1px solid var(--line); padding-bottom: 16px; }
.detail-head h1 { margin: 10px 0 6px; font-size: 30px; letter-spacing: 2px; }
.detail-author { margin: 0 0 8px; color: var(--red); font-size: 16px; letter-spacing: 1px; }
.detail-meta { margin: 0; color: var(--ink-soft); font-size: 14px; }
.detail-meta strong { color: var(--red); font-size: 18px; font-family: Arial, sans-serif; }
.detail-feature { color: var(--red); font-weight: 700; }
.sub-head { margin: 22px 0 6px; font-size: 19px; letter-spacing: 2px; }
.detail-note { margin: 0 0 18px; color: var(--ink-soft); font-size: 13.5px; }
.format-cards { display: grid; gap: 12px; grid-template-columns: repeat(6, minmax(0, 1fr)); }
.format-card {
    border: 1px solid var(--line); border-radius: 8px; padding: 16px;
    background: #fff; text-align: center;
}
.format-card.is-txt { background: #fdf8ee; border-color: #dcc9a3; }
.format-card-top { display: flex; justify-content: center; align-items: center; gap: 8px; }
.fmt-pill {
    display: inline-block; padding: 2px 10px; border-radius: 4px;
    background: #f0e9da; color: var(--ink); font-size: 12px; font-weight: 700;
    font-family: Arial, sans-serif; letter-spacing: 1px;
}
.fmt-pill.big { font-size: 15px; padding: 4px 14px; }
.fmt-flag { font-size: 11px; color: var(--red); }
.format-size { margin: 12px 0 2px; color: var(--ink-soft); font-size: 12.5px; }
.format-price { margin: 4px 0 0; color: var(--red); font-family: Arial, sans-serif; }
.format-price strong { font-size: 26px; }
.add-btn {
    width: 100%; margin-top: 14px; padding: 9px 10px;
    background: var(--red); color: #fff; border: 1px solid var(--red); font-size: 14px;
}
.add-btn:hover:not(:disabled) { background: var(--red-dark); }
.add-btn:disabled { background: #e8e3d6; border-color: #ddd5c2; color: var(--green); cursor: not-allowed; }
/* 已购买的格式：详情页标「已购买」并直接给下载入口，不再显示加入购物车 */
.format-card.is-owned { border-color: var(--green); background: #f6faf5; }
.format-card.is-owned .format-price, .format-card.is-owned .format-price strong { color: var(--ink-soft); }
.fmt-owned {
    display: inline-block; padding: 2px 7px; border-radius: 3px;
    background: var(--green); color: #fff; font-size: 11px; font-weight: 700;
}
.add-btn.btn-owned {
    display: block; box-sizing: border-box; text-align: center;
    background: var(--green); border-color: var(--green); color: #fff;
    font-family: inherit; cursor: pointer; border-radius: 6px;
}
.add-btn.btn-owned:hover { background: #2f5b39; border-color: #2f5b39; color: #fff; text-decoration: none; }
.detail-back { margin: 24px 0 0; font-size: 14px; }

/* ---------- 购物车 ---------- */
.cart-table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.cart-table { width: 100%; border-collapse: collapse; min-width: 760px; }
.cart-table th, .cart-table td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--line); font-size: 14px; }
.cart-table th { background: var(--paper-deep); font-weight: 600; color: var(--ink); }
.cart-table tbody tr:last-child td { border-bottom: none; }
.cart-title { font-size: 15px; font-weight: 600; max-width: 340px; }
.price-cell { color: var(--red); font-family: Arial, sans-serif; font-weight: 700; }
.cart-actions { white-space: nowrap; }
.link-btn {
    background: none; border: none; padding: 2px 4px; cursor: pointer;
    font-family: inherit; font-size: 13px; color: var(--red);
}
.link-btn:hover { text-decoration: underline; }
.link-btn.danger { color: var(--ink-soft); }
.cart-summary {
    margin-top: 20px; padding: 18px 22px; text-align: right;
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
}
.sum-line { margin: 0; font-size: 17px; }
.sum-line strong { font-size: 28px; color: var(--red); font-family: Arial, sans-serif; margin-left: 8px; }
.summary-note { margin: 6px 0 14px; color: var(--ink-soft); font-size: 16px; line-height: 1.7; }
.primary-link {
    display: inline-block; padding: 8px 20px; background: var(--red);
    color: #fff; border: 1px solid var(--red); font-size: 14px;
}
.primary-link:hover { background: var(--red-dark); color: #fff; text-decoration: none; }
button.primary-link { font-family: inherit; cursor: pointer; }
.cart-summary .primary-link {
    box-sizing: border-box; display: inline-flex; align-items: center;
    justify-content: center; width: 132px; height: 40px; padding: 0 12px;
    vertical-align: middle;
}
.cart-summary .checkout-form {
    display: inline-block; margin: 0 0 0 10px; vertical-align: middle;
}
.cart-summary .checkout-form .btn-primary {
    box-sizing: border-box; display: inline-flex; align-items: center; justify-content: center;
    width: 132px; height: 40px; padding: 0 12px; border-radius: 6px;
    font-size: 14px; letter-spacing: 1px;
}

/* ---------- 空状态 / 页脚 / Toast ---------- */
.empty {
    padding: 54px 20px; text-align: center; color: var(--ink-soft);
    background: var(--card); border: 1px dashed var(--line); border-radius: var(--radius);
}
.empty h2 { color: var(--ink); }
.empty .primary-link { margin-top: 12px; }

.site-footer {
    border-top: 1px solid var(--line); background: #f0e9d8;
    padding: 22px 0; color: var(--ink-soft); font-size: 12.5px;
}
.site-footer p { margin: 2px 0; }
.footer-inner {
    display: flex; align-items: center; justify-content: space-between;
    gap: 16px; flex-wrap: wrap;
}
.footer-main { display: flex; align-items: center; gap: 8px 18px; flex-wrap: wrap; }
.footer-brand { color: var(--red); font-size: 15px; font-weight: 700; letter-spacing: 2px; }
.footer-slogan { color: var(--gold); letter-spacing: 3px; }
.footer-meta { display: flex; align-items: center; gap: 6px 18px; flex-wrap: wrap; }
.footer-item { color: var(--ink-soft); white-space: nowrap; }
.footer-item a { color: var(--ink-soft); text-decoration: none; border-bottom: 1px dotted rgba(120, 100, 70, .45); }
.footer-item a:hover { color: var(--red); border-bottom-color: var(--red); }
.footer-top { color: var(--ink-soft); font-size: 12.5px; white-space: nowrap; }
.footer-top:hover { color: var(--red); }
@media (max-width: 720px) {
    .site-footer { padding: 18px 0; }
    .footer-inner { flex-direction: column; align-items: flex-start; gap: 10px; }
    .footer-main { gap: 4px 12px; }
    .footer-meta { gap: 4px 14px; }
    .footer-item, .footer-top { font-size: 12px; white-space: normal; word-break: break-all; }
}

.toast {
    position: fixed; left: 50%; bottom: 38px; transform: translate(-50%, 16px);
    min-width: 220px; max-width: 86vw; padding: 12px 22px; text-align: center;
    border-radius: 6px; background: #3a352c; color: #fff; font-size: 14px;
    opacity: 0; pointer-events: none; transition: opacity .2s ease, transform .2s ease;
    z-index: 60; box-shadow: 0 8px 24px rgba(0,0,0,.18);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.ok { background: #3f6b4a; }
.toast.warn { background: #8a4a34; }

/* ---------- 自定义确认框（遮罩层视口垂直居中） ---------- */
.confirm-mask {
    position: fixed; inset: 0; z-index: 1000;
    display: grid; place-items: center; padding: 20px;
    background: rgba(30, 25, 18, .46);
    backdrop-filter: blur(2px);
}
.confirm-mask[hidden] { display: none; }
.confirm-box {
    width: min(420px, 100%); padding: 22px 24px 18px;
    background: var(--card); border: 1px solid var(--line);
    border-top: 4px solid var(--red); border-radius: var(--radius);
    box-shadow: 0 16px 48px rgba(30, 25, 18, .28);
    text-align: center;
}
.confirm-message {
    margin: 0 0 20px; color: var(--ink); font-size: 16px;
    line-height: 1.7; word-break: break-word;
}
.confirm-actions { display: flex; justify-content: center; gap: 12px; }
.confirm-actions button {
    min-width: 108px; height: 40px; padding: 0 18px;
    border-radius: 6px; cursor: pointer; font-family: inherit; font-size: 14px;
}
.confirm-cancel { background: var(--card); border: 1px solid var(--line); color: var(--ink); }
.confirm-cancel:hover { border-color: var(--ink-soft); }
.confirm-ok { background: var(--red); border: 1px solid var(--red); color: #fff; }
.confirm-ok:hover { background: var(--red-dark); }
@media (max-width: 720px) {
    .confirm-mask { padding: 14px; }
    .confirm-box { padding: 20px 16px 16px; }
    .confirm-message { font-size: 15px; }
    .confirm-actions button { min-width: 96px; }
}

/* ---------- 封面：优先显示由 PDF 首页生成的真实封面，失败时回退程序化线装书 ---------- */
.cover-grid {
    display: grid; gap: 20px;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
}
.cover {
    position: relative; display: block; aspect-ratio: 417 / 590;
    padding: 20px 16px 16px 26px; overflow: hidden;
    background: linear-gradient(135deg, #f4e8cd, #e9d6ae 58%, #dcc18f);
    border: 1px solid #c9ad79; border-radius: 3px 7px 7px 3px;
    box-shadow: 4px 6px 14px rgba(74,58,34,.20), inset 0 0 0 6px rgba(255,253,244,.55), inset 0 0 0 7px #d5bd92;
    color: var(--ink); text-decoration: none;
    transition: transform .18s ease, box-shadow .18s ease;
}
.cover:hover, .cover:focus-visible {
    transform: translateY(-4px);
    box-shadow: 6px 12px 22px rgba(74,58,34,.28), inset 0 0 0 6px rgba(255,253,244,.55), inset 0 0 0 7px #d5bd92;
    color: var(--ink); text-decoration: none;
}
.cover-spine {
    position: absolute; left: 0; top: 0; bottom: 0; width: 12px;
    background: linear-gradient(90deg, #87663a, #b28d55, #87663a);
    border-right: 1px solid #6f522f;
}
.cover-cat { display: block; font-size: 11px; color: #8a4a34; letter-spacing: 2px; }
.cover-title {
    display: block; margin: 10px auto 0; max-height: 70%; overflow: hidden;
    writing-mode: vertical-rl; text-orientation: upright; white-space: nowrap;
    font-size: 19px; line-height: 1.5; letter-spacing: 3px; font-weight: 600;
}
.cover-seal {
    position: absolute; right: 14px; bottom: 32px; width: 30px; height: 30px;
    display: grid; place-items: center; background: var(--red); color: #fff;
    border-radius: 3px; font-size: 16px;
    box-shadow: inset 0 0 0 2px rgba(255,255,255,.4);
}
.cover-foot {
    position: absolute; left: 26px; right: 10px; bottom: 8px;
    font-size: 9px; color: #8c7550; letter-spacing: 1px;
}

/* 真实封面（PDF 第一页缩略图）默认直接显示，不依赖脚本；
   仅当图片加载失败时由 site.js 加 no-real-cover 类回退到程序化线装书。 */
.cover-img {
    position: absolute; inset: 0; z-index: 1;
    width: 100%; height: 100%; object-fit: cover;
    display: block; background: #f4e8cd;
}
.cover.no-real-cover .cover-img { display: none; }
.cover:hover, .cover:focus-visible {
    box-shadow: 6px 12px 22px rgba(74,58,34,.28), 0 0 0 2px var(--red);
}

.detail-top { display: flex; gap: 22px; align-items: flex-start; flex-wrap: wrap; }
.cover.mini { width: 150px; flex: 0 0 auto; padding: 14px 12px 12px 20px; }
.cover.mini .cover-title { font-size: 14px; letter-spacing: 2px; }
.cover.mini .cover-seal { width: 22px; height: 22px; font-size: 12px; bottom: 26px; right: 10px; }
.cover.mini .cover-foot { left: 20px; font-size: 7px; }
.detail-top .detail-head { flex: 1 1 320px; border-bottom: none; padding-bottom: 0; }

/* ---------- 详情页在线预览 ---------- */
.preview-section { margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--line); }
.preview-tabs { display: flex; gap: 6px; }
.tab-btn {
    padding: 8px 22px; background: var(--paper-deep); border: 1px solid var(--line);
    border-radius: 6px 6px 0 0; cursor: pointer; font-family: inherit;
    font-size: 14px; color: var(--ink);
}
.tab-btn.active { background: var(--red); border-color: var(--red); color: #fff; }
.tab-btn:disabled { opacity: .45; cursor: not-allowed; }
.preview-panel {
    background: var(--card); border: 1px solid var(--line);
    border-radius: 0 6px 6px 6px; padding: 14px;
}
.preview-panel[hidden] { display: none; }
.txt-preview {
    margin: 0; padding: 14px; max-height: 520px; overflow: auto;
    background: #fdfaf1; border: 1px solid #eee5d0; border-radius: 4px;
    white-space: pre-wrap; word-break: break-word;
    font-family: "Songti SC", "SimSun", serif; font-size: 15.5px;
    line-height: 1.9; color: var(--ink);
}
/* PDF 试读：只显示前几页 WebP 图片，不暴露完整 PDF 地址 */
.preview-stage {
    display: flex; gap: 14px; align-items: flex-start;
    min-height: 280px; padding: 16px;
    background: #e9e2d5; border: 1px solid var(--line); border-radius: 4px;
}
.preview-side {
    display: flex; flex-direction: column;
    flex: 0 0 190px; max-height: min(70vh, 760px);
    background: #fdfaf1; border: 1px solid var(--line); border-radius: 4px;
    overflow: hidden;
}
.side-tabs { display: flex; flex: 0 0 auto; border-bottom: 1px solid var(--line); }
.side-tab {
    flex: 1; padding: 7px 4px; border: 0; background: #f0e3c6;
    color: var(--ink); font-size: 12px; cursor: pointer;
}
.side-tab.active { background: var(--red); color: #fff; font-weight: 600; }
.side-body { flex: 1 1 auto; overflow-y: auto; padding: 8px; }
.side-body[hidden] { display: none; }
.toc-hint { margin: 0 0 6px; font-size: 10px; color: #a08a63; line-height: 1.4; }
.toc-loading { margin: 4px 0; font-size: 12px; color: #8c7550; }
.toc-item {
    display: block; width: 100%; margin-bottom: 2px; padding: 5px 6px;
    border: 0; border-radius: 3px; background: none; text-align: left;
    color: var(--ink); font-size: 12px; line-height: 1.45;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer;
}
.toc-item:hover { background: #ede2c9; }
.toc-item.current { background: var(--red); color: #fff; }
.toc-item.locked { color: #a08f75; }
.toc-item.locked::after { content: ' · 需购买'; font-size: 10px; color: #b06a55; }
.thumb-nav { display: flex; flex-direction: column; gap: 8px; }
.thumb {
    display: block; width: 100%; padding: 4px;
    border: 2px solid transparent; border-radius: 3px;
    background: #fff; cursor: pointer;
    box-shadow: 0 1px 4px rgba(74,58,34,.18);
}
.thumb:hover { border-color: #c9ad79; }
.thumb.active { border-color: var(--red); }
.thumb img { display: block; width: 100%; height: auto; }
.thumb span {
    display: block; padding-top: 2px; text-align: center;
    font-size: 11px; color: #8c7550;
}
.thumb.active span { color: var(--red); font-weight: 600; }
.preview-main {
    flex: 1 1 auto; min-width: 0;
    display: flex; justify-content: center; align-items: center;
}
.preview-page {
    display: none; max-width: 100%; max-height: min(70vh, 760px);
    object-fit: contain; background: #fff;
    box-shadow: 0 4px 18px rgba(74,58,34,.24);
}
.preview-page.active { display: block; }
.preview-ctrl {
    display: flex; justify-content: center; align-items: center;
    gap: 16px; padding-top: 12px;
}
.preview-ctrl button:disabled { opacity: .45; cursor: not-allowed; }

/* ---------- 试读图片放大灯箱 ---------- */
.lightbox {
    position: fixed; inset: 0; z-index: 9999;
    display: flex; align-items: center; justify-content: center;
    background: rgba(20,16,10,.88); padding: 40px 64px;
}
.lightbox[hidden] { display: none; }
.lightbox .lb-img {
    max-width: 100%; max-height: calc(100vh - 90px);
    object-fit: contain; background: #fff;
    box-shadow: 0 8px 40px rgba(0,0,0,.5);
}
.lightbox .lb-nav, .lightbox .lb-close {
    position: absolute; border: 0; cursor: pointer; color: #fff;
    background: rgba(255,255,255,.14); border-radius: 50%;
    font-family: Arial, sans-serif; line-height: 1;
}
.lightbox .lb-nav:hover, .lightbox .lb-close:hover { background: rgba(255,255,255,.28); }
.lightbox .lb-nav { top: 50%; transform: translateY(-50%); width: 52px; height: 52px; font-size: 38px; }
.lightbox .lb-prev { left: 16px; }
.lightbox .lb-next { right: 16px; }
.lightbox .lb-close { top: 16px; right: 18px; width: 42px; height: 42px; font-size: 30px; }
.lightbox .lb-cap {
    position: absolute; bottom: 16px; left: 0; right: 0;
    text-align: center; color: rgba(255,255,255,.85); font-size: 13px;
}
@media (max-width: 720px) {
    .lightbox { padding: 30px 12px; }
    .lightbox .lb-nav { width: 40px; height: 40px; font-size: 30px; }
    .lightbox .lb-prev { left: 4px; }
    .lightbox .lb-next { right: 4px; }
}

@media (max-width: 720px) {
    .header-inner { gap: 12px; }
    /* 手机端点按目标要够大：用户名按钮 40px 高，下拉项 44px 高 */
    .account-name { padding: 10px 14px; line-height: 1.2; }
    .account-drop { min-width: 156px; }
    .account-drop a {
        display: flex; align-items: center; min-height: 44px;
        padding: 0 16px; font-size: 15px;
    }
    .brand-text strong { font-size: 18px; }
    .brand-text small { font-size: 14px; letter-spacing: 1px; }
    .search-form { order: 3; flex-basis: 100%; max-width: none; }
    .hero { padding: 22px; }
    .hero h1 { font-size: 26px; }
    .detail-card { padding: 20px 16px; }
    .book-grid { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
    .cover-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 14px; }
    .cover-title { font-size: 16px; }
    .cover.mini { width: 120px; }
    .preview-stage { min-height: 200px; padding: 10px; gap: 8px; }
    .preview-side { flex-basis: 132px; }
    .side-body { padding: 6px; }
    .toc-item { font-size: 11px; }
    .preview-page { max-height: 60vh; }
}

/* ---------- 顶部账户入口 ---------- */
.header-actions { display: flex; align-items: center; gap: 14px; }
.account-login, .account-name {
    padding: 6px 12px; border: 1px solid var(--line); border-radius: 5px;
    color: var(--red); background: var(--card); font-size: 13.5px; white-space: nowrap;
}
.account-login:hover, .account-name:hover { border-color: var(--red); text-decoration: none; }
.account-menu { position: relative; }
.account-drop {
    display: none; position: absolute; right: 0; top: 100%; z-index: 30;
    min-width: 130px; background: var(--card); border: 1px solid var(--line);
    border-radius: 5px; box-shadow: var(--shadow); padding: 6px 0;
}
/* 只在真正有 hover 的设备上用悬停展开；触屏的 hover 会「粘住」并吃掉第一次点击，
   导致「退出登录」点不动，触屏一律交给 JS 的 .open 控制。 */
@media (hover: hover) {
    .account-menu:hover .account-drop,
    .account-menu:focus-within .account-drop { display: block; }
}
.account-menu.open .account-drop { display: block; }
.account-drop a { display: block; padding: 7px 14px; color: var(--ink); font-size: 13.5px; }
.account-drop a:hover { background: var(--paper-deep); text-decoration: none; }

/* ---------- 认证表单（注册/登录/用户中心） ---------- */
.auth-box {
    max-width: 440px; margin: 18px auto 40px; background: var(--card);
    border: 1px solid var(--line); border-top: 4px solid var(--gold);
    border-radius: var(--radius); box-shadow: var(--shadow); padding: 26px 28px;
}
.auth-box h2 { margin: 0 0 6px; font-size: 21px; text-align: center; letter-spacing: 2px; }
.auth-tip { margin: 0 0 22px; text-align: center; font-size: 13px; color: var(--ink-soft); }
.form-field { margin-bottom: 15px; }
.form-field label { display: block; font-size: 13.5px; margin-bottom: 6px; color: var(--ink); }
.form-field input, .form-field select {
    width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 4px;
    font-size: 14px; font-family: inherit; background: #fff; color: var(--ink);
}
.form-field input:focus, .form-field select:focus {
    outline: none; border-color: var(--gold); box-shadow: 0 0 0 2px rgba(176,138,74,.18);
}
.form-check { display: flex; align-items: center; gap: 7px; font-size: 13.5px; color: var(--ink-soft); }
.form-check input { width: auto; }
.field-error { display: block; color: var(--red); font-size: 12.5px; margin-top: 3px; }
.btn-primary {
    width: 100%; padding: 10px; border: none; border-radius: 4px; cursor: pointer;
    background: var(--red); color: #fff; font-size: 15px; letter-spacing: 3px; font-family: inherit;
}
.btn-primary:hover { background: var(--red-dark); }
.auth-alt { margin-top: 16px; text-align: center; font-size: 13.5px; color: var(--ink-soft); }
.pricing-note {
    font-size: 13px; line-height: 1.8; color: var(--ink-soft);
    margin: 0 0 16px; max-width: 760px;
}
.pricing-note strong { color: var(--red); }
.pricing-form {
    display: flex; flex-wrap: wrap; gap: 14px 18px; align-items: flex-end;
    padding: 16px 18px; margin: 0 0 22px;
    background: var(--card); border: 1px solid var(--line); border-radius: 6px;
}
.pricing-form label {
    display: flex; flex-direction: column; gap: 5px;
    font-size: 13px; color: var(--ink-soft); white-space: nowrap;
}
.pricing-form input {
    width: 132px; padding: 7px 9px; font-size: 14px; font-family: inherit;
    font-variant-numeric: tabular-nums; color: var(--ink);
    background: #fff; border: 1px solid var(--line); border-radius: 4px;
}
.pricing-form input:focus {
    outline: none; border-color: var(--gold);
    box-shadow: 0 0 0 2px rgba(176, 138, 74, .18);
}
.pricing-form button {
    padding: 8px 20px; font-size: 14px; font-family: inherit; cursor: pointer;
    color: #fff; background: var(--red); border: 1px solid var(--red); border-radius: 4px;
}
.pricing-form button:hover { background: var(--red-dark); border-color: var(--red-dark); }
.admin-table tfoot th {
    padding-top: 10px; border-top: 1px solid var(--line);
    font-size: 13px; color: var(--ink); text-align: left;
}
@media (max-width: 720px) {
    .pricing-form { padding: 14px; gap: 12px; }
    .pricing-form label { flex: 1 1 44%; }
    .pricing-form input { width: 100%; }
    .pricing-form button { width: 100%; }
}

.alert-error, .alert-ok {
    font-size: 13.5px; padding: 9px 12px; margin-bottom: 16px; border-radius: 4px;
}
.alert-error { background: #fdeeeb; border: 1px solid #f0c9bd; color: var(--red-dark); }
.alert-ok { background: #eef6ee; border: 1px solid #c7e0c9; color: var(--green); }
.captcha-row { display: flex; gap: 8px; align-items: center; }
.captcha-input { flex: 1; text-transform: uppercase; letter-spacing: 2px; }
.captcha-img { height: 40px; border: 1px solid var(--line); border-radius: 3px; cursor: pointer; }
.captcha-refresh { display: inline-block; margin-top: 4px; font-size: 12.5px; color: var(--ink-soft); }
.captcha-hint { display: inline-block; margin-top: 4px; font-size: 12.5px; color: var(--ink-soft); }

/* ---------- 用户中心 ---------- */
.profile-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 18px; }
.profile-card {
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 20px 22px;
}
.profile-card h3 { margin: 0 0 14px; font-size: 17px; letter-spacing: 1px; }
.info-list { display: grid; grid-template-columns: 76px 1fr; gap: 8px 12px; margin: 0 0 14px; font-size: 14px; }
.info-list dt { color: var(--ink-soft); }
.info-list dd { margin: 0; }

/* 用户中心选项卡 */
.profile-tabs {
    display: flex; gap: 4px; flex-wrap: wrap;
    border-bottom: 2px solid var(--line); margin-bottom: 20px;
}
.ptab {
    padding: 9px 18px; background: none; border: none; border-bottom: 2px solid transparent;
    margin-bottom: -2px; color: var(--ink-soft); font-size: 15px; font-family: inherit; cursor: pointer;
}
.ptab:hover { color: var(--red); }
.ptab.active { color: var(--red); border-bottom-color: var(--red); font-weight: 600; }
.tab-count {
    display: inline-block; margin-left: 5px; padding: 0 6px; border-radius: 9px;
    background: var(--red); color: #fff; font-size: 11px; line-height: 17px; vertical-align: 1px;
}
.tab-pane.is-hidden { display: none; }

/* 我购买的图书 */
.orders-summary { margin: 0 0 14px; color: var(--ink-soft); font-size: 13.5px; }
.order-card {
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
    box-shadow: var(--shadow); margin-bottom: 16px; overflow: hidden;
}
.order-head {
    display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
    padding: 11px 18px; background: var(--paper-deep); border-bottom: 1px solid var(--line);
    font-size: 13px; color: var(--ink-soft);
}
.order-no { font-weight: 600; color: var(--ink); letter-spacing: .5px; }
.order-total { margin-left: auto; color: var(--red); font-weight: 700; font-size: 15px; }
.order-items { list-style: none; margin: 0; padding: 0; }
.order-item {
    display: flex; align-items: center; gap: 12px; padding: 10px 18px;
    border-bottom: 1px solid var(--line);
}
.order-item:last-child { border-bottom: 0; }
.oi-cover { flex: none; width: 40px; height: 56px; object-fit: cover; border-radius: 3px; background: var(--paper-deep); }
.oi-main { min-width: 0; flex: 1; }
.oi-title {
    display: block; font-size: 15px; color: var(--ink);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.oi-title:hover { color: var(--red); }
.oi-meta { margin: 3px 0 0; font-size: 12.5px; color: var(--ink-soft); }
.oi-price { flex: none; color: var(--red); font-family: Arial, sans-serif; font-size: 14px; }
.order-empty p { margin: 0; color: var(--ink-soft); line-height: 1.75; }
@media (max-width: 520px) {
    .order-head { font-size: 12px; }
    .order-total { margin-left: 0; }
}

/* ---------- 后台管理 ---------- */
.admin-tabs {
    display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
    border-bottom: 2px solid var(--line); margin-bottom: 22px;
}
.admin-tab {
    padding: 8px 16px; color: var(--ink-soft); font-size: 14px; border-bottom: 2px solid transparent;
    margin-bottom: -2px;
}
.admin-tab:hover { text-decoration: none; color: var(--red); }
.admin-tab.active { color: var(--red); border-bottom-color: var(--red); font-weight: 600; }
.admin-who { margin-left: auto; color: var(--ink-soft); font-size: 13px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; }
.stat-card {
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 18px 20px;
}
.stat-card span { display: block; color: var(--ink-soft); font-size: 13px; }
.stat-card strong { display: block; font-size: 28px; color: var(--red); margin-top: 4px; }
.admin-search { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.admin-search input[type=search] {
    padding: 8px 11px; border: 1px solid var(--line); border-radius: 4px; font-family: inherit;
    font-size: 14px; min-width: 260px;
}
.admin-search select { padding: 8px 10px; border: 1px solid var(--line); border-radius: 4px; font-family: inherit; }
.admin-search button {
    padding: 8px 18px; border: none; border-radius: 4px; background: var(--red); color: #fff;
    cursor: pointer; font-family: inherit;
}
.admin-table { width: 100%; border-collapse: collapse; background: var(--card); font-size: 13.5px; }
.admin-table th, .admin-table td {
    border: 1px solid var(--line); padding: 8px 10px; text-align: left; vertical-align: middle;
}
.admin-table th { background: var(--paper-deep); font-weight: 600; }
.admin-table tr:hover td { background: #fdfaf2; }
.badge-status { padding: 2px 8px; border-radius: 10px; font-size: 12px; }
.badge-status.on { background: #eef6ee; color: var(--green); }
.badge-status.off { background: #f6eded; color: var(--red); }
.op-cell { white-space: nowrap; }
.btn-mini {
    display: inline-block; padding: 4px 10px; margin: 1px 2px; border: 1px solid var(--line);
    border-radius: 4px; background: var(--card); color: var(--ink); cursor: pointer; font-size: 12.5px;
    font-family: inherit; list-style: none;
}
.btn-mini:hover { border-color: var(--red); text-decoration: none; }
.btn-danger { color: var(--red); }
.edit-detail { display: inline-block; position: relative; }
.edit-detail summary { cursor: pointer; }
.edit-form {
    position: absolute; right: 0; top: 100%; z-index: 20; width: 240px; padding: 12px;
    background: var(--card); border: 1px solid var(--line); border-radius: 5px; box-shadow: var(--shadow);
}
.edit-form label { display: block; font-size: 12.5px; margin-bottom: 8px; }
.edit-form select, .edit-form input { width: 100%; padding: 5px 7px; margin-top: 2px; border: 1px solid var(--line); border-radius: 3px; font-family: inherit; }

@media (max-width: 720px) {
    .header-actions { gap: 8px; }
    .admin-table { font-size: 12px; }
    .admin-table th, .admin-table td { padding: 5px 6px; }
    .admin-search input[type=search] { min-width: 0; width: 100%; }
    /* 移动端：格式卡片一行两种 */
    .format-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .format-card { padding: 12px 10px; }
    .format-price strong { font-size: 22px; }
    .fmt-pill.big { font-size: 11px; padding: 2px 6px; }
}

/* ---------- 在线支付 / 已购下载 ---------- */
.order-status {
    flex: none; padding: 2px 8px; border-radius: 3px; font-size: 12px; font-weight: 600;
    border: 1px solid currentColor;
}
.order-status.is-paid { color: var(--green); background: rgba(63, 107, 74, .08); }
.order-status.is-pending { color: #a9661e; background: rgba(169, 102, 30, .08); }
.btn-pay {
    flex: none; padding: 5px 12px; border-radius: 4px; font-size: 12.5px; font-weight: 600;
    background: var(--red); color: #fff; border: 1px solid var(--red);
}
.btn-pay:hover { background: var(--red-dark); color: #fff; text-decoration: none; }
.oi-download {
    flex: none; min-width: 64px; text-align: center; padding: 6px 12px;
    border: 1px solid var(--red); border-radius: 4px; color: var(--red); font-size: 13px;
}
.oi-download:hover { background: var(--red); color: #fff; text-decoration: none; }
.order-paid-at { margin: 0; padding: 8px 18px; font-size: 12px; color: var(--ink-soft); background: var(--paper); }
.pay-box { max-width: 560px; }
.pay-order-line {
    display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
    padding: 9px 0; border-bottom: 1px dashed var(--line); font-size: 14px;
}
.pay-order-line span { color: var(--ink-soft); }
.pay-order-line strong { color: var(--ink); font-weight: 600; word-break: break-all; }
.pay-amount { color: var(--red) !important; font-size: 20px; font-weight: 700 !important; }
.pay-tip { margin: 16px 0 8px; font-size: 13px; color: var(--ink-soft); line-height: 1.7; }
.pay-tip a { color: var(--red); }
.pay-submit { width: 100%; height: 44px; margin-top: 6px; font-size: 15px; letter-spacing: 1px; }
.pay-actions { display: flex; align-items: center; gap: 18px; margin: 20px 0 0; font-size: 13.5px; }
@media (max-width: 520px) {
    .order-item { gap: 8px; padding: 10px 12px; }
    .oi-download { min-width: 56px; padding: 6px 8px; font-size: 12.5px; }
    .order-head { gap: 8px; }
}
