/* ==========================================================================
   佛历日历 · 视觉系统 v2
   「一页经卷」：编号分章 + 发丝金线 + 大留白；双主题（宣纸晨光 / 墨夜）
   ========================================================================== */

/* ---------- 1. 设计令牌 ---------- */
:root {
  --font-display: "Songti SC", "STSong", "Noto Serif SC", "SimSun", "Times New Roman", serif;
  --font-sans: "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  --font-num: "Didot", "Bodoni 72", "Songti SC", "Times New Roman", serif;

  --step-0: 13.5px;
  --step-1: 15px;
  --step-2: 17px;
  --step-3: clamp(20px, 1.6vw, 24px);
  --step-4: clamp(26px, 2.4vw, 34px);
  --step-5: clamp(56px, 8.5vw, 124px);

  --gutter: clamp(16px, 4vw, 40px);
  --radius: 4px;
  --radius-pill: 999px;

  --ease: cubic-bezier(.2, .7, .2, 1);
  --t-fast: 160ms;
  --t-base: 260ms;
  --t-slow: 700ms;
}

/* 宣纸晨光（默认） */
:root,
[data-theme="day"] {
  color-scheme: light;

  --bg: #f3eee3;
  --bg-deep: #e9e1d1;
  --surface: rgba(255, 253, 248, .78);
  --surface-solid: #fffdf8;
  --surface-sunk: rgba(240, 232, 218, .55);
  --cell: rgba(255, 253, 248, .55);
  --cell-hover: #fffdf8;

  --ink: #241f18;
  --ink-2: #574f42;
  --ink-3: #8a8171;
  --line: rgba(90, 74, 50, .16);
  --line-strong: rgba(90, 74, 50, .34);

  --gold: #a2803c;
  --gold-soft: rgba(162, 128, 60, .12);
  --gold-line: rgba(162, 128, 60, .38);

  --g-buddhist: #9d4b34;
  --g-buddhist-soft: rgba(157, 75, 52, .10);
  --g-taoist: #4a5c81;
  --g-taoist-soft: rgba(74, 92, 129, .10);
  --g-fasting: #567555;
  --g-fasting-soft: rgba(86, 117, 85, .11);
  --g-folk: #8e5460;
  --g-folk-soft: rgba(142, 84, 96, .10);
  --g-calendar: #8a6a29;
  --g-calendar-soft: rgba(138, 106, 41, .12);

  --shadow-panel: 0 30px 70px -50px rgba(60, 45, 25, .55), 0 1px 0 rgba(255, 255, 255, .7) inset;
  --shadow-lift: 0 18px 40px -28px rgba(60, 45, 25, .45);

  --grain: .035;
  --grain-blend: multiply;
  --wash-1: rgba(255, 255, 255, .85);
  --wash-2: rgba(206, 183, 143, .45);
  --wash-3: rgba(157, 75, 52, .10);
  --particle: 226, 142, 172;   /* 背景莲花主色（粉色） */
}

/* 墨夜 */
[data-theme="night"] {
  color-scheme: dark;

  --bg: #0b0d0e;
  --bg-deep: #070909;
  --surface: rgba(20, 24, 26, .70);
  --surface-solid: #12171a;
  --surface-sunk: rgba(255, 255, 255, .035);
  --cell: rgba(255, 255, 255, .022);
  --cell-hover: rgba(255, 255, 255, .06);

  --ink: #ece6d7;
  --ink-2: #b6ae9c;
  --ink-3: #7e7767;
  --line: rgba(210, 190, 150, .15);
  --line-strong: rgba(210, 190, 150, .30);

  --gold: #cfab6a;
  --gold-soft: rgba(207, 171, 106, .13);
  --gold-line: rgba(207, 171, 106, .42);

  --g-buddhist: #cf7a5e;
  --g-buddhist-soft: rgba(207, 122, 94, .14);
  --g-taoist: #8fa3cf;
  --g-taoist-soft: rgba(143, 163, 207, .13);
  --g-fasting: #92b48e;
  --g-fasting-soft: rgba(146, 180, 142, .13);
  --g-folk: #c98e99;
  --g-folk-soft: rgba(201, 142, 153, .13);
  --g-calendar: #cbab72;
  --g-calendar-soft: rgba(203, 171, 114, .14);

  --shadow-panel: 0 40px 90px -60px #000, 0 1px 0 rgba(255, 255, 255, .045) inset;
  --shadow-lift: 0 24px 50px -30px #000;

  --grain: .05;
  --grain-blend: screen;
  --wash-1: rgba(58, 78, 96, .28);
  --wash-2: rgba(120, 92, 48, .22);
  --wash-3: rgba(150, 60, 40, .12);
  --particle: 214, 178, 110;
}

/* ---------- 2. 基础 ---------- */
* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: 84px;
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
  /* 浮层打开时 html 会被锁成 overflow:hidden，滚动条消失会让页面横向跳 15px；
     常驻预留滚动条槽位，锁与不锁的内容宽度完全一致 */
  scrollbar-gutter: stable;
}

body {
  margin: 0;
  overflow-x: hidden;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--step-0);
  line-height: 1.75;
  letter-spacing: .01em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color var(--t-slow) var(--ease), color var(--t-slow) var(--ease);
}

h1, h2, h3, h4 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: .02em;
  line-height: 1.25;
  text-wrap: pretty;
}

p { margin: 0; text-wrap: pretty; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
a { color: inherit; text-decoration: none; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }

::selection { background: var(--gold-soft); }

/* ---------- 3. 背景层 ---------- */
.bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.bg-wash {
  position: absolute;
  inset: -20%;
  background:
    radial-gradient(60% 50% at 12% 8%, var(--wash-1), transparent 70%),
    radial-gradient(50% 45% at 88% 6%, var(--wash-2), transparent 70%),
    radial-gradient(55% 50% at 70% 92%, var(--wash-3), transparent 72%);
  filter: blur(18px);
  animation: washDrift 34s var(--ease) infinite alternate;
}

.bg-grain {
  position: absolute;
  inset: 0;
  opacity: var(--grain);
  mix-blend-mode: var(--grain-blend);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/></filter><rect width='180' height='180' filter='url(%23n)'/></svg>");
  background-size: 180px 180px;
}

#atmos {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: .9;
}

@keyframes washDrift {
  0% { transform: translate3d(-1.5%, -1%, 0) scale(1.02); }
  100% { transform: translate3d(2%, 1.8%, 0) scale(1.08); }
}

/* ---------- 4. 顶栏 ---------- */
.progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 2px;
  width: 0;
  z-index: 60;
  background: linear-gradient(90deg, var(--gold), var(--g-buddhist));
  transition: width 90ms linear;
}

