/* ============================================================
   香乘 · 中华香道学习站  —  宣纸 · 玄墨 · 朱砂
   ============================================================ */
:root {
  --paper: #f4eee1;          /* 宣纸 */
  --paper-2: #faf6ec;        /* 卡片纸 */
  --paper-3: #ece3cf;        /* 深一度 */
  --ink: #2f2a24;            /* 玄墨 */
  --ink-2: #5a5248;          /* 淡墨 */
  --ink-3: #8c8271;          /* 灰墨 */
  --cinnabar: #a4342a;       /* 朱砂 */
  --cinnabar-2: #c05248;     /* 朱砂浅 */
  --gold: #a07f3c;           /* 鎏金 */
  --line: #d9cdb4;           /* 界线 */
  --shadow: 0 2px 14px rgba(66, 50, 30, .10);
  --radius: 10px;
  --font-kai: "Kaiti SC", "KaiTi", "STKaiti", "楷体", "Songti SC", serif;
  --font-song: "Songti SC", "SimSun", "宋体", "Noto Serif SC", serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-song);
  background: var(--paper);
  color: var(--ink);
  line-height: 1.85;
  font-size: 16px;
  background-image:
    radial-gradient(rgba(160, 127, 60, .045) 1px, transparent 1.2px),
    linear-gradient(180deg, #f6f1e5, #f2ebdb);
  background-size: 22px 22px, 100% 100%;
}

img { max-width: 100%; display: block; }
a { color: var(--cinnabar); text-decoration: none; }
a:hover { color: var(--cinnabar-2); }

.wrap { max-width: 1160px; margin: 0 auto; padding: 0 18px; }

