/* 书法全景库 —— 宣纸墨色主题 */
:root {
  --paper: #f4efe4;
  --paper-2: #ece5d4;
  --ink: #2c2a26;
  --ink-2: #6b655a;
  --line: #d8d0bd;
  --accent: #a03c28;       /* 朱砂 */
  --accent-ink: #7d2f1f;
  --card: #fbf8f0;
  --shadow: 0 2px 10px rgba(60, 50, 30, .12);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: "Noto Serif SC", "Source Han Serif SC", "SimSun", serif;
  background: var(--paper); color: var(--ink);
  display: flex; flex-direction: column;
}

/* ---- 顶栏 ---- */
.topbar {
  display: flex; align-items: center; gap: 0px;
  padding: 0px 10px; background: var(--paper-2);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20; flex-wrap: wrap;
}
.brand { white-space: nowrap; display: inline-flex; align-items: center; }
.brand img { height: 60px; width: auto; display: block; }
.searchbox { margin-left: auto; }
.top-actions { display: flex; align-items: center; }
.top-actions .searchbox { margin-left: 0; }
.seal {
  display: inline-grid; place-items: center; width: 30px; height: 30px;
  background: var(--accent); color: #fff; border-radius: 4px;
  font-size: 16px; margin-right: 10px; letter-spacing: 0;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.35);
}
.searchbox { flex: 1; min-width: 120px; max-width: 520px; }
.searchbox input {
  width: 100%; padding: 8px 14px; font: inherit; font-size: 14px;
  border: 1px solid var(--line); border-radius: 5px; background: var(--card);
  color: var(--ink); outline: none; transition: border-color .2s;
}
.searchbox input:focus { border-color: var(--accent); }
.top-actions { display: flex; align-items: center; gap: 0px; margin-left: auto; }
.stat { font-size: 12px; color: var(--ink-2); }
button {
  font: inherit; cursor: pointer; border: 1px solid var(--line);
  background: var(--card); color: var(--ink);
  border-radius: 6px; padding: 6px 14px; font-size: 14px; transition: all .15s;
}
button:hover { border-color: var(--accent); color: var(--accent); }
button.ghost { background: transparent; }
button.on { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ---- 布局 ---- */
.layout { display: flex; flex: 1; min-height: 0; }
.sidebar {
  width: 220px; flex-shrink: 0; overflow-y: auto;
  border-right: 1px solid var(--line); padding: 14px 10px;
  background: linear-gradient(180deg, var(--paper-2), var(--paper));
}
.main { flex: 1; min-width: 0; overflow-y: auto; padding: 10px 20px 10px; }

/* ---- 分类树 ---- */
.cat-item {
  padding: 7px 12px; border-radius: 6px; cursor: pointer;
  font-size: 15px; display: flex; align-items: baseline; gap: 8px;
  user-select: none; transition: background .15s; font-weight: 700;
}
.cat-item:hover { background: rgba(160, 60, 40, .08); }
.cat-item.active { background: var(--accent); color: #fff; }
.cat-item .cnt { margin-left: auto; font-size: 12px; color: var(--ink-2); }
.cat-item.active .cnt { color: rgba(255,255,255,.85); }
.cat-item .arrow { width: 14px; font-size: 11px; color: var(--ink-2); transition: transform .2s; }
.cat-item .arrow.open { transform: rotate(90deg); }
.cat-children { margin-left: 16px; border-left: 1px dashed var(--line); padding-left: 6px; display: none; }
.cat-children.open { display: block; }

/* ---- 面包屑 ---- */
.crumb {
  font-size: 13px; color: var(--ink-2); margin-bottom: 14px;
  display: flex; align-items: center; flex-wrap: wrap; row-gap: 4px;
}
.crumb a, .crumb span {
  padding: 3px 10px; border-radius: 999px; text-decoration: none;
  color: var(--ink-2); white-space: nowrap; transition: background .15s, color .15s;
}
.crumb a:hover { background: rgba(160, 60, 40, .08); color: var(--accent); }
.crumb .crumb-home::before { content: "🏠 "; font-size: 11px; }
.crumb span { color: var(--ink); font-weight: 700; }
.crumb .sep { font-style: normal; color: #c9c0ac; padding: 0 1px; user-select: none; }

/* ---- 作品上下篇导航 ---- */
.work-pager { display: flex; gap: 12px; margin: 20px 0; }
.work-pager > div { flex: 1; min-width: 0; }
.work-pager a {
  display: flex; align-items: center; gap: 6px; min-width: 0;
  padding: 10px 14px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--card); color: var(--ink); text-decoration: none; font-size: 14px;
  transition: border-color .15s, color .15s, box-shadow .15s;
}
.work-pager a:hover { border-color: var(--accent); color: var(--accent); box-shadow: var(--shadow); }
.work-pager a span {
  flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.work-pager .wp-prev { justify-content: flex-start; }
.work-pager .wp-next { justify-content: flex-end; }

/* ---- 作品网格 ---- */
.grid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 8px;
  overflow: hidden; cursor: pointer; transition: transform .15s, box-shadow .15s;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.card .thumb {
  aspect-ratio: 4 / 3; background: var(--paper-2);
  display: grid; place-items: center; overflow: hidden; position: relative;
}
.card .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card .thumb img.err { display: none; }
.card .thumb .ph { font-size: 40px; color: var(--line); font-family: "KaiTi", serif; }
.card .t { padding: 10px 12px 11px; display: flex; flex-direction: column; gap: 6px; }
.card .t .name {
  font-size: 15px; font-weight: 600; line-height: 1.45; height: 2.9em; color: var(--ink);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card .t .meta {
  display: flex; align-items: baseline; gap: 6px;
  font-size: 12px; color: var(--ink-2); line-height: 1;
  white-space: nowrap; overflow: hidden;
}
.card .t .meta .author {
  color: var(--accent-ink); font-size: 13px; flex-shrink: 0; max-width: 55%;
  overflow: hidden; text-overflow: ellipsis;
}
.card .t .meta .dyn { flex-shrink: 0; }
.card .t .meta .dim {
  margin-left: auto; flex-shrink: 0; font-family: Consolas, monospace; opacity: .85;
}
.card .t .meta .views {
  flex-shrink: 0; color: #b8860b; opacity: .9;
}
.more-wrap { text-align: center; margin: 24px 0; }
.hint { font-size: 13px; color: var(--ink-2); margin-top: 10px; }

/* ---- 查看器 ---- */
.viewer-wrap {
  position: fixed; inset: 0; z-index: 100; background: #161411;
  display: flex; flex-direction: column;
}
.viewer-wrap[hidden] { display: none; }  /* 覆盖 display:flex, 保证 hidden 生效 */
.viewer-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; color: #e8e2d4; background: rgba(0,0,0,.35);
}
.viewer-title { font-size: 17px; letter-spacing: 1px; flex: 1; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.viewer-tools { display: flex; gap: 8px; }
.viewer-tools button {
  background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.2);
  color: #e8e2d4; width: 34px; height: 34px; padding: 0; font-size: 16px;
  display: inline-flex; align-items: center; justify-content: center;
  line-height: 1; flex-shrink: 0;
}
.viewer-tools button:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.osd { flex: 1; min-height: 0; cursor: grab; }
.osd:active { cursor: grabbing; }
.viewer-meta {
  position: absolute; right: 16px; bottom: 12px;
  font-size: 12px; color: rgba(255,255,255,.55); pointer-events: none;
  font-family: Consolas, monospace;
}

/* ---- 滚动条 ---- */
::-webkit-scrollbar { width: 10px; }
::-webkit-scrollbar-thumb { background: #c9c0a8; border-radius: 5px; }
::-webkit-scrollbar-track { background: transparent; }

/* ---- 跳到主要内容 ---- */
.skip-link { position: absolute; left: -9999px; top: 0; z-index: 999;
  background: var(--accent); color: #fff; padding: 8px 16px; border-radius: 0 0 6px 0; }
.skip-link:focus { left: 0; }

/* ---- 汉堡按钮(移动端侧栏 toggle) ---- */
.cat-toggle { display: none; background: none; border: none; font-size: 22px;
  cursor: pointer; padding: 4px 8px; color: var(--ink); line-height: 1; }

/* ====== SEO 版新增: 通用区块 ====== */
.h1 { font-size: 26px; letter-spacing: 1px; margin: 6px 0 10px; }
.h1-row { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.h1-row .h1 { margin-bottom: 10px; }
.h1-links { display: flex; gap: 10px; align-items: center; margin: 6px 0 10px; white-space: nowrap; }
.h1-links a {
  display: inline-block; padding: 7px 16px; border: 1px solid var(--line);
  border-radius: 20px; background: var(--card); color: var(--ink);
  text-decoration: none; font-size: 14px;
}
.h1-links a:hover { border-color: var(--accent); color: var(--accent); }
.h2 { font-size: 19px; margin: 26px 0 12px; padding-left: 10px; border-left: 4px solid var(--accent); }
.h2 a { color: inherit; text-decoration: none; }
.h2 a:hover { color: var(--accent); }
.lead { color: var(--ink-2); line-height: 1.9; font-size: 15px; margin: 8px 0 14px; }
.main.wide { margin: 0 auto; width: 100%; }
.footer {
  text-align: center; padding: 5px 10px 5px; color: var(--ink-2); font-size: 12px;
  border-top: 1px solid var(--line); margin-top: 0px; line-height: 1.5;
}
.footer a { color: var(--ink-2); }
.footer a:hover { color: var(--accent); }
.footer-nav a { text-decoration: none; }
.pager { text-align: center; margin: 22px 0; }
.pager a, .pager b {
  display: inline-block; min-width: 34px; padding: 6px 10px; margin: 0 4px;
  border: 1px solid var(--line); border-radius: 6px; text-decoration: none; color: var(--ink);
}
.pager b.cur { background: var(--accent); color: #fff; border-color: var(--accent); }
.pager a:hover { border-color: var(--accent); color: var(--accent); }
.pager .dots { color: #999; padding: 6px 2px; margin: 0 1px; }
.dyn-chips .chip.cur{ background: var(--accent); color: #fff; border-color: var(--accent); }
.cur b { background: var(--accent); color: #fff; border-color: var(--accent); }
.meta-inline a { color: var(--accent); text-decoration: none; }

/* 作品要素: 信息卡 / 作者小卡 / 释文译文 */
.work-info { margin: 14px 0; padding: 12px 16px; border: 1px solid var(--line); border-radius: 10px; background: #faf9f6; }
.work-info dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0; }
.work-info dt { color: #888; white-space: nowrap; }
.work-info dd { margin: 0; color: var(--ink); }
.author-card { margin-bottom: 14px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.ac-head { display: flex; align-items: center; gap: 10px; }
.ac-t { display: flex; flex-direction: column; }
.ac-name { font-weight: 600; color: var(--ink); text-decoration: none; }
.ac-line { font-size: 12px; color: #888; }
.ac-bio { font-size: 13px; color: #555; line-height: 1.7; margin: 8px 0 4px; }
.ac-more { font-size: 13px; color: var(--accent); text-decoration: none; }
.bio-src { font-size: 12px; color: #aaa; }
.article details { margin: 8px 0; }
.article summary { cursor: pointer; font-weight: 600; color: var(--accent); }
.article details p { margin: 8px 0; line-height: 1.9; }
.meta-line { font-size: 13px; color: #666; margin: 10px 0 6px; }
.meta-line b { color: #999; font-weight: 400; margin-right: 2px; }
.meta-line .sep { color: #ccc; }
.side-col { display: flex; flex-direction: column; gap: 12px; }
.side-col .ad-slot { flex-shrink: 0; }
.vol-author { max-width: 100%; margin: 18px 0; }
.timeline { margin: 14px 0; border: 1px solid var(--line); border-radius: 10px; padding: 10px 16px; background: #faf9f6; }
.timeline summary { cursor: pointer; font-weight: 600; color: var(--accent); }
.timeline .tl-body p { margin: 7px 0; line-height: 1.8; font-size: 14px; color: #444; }
.shiwen-panel { margin: 20px 0; padding: 14px 18px; border: 1px solid var(--line); border-radius: 10px; background: #fff; display: grid; grid-template-columns: 1fr 1fr; gap: 0 22px; }
.shiwen-panel .sw-col h3 { margin: 6px 0; font-size: 15px; color: var(--accent); }
.shiwen-panel .sw-col p { margin: 8px 0; line-height: 2; font-size: 15px; max-height: 340px; overflow: auto; }
@media (max-width: 900px) { .shiwen-panel { grid-template-columns: 1fr; } }
.card { display: block; text-decoration: none; color: inherit; }
.avatar { border-radius: 10px; box-shadow: var(--shadow); flex-shrink: 0; }
.person-head { display: block; margin: 12px 0 6px; }
/* 图文混排: 头像居左浮动, 标题与简介文字环绕 */
.person-head > .avatar { float: left; margin: 4px 18px 10px 0; }
.person-head::after { content: ""; display: block; clear: both; }
.person-info .h1 .sub-line { font-size: 14px; color: var(--ink-2); margin-left: 12px; letter-spacing: 0; }
.person-stats { color: var(--ink-2); font-size: 13px; margin-top: 4px; }
.dyn-chips { display: flex; flex-wrap: wrap; gap: 10px; margin: 12px 0 6px; }
.chip {
  display: inline-block; padding: 7px 16px; border: 1px solid var(--line);
  border-radius: 20px; background: var(--card); color: var(--ink);
  text-decoration: none; font-size: 14px;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }
.person-list {
  display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  margin: 12px 0 8px;
}
.person-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--card);
  text-decoration: none; color: var(--ink); transition: all .15s;
}
.person-item:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow); }
.person-item .avatar { width: 44px !important; height: 44px !important; }
.pi-name { font-size: 15px; }
.pi-cnt { margin-left: auto; font-size: 12px; color: var(--ink-2); }
.dyn-card {
  border: 1px solid var(--line); border-radius: 8px; background: var(--card);
  padding: 14px 18px; margin: 12px 0;
}
.dyn-intro { color: var(--ink-2); font-size: 14px; line-height: 1.9; }
.cat-item a { color: inherit; text-decoration: none; flex: 1; }
.cat-item.sub { margin-left: 14px; }

/* ---- 移动端 ---- */
@media (max-width: 720px) {
  /* 整页自然滚动: 顶栏/页脚跟随页面滑动, 不再固定 */
  body { height: auto; display: block; }
  .layout { min-height: 0; }
  /* 顶栏两行: 第一行 ☰ logo 🎲居中, 第二行搜索框通栏 */
  .topbar { position: static; padding: 8px 12px; gap: 8px;
    justify-content: center; align-items: center; }
  .topbar .cat-toggle { order: 1; }
  .topbar .brand { order: 2; }
  .topbar .random-btn { order: 3; }
  .topbar .reward-btn { order: 4; }
  .top-actions { order: 5; width: 100%; margin-left: 0; }
  .top-actions .searchbox { margin-left: 0; max-width: 100%; }
  .brand img { height: 40px; }
  .sidebar { position: fixed; z-index: 50; top: 0; bottom: 0; left: -240px;
    transition: left .25s; box-shadow: var(--shadow); }
  .sidebar.show { left: 0; }
  .main { overflow: visible; padding: 12px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
  .cat-toggle { display: inline-block !important; }
  .pager a, .pager b {
    display: inline-block;
    min-width: 30px;
    padding: 5px 8px;
    margin: 0 2px;
    border: 1px solid var(--line);
    border-radius: 6px;
    text-decoration: none;
    color: var(--ink);
}
  .person-head > .avatar { margin: 2px 14px 8px 0; }
  .work-pager { gap: 8px; margin: 14px 0; }
  .work-pager a { padding: 9px 10px; font-size: 13px; }
}
/* ---- 随机欣赏按钮 ---- */
.random-btn { text-decoration: none; font-size: 14px; color: var(--accent);
  padding: 4px 8px; border-radius: 5px; white-space: nowrap;
  border: 1px solid var(--line); background: var(--card); transition: all .15s; }
.random-btn:hover { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ---- 打赏按钮与弹层 ---- */
.reward-btn { font-size: 14px; color: var(--accent); padding: 4px 8px; border-radius: 5px;
  white-space: nowrap; cursor: pointer; font-family: inherit; transition: all .15s;
  border: 1px solid var(--line); background: var(--card); }
.reward-btn:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.reward-modal { position: fixed; inset: 0; z-index: 9998; display: flex;
  align-items: center; justify-content: center; padding: 20px; }
.reward-modal[hidden] { display: none; }
.reward-mask { position: absolute; inset: 0; background: rgba(15, 12, 8, .62); }
.reward-box { position: relative; z-index: 1; background: #fff; border-radius: 14px;
  padding: 26px 24px 20px; max-width: 460px; width: 100%; text-align: center;
  box-shadow: 0 12px 40px rgba(0,0,0,.3); max-height: calc(100vh - 40px); overflow: auto; }
.reward-close { position: absolute; top: 10px; right: 12px; width: 32px; height: 32px;
  border: none; background: transparent; color: #999; font-size: 16px; cursor: pointer;
  border-radius: 6px; }
.reward-close:hover { background: #f2ede2; color: var(--ink); }
.reward-title { margin: 0 0 4px; font-size: 20px; color: var(--ink); }
.reward-sub { margin: 0 0 16px; font-size: 13px; color: var(--ink-2); }
.reward-qr { display: flex; gap: 18px; justify-content: center; flex-wrap: wrap; }
.reward-qr figure { margin: 0; }
.reward-qr img { width: 190px; height: 190px; border: 1px solid var(--line);
  border-radius: 10px; background: #fff; }
.reward-qr figcaption { margin-top: 6px; font-size: 14px; color: var(--ink); font-weight: 600; }
@media (max-width: 480px) {
  .reward-box { padding: 20px 14px 14px; }
  .reward-qr img { width: 150px; height: 150px; }
}

/* ---- 繁简切换浮动按钮 ---- */
.s2t-btn { position: fixed; right: 18px; bottom: 18px; z-index: 9000;
  width: 45px; height: 45px; border-radius: 50%; cursor: pointer;
  font-size: 17px; font-family: inherit; color: var(--accent);
  background: var(--card); border: 1.5px solid var(--accent);
  box-shadow: 0 4px 14px rgba(0,0,0,.18); transition: all .15s;
  display: inline-flex; align-items: center; justify-content: center;
  line-height: 1; padding: 0; }
.s2t-btn:hover { background: var(--accent); color: #fff; }
.s2t-btn.busy { opacity: .5; pointer-events: none; }
.s2t-btn.hide { opacity: 0; pointer-events: none; }
@media (max-width: 720px) {
  .s2t-btn { right: 12px; bottom: 12px; width: 40px; height: 40px; font-size: 15px; }
}

/* ---- 书法术语: 对观实物链接 ---- */
.term-links { margin: -2px 0 10px; font-size: 13px; color: var(--ink-2); }
.term-links a { color: var(--accent); text-decoration: none; }
.term-links a:hover { text-decoration: underline; }

/* ---- 每日一帖: 居中展示, 桌面/移动自适应 ---- */
.meiri-main { max-width: 860px; margin: 0 auto; }
.meiri-main > .h1, .meiri-main > .lead { text-align: center; }
.meiri-figure { text-align: center; margin: 16px 0 4px; }
.meiri-figure img { display: block; max-width: 100%; max-height: 62vh; width: auto; height: auto;
  margin: 0 auto; border: 1px solid var(--line); border-radius: 8px; background: var(--card); }
.meiri-figure .meta-inline { margin: 12px 0 0; }
.meiri-actions { text-align: center; margin: 16px 0; }
.meiri-btn { display: inline-block; padding: 10px 22px; background: var(--accent); color: #fff;
  border-radius: 6px; text-decoration: none; font-size: 15px; transition: background .15s; }
.meiri-btn:hover { background: var(--accent-ink); color: #fff; }
.meiri-meta { text-align: center; line-height: 1.9; max-width: 100%; overflow-wrap: break-word; }
.meiri-card { margin: 0 auto 18px; }
.meiri-card .h2 { text-align: center; }
.meiri-cards { text-align: center; }
.meiri-cards .article { text-align: left; }
.meiri-cards .author-card { text-align: left; }
.meiri-main .dyn-chips { justify-content: center; }
.meiri-main .crumb { justify-content: center; }
@media (max-width: 720px) {
  .meiri-main { max-width: 100%; }
  .meiri-figure img { max-height: 52vh; }
  .meiri-cards .article { text-align: justify; }
}

/* ---- 最近更新页: 日期徽章 ---- */
.recent-item { position: relative; min-width: 0; }
.recent-item .upd-badge {
  position: absolute; top: 8px; left: 8px; z-index: 2;
  background: rgba(0, 0, 0, .55); color: #fff; border-radius: 10px;
  font-size: 12px; padding: 2px 8px; font-family: Consolas, monospace;
  pointer-events: none;
}

/* ---- 打印样式(教育用途) ---- */
@media print {
  .topbar, .sidebar, .footer, .viewer-wrap, .random-btn, .cat-toggle, .s2t-btn,
  .work-actions, .searchbox, audio, .page-grid, .grid, .dyn-chips, .pager,
  .work-pager, .hint, details[open] summary { display: none !important; }
  body { font-size: 12pt; line-height: 1.8; color: #000; background: #fff; }
  .main { padding: 0; max-width: 100%; }
  .work-title, .h1 { font-size: 18pt; page-break-after: avoid; }
  .h2 { font-size: 14pt; page-break-after: avoid; }
  .article p { font-size: 12pt; max-height: none !important; overflow: visible !important; }
  .work-thumb { page-break-inside: avoid; }
  .work-hero { page-break-inside: avoid; }
  .person-head { page-break-inside: avoid; }
  .skip-link { display: none; }
  a { color: #000; text-decoration: none; }
  img { max-width: 100% !important; max-height: 400pt !important; }
}