.topbar {
  position: sticky;
  max-width: 100vw;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: clamp(16px, 3vw, 40px);
  height: 68px;
  padding: 0 var(--gutter);
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex: none;
}

.brand svg { width: 24px; height: 24px; color: var(--gold); }

.brand-name {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: .14em;
}

.brand-lotus {
  display: inline-flex;
  width: 26px;
  height: 26px;
  color: var(--gold);
  cursor: pointer;
  transition: color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}

.brand-lotus svg { width: 100%; height: 100%; }

.brand-lotus:hover { color: var(--ink); transform: translateY(-1px); }

.brand-lotus:focus-visible { outline: 1px solid var(--gold); outline-offset: 3px; border-radius: 50%; }

.brand-sub {
  display: none;
  color: var(--ink-3);
  font-size: 10px;
  letter-spacing: .28em;
}

.nav {
  display: flex;
  min-width: 0;
  gap: clamp(14px, 2.4vw, 32px);
  margin-left: auto;
  overflow-x: auto;
  scrollbar-width: none;
}

.nav::-webkit-scrollbar { display: none; }

.nav a {
  position: relative;
  padding: 20px 0;
  color: var(--ink-2);
  font-size: 12.5px;
  letter-spacing: .12em;
  white-space: nowrap;
  transition: color var(--t-fast) var(--ease);
}

.nav a::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 14px;
  height: 1px;
  background: var(--gold);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform var(--t-base) var(--ease);
}

.nav a:hover { color: var(--ink); }
.nav a:hover::after { transform: scaleX(1); }
.nav a.is-current { color: var(--ink); }
.nav a.is-current::after { transform: scaleX(1); }


.theme-toggle {
  position: relative;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  color: var(--ink-2);
  transition: color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}

.theme-toggle:hover { color: var(--gold); border-color: var(--gold-line); transform: rotate(-12deg); }
.theme-toggle svg { width: 16px; height: 16px; }
.theme-toggle .icon-moon { display: none; }
[data-theme="night"] .theme-toggle .icon-sun { display: none; }
[data-theme="night"] .theme-toggle .icon-moon { display: block; }

/* ---------- 5. 页面骨架 ---------- */
.page-shell {
  position: relative;
  z-index: 1;
  width: min(1320px, calc(100% - var(--gutter) * 2));
  margin: 0 auto;
  padding-bottom: 40px;
}

/* ---------- 6. Hero ---------- */
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: clamp(20px, 3vw, 44px);
  align-items: end;
  padding: clamp(20px, 2.8vw, 38px) 0 clamp(18px, 2.2vw, 30px);
  border-bottom: 1px solid var(--line);
}

.kicker {
  margin-bottom: 10px;
  color: var(--gold);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .34em;
  text-transform: uppercase;
}

.hero-date {
  display: flex;
  align-items: flex-end;
  gap: clamp(14px, 2vw, 26px);
}

.hero-num {
  font-family: var(--font-num);
  font-size: clamp(46px, 5.4vw, 78px);
  font-weight: 400;
  line-height: .86;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

.hero-stack {
  display: grid;
  gap: 3px;
  padding-bottom: 6px;
}

.hero-stack .hero-cn {
  font-family: var(--font-display);
  font-size: var(--step-3);
  letter-spacing: .06em;
}

.hero-stack .hero-sub {
  color: var(--ink-3);
  font-size: 12px;
  letter-spacing: .14em;
}

.hero-lunar {
  margin-top: 6px;
  color: var(--g-buddhist);
  font-family: var(--font-display);
  font-size: var(--step-2);
  letter-spacing: .12em;
}

.today-summary[hidden] { display: none; }

/* 胶囊在详情卡里：紧贴标题，作为当天条目速览 */
.detail-panel .today-summary {
  margin: 12px 0 4px;
  min-height: 0;
}

.detail-panel .summary-chip {
  font-size: 11px;
  padding: 3px 10px;
}

.today-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 14px;
  min-height: 26px;
}

.summary-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--ink-2);
  font-size: 11.5px;
  letter-spacing: .04em;
  transition: border-color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}

.summary-chip:hover { border-color: var(--gold-line); transform: translateY(-1px); }
.summary-chip strong { color: var(--ink); font-weight: 600; }
.summary-chip.is-fast, .summary-chip.is-fasting { border-color: var(--g-fasting); color: var(--g-fasting); }
.summary-chip.is-buddhist, .summary-chip.is-event { border-color: var(--g-buddhist); color: var(--g-buddhist); }
.summary-chip.is-taoist { border-color: var(--g-taoist); color: var(--g-taoist); }
.summary-chip.is-folk { border-color: var(--g-folk); color: var(--g-folk); }
.summary-chip.is-calendar { border-color: var(--g-calendar); color: var(--g-calendar); }
.summary-chip.is-more { color: var(--ink-3); }

.skeleton-line {
  display: block;
  width: 260px;
  height: 18px;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--line), var(--surface-sunk), var(--line));
  background-size: 200% 100%;
  animation: shimmer 1.5s linear infinite;
}

@keyframes shimmer { to { background-position: -200% 0; } }

.hero-aside {
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  gap: clamp(14px, 1.6vw, 22px);
  position: relative;
  min-width: 0;
}

.hero-figure { align-self: flex-end; margin-bottom: -30px; }

.hero-meta {
  display: grid;
  justify-items: end;
  gap: 10px;
}

.hero-year {
  position: relative;
  display: grid;
  gap: 2px;
  padding: 9px 14px 9px 16px;
  border-left: 1px solid var(--gold);
  text-align: right;
}

.hero-year span { color: var(--ink-3); font-size: 10.5px; letter-spacing: .22em; }
.hero-year strong {
  font-family: var(--font-display);
  font-size: clamp(22px, 2vw, 26px);
  font-weight: 500;
  line-height: 1.1;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}
.hero-year small {
  color: var(--ink-3);
  font-size: 10.5px;
  letter-spacing: .04em;
  font-variant-numeric: tabular-nums;
}

/* 手机端佛历：桌面 .hero-year 在窄屏隐藏，这行补上主口径 + 国际对照 */
.hero-fo {
  display: none;
  align-items: baseline;
  gap: 7px;
  margin-top: 3px;
  font-family: var(--font-display);
  font-size: 11.5px;
  letter-spacing: .06em;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}
.hero-fo em { font-style: normal; color: var(--ink-3); font-size: 10px; letter-spacing: .04em; }

