/* 侨批数字朗读馆 · 第 1 段样式 */

:root {
  --paper: #f4e9d2;
  --paper-light: #fbf5e8;
  --paper-deep: #e8d8b8;
  --ink: #34291f;
  --ink-soft: #6f6151;
  --seal: #9b3b2f;
  --line: #d8c7a6;
  --nav-height: 64px;
  --nav-space: calc(var(--nav-height) + env(safe-area-inset-bottom, 0px));
  --wechat-tip-height: calc(38px + env(safe-area-inset-top, 0px));
  --serif: "Kaiti SC", "STKaiti", "KaiTi", "Songti SC", "STSong", "SimSun", serif;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
}

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.75;
  background-color: var(--paper);
  background-image:
    radial-gradient(circle at 18% 12%, rgba(255, 255, 255, .45), transparent 45%),
    radial-gradient(circle at 82% 78%, rgba(160, 126, 74, .10), transparent 50%),
    repeating-linear-gradient(0deg, rgba(120, 90, 50, .025) 0 1px, transparent 1px 5px);
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }

/* 微信内打开提示 */
.wechat-tip[hidden] { display: none; }
.wechat-tip {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: var(--wechat-tip-height);
  padding: calc(8px + env(safe-area-inset-top, 0px)) 12px 8px;
  background: var(--seal);
  color: var(--paper-light);
  font-size: 13px;
  letter-spacing: .04em;
  text-align: center;
  box-shadow: 0 2px 10px rgba(38, 28, 18, .18);
}
body.has-wechat-tip .topbar { margin-top: var(--wechat-tip-height); top: var(--wechat-tip-height); }

/* 顶栏 */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 64px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(251, 245, 232, .92);
  backdrop-filter: blur(6px);
}

.brand { display: inline-flex; align-items: center; gap: 10px; min-width: 0; }

.brand-seal {
  flex: none;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 2px solid var(--seal);
  border-radius: 4px;
  color: var(--seal);
  font: 700 20px/1 var(--serif);
  transform: rotate(-4deg);
}

.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-text strong { font: 600 16px/1.3 var(--serif); letter-spacing: .08em; white-space: nowrap; }
.brand-text small { color: var(--ink-soft); font-size: 11px; letter-spacing: .12em; white-space: nowrap; }

/* 内容区 */
.app {
  width: 100%;
  max-width: 980px;
  margin: 0 auto;
  padding: 28px 20px calc(var(--nav-space) + 36px);
}

.app:focus { outline: none; }

.page-title {
  margin: 0 0 6px;
  font: 600 30px/1.35 var(--serif);
  letter-spacing: .1em;
}

.page-lead { margin: 0 0 24px; color: var(--ink-soft); font-size: 14px; }

.section-title {
  margin: 32px 0 12px;
  font: 600 20px/1.4 var(--serif);
  letter-spacing: .08em;
}

/* 进门 */
.enter { position: relative; min-height: calc(100vh - 64px - var(--nav-space)); display: grid; place-items: center; padding: 40px 0 56px; }

.enter-inner { position: relative; z-index: 1; max-width: 640px; text-align: center; }

.eyebrow {
  margin: 0 0 18px;
  color: var(--seal);
  font-size: 13px;
  letter-spacing: .35em;
}

.enter h1 {
  margin: 0 0 20px;
  font: 600 clamp(42px, 10vw, 76px)/1.25 var(--serif);
  letter-spacing: .18em;
  text-indent: .18em;
}

.enter-desc {
  margin: 0 auto 32px;
  max-width: 30em;
  color: var(--ink-soft);
  font-size: 15px;
  line-height: 2;
}

.enter-btn {
  display: inline-flex;
  align-items: center;
  gap: 18px;
  min-height: 54px;
  padding: 12px 32px;
  border: 1px solid var(--seal);
  border-radius: 2px;
  background: var(--seal);
  color: #fff8e8;
  font: 600 17px/1.4 var(--serif);
  letter-spacing: .16em;
  box-shadow: 0 6px 18px rgba(120, 60, 40, .18);
  transition: transform .18s ease, box-shadow .18s ease;
}

.enter-btn:hover, .enter-btn:focus-visible { transform: translateY(-2px); box-shadow: 0 10px 22px rgba(120, 60, 40, .24); }
.enter-btn span { font-size: 20px; }

.enter-count { margin: 22px 0 0; color: var(--ink-soft); font-size: 12px; letter-spacing: .18em; }