/* ── 顶部导航 ── */
.nav {
  position: sticky; top: 0; z-index: 90;
  background: rgba(250, 246, 236, .94);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.nav-inner { display: flex; align-items: center; height: 58px; gap: 10px; }
.brand {
  display: flex; align-items: center; gap: 9px;
  font-family: var(--font-kai); font-size: 21px; font-weight: 700;
  color: var(--ink); white-space: nowrap;
}
.brand .seal {
  width: 30px; height: 30px; background: var(--cinnabar); color: #fdf6e9;
  border-radius: 5px; display: flex; align-items: center; justify-content: center;
  font-size: 15px; box-shadow: inset 0 0 0 1.5px rgba(255,255,255,.35);
}
.brand em { font-style: normal; font-size: 12px; color: var(--ink-3); font-weight: 400; margin-left: 2px; }
.nav-links { display: flex; gap: 2px; margin-left: auto; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
.nav-links::-webkit-scrollbar { display: none; }
.nav-links a {
  padding: 7px 11px; border-radius: 7px; color: var(--ink-2);
  font-size: 14.5px; white-space: nowrap; font-family: var(--font-kai);
}
.nav-links a:hover { background: var(--paper-3); color: var(--ink); }
.nav-links a.on { background: var(--cinnabar); color: #fdf6e9; }
.menu-btn { display: none; margin-left: auto; border: 1px solid var(--line); background: var(--paper-2); border-radius: 8px; width: 40px; height: 38px; font-size: 19px; color: var(--ink); cursor: pointer; }

/* ── 面包屑与页头 ── */
.page-head { padding: 34px 0 8px; }
.page-head h1 { font-family: var(--font-kai); font-size: 32px; letter-spacing: 3px; }
.page-head h1 span { color: var(--cinnabar); }
.page-head .sub { color: var(--ink-3); font-size: 14.5px; margin-top: 4px; }
.head-rule { display: flex; align-items: center; gap: 12px; margin: 14px 0 22px; }
.head-rule::before, .head-rule::after { content: ""; height: 1px; background: var(--line); flex: 1; }
.head-rule .dot { width: 7px; height: 7px; background: var(--cinnabar); transform: rotate(45deg); }

/* ── 卡片 ── */
.card {
  background: var(--paper-2); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px; position: relative;
}
.card:hover { border-color: #c9b990; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, 1fr); }
.g3 { grid-template-columns: repeat(3, 1fr); }
.g4 { grid-template-columns: repeat(4, 1fr); }

.section { margin: 26px 0 40px; }
.section > h2 {
  font-family: var(--font-kai); font-size: 23px; letter-spacing: 2px;
  display: flex; align-items: center; gap: 10px; margin-bottom: 14px;
}
.section > h2::before { content: ""; width: 5px; height: 20px; background: var(--cinnabar); border-radius: 2px; }
.section > .hint { color: var(--ink-3); font-size: 14px; margin: -8px 0 14px; }

/* ── 印章角标 ── */
.seal-tag {
  position: absolute; top: 12px; right: 12px; width: 30px; height: 30px;
  background: var(--cinnabar); color: #fdf6e9; border-radius: 4px;
  font-family: var(--font-kai); font-size: 12px; line-height: 1.15;
  display: flex; align-items: center; justify-content: center; text-align: center;
  box-shadow: inset 0 0 0 1.5px rgba(255,255,255,.35); padding: 2px;
}

/* ── chips ── */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-block; padding: 3px 11px; border-radius: 999px;
  background: var(--paper-3); border: 1px solid var(--line);
  font-size: 13px; color: var(--ink-2); font-family: var(--font-kai);
  cursor: default;
}
a.chip:hover { border-color: var(--cinnabar-2); color: var(--cinnabar); }
.chip.on { background: var(--cinnabar); border-color: var(--cinnabar); color: #fdf6e9; }
.chip.gold { background: #f3e8ce; border-color: #d8c391; color: #7c6224; }

/* ── 按钮 / 输入 ── */
.btn {
  display: inline-block; border: 1px solid var(--cinnabar); color: var(--cinnabar);
  background: transparent; border-radius: 8px; padding: 8px 18px;
  font-family: var(--font-kai); font-size: 15px; cursor: pointer; transition: .15s;
}
.btn:hover { background: var(--cinnabar); color: #fdf6e9; }
.btn.solid { background: var(--cinnabar); color: #fdf6e9; }
.btn.solid:hover { background: #8e2c23; }
.btn.sm { padding: 5px 12px; font-size: 13.5px; }

input[type=text], input[type=number], select, textarea {
  width: 100%; padding: 9px 13px; border: 1px solid var(--line); border-radius: 8px;
  background: #fdfaf3; font-family: var(--font-song); font-size: 15px; color: var(--ink);
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--cinnabar-2); box-shadow: 0 0 0 3px rgba(164,52,42,.08); }
label.fld { display: block; font-size: 13.5px; color: var(--ink-2); margin: 10px 0 4px; font-family: var(--font-kai); }

.searchbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.searchbar input { flex: 1; min-width: 200px; }
.searchbar select { width: auto; min-width: 130px; }

/* ── 统计 ── */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.stat { text-align: center; padding: 16px 8px; }
.stat b { font-family: var(--font-kai); font-size: 34px; color: var(--cinnabar); display: block; line-height: 1.2; }
.stat span { font-size: 13.5px; color: var(--ink-3); letter-spacing: 2px; }

/* ── 图片卡片 ── */
.imgcard { overflow: hidden; padding: 0; display: flex; flex-direction: column; cursor: pointer; }
.imgcard .ph { position: relative; padding-top: 72%; overflow: hidden; background: var(--paper-3); }
.imgcard .ph img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transition: transform .5s; }
.imgcard:hover .ph img { transform: scale(1.05); }
.imgcard .info { padding: 13px 15px 15px; }
.imgcard .info h3 { font-family: var(--font-kai); font-size: 18px; letter-spacing: 1px; }
.imgcard .info .alias { color: var(--ink-3); font-size: 12.5px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.imgcard .info p { color: var(--ink-2); font-size: 13.5px; margin-top: 6px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* ── 列表条目（香方/典故）── */
.entry {
  background: var(--paper-2); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; margin-bottom: 12px; cursor: pointer; transition: .15s;
}
.entry:hover { border-color: var(--cinnabar-2); box-shadow: var(--shadow); }
.entry h3 { font-family: var(--font-kai); font-size: 18.5px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.entry h3 .vol { font-size: 12px; color: var(--gold); font-weight: 400; letter-spacing: 1px; }
.entry p { color: var(--ink-2); font-size: 14px; margin-top: 6px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.entry .tags { margin-top: 8px; }

/* ── 弹层 ── */
.modal-mask {
  position: fixed; inset: 0; background: rgba(40, 30, 18, .55); z-index: 200;
  display: none; align-items: flex-end; justify-content: center;
}
.modal-mask.show { display: flex; }
.modal {
  background: var(--paper-2); width: 100%; max-width: 780px; max-height: 88vh;
  overflow-y: auto; border-radius: 16px 16px 0 0; padding: 26px 24px 40px;
  position: relative; animation: up .25s ease;
}
@keyframes up { from { transform: translateY(40px); opacity: .4; } to { transform: none; opacity: 1; } }
.modal .close {
  position: sticky; top: 0; float: right; width: 34px; height: 34px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--paper-2); color: var(--ink-2);
  font-size: 17px; cursor: pointer; z-index: 5;
}
.modal h2 { font-family: var(--font-kai); font-size: 26px; letter-spacing: 2px; margin-bottom: 4px; padding-right: 44px; }
.modal .meta { color: var(--ink-3); font-size: 13.5px; margin-bottom: 14px; }
.modal .cover { border-radius: 10px; overflow: hidden; margin: 10px 0 16px; max-height: 320px; }
.modal .cover img { width: 100%; object-fit: cover; max-height: 320px; }
/* 一具多图 */
.imgcard .ph-n { position: absolute; right: 8px; bottom: 8px; z-index: 2; font-size: 11px;
  padding: 2px 8px; border-radius: 10px; background: rgba(30,25,20,.62); color: #f5efe4; letter-spacing: 1px; }
.modal .multi-imgs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 10px 0 16px; }
.modal .multi-imgs .cover { margin: 0; max-height: 220px; }
.modal .multi-imgs .cover img { max-height: 220px; }
@media (max-width: 560px) { .modal .multi-imgs { grid-template-columns: 1fr; } }
.modal h4 { font-family: var(--font-kai); font-size: 17px; color: var(--cinnabar); margin: 18px 0 6px; }
.modal p, .modal li { font-size: 15px; color: var(--ink-2); }
.modal blockquote {
  border-left: 3px solid var(--gold); background: #f6efdd; padding: 10px 14px;
  margin: 10px 0; font-size: 14px; color: var(--ink-2); border-radius: 0 8px 8px 0;
}
.ing-table { width: 100%; border-collapse: collapse; margin: 8px 0; font-size: 14.5px; }
.ing-table th, .ing-table td { border-bottom: 1px dashed var(--line); padding: 7px 6px; text-align: left; }
.ing-table th { color: var(--ink-3); font-weight: 400; font-size: 13px; }
.ing-table td:first-child { font-family: var(--font-kai); font-size: 16px; }

/* ── 时间轴 ── */
.timeline { position: relative; padding-left: 26px; }
.timeline::before { content: ""; position: absolute; left: 7px; top: 6px; bottom: 6px; width: 2px; background: linear-gradient(var(--cinnabar-2), var(--line)); }
.tl-item { position: relative; padding: 0 0 22px 12px; }
.tl-item::before {
  content: ""; position: absolute; left: -26px; top: 8px; width: 12px; height: 12px;
  border-radius: 50%; background: var(--paper); border: 3px solid var(--cinnabar);
}
.tl-item .era { font-family: var(--font-kai); font-size: 18px; color: var(--cinnabar); }
.tl-item .era b { font-size: 13px; color: var(--gold); font-weight: 400; margin-left: 8px; }
.tl-item p { color: var(--ink-2); font-size: 14.5px; margin-top: 4px; }

/* ── 步骤 ── */
.steps { counter-reset: st; }
.step { display: flex; gap: 14px; padding: 13px 0; border-bottom: 1px dashed var(--line); }
.step:last-child { border-bottom: 0; }
.step .no {
  counter-increment: st; flex: 0 0 34px; height: 34px; border-radius: 50%;
  background: var(--cinnabar); color: #fdf6e9; font-family: var(--font-kai);
  display: flex; align-items: center; justify-content: center; font-size: 16px;
}
.step .no::before { content: counter(st, cjk-ideographic); }
.step h4 { font-family: var(--font-kai); font-size: 17px; }
.step p { color: var(--ink-2); font-size: 14px; margin-top: 3px; }

/* ── Tabs ── */
.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.tabs button {
  border: 1px solid var(--line); background: var(--paper-2); color: var(--ink-2);
  padding: 6px 16px; border-radius: 999px; font-family: var(--font-kai); font-size: 14.5px; cursor: pointer;
}
.tabs button.on { background: var(--cinnabar); border-color: var(--cinnabar); color: #fdf6e9; }

/* ── Hero（首页）── */
.hero {
  position: relative; border-radius: 14px; overflow: hidden; margin: 20px 0 30px;
  min-height: 420px; display: flex; align-items: center;
  background: #22190f;
}
.hero .bg { position: absolute; inset: 0; }
.hero .bg img { width: 100%; height: 100%; object-fit: cover; opacity: .8; }
.hero .bg::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, rgba(20,14,6,.82) 8%, rgba(20,14,6,.35) 60%, rgba(20,14,6,.65)); }
.hero .txt { position: relative; z-index: 2; color: #f3ead8; padding: 56px 48px; max-width: 640px; }
.hero .txt h1 { font-family: var(--font-kai); font-size: 54px; letter-spacing: 10px; text-shadow: 0 2px 18px rgba(0,0,0,.5); }
.hero .txt .st { font-size: 17px; letter-spacing: 4px; margin: 10px 0 18px; color: #e5d6b8; }
.hero .txt p { font-size: 15px; color: #cfc2a6; max-width: 480px; }
.hero .txt .acts { margin-top: 24px; display: flex; gap: 12px; flex-wrap: wrap; }
.hero .txt .acts .btn { color: #f3ead8; border-color: rgba(243,234,216,.6); }
.hero .txt .acts .btn:hover { background: var(--cinnabar); border-color: var(--cinnabar); }
.hero .txt .acts .btn.solid { background: var(--cinnabar); border-color: var(--cinnabar); }
.hero .seal-big {
  position: absolute; right: 52px; bottom: 44px; z-index: 2; width: 64px; height: 64px;
  background: var(--cinnabar); color: #fdf6e9; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-kai); font-size: 22px; letter-spacing: 2px; text-align: center; line-height: 1.2;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.4), 0 6px 20px rgba(0,0,0,.4);
  writing-mode: vertical-rl;
}

/* ── 名句 ── */
.quote-band { text-align: center; padding: 26px 20px; background: linear-gradient(180deg, transparent, #efe6d2, transparent); }
.quote-band .q { font-family: var(--font-kai); font-size: 22px; letter-spacing: 3px; color: var(--ink); }
.quote-band .a { color: var(--ink-3); font-size: 13.5px; margin-top: 6px; }

/* ── footer ── */
footer { border-top: 1px solid var(--line); margin-top: 50px; padding: 30px 0 40px; color: var(--ink-3); font-size: 13.5px; }
footer .f-in { display: flex; flex-wrap: wrap; gap: 20px; justify-content: space-between; align-items: flex-start; }
footer a { color: var(--ink-2); margin-right: 12px; }
footer .seal-mini { display: inline-block; width: 24px; height: 24px; vertical-align: -6px; background: var(--cinnabar); color: #fdf6e9; border-radius: 4px; text-align: center; line-height: 24px; font-family: var(--font-kai); margin-right: 8px; }

/* ── 杂项 ── */
.pager { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin: 22px 0; }
.pager button { min-width: 38px; padding: 6px 12px; border: 1px solid var(--line); background: var(--paper-2); border-radius: 8px; font-family: var(--font-kai); cursor: pointer; color: var(--ink-2); }
.pager button.on { background: var(--cinnabar); border-color: var(--cinnabar); color: #fdf6e9; }
.empty { text-align: center; color: var(--ink-3); padding: 46px 0; font-family: var(--font-kai); font-size: 17px; letter-spacing: 2px; }
.note {
  background: #f7f1e0; border: 1px dashed var(--gold); border-radius: 8px;
  padding: 10px 14px; font-size: 13.5px; color: var(--ink-2); margin: 12px 0;
}
.divider { height: 1px; background: var(--line); margin: 26px 0; }
.toc-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.toc-item { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; background: var(--paper-2); border: 1px solid var(--line); border-radius: 8px; cursor: pointer; font-family: var(--font-kai); }
.toc-item:hover { border-color: var(--cinnabar-2); }
.toc-item .cnt { color: var(--ink-3); font-size: 12.5px; }
.reader { font-size: 16.5px; }
.reader h3 { font-family: var(--font-kai); font-size: 21px; margin: 26px 0 8px; color: var(--cinnabar); }
.reader .grp { color: var(--gold); font-size: 13.5px; letter-spacing: 2px; margin: 22px 0 -6px; }
.reader p { margin: 10px 0; color: var(--ink-2); text-indent: 2em; }
.reader p.noindent { text-indent: 0; }

/* ── 移动端 ── */
@media (max-width: 900px) {
  .g4 { grid-template-columns: repeat(2, 1fr); }
  .g3 { grid-template-columns: repeat(2, 1fr); }
  .hero .txt h1 { font-size: 40px; letter-spacing: 6px; }
  .hero { min-height: 340px; }
  .hero .txt { padding: 40px 26px; }
  .hero .seal-big { right: 20px; bottom: 24px; width: 54px; height: 54px; font-size: 18px; }
}
@media (max-width: 640px) {
  body { font-size: 15px; }
  .g2, .g3, .g4 { grid-template-columns: 1fr 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .page-head h1 { font-size: 26px; }
  .nav-links {
    display: none; position: absolute; top: 58px; left: 0; right: 0;
    background: var(--paper-2); border-bottom: 1px solid var(--line);
    flex-direction: column; padding: 8px 14px 14px; overflow: visible;
  }
  .nav-links.open { display: flex; }
  .nav-links a { padding: 11px 10px; font-size: 16px; border-bottom: 1px dashed var(--line); }
  .menu-btn { display: block; }
  .modal { padding: 20px 16px 34px; }
  .imgcard .info h3 { font-size: 16px; }
}
@media (max-width: 420px) {
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
}

/* 懒加载淡入 */
.fade-img { opacity: 0; transition: opacity .6s; }
.fade-img.ld { opacity: 1; }