.load-status {
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  color: var(--ink-3);
  font-size: 10.5px;
  letter-spacing: .06em;
}

.load-status[hidden] { display: none; }
.load-status.is-error { color: var(--g-buddhist); border-color: var(--g-buddhist); }

/* ---------- 7. 分章 ---------- */
.chapter {
  padding-top: clamp(30px, 4vw, 52px);
  scroll-margin-top: 84px;
}

.chapter-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: end;
  gap: clamp(14px, 2.4vw, 28px);
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.chapter-no {
  font-family: var(--font-num);
  font-size: 40px;
  line-height: .8;
  color: var(--gold);
  opacity: .55;
  font-variant-numeric: tabular-nums;
}

.chapter-title { display: grid; gap: 4px; }
.chapter-title h2 { font-size: var(--step-4); letter-spacing: .10em; }
.chapter-title p { color: var(--ink-3); font-size: 12px; letter-spacing: .06em; }

.chapter-tools { display: flex; align-items: center; gap: 8px; }

/* ---------- 8. 面板 ---------- */
/* ---------- 8b. 视图切换：今日详情 ⇄ 月视图 ---------- */
.viewer { margin-top: clamp(20px, 3vw, 32px); }

.viewer-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: clamp(12px, 1.6vw, 18px);
}

.seg {
  position: relative;
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--surface-sunk);
}

.seg-btn {
  position: relative;
  z-index: 1;
  min-width: 102px;
  padding: 8px 16px;
  border: 0;
  border-radius: var(--radius-pill);
  background: none;
  color: var(--ink-3);
  font-family: inherit;
  font-size: 12px;
  letter-spacing: .10em;
  cursor: pointer;
  transition: color var(--t-fast) var(--ease);
}

.seg-btn.is-active { color: var(--ink); }

.seg-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  bottom: 3px;
  width: calc(50% - 3px);
  border-radius: var(--radius-pill);
  background: var(--surface-solid);
  box-shadow: 0 1px 3px rgba(24, 18, 8, .08), inset 0 0 0 1px var(--gold-line);
  transition: transform var(--t-base) var(--ease);
}

.seg.is-month .seg-thumb { transform: translateX(100%); }

.viewer-hint {
  display: none;
  color: var(--ink-3);
  font-size: 10.5px;
  letter-spacing: .16em;
  white-space: nowrap;
}

.deck {
  position: relative;
  transition: height var(--t-base) var(--ease);
}

.deck-track {
  display: grid;
  grid-template-columns: minmax(320px, .78fr) minmax(0, 1.22fr);
  gap: clamp(16px, 2vw, 26px);
}

.deck-slide { min-width: 0; }

.month-nav { display: flex; align-items: center; gap: 6px; flex: none; }

.panel {
  position: relative;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-panel);
  backdrop-filter: blur(10px) saturate(120%);
  -webkit-backdrop-filter: blur(10px) saturate(120%);
}

/* ---------- 9. 日历 ---------- */
.calendar-panel { padding: clamp(18px, 2.4vw, 28px); }

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  margin-bottom: 18px;
}

.section-kicker {
  margin: 0;
  color: var(--gold);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .30em;
  text-transform: uppercase;
}

.panel-head h3 {
  font-size: var(--step-3);
  letter-spacing: .08em;
  font-variant-numeric: tabular-nums;
}

.icon-btn,
.today-btn {
  height: 34px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-solid);
  color: var(--ink-2);
  transition: color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), background-color var(--t-fast) var(--ease);
}

.icon-btn {
  width: 34px;
  display: grid;
  place-items: center;
  font-size: 18px;
  line-height: 1;
}

.today-btn {
  padding: 0 14px;
  font-size: 11.5px;
  letter-spacing: .10em;
}

.icon-btn:hover,
.today-btn:hover {
  border-color: var(--gold-line);
  background: var(--gold-soft);
  color: var(--gold);
}

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 14px 0 16px;
  border-top: 1px solid var(--line);
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 11px;
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  background: var(--surface-sunk);
  color: var(--ink-3);
  font-size: 11.5px;
  letter-spacing: .05em;
  transition: color var(--t-fast) var(--ease), background-color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}

.filter-chip::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  opacity: .45;
  transition: opacity var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}

.filter-chip:hover { color: var(--ink-2); }

.filter-chip.is-active {
  border-color: var(--line-strong);
  background: var(--surface-solid);
  color: var(--ink);
}

.filter-chip.is-active::before { opacity: 1; transform: scale(1.25); }

.filter-chip[data-filter="buddhist"].is-active::before { background: var(--g-buddhist); }
.filter-chip[data-filter="taoist"].is-active::before { background: var(--g-taoist); }
.filter-chip[data-filter="fasting"].is-active::before { background: var(--g-fasting); }
.filter-chip[data-filter="folk"].is-active::before { background: var(--g-folk); }
.filter-chip[data-filter="calendar"].is-active::before { background: var(--g-calendar); }

.weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  padding: 0 0 10px;
}

.weekdays span {
  color: var(--ink-3);
  font-size: 10.5px;
  letter-spacing: .22em;
  text-align: center;
}

.weekdays span:first-child,
.weekdays span:last-child { color: var(--g-buddhist); }

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 1px;
  grid-auto-rows: minmax(112px, auto);
  border: 1px solid var(--line);
  background: var(--line);
}

.day-cell {
  position: relative;
  display: block;
  min-width: 0;
  padding: 9px 9px 7px;
  border: 0;
  background: var(--cell);
  text-align: left;
  transition: background-color var(--t-fast) var(--ease), box-shadow var(--t-base) var(--ease);
  animation: cellIn var(--t-slow) var(--ease) both;
  animation-delay: calc(var(--i, 0) * 9ms);
}

@keyframes cellIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.day-cell:hover { background: var(--cell-hover); z-index: 1; box-shadow: 0 0 0 1px var(--gold-line); }
.day-cell.is-void { display: none; }
.day-cell.is-outside { background: transparent; }
.day-cell.is-outside .day-num { color: var(--ink-3); opacity: .55; }
.day-cell.is-outside .day-lunar { opacity: .5; }

.day-cell.is-selected {
  background: var(--gold-soft);
  box-shadow: 0 0 0 1px var(--gold);
  z-index: 2;
}

.day-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px;
}