.enter-seal {
  position: absolute;
  right: max(4%, 12px);
  bottom: 18%;
  display: grid;
  place-items: center;
  width: clamp(90px, 18vw, 150px);
  aspect-ratio: 1;
  border: 3px double var(--seal);
  border-radius: 50%;
  color: var(--seal);
  font: 600 clamp(44px, 9vw, 76px)/1 var(--serif);
  opacity: .16;
  transform: rotate(12deg);
  pointer-events: none;
}

/* 展厅卡片 */
.letter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
  gap: 18px;
  margin: 0;
}

.letter-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--paper-light);
  box-shadow: 0 3px 12px rgba(90, 64, 30, .07);
  transition: transform .18s ease, box-shadow .18s ease;
}

.letter-card:hover, .letter-card:focus-visible { transform: translateY(-3px); box-shadow: 0 10px 22px rgba(90, 64, 30, .15); }

.card-image {
  width: 100%;
  height: 170px;
  overflow: hidden;
  background: var(--paper-deep);
  border-bottom: 1px solid var(--line);
}

.card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 24%;
  filter: sepia(.14) contrast(.96);
}

.card-body { display: flex; flex: 1; flex-direction: column; padding: 18px; }

.card-meta { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }

.card-year {
  padding: 2px 10px;
  border: 1px solid var(--seal);
  border-radius: 2px;
  color: var(--seal);
  font: 600 13px/1.5 var(--serif);
  letter-spacing: .12em;
}

.card-index { color: var(--ink-soft); font-size: 12px; letter-spacing: .1em; }

.card-title { margin: 0 0 4px; font: 600 22px/1.4 var(--serif); letter-spacing: .06em; }
.card-subtitle { margin: 0 0 12px; color: var(--seal); font-size: 13px; letter-spacing: .04em; }
.card-summary { margin: 0 0 18px; color: var(--ink-soft); font-size: 14px; overflow-wrap: anywhere; }
.card-go { margin-top: auto; color: var(--seal); font-size: 13px; letter-spacing: .08em; }

/* 关于 */
.source-list { display: grid; gap: 14px; margin: 0; padding: 0; list-style: none; }

.source-card {
  padding: 18px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--seal);
  border-radius: 2px;
  background: var(--paper-light);
}

.source-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px 12px; margin-bottom: 10px; }
.source-head strong { font: 600 18px/1.4 var(--serif); letter-spacing: .06em; }
.source-head span { color: var(--seal); font-size: 13px; }

.source-rows { display: grid; gap: 6px; margin: 0; font-size: 14px; }
.source-rows div { display: grid; grid-template-columns: 4.5em minmax(0, 1fr); gap: 8px; }
.source-rows dt { color: var(--ink-soft); }
.source-rows dd { margin: 0; overflow-wrap: anywhere; }

.source-note { margin: 10px 0 0; color: var(--ink-soft); font-size: 12px; overflow-wrap: anywhere; }
.source-link { color: var(--seal); border-bottom: 1px solid currentColor; }

.notice-panel {
  margin-top: 28px;
  padding: 16px 18px;
  border: 1px dashed var(--line);
  border-radius: 2px;
  background: rgba(255, 255, 255, .3);
  font-size: 13px;
  color: var(--ink-soft);
}

.notice-panel p { margin: 0 0 6px; }
.notice-panel p:last-child { margin-bottom: 0; }

/* 读信页占位（第 2 段补全） */
.info-table { display: grid; gap: 8px; margin: 20px 0; font-size: 14px; }
.info-table div { display: grid; grid-template-columns: 5em minmax(0, 1fr); gap: 10px; padding-bottom: 8px; border-bottom: 1px dotted var(--line); }
.info-table dt { color: var(--ink-soft); }
.info-table dd { margin: 0; overflow-wrap: anywhere; }

.back-link { display: inline-block; margin-top: 12px; color: var(--seal); font-size: 14px; border-bottom: 1px solid currentColor; }

.stub-panel {
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--paper-light);
  text-align: center;
}
.stub-panel p { margin: 0 0 8px; color: var(--ink-soft); font-size: 14px; }

/* 底部导航 */
.bottom-nav {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  height: var(--nav-space);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  border-top: 1px solid var(--line);
  background: rgba(251, 245, 232, .97);
  backdrop-filter: blur(8px);
  box-shadow: 0 -3px 14px rgba(90, 64, 30, .08);
}

.bottom-nav a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-width: 0;
  min-height: var(--nav-height);
  color: var(--ink-soft);
  font-size: 12px;
  letter-spacing: .06em;
}

.nav-icon {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border: 1px solid currentColor;
  border-radius: 50%;
  font: 600 14px/1 var(--serif);
}