.day-num {
  font-family: var(--font-num);
  font-size: 22px;
  font-weight: 500;
  line-height: 1;
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

.day-cell.is-today .day-num {
  display: inline-grid;
  place-items: center;
  width: 27px;
  height: 27px;
  margin: -3px 0 -3px -4px;
  border-radius: 50%;
  background: var(--g-buddhist);
  color: #fff;
  font-size: 18px;
}

.day-lunar {
  display: block;
  margin-top: 5px;
  color: var(--ink-3);
  font-size: 10.5px;
  letter-spacing: .02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.day-dots { display: none; }

.day-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  margin-top: 7px;
}

.day-tag {
  max-width: 100%;
  overflow: hidden;
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 10px;
  line-height: 1.5;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.day-tag.group-buddhist { background: var(--g-buddhist-soft); color: var(--g-buddhist); }
.day-tag.group-taoist { background: var(--g-taoist-soft); color: var(--g-taoist); }
.day-tag.group-fasting { background: var(--g-fasting-soft); color: var(--g-fasting); }
.day-tag.group-folk { background: var(--g-folk-soft); color: var(--g-folk); }
.day-tag.group-calendar { background: var(--g-calendar-soft); color: var(--g-calendar); }

.day-more { margin-top: 2px; color: var(--ink-3); font-size: 9.5px; }

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  color: var(--ink-3);
  font-size: 11px;
}

.legend span { display: inline-flex; align-items: center; gap: 6px; }
.dot { width: 6px; height: 6px; border-radius: 50%; }
.dot-buddhist { background: var(--g-buddhist); }
.dot-taoist { background: var(--g-taoist); }
.dot-fasting { background: var(--g-fasting); }
.dot-folk { background: var(--g-folk); }
.dot-calendar { background: var(--g-calendar); }
.dot-today { background: var(--g-buddhist); box-shadow: 0 0 0 2px var(--g-buddhist-soft); }

/* ---------- 10. 当日详解 ---------- */
.detail-panel {
  position: sticky;
  top: 86px;
  padding: clamp(18px, 2.4vw, 26px);
  max-height: calc(100vh - 110px);
  overflow-y: auto;
  scrollbar-width: thin;
}

.detail-panel::-webkit-scrollbar { width: 6px; }
.detail-panel::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 3px; }

.detail-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.detail-heading { min-width: 0; }

/* 星期并入 DAY DETAIL 这行小字，右侧只留印章，左右各一件，视觉对称 */
.kicker-sep {
  margin: 0 .42em;
  color: var(--line-strong);
}

.kicker-day {
  color: var(--gold);
  letter-spacing: .08em;
}

/* 节日小像：右上角留白里的一枚线描图案，随主题与所属传统变色 */
.hero-figure {
  width: clamp(132px, 13.5vw, 196px);
  height: clamp(132px, 13.5vw, 196px);
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--gold);
  opacity: 1;
  transition: opacity var(--t-mid) var(--ease), color var(--t-mid) var(--ease);
}

.hero-figure[hidden] { display: none; }

/* 人物小像：去掉金底，只留细圈，让白描本身成为主体 */
.hero-figure[data-kind="portrait"] {
  width: clamp(128px, 12.8vw, 182px);
  height: auto;
  aspect-ratio: 1 / 1;
  /* 画卷式装裱：米色绫边 + 细线 + 柔和投影 */
  position: relative;
  background: linear-gradient(158deg, #fdfaf3 0%, #f4ede0 100%);
  border: 1px solid rgba(120, 100, 70, .34);
  border-radius: 0;
  padding: 5px;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(80, 60, 30, .13), 0 0 0 1px rgba(255, 255, 255, .55) inset;
  color: var(--ink-2);
  opacity: 1;
}

.hero-figure[data-kind="portrait"] svg { stroke-width: 1.25; }

[data-theme="day"] .hero-figure img { mix-blend-mode: multiply; }

.hero-figure img {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 0;
  object-fit: cover;
  box-shadow: inset 0 0 0 1px rgba(120, 100, 70, .16);
}

.hero-figure[data-kind="portrait"] { padding: 0; }
/* 同日多画像轮播：横向滑动 + 圆点 + 箭头 */
.hero-figure[data-art="portrait-group"] { position: relative; overflow: visible; padding: 0; }
.portrait-track {
  display: flex;
  width: 100%;
  height: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  border-radius: inherit;
  background: linear-gradient(158deg, #fdfaf3 0%, #f4ede0 100%);
  border: 1px solid rgba(120, 100, 70, .34);
  box-shadow: 0 1px 4px rgba(80, 60, 30, .13), 0 0 0 1px rgba(255, 255, 255, .55) inset;
}
.portrait-track::-webkit-scrollbar { display: none; }
.portrait-cell {
  flex: 0 0 100%;
  width: 100%;
  height: 100%;
  scroll-snap-align: center;
  overflow: hidden;
}
.portrait-cell img, .portrait-cell svg { display: block; width: 100%; height: 100%; object-fit: cover; }
.portrait-dots {
  position: absolute; left: 0; right: 0; bottom: -14px;
  display: flex; justify-content: center; gap: 5px; pointer-events: none;
}
.portrait-dot {
  width: 5px; height: 5px; border-radius: 50%;
  background: rgba(120, 100, 70, .28); transition: background .2s, transform .2s;
}
.portrait-dot.is-on { background: var(--gold, #a9853f); transform: scale(1.25); }
.portrait-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 20px; height: 32px; padding: 0;
  border: 0; background: rgba(255, 255, 255, .55); color: var(--ink-2, #5a4a30);
  font-size: 18px; line-height: 1; cursor: pointer; border-radius: 3px;
  opacity: 0; transition: opacity .2s, background .2s;
  display: flex; align-items: center; justify-content: center;
}
.portrait-nav.is-prev { left: -6px; }
.portrait-nav.is-next { right: -6px; }
.hero-figure[data-art="portrait-group"]:hover .portrait-nav,
.hero-figure[data-art="portrait-group"]:focus-within .portrait-nav { opacity: 1; }
.portrait-nav:hover { background: rgba(255, 255, 255, .85); }
@media (hover: none) { .portrait-nav { display: none; } }

.hero-figure svg { display: block; width: 100%; height: 100%; }

.hero-figure[data-art="lotus"],
.hero-figure[data-art="wheel"],
.hero-figure[data-art="bodhi"],
.hero-figure[data-art="staff"],
.hero-figure[data-art="bowl"],
.hero-figure[data-art="elephant"],
.hero-figure[data-art="bag"],
.hero-figure[data-art="sutra"],
.hero-figure[data-art="censer"],
.hero-figure[data-art="vajra"],
.hero-figure[data-art="lamp"],
.hero-figure[data-art="riverlamp"] { color: var(--g-buddhist); }

.hero-figure[data-art="taiji"],
.hero-figure[data-art="bagua"],
.hero-figure[data-art="gourd"],
.hero-figure[data-art="crown"],
.hero-figure[data-art="brush"],
.hero-figure[data-art="boat"],
.hero-figure[data-art="mountain"],
.hero-figure[data-art="peach"],
.hero-figure[data-art="dipper"],
.hero-figure[data-art="turtle"] { color: var(--g-taoist); }

.hero-figure[data-art="ingot"],
.hero-figure[data-art="lantern"],
.hero-figure[data-art="zongzi"],
.hero-figure[data-art="chrys"],
.hero-figure[data-art="willow"],
.hero-figure[data-art="bell"],
.hero-figure[data-art="fire"] { color: var(--g-folk); }

.hero-figure[data-art="moon"],
.hero-figure[data-art="sun"],
.hero-figure[data-art="snow"],
.hero-figure[data-art="sprout"],
.hero-figure[data-art="wheat"],
.hero-figure[data-art="maple"],
.hero-figure[data-art="plum"] { color: var(--g-calendar); }

.detail-head h2 {
  font-size: var(--step-3);
  letter-spacing: .04em;
  font-variant-numeric: tabular-nums;
}

.weekday-badge {
  flex: none;
  padding: 3px 10px;
  border: 1px solid var(--gold-line);
  border-radius: var(--radius-pill);
  color: var(--gold);
  font-size: 10.5px;
  letter-spacing: .10em;
  white-space: nowrap;
}

.detail-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  margin: 16px 0 6px;
  background: var(--line);
  border: 1px solid var(--line);
}

.meta-item { padding: 9px 11px; background: var(--surface-solid); }
.meta-item span { display: block; color: var(--ink-3); font-size: 10px; letter-spacing: .10em; }
.meta-item strong { display: block; margin-top: 1px; font-size: 12.5px; font-weight: 600; }
.meta-sub {
  display: block;
  margin-top: 2px;
  color: var(--ink-3);
  font-size: 10px;
  letter-spacing: .04em;
  font-variant-numeric: tabular-nums;
}

/* 「节气」格可点开词条浮层：只在这一格挂 is-link，其余元信息保持静态 */
.meta-item.is-link { cursor: pointer; transition: background var(--t-fast) var(--ease); }
.meta-item.is-link strong { color: var(--gold); }
.meta-item.is-link:hover { background: var(--surface); }
.meta-item.is-link:hover strong { text-decoration: underline; text-underline-offset: 2px; }
.meta-item.is-link:focus-visible { outline: 2px solid var(--gold); outline-offset: -2px; }

.detail-section { margin-top: 20px; }
.detail-section:empty { display: none; }

.detail-section h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 10px;
  color: var(--ink-2);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .22em;
  text-transform: uppercase;
}

.detail-section h3::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.badge-row { display: flex; flex-wrap: wrap; gap: 5px; }

.badge {
  padding: 2px 9px;
  border-radius: var(--radius-pill);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: .04em;
}

.badge.group-buddhist { background: var(--g-buddhist-soft); color: var(--g-buddhist); }
.badge.group-taoist { background: var(--g-taoist-soft); color: var(--g-taoist); }
.badge.group-fasting { background: var(--g-fasting-soft); color: var(--g-fasting); }
.badge.group-folk { background: var(--g-folk-soft); color: var(--g-folk); }
.badge.group-calendar { background: var(--g-calendar-soft); color: var(--g-calendar); }

.event-list { display: grid; gap: 1px; background: var(--line); border: 1px solid var(--line); }

.event-item {
  padding: 11px 12px;
  background: var(--surface-solid);
  transition: background-color var(--t-fast) var(--ease);
}

.event-item:hover { background: var(--surface-sunk); }
.event-item h4 { font-size: 13.5px; letter-spacing: .02em; }
.event-item p { color: var(--ink-2); font-size: 11.5px; line-height: 1.7; }
.event-item .source-link { display: inline-block; margin-top: 6px; color: var(--gold); font-size: 10.5px; letter-spacing: .04em; }
.event-item .source-link::after { content: " ↗"; font-size: 9px; }

.item-category, .item-schedule { margin-top: 3px; color: var(--ink-3); font-size: 10.5px; }
.item-schedule { color: var(--g-buddhist); font-weight: 600; }

.level-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 0 6px;
  border-radius: 3px;
  font-size: 9.5px;
  font-weight: 500;
  vertical-align: 1px;
}

.level-high { background: var(--g-fasting-soft); color: var(--g-fasting); }
.level-medium { background: var(--g-taoist-soft); color: var(--g-taoist); }
.level-note { background: var(--g-folk-soft); color: var(--g-folk); }

.lore-box {
  margin-top: 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-sunk);
  overflow: hidden;
}

.lore-box > summary {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 10px;
  color: var(--gold);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .08em;
  cursor: pointer;
  list-style: none;
  transition: background-color var(--t-fast) var(--ease);
}

.lore-box > summary:hover { background: var(--gold-soft); }
.lore-box > summary::-webkit-details-marker { display: none; }
.lore-box > summary::before {
  content: "";
  width: 5px;
  height: 5px;
  border-right: 1px solid currentColor;
  border-bottom: 1px solid currentColor;
  transform: rotate(-45deg);
  transition: transform var(--t-fast) var(--ease);
}
.lore-box[open] > summary::before { transform: rotate(45deg); }
.lore-box > summary span { margin-left: auto; color: var(--ink-3); font-size: 9.5px; font-weight: 400; letter-spacing: 0; }

.lore-body { display: grid; gap: 6px; padding: 0 10px 10px; animation: fadeUp var(--t-base) var(--ease); }

.lore-row { display: grid; grid-template-columns: 58px minmax(0, 1fr); gap: 8px; }
.lore-label { color: var(--gold); font-size: 10px; letter-spacing: .06em; }
.lore-text { color: var(--ink-2); font-size: 11px; line-height: 1.7; }

.lore-credit {
  margin-top: 2px;
  padding-top: 7px;
  border-top: 1px dashed var(--line);
  color: var(--ink-3);
  font-size: 10px;
}
.lore-credit a { color: var(--gold); }

.lore-flag {
  display: inline-block;
  margin-left: 4px;
  padding: 0 5px;
  border-radius: 3px;
  background: var(--gold-soft);
  color: var(--gold);
  font-size: 9px;
  font-style: normal;
}

.detail-section.is-quiet-empty { display: none; }

.detail-quiet {
  margin: 16px 0 2px;
  padding: 8px 0 8px 12px;
  border-left: 1px solid var(--line-strong);
  color: var(--ink-3);
  font-size: 11.5px;
  line-height: 1.8;
  letter-spacing: .03em;
}