.nav-label { white-space: nowrap; }

.bottom-nav a[aria-current="page"] { color: var(--seal); }
.bottom-nav a[aria-current="page"] .nav-icon { background: var(--seal); border-color: var(--seal); color: #fff8e8; }

/* 小屏 */
@media (max-width: 600px) {
  .topbar { min-height: 56px; padding: 6px 12px; }
  .brand-text strong { font-size: 14px; }
  .brand-text small { font-size: 10px; }
  .app { padding: 22px 14px calc(var(--nav-space) + 28px); }
  .page-title { font-size: 25px; }
  .enter { min-height: calc(100vh - 56px - var(--nav-space)); padding: 30px 0 40px; }
  .enter h1 { font-size: clamp(38px, 12vw, 56px); }
  .enter-desc { font-size: 14px; }
  .card-image { height: 145px; }
  .source-rows div, .info-table div { grid-template-columns: 1fr; gap: 0; }
  .source-rows dt, .info-table dt { font-size: 12px; }
}

/* ---------- 第 2 段：读信页 / 朗读 / 原件图 ---------- */

.read-tools { display: flex; flex-wrap: wrap; gap: 10px; margin: 18px 0; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 9px 18px;
  border: 1px solid var(--seal);
  border-radius: 2px;
  background: transparent;
  color: var(--seal);
  font: 600 14px/1.4 var(--sans);
  letter-spacing: .06em;
  cursor: pointer;
}
.btn:hover, .btn:focus-visible { background: rgba(155, 59, 47, .08); }
.btn-primary { background: var(--seal); color: #fff8e8; }
.btn-primary:hover, .btn-primary:focus-visible { background: #853126; }
.btn-small { min-height: 38px; padding: 6px 14px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }

.mode-tabs { display: flex; gap: 0; margin: 0 0 14px; border-bottom: 1px solid var(--line); }
.mode-tab {
  flex: 1;
  min-height: 44px;
  padding: 8px 10px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--ink-soft);
  font: 600 14px/1.4 var(--sans);
  cursor: pointer;
}
.mode-tab[aria-selected="true"] { border-bottom-color: var(--seal); color: var(--seal); }
.tab-count { font-size: 11px; opacity: .8; }

.mode-panel { padding: 16px; border: 1px solid var(--line); background: var(--paper-light); border-radius: 2px; }
.mode-panel[hidden], .image-modal[hidden] { display: none !important; }
.tool-row { display: flex; flex-wrap: wrap; gap: 8px; }
.notice-inline { margin: 0 0 12px; color: var(--ink-soft); font-size: 13px; }
.hint { margin: 12px 0 0; color: var(--ink-soft); font-size: 12px; }

.record-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; font-weight: 600; }
.record-list { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.record-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: var(--paper);
}
.rec-meta { color: var(--ink-soft); font-size: 12px; overflow-wrap: anywhere; }
.record-empty { margin: 0; padding: 18px; border: 1px dashed var(--line); color: var(--ink-soft); font-size: 13px; text-align: center; }

.para-block {
  margin: 0 0 14px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-left: 4px solid transparent;
  border-radius: 2px;
  background: var(--paper-light);
  scroll-margin-top: 80px;
  transition: background .2s ease, border-color .2s ease;
}
.para-block.is-reading { border-left-color: var(--seal); background: #fff8e5; box-shadow: 0 0 0 2px rgba(155, 59, 47, .12) inset; }
.para-no { margin-bottom: 10px; color: var(--seal); font-size: 12px; letter-spacing: .12em; }
.field { margin: 0 0 12px; }
.field:last-child { margin-bottom: 0; }
.field-label {
  display: inline-block;
  min-width: 3.4em;
  margin-right: 8px;
  padding: 1px 6px;
  border: 1px solid var(--line);
  border-radius: 2px;
  color: var(--ink-soft);
  font-size: 12px;
  vertical-align: top;
}
.field-text { display: inline; margin: 0; font-size: 15px; overflow-wrap: anywhere; }
.field-text.original { white-space: pre-wrap; font-family: var(--serif); font-size: 16px; line-height: 2; }
.speech-field .field-text { color: var(--ink-soft); font-size: 14px; }
.notes-list { display: inline-block; margin: 0; padding-left: 1.2em; font-size: 13px; color: var(--ink-soft); vertical-align: top; }
.notes-list li { margin-bottom: 4px; overflow-wrap: anywhere; }
.notes-list b { color: var(--ink); }
.story-text { margin: 0; white-space: pre-line; font-size: 15px; line-height: 2; overflow-wrap: anywhere; }

/* 原件图放大查看 */
.image-modal { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(38, 28, 18, .76); }
.modal-box {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(100%, 960px);
  max-height: calc(100vh - 32px);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--paper-light);
}
.modal-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); font-size: 14px; }
.modal-tools { display: flex; flex-wrap: wrap; gap: 6px; }
.modal-tools button { min-height: 36px; min-width: 40px; padding: 4px 10px; border: 1px solid var(--line); border-radius: 2px; background: var(--paper); color: var(--ink); font-size: 13px; cursor: pointer; }
.modal-tools button:hover, .modal-tools button:focus-visible { border-color: var(--seal); color: var(--seal); }
.modal-body { flex: 1; min-height: 0; overflow: auto; padding: 12px; background: #e9dcc2; text-align: center; }
.modal-img { display: inline-block; width: 100%; max-width: 100%; height: auto; transform-origin: top center; }
body.modal-open { overflow: hidden; }

@media (max-width: 600px) {
  .app { padding-bottom: calc(var(--nav-space) + 24px); }
  .btn { min-height: 46px; flex: 1 1 auto; }
  .mode-tab { font-size: 13px; }
  .para-block { padding: 14px; }
  .field-text { display: block; margin-top: 4px; }
  .notes-list { display: block; margin-top: 4px; }
  .field-label { margin-right: 0; }
  .image-modal { padding: 8px; }
  .modal-box { max-height: calc(100vh - 16px); }
  .modal-head { padding: 8px; }
}

/* ---------- 第 3 段：录音 / 声音邮局 ---------- */

.record-card {
  margin-bottom: 16px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: var(--paper-light);
}
.record-card[hidden] { display: none !important; }
.rec-target { margin: 0 0 6px; font: 600 18px/1.5 var(--serif); letter-spacing: .04em; }
.rec-status { margin: 0 0 4px; color: var(--seal); font-size: 13px; }
.rec-timer { margin: 0 0 12px; font: 600 26px/1.3 var(--serif); letter-spacing: .08em; }
.wave-canvas { display: block; width: 100%; height: 80px; max-width: 100%; border: 1px solid var(--line); background: #e8d8b8; }
.record-card audio { display: block; width: 100%; max-width: 100%; margin: 10px 0; }
.picker-list { display: grid; gap: 8px; margin-top: 12px; }
.post-letter-link { display: block; padding: 12px; border: 1px solid var(--line); background: var(--paper); color: var(--seal); }

.post-list { display: grid; gap: 12px; margin: 0; padding: 0; list-style: none; }
.post-item { padding: 16px; border: 1px solid var(--line); border-left: 4px solid var(--seal); border-radius: 2px; background: var(--paper-light); }
.post-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 12px; margin-bottom: 10px; }
.post-letter { color: var(--seal); font: 600 17px/1.4 var(--serif); border-bottom: 1px solid currentColor; }
.post-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.post-confirm { margin-top: 10px; padding: 10px; border: 1px dashed var(--seal); border-radius: 2px; background: rgba(155, 59, 47, .06); font-size: 13px; }
.post-confirm[hidden] { display: none !important; }
.post-confirm .tool-row { margin-top: 8px; }
.post-empty { padding: 36px 18px; border: 1px dashed var(--line); border-radius: 2px; color: var(--ink-soft); text-align: center; }
.post-empty a { color: var(--seal); border-bottom: 1px solid currentColor; }

@media (max-width: 600px) {
  .rec-timer { font-size: 22px; }
  .wave-canvas { height: 70px; }
  .post-actions .btn { flex: 1 1 auto; }
}

/* 录音页照读原文 */
.source-text-box {
  max-height: 260px;
  overflow-y: auto;
  margin: 12px 0 8px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: var(--paper);
  font-family: var(--serif);
  font-size: 15px;
  line-height: 2;
}
.source-text-box p { margin: 0 0 10px; white-space: pre-wrap; overflow-wrap: anywhere; }
.source-text-box p:last-child { margin-bottom: 0; }

@media (max-width: 600px) {
  .source-text-box { max-height: 220px; font-size: 14px; padding: 12px; }
}

/* ---------- 第 5 段：手机安装与录音环境提示 ---------- */

.notice-warn {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-left: 3px solid var(--seal);
  background: rgba(155, 59, 47, .08);
  color: var(--seal);
  font-size: 13px;
  line-height: 1.6;
}
.notice-warn[hidden] { display: none; }

.install-panel { margin-top: 18px; }
.install-panel p { margin: 0 0 8px; }
.install-panel .btn { margin-top: 10px; }
.install-panel[hidden] { display: none; }