.empty-note {
  padding: 9px 0 9px 12px;
  border-left: 1px solid var(--line-strong);
  color: var(--ink-3);
  font-size: 11.5px;
  letter-spacing: .04em;
  text-align: left;
}

/* 详情刷新动画 */
.detail-panel.is-refresh .detail-section,
.detail-panel.is-refresh .detail-meta { animation: fadeUp var(--t-base) var(--ease) both; }
.detail-panel.is-refresh .detail-section:nth-of-type(2) { animation-delay: 40ms; }
.detail-panel.is-refresh .detail-section:nth-of-type(3) { animation-delay: 80ms; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

/* ---------- 11. 速查索引 ---------- */
.index-panel { margin-top: clamp(20px, 3vw, 32px); padding: clamp(18px, 2.4vw, 28px); }

.index-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.index-head h3 { font-size: var(--step-3); letter-spacing: .06em; }

.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink-3);
  font-size: 11px;
  letter-spacing: .10em;
  white-space: nowrap;
}

.search-box input {
  width: clamp(160px, 22vw, 240px);
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-solid);
  color: var(--ink);
  font-size: 12.5px;
  letter-spacing: .02em;
  outline: none;
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}

.search-box input::placeholder { color: var(--ink-3); opacity: .8; }
.search-box input:focus { border-color: var(--gold-line); box-shadow: 0 0 0 3px var(--gold-soft); }

.event-index,
.rule-index,
.source-list {
  display: grid;
  gap: 1px;
  margin-top: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-top: 0;
}

.event-index { grid-template-columns: repeat(auto-fill, minmax(224px, 1fr)); }
.rule-index { grid-template-columns: repeat(auto-fill, minmax(268px, 1fr)); }
.source-list { grid-template-columns: repeat(auto-fill, minmax(268px, 1fr)); margin: 18px 0 22px; border-top: 1px solid var(--line); }

/* ---------- 11b. 节日速查：佛家 / 道家 / 民俗·节气 三分屏 ---------- */
.seg-three .seg-thumb { width: calc((100% - 6px) / 3); }

.event-bar { margin-top: clamp(14px, 1.8vw, 20px); }
/* 三分屏已有分段控件，窄屏不再重复「左右滑动」提示，避免与分段条重叠 */
.event-bar .viewer-hint { display: none; }

.event-viewport {
  overflow: hidden;
  transition: height var(--t-base) var(--ease);
}

.event-track {
  display: flex;
  align-items: flex-start;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}

.event-track::-webkit-scrollbar { display: none; }

.event-slide {
  flex: 0 0 100%;
  min-width: 0;
  scroll-snap-align: start;
  scroll-snap-stop: always;
}

.event-slide-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 2px 2px 10px;
  color: var(--ink-2);
  font-size: 11.5px;
  letter-spacing: .10em;
}

.event-slide-count { color: var(--ink-3); font-size: 10.5px; letter-spacing: .08em; }

.event-slide .event-index { margin-top: 0; border-top: 1px solid var(--line); }

.index-item {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 11px 13px;
  background: var(--surface-solid);
  color: var(--ink);
  text-align: left;
  transition: background-color var(--t-fast) var(--ease), padding-left var(--t-fast) var(--ease);
}

.index-item:hover { background: var(--surface-sunk); padding-left: 17px; }
.index-item strong { display: block; font-size: 12.5px; font-weight: 600; }
.index-item small { display: block; margin-top: 1px; color: var(--ink-3); font-size: 10.5px; }

.index-item .index-date {
  flex: none;
  color: var(--gold);
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .04em;
  white-space: nowrap;
}

.index-item.group-taoist .index-date { color: var(--g-taoist); }
.index-item.group-fasting .index-date { color: var(--g-fasting); }
.index-item.group-folk .index-date { color: var(--g-folk); }
.index-item.group-calendar .index-date { color: var(--g-calendar); }

/* ---------- 11c. 二十四节气图说 ---------- */
.term-legend {
  display: flex;
  gap: 6px;
  font-size: 10px;
  letter-spacing: .10em;
  color: var(--ink-3);
}
.term-legend span {
  padding: 2px 7px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
}
.term-legend .is-spring { color: #6f8b58; border-color: rgba(111, 139, 88, .40); }
.term-legend .is-summer { color: #96703a; border-color: rgba(150, 112, 58, .40); }
.term-legend .is-autumn { color: #9a6b3c; border-color: rgba(154, 107, 60, .40); }
.term-legend .is-winter { color: #5f7691; border-color: rgba(95, 118, 145, .40); }

.term-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.term-card {
  display: grid;
  gap: 0;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--surface-solid);
  overflow: hidden;
  cursor: pointer;
  text-align: left;
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-base) var(--ease), transform var(--t-base) var(--ease);
}

.term-card:hover,
.term-card:focus-visible {
  border-color: var(--gold-line);
  box-shadow: 0 12px 30px -22px rgba(60, 45, 25, .55);
  transform: translateY(-2px);
}
.term-card:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }

.term-pic { display: block; aspect-ratio: 1 / 1; overflow: hidden; background: var(--surface-sunk); }
.term-pic img {
  width: 100%; height: 100%; display: block; object-fit: cover;
  transition: transform var(--t-base) var(--ease);
}
.term-card:hover .term-pic img { transform: scale(1.035); }

.term-cap {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px 9px;
  border-top: 1px solid var(--line);
}
.term-cap strong { font-size: 12.5px; font-weight: 600; letter-spacing: .06em; }
.term-cap small {
  flex: none;
  color: var(--ink-3);
  font-family: var(--font-display);
  font-size: 11px;
  letter-spacing: .02em;
  font-variant-numeric: tabular-nums;
}
.term-card.is-spring .term-cap strong { color: #6f8b58; }
.term-card.is-summer .term-cap strong { color: #96703a; }
.term-card.is-autumn .term-cap strong { color: #9a6b3c; }
.term-card.is-winter .term-cap strong { color: #5f7691; }

.term-note {
  margin-top: 12px;
  color: var(--ink-3);
  font-size: 11px;
  line-height: 1.8;
}

/* 详情浮层大图统一走 11e 段的 .sheet-figure（画像与节气图共用） */

.rule-item,
.source-item {
  padding: 13px 14px;
  background: var(--surface-solid);
}

.rule-item { border-left: 2px solid var(--g-fasting); }
.rule-item.group-taoist { border-left-color: var(--g-taoist); }
.rule-item.group-buddhist { border-left-color: var(--g-buddhist); }
.rule-item.group-folk { border-left-color: var(--g-folk); }
.rule-item.group-calendar { border-left-color: var(--g-calendar); }

.rule-item h4 { font-size: 12.5px; letter-spacing: .02em; }
.rule-item p { margin-top: 3px; color: var(--ink-2); font-size: 11px; line-height: 1.7; }
.rule-item .source-link { display: inline-block; margin-top: 6px; color: var(--gold); font-size: 10px; }

.source-item strong { display: block; font-size: 12px; letter-spacing: .02em; }
.source-item a {
  display: -webkit-box;
  margin-top: 4px;
  overflow: hidden;
  color: var(--gold);
  font-size: 10.5px;
  overflow-wrap: anywhere;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.sources-note { color: var(--ink-3); font-size: 11.5px; max-width: 520px; }

.method-note {
  padding: 20px 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-sunk);
  color: var(--ink-2);
  font-size: 12px;
}

.method-note h3 {
  margin-bottom: 10px;
  font-size: var(--step-2);
  letter-spacing: .08em;
  color: var(--ink);
}

.method-note p { margin: 7px 0; line-height: 1.8; }
.method-note strong { color: var(--gold); font-weight: 600; }

/* ---------- 12. 页脚 ---------- */
.page-footer {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: clamp(40px, 6vw, 72px);
  padding-top: 20px;
  border-top: 1px solid var(--line);
  color: var(--ink-3);
  font-size: 10.5px;
  letter-spacing: .08em;
}

/* ---------- 13. 入场 ---------- */
.reveal {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity var(--t-slow) var(--ease), transform var(--t-slow) var(--ease);
}

.reveal.is-in { opacity: 1; transform: none; }

/* ---------- 14. 响应式 ---------- */
@media (max-width: 1080px) {
  .viewer-hint { display: inline; }
  .deck { overflow: hidden; }
  .deck-track {
    display: flex;
    align-items: flex-start;
    gap: 0;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .deck-track::-webkit-scrollbar { display: none; }
  .deck-slide {
    flex: 0 0 100%;
    width: 100%;
    scroll-snap-align: start;
    scroll-snap-stop: always;
  }
  .detail-panel { position: static; max-height: none; overflow: visible; }
  .brand-sub { display: none; }
}

@media (max-width: 820px) {
  .topbar { height: 60px; gap: 12px; }
  .brand-name { font-size: 14px; letter-spacing: .10em; }
  .nav { gap: 16px; }
  .nav a { padding: 16px 0; font-size: 11.5px; letter-spacing: .06em; }
  .nav a::after { bottom: 10px; }

  .hero { grid-template-columns: 1fr; align-items: start; gap: 16px; }
  .hero-aside { justify-items: start; }
  .hero-art { display: none; }
  .hero-year { text-align: left; }
  .hero-date { flex-direction: row; align-items: flex-end; }

  .chapter-head { grid-template-columns: auto minmax(0, 1fr); }
  .chapter-tools { grid-column: 1 / -1; justify-content: flex-start; }
  .index-head { flex-direction: column; align-items: flex-start; gap: 12px; }
  .search-box { width: 100%; }
  .search-box input { width: 100%; flex: 1; }
  .page-footer { flex-direction: column; gap: 6px; }
}

@media (max-width: 620px) {
  .page-shell { width: calc(100% - 24px); }
  .hero-year { display: none; }
  .hero-fo { display: inline-flex; }
  .hero-aside { gap: 10px; }
  .viewer-bar { gap: 10px; }
  .seg-btn { min-width: 92px; padding: 7px 12px; font-size: 11.5px; }
  .viewer-hint { font-size: 10px; letter-spacing: .10em; }
  .topbar { padding: 0 14px; gap: 10px; height: 56px; }
  .brand { gap: 7px; }
  .brand-name { font-size: 13px; letter-spacing: .06em; }
  .nav { gap: 13px; }
  .nav a { padding: 14px 0; font-size: 11px; letter-spacing: .02em; }
  .nav a::after { bottom: 8px; }
  .hero-year { border-left: 0; padding-left: 0; border-top: 1px solid var(--line); padding-top: 12px; }

  .hero { padding-top: 14px; position: relative; }
  .hero-main { padding-right: 0; }
  .hero:has(.hero-figure:not([hidden])) .hero-main { padding-right: 116px; }
  .hero-aside { position: absolute; right: 0; bottom: 0; top: auto; gap: 0; }
  .hero-meta { display: none; }
  .hero-figure { width: 116px; height: 116px; padding: 0; margin-bottom: 6px; }
  .hero-num { font-size: 58px; }
  .load-status { font-size: 10px; padding: 2px 8px; letter-spacing: .04em; }

  .calendar-panel { padding: 14px 10px 12px; }
  .panel-head { margin-bottom: 12px; }
  .filter-bar { gap: 5px; padding: 10px 0 12px; }
  .filter-chip { padding: 3px 9px; font-size: 10.5px; }

  .calendar-grid { grid-auto-rows: minmax(58px, auto); }
  .day-cell { padding: 6px 2px 5px; display: flex; flex-direction: column; align-items: center; gap: 2px; text-align: center; }
  .day-top { flex-direction: column; align-items: center; gap: 1px; width: 100%; }
  .day-num { font-size: 15px; }
  .day-cell.is-today .day-num { width: 22px; height: 22px; margin: 0; font-size: 14px; }
  .day-lunar { order: 2; margin-top: 0; max-width: 100%; font-size: 9px; }
  .day-tags, .day-more { display: none; }
  .day-dots { order: 3; display: flex; justify-content: center; gap: 2px; min-height: 5px; }
  .day-dot { width: 4px; height: 4px; border-radius: 50%; }
  .day-dot.dot-buddhist { background: var(--g-buddhist); }
  .day-dot.dot-taoist { background: var(--g-taoist); }
  .day-dot.dot-fasting { background: var(--g-fasting); }
  .day-dot.dot-folk { background: var(--g-folk); }
  .day-dot.dot-calendar { background: var(--g-calendar); }

  .legend { gap: 6px 12px; font-size: 10px; }
  .detail-meta { grid-template-columns: 1fr 1fr; }
  .event-index, .rule-index, .source-list { grid-template-columns: 1fr; }
  .lore-row { grid-template-columns: 1fr; gap: 0; }
  .method-note { padding: 16px; }

  .term-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .term-legend { display: none; }
  .term-cap { padding: 7px 9px 8px; }
  .term-cap strong { font-size: 12px; }
  .term-cap small { font-size: 10px; }
  .term-note { font-size: 10.5px; }

}

/* ---------- 15. 无障碍 / 降级 ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *,
  *::before,
  *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
  .reveal { opacity: 1; transform: none; }
}

@media print {
  .bg, .topbar, .progress, .theme-toggle { display: none !important; }
  body { background: #fff; }
  .panel { box-shadow: none; }
}

/* ============ 词条详情浮层 ============ */
/* html 上有 overflow-x: hidden，它自己就成了滚动容器：只锁 body 挡不住页面滚动，
   必须连 html 一起锁；同时给浮层卡片 contain，滚到底不会把滚动传导给页面。 */
html.is-locked,
body.is-locked { overflow: hidden; }
.sheet[hidden] { display: none; }
.event-item.is-card { cursor: pointer; transition: border-color .2s, box-shadow .2s, background .2s; }
.event-item.is-card:hover { border-color: var(--gold-line); box-shadow: 0 10px 26px -20px rgba(60, 45, 25, .5); }
.event-item.is-card:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }

.index-item { cursor: pointer; }
.index-item:hover strong { color: var(--gold); }
.rule-item { cursor: pointer; transition: border-color .2s, box-shadow .2s; }
.rule-item:hover { border-color: var(--gold-line); box-shadow: 0 8px 24px -16px rgba(60, 48, 30, .4); }
.rule-item:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }

.sheet { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; padding: 22px; overscroll-behavior: contain; }
.sheet-mask { position: absolute; inset: 0; background: rgba(34, 27, 18, .46); backdrop-filter: blur(2px); }
.sheet-card {
  position: relative;
  width: min(660px, 100%);
  max-height: min(86vh, 760px);
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 28px 30px 24px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-solid);
  box-shadow: 0 34px 80px -34px rgba(30, 24, 16, .55);
  animation: sheetIn .24s var(--ease, ease);
}
@keyframes sheetIn { from { opacity: 0; transform: translateY(10px) scale(.99); } }

.sheet-x {
  position: absolute; top: 10px; right: 12px;
  width: 32px; height: 32px; border: 0; border-radius: 50%;
  background: transparent; color: var(--ink-3); font-size: 21px; line-height: 1; cursor: pointer;
}
.sheet-x:hover { background: var(--surface-sunk); color: var(--ink); }

.sheet-head { display: flex; gap: 20px; align-items: center; margin-bottom: 16px; }
/* 详情浮层大图：画像与节气图共用同一容器，整幅铺满正文宽度 */
.sheet-figure {
  margin: 0 0 16px;
  border: 1px solid rgba(120, 100, 70, .34);
  border-radius: 0;
  overflow: hidden;
  background: linear-gradient(158deg, #fdfaf3 0%, #f4ede0 100%);
  box-shadow: 0 1px 3px rgba(80, 60, 30, .11), 0 0 0 1px rgba(255, 255, 255, .50) inset;
  line-height: 0;
  position: relative;
}
/* [hidden] 必须压过上面的 display，否则空容器会留白 */
.sheet-figure[hidden] { display: none; }

.sheet-figure img { width: 100%; height: auto; display: block; border-radius: 0; }

/* 人物画像：1:1 方图（原图就是方图，这里兜住属性里的 384×512 比例） */
.sheet-figure.is-square img {
  aspect-ratio: 1 / 1;
  object-fit: cover;
  mix-blend-mode: multiply;
}

/* 没有创作画像时回退的白描线稿 */
.sheet-figure svg { display: block; width: 100%; height: auto; aspect-ratio: 1 / 1; padding: 12%; color: var(--gold); box-sizing: border-box; }

/* 装裱内侧细线 */
.sheet-figure::after {
  content: ""; position: absolute; inset: 5px; pointer-events: none;
  border: 1px solid rgba(120, 100, 70, .22); border-radius: 0;
}
.hero-figure[data-kind="portrait"]::after {
  content: ""; position: absolute; inset: 3px; pointer-events: none;
  border: 1px solid rgba(120, 100, 70, .20); border-radius: 0;
}
.sheet-headtext { min-width: 0; }
.sheet-kicker { margin: 0 0 4px; font-size: 10.5px; letter-spacing: .16em; color: var(--ink-3); }
.sheet-headtext h2 { margin: 0 0 8px; font: 600 22px/1.4 var(--serif); letter-spacing: .01em; }
.sheet-tags { margin: 0; display: flex; gap: 6px; flex-wrap: wrap; }
.sheet-tag {
  padding: 2px 8px; border-radius: 3px; background: var(--surface-sunk);
  color: var(--ink-2); font-size: 11px; line-height: 1.7;
}
.sheet-tag.is-gold { background: var(--gold-soft); color: var(--gold); }

.sheet-schedule {
  margin: 0 0 12px; padding: 8px 12px;
  border-left: 2px solid var(--gold-line); background: var(--surface-sunk);
  font-size: 12.5px; color: var(--ink-2);
}
.sheet-desc { margin: 0 0 14px; font-size: 13.5px; line-height: 1.9; color: var(--ink-2); }

.sheet-lore { margin: 0 0 14px; display: grid; gap: 10px; }
.sheet-lore div { display: grid; grid-template-columns: 64px 1fr; gap: 10px; align-items: start; }
.sheet-lore dt { font-size: 11px; color: var(--gold); letter-spacing: .06em; padding-top: 2px; }
.sheet-lore dd { margin: 0; font-size: 13px; line-height: 1.9; color: var(--ink-2); }

.sheet-source { margin: 0 0 18px; font-size: 11.5px; color: var(--ink-3); line-height: 1.8; }
.sheet-source a { color: var(--gold); }

.sheet-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.sheet-btn {
  height: 36px; padding: 0 16px;
  border: 1px solid var(--ink); border-radius: 4px;
  background: var(--ink); color: #fdf9f0;
  font: inherit; font-size: 13px; cursor: pointer;
  transition: background .18s, color .18s, border-color .18s;
}
.sheet-btn:hover { background: #3a3126; }
.sheet-btn.is-quiet { background: transparent; border-color: var(--line-strong); color: var(--ink-2); }
.sheet-btn.is-quiet:hover { background: var(--surface-sunk); color: var(--ink); }

@media (max-width: 620px) {
  .sheet { padding: 0; align-items: end; }
  .sheet-card {
    width: 100%; max-height: 92vh;
    border-radius: 14px 14px 0 0;
    padding: 22px 18px calc(74px + env(safe-area-inset-bottom, 0px));
  }
  .sheet-head { gap: 14px; }
  .sheet-figure { margin-bottom: 14px; }
  .sheet-headtext h2 { font-size: 19px; }
  .sheet-lore div { grid-template-columns: 1fr; gap: 2px; }
}
