/* ============================================================
   Sanskrit Corpus — 設計系統 v1（羊皮紙學術風）
   字體棧覆蓋：Latin/IAST/Greek · Devanāgarī · Thai · CJK
   ============================================================ */
:root {
  /* 配色 —— 暖米/羊皮紙 */
  --bg:        #F4EDDE;
  --surface:   #FBF6EB;
  --surface-2: #FFFDF7;
  --ink:       #2E2A23;
  --ink-soft:  #4A4337;
  --muted:     #7A715F;
  --line:      #E2D7C0;
  --line-soft: #ECE3D1;
  --accent:    #6E2B2B;   /* 深棓朱 */
  --accent-2:  #8A6D3B;   /* 赭金 */
  --link:      #7A3026;
  --link-hover:#9c3a2c;

  /* 狀態色 */
  --st-final:  #5B7553;   /* 終稿 S / 已歸檔 — 沉綠 */
  --st-review: #9C6B1E;   /* 校對中 — 琥珀 */
  --st-ocr:    #6B6356;   /* OCR 完成 — 灰褐 */

  --radius: 10px;
  --shadow: 0 1px 2px rgba(60,46,24,.06), 0 6px 18px rgba(60,46,24,.06);
  --maxw: 1120px;

  --serif-latin: "Gentium Plus", "Gentium Book Plus", Georgia, "Times New Roman", serif;
  --serif-deva:  "Noto Serif Devanagari";
  --serif-thai:  "Noto Serif Thai", "Noto Sans Thai";
  --serif-cjk:   "Noto Serif SC", "Songti SC", "Source Han Serif SC", serif;
  --font-body:   var(--serif-latin), var(--serif-deva), var(--serif-thai), var(--serif-cjk);
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.7;
  /* 紙紋：極淡的對角織理 */
  background-image:
    radial-gradient(rgba(120,90,40,.025) 1px, transparent 1px);
  background-size: 22px 22px;
}

a { color: var(--link); text-decoration: none; }
a:hover { color: var(--link-hover); text-decoration: underline; text-underline-offset: 2px; }

/* ---------- 頂欄 ---------- */
.site-header {
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  position: sticky; top: 0; z-index: 50;
  backdrop-filter: saturate(1.1);
}
.site-header .bar {
  max-width: var(--maxw); margin: 0 auto; padding: .7rem 1.5rem;
  display: flex; align-items: baseline; gap: 1.4rem;
}
.brand { display: flex; align-items: baseline; gap: .6rem; }
.brand .logo { font-size: 1.35rem; font-weight: 700; letter-spacing: .02em; color: var(--ink); }
.brand .sub  { font-size: .82rem; color: var(--muted); }
.brand a { color: inherit; }
.brand a:hover { text-decoration: none; }
.nav { margin-left: auto; display: flex; align-items: center; gap: 1.3rem; }
.nav a { color: var(--ink-soft); font-size: .95rem; }
.nav a.active { color: var(--accent); font-weight: 600; }
.nav .who { color: var(--muted); font-size: .85rem; }
.btn-link { background: none; border: 0; color: var(--muted); cursor: pointer; font: inherit; font-size: .85rem; padding: 0; }
.btn-link:hover { color: var(--accent); }

/* ---------- 容器 ---------- */
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 2.2rem 1.5rem 4rem; }
.page-head { margin-bottom: 1.6rem; }
.page-head h1 { font-size: 1.9rem; margin: 0 0 .35rem; letter-spacing: .01em; }
.page-head .lede { color: var(--muted); max-width: 60ch; margin: 0; font-size: 1rem; }
.kicker { color: var(--accent-2); font-size: .8rem; letter-spacing: .14em; text-transform: uppercase; margin: 0 0 .5rem; }

/* ---------- 統計帶 ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin: 1.5rem 0 2.4rem; }
.stat {
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1.1rem 1.2rem; box-shadow: var(--shadow);
}
.stat .v { font-size: 2.1rem; font-weight: 700; color: var(--accent); line-height: 1; }
.stat .v .u { font-size: 1rem; color: var(--ink-soft); font-weight: 400; margin-left: .25rem; }
.stat .l { margin-top: .45rem; font-size: .95rem; color: var(--ink-soft); }
.stat .n { margin-top: .15rem; font-size: .8rem; color: var(--muted); }

/* ---------- 區塊 ---------- */
section.block { margin: 2.6rem 0; }
section.block > h2 {
  font-size: 1.25rem; margin: 0 0 1rem; padding-bottom: .4rem;
  border-bottom: 2px solid var(--line); color: var(--ink);
}
section.block > h2 .meta { font-size: .82rem; color: var(--muted); font-weight: 400; margin-left: .6rem; }

/* ---------- pipeline 流水 ---------- */
.pipeline { display: flex; gap: .5rem; flex-wrap: wrap; }
.pl-step {
  flex: 1 1 0; min-width: 150px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: .9rem 1rem; position: relative;
}
.pl-step .no { color: var(--accent-2); font-size: .78rem; letter-spacing: .1em; }
.pl-step .nm { font-weight: 700; font-size: 1.02rem; margin: .15rem 0; }
.pl-step .zh { color: var(--accent); font-size: .9rem; }
.pl-step .ds { color: var(--muted); font-size: .82rem; margin-top: .35rem; line-height: 1.5; }
.pl-step:not(:last-child)::after {
  content: "›"; position: absolute; right: -.55rem; top: 50%; transform: translateY(-50%);
  color: var(--line); font-size: 1.4rem; z-index: 1;
}

/* ---------- 主線高亮卡 ---------- */
.mainline {
  background: linear-gradient(160deg, #2E2A23, #3a3024);
  color: #F1E7D2; border-radius: 14px; padding: 1.6rem 1.7rem; box-shadow: var(--shadow);
}
.mainline h3 { margin: 0 0 .4rem; font-size: 1.2rem; color: #F4ECDB; }
.mainline p { color: #cdbfa3; font-size: .92rem; margin: 0 0 1.1rem; max-width: 70ch; }
.vol-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px,1fr)); gap: .55rem; }
.vol {
  display: flex; align-items: center; justify-content: space-between; gap: .8rem;
  background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.09);
  border-radius: 8px; padding: .55rem .8rem;
}
.vol .vn { font-size: .88rem; color: #ece2cd; }
.vol .vp { font-size: .76rem; color: #b6a584; }

/* ---------- 書目矩陣 / 書架 ---------- */
.cat-block { margin-bottom: 2rem; }
.cat-block h3 { font-size: 1.05rem; color: var(--accent); margin: 0 0 .2rem; }
.cat-block .cnt { color: var(--muted); font-size: .82rem; margin: 0 0 .8rem; }
.book-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px,1fr)); gap: .9rem; }
.book-card {
  display: block; background: var(--surface-2); border: 1px solid var(--line);
  border-left: 4px solid var(--accent-2); border-radius: var(--radius);
  padding: .95rem 1.1rem; box-shadow: var(--shadow); transition: transform .12s, box-shadow .12s;
}
.book-card:hover { transform: translateY(-2px); text-decoration: none; box-shadow: 0 4px 10px rgba(60,46,24,.1), 0 14px 30px rgba(60,46,24,.1); }
.book-card .bt { font-weight: 700; color: var(--ink); line-height: 1.35; }
.book-card .bs { color: var(--ink-soft); font-size: .85rem; font-style: italic; margin-top: .1rem; }
.book-card .ba { color: var(--muted); font-size: .85rem; margin-top: .35rem; }
.book-card .bm { display: flex; align-items: center; gap: .6rem; margin-top: .6rem; flex-wrap: wrap; }
.book-card .pp { color: var(--muted); font-size: .78rem; }

/* 狀態徽章 */
.badge { font-size: .72rem; padding: .12rem .55rem; border-radius: 99px; font-family: var(--sans); white-space: nowrap; border: 1px solid transparent; }
.badge.final  { background: #e7eee2; color: var(--st-final);  border-color:#cfe0c4; }
.badge.review { background: #f6ecd5; color: var(--st-review); border-color:#ecd9ad; }
.badge.ocr    { background: #efe9dd; color: var(--st-ocr);    border-color:#e0d6c2; }

/* ---------- 遺留問題 ---------- */
.issues { list-style: none; padding: 0; margin: 0; display: grid; gap: .5rem; }
.issues li { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: .6rem .85rem; font-size: .9rem; }
.issues .bk { color: var(--accent); font-weight: 600; margin-right: .5rem; }
.note-line { color: var(--muted); font-size: .88rem; margin-top: 1rem; border-top: 1px dashed var(--line); padding-top: .8rem; }

/* ---------- 認証頁 ---------- */
.auth-wrap { min-height: 78vh; display: grid; place-items: center; padding: 2rem 1rem; }
.auth-card { width: 100%; max-width: 400px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 2rem 1.9rem; }
.auth-card h1 { font-size: 1.5rem; margin: 0 0 .2rem; }
.auth-card .sub { color: var(--muted); font-size: .9rem; margin: 0 0 1.4rem; }
.field { margin-bottom: 1rem; }
.field label { display: block; font-size: .85rem; color: var(--ink-soft); margin-bottom: .3rem; }
.field input {
  width: 100%; padding: .6rem .7rem; font: inherit; font-size: .95rem;
  border: 1px solid var(--line); border-radius: 8px; background: var(--surface);
  color: var(--ink);
}
.field input:focus { outline: 2px solid var(--accent-2); outline-offset: 0; border-color: var(--accent-2); }
.btn {
  width: 100%; padding: .65rem 1rem; font: inherit; font-weight: 600; cursor: pointer;
  background: var(--accent); color: #fbf3e6; border: 0; border-radius: 8px;
}
.btn:hover { background: #7d3331; }
.auth-foot { margin-top: 1.2rem; font-size: .88rem; color: var(--muted); text-align: center; }
.flash { padding: .6rem .8rem; border-radius: 8px; font-size: .88rem; margin-bottom: 1rem; }
.flash.error { background: #f7e3df; color: #8c3026; border: 1px solid #e9c4bd; }
.flash.info  { background: #e9f0e5; color: #4f6a48; border: 1px solid #cfe0c4; }
.hint { font-size: .8rem; color: var(--muted); margin-top: .35rem; }

/* ---------- 閱讀頁 ---------- */
.reader { display: grid; grid-template-columns: 250px minmax(0,1fr); gap: 2.2rem; align-items: start; }
.toc { position: sticky; top: 72px; max-height: calc(100vh - 92px); overflow: auto; font-size: .86rem; border-right: 1px solid var(--line); padding-right: 1rem; }
.toc .toc-title { font-size: .78rem; text-transform: uppercase; letter-spacing: .12em; color: var(--accent-2); margin-bottom: .6rem; }
.toc ul { list-style: none; margin: 0; padding: 0; }
.toc li a { display: block; color: var(--ink-soft); padding: .15rem 0; line-height: 1.4; }
.toc li a:hover { color: var(--accent); text-decoration: none; }
.toc li.lvl-2 { padding-left: .8rem; }
.toc li.lvl-3 { padding-left: 1.6rem; font-size: .82rem; color: var(--muted); }

.doc { max-width: 74ch; }
.doc-head { margin-bottom: 1.6rem; padding-bottom: 1rem; border-bottom: 2px solid var(--line); }
.doc-head h1 { margin: 0 0 .3rem; font-size: 1.8rem; }
.doc-head .da { color: var(--muted); font-size: .95rem; }
.prose { }
.prose h1 { font-size: 1.55rem; margin: 2rem 0 .8rem; padding-bottom: .25rem; border-bottom: 1px solid var(--line-soft); }
.prose h2 { font-size: 1.3rem; margin: 1.8rem 0 .6rem; color: var(--ink); }
.prose h3 { font-size: 1.1rem; margin: 1.4rem 0 .5rem; color: var(--ink-soft); }
.prose p { margin: .8rem 0; }
.prose table { border-collapse: collapse; margin: 1.2rem 0; font-size: .95rem; width: auto; }
.prose th, .prose td { border: 1px solid var(--line); padding: .4rem .7rem; text-align: left; vertical-align: top; }
.prose th { background: var(--surface); }
.prose code { background: var(--surface); padding: .1rem .35rem; border-radius: 4px; font-size: .9em; }
.prose pre { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: .9rem 1rem; overflow: auto; }
.prose blockquote { border-left: 3px solid var(--accent-2); margin: 1rem 0; padding: .2rem 1rem; color: var(--ink-soft); background: var(--surface); }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 2rem 0; }
.prose img { max-width: 100%; height: auto; }

.back { font-size: .88rem; color: var(--muted); margin-bottom: 1rem; display: inline-block; }

/* ---------- 管理面板 ---------- */
.admin-table {
  width: 100%; border-collapse: collapse; font-size: .9rem; margin-top: .8rem;
}
.admin-table th, .admin-table td {
  border: 1px solid var(--line); padding: .45rem .75rem; text-align: left; vertical-align: middle;
}
.admin-table th { background: var(--surface); font-size: .82rem; font-weight: 600; color: var(--ink-soft); }
.admin-table tr:hover td { background: var(--surface-2); }
.admin-table .muted { color: var(--muted); font-size: .83rem; }
.action-cell { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; }
.inline-form { display: inline; }
.btn-xs {
  font: inherit; font-size: .78rem; padding: .18rem .55rem; border-radius: 6px;
  cursor: pointer; border: 1px solid var(--line); background: var(--surface);
  color: var(--ink-soft); white-space: nowrap;
}
.btn-xs:hover { background: var(--surface-2); color: var(--ink); }
.btn-xs.danger { border-color: #e9c4bd; background: #f7e3df; color: #8c3026; }
.btn-xs.danger:hover { background: #f1cfc8; }
.btn-sm {
  font: inherit; font-size: .85rem; padding: .3rem .9rem; border-radius: 7px;
  cursor: pointer; border: 0; background: var(--accent); color: #fbf3e6;
}
.btn-sm:hover { background: #7d3331; }
.code-cell { font-family: "SF Mono", "Fira Code", monospace; font-size: .85rem; letter-spacing: .04em; color: var(--accent); }
.used-row td { opacity: .6; }

.pw-details { display: inline; }
.pw-details summary.btn-xs { display: inline-block; cursor: pointer; list-style: none; }
.pw-details summary::-webkit-details-marker { display: none; }
.pw-form { display: flex; gap: .35rem; align-items: center; margin-top: .35rem; flex-wrap: wrap; }
.pw-form input {
  font: inherit; font-size: .85rem; padding: .25rem .5rem;
  border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--ink);
  width: 160px;
}
.pw-form input:focus { outline: 2px solid var(--accent-2); border-color: var(--accent-2); }

.invite-gen {
  display: flex; align-items: center; gap: .7rem; flex-wrap: wrap;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 10px; padding: .7rem 1rem; margin-bottom: 1rem; font-size: .9rem;
}
.invite-gen label { display: flex; align-items: center; gap: .35rem; }
.count-input {
  width: 52px; font: inherit; font-size: .9rem; padding: .2rem .4rem;
  border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--ink); text-align: center;
}
.note-input {
  flex: 1; min-width: 180px; font: inherit; font-size: .9rem; padding: .25rem .55rem;
  border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--ink);
}
.invite-table .code-cell { font-size: .82rem; }

/* ---------- 詞典庫 ---------- */
.dict-table {
  width: 100%; border-collapse: collapse; font-size: .9rem; margin-top: .8rem;
}
.dict-table th, .dict-table td {
  border: 1px solid var(--line); padding: .5rem .8rem; text-align: left; vertical-align: top;
}
.dict-table th { background: var(--surface); font-size: .82rem; font-weight: 600; color: var(--ink-soft); }
.dict-table .col-title  { width: 38%; }
.dict-table .col-author { width: 24%; }
.dict-table .col-year   { width: 8%; white-space: nowrap; }
.dict-table .col-dl     { width: 15%; }
.dict-table .col-src    { width: 15%; }
.dict-table tr:hover td { background: var(--surface-2); }
.dt { font-weight: 600; color: var(--ink); line-height: 1.35; }
.dn { font-size: .82rem; color: var(--muted); margin-top: .2rem; }
.dl-cell { vertical-align: middle; }
.dl-btn {
  display: inline-flex; align-items: center; gap: .25rem;
  font-family: var(--sans); font-size: .75rem; font-weight: 600; white-space: nowrap;
  padding: .22rem .65rem; border-radius: 6px;
  background: var(--accent); color: #fbf3e6; border: 0; text-decoration: none;
}
.dl-btn:hover { background: #7d3331; color: #fbf3e6; text-decoration: none; }
.dl-btn.secondary { background: var(--accent-2); }
.dl-btn.secondary:hover { background: #7a5a28; }
.fsize { font-weight: 400; opacity: .8; }
.dl-btn-inline {
  display: inline-block; margin-left: .9rem; font-family: var(--sans); font-size: .78rem;
  padding: .12rem .5rem; border-radius: 6px;
  background: var(--surface); border: 1px solid var(--line); color: var(--ink-soft);
  text-decoration: none;
}
.dl-btn-inline:hover { background: var(--line-soft); color: var(--ink); text-decoration: none; }

/* ---------- 字體下載區 ---------- */
.font-section { margin-bottom: 2.8rem; }
.font-note { color: var(--muted); font-size: .9rem; margin: -.4rem 0 1rem; }
.font-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .85rem;
}
.font-card {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1rem 1.1rem; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: .35rem;
}
.font-card-all {
  border-color: var(--accent-2); border-left-width: 4px;
}
.font-name { font-weight: 700; font-size: 1rem; color: var(--ink); }
.font-desc { font-size: .83rem; color: var(--ink-soft); line-height: 1.45; flex: 1; }
.font-files { font-size: .78rem; color: var(--muted); }
.font-dl { margin-top: .3rem; }

/* ---------- 響應式 ---------- */
@media (max-width: 860px) {
  .stat-grid { grid-template-columns: repeat(2,1fr); }
  .reader { grid-template-columns: 1fr; }
  .toc { position: static; max-height: none; border-right: 0; border-bottom: 1px solid var(--line); padding-right: 0; padding-bottom: 1rem; margin-bottom: 1rem; }
  .pl-step:not(:last-child)::after { content: none; }
}
@media (max-width: 520px) {
  .stat-grid { grid-template-columns: 1fr; }
  .nav { gap: .9rem; }
}

/* ── i18n 語言切換條 ── */
.lang-bar{display:flex;gap:.25rem;justify-content:flex-end;align-items:center;
  padding:.3rem .9rem;background:var(--surface,#FBF6EB);
  border-bottom:1px solid rgba(0,0,0,.06);font-size:.82rem}
.lang-link{color:var(--accent-2,#8A6D3B);text-decoration:none;
  padding:.12rem .55rem;border-radius:.4rem;line-height:1.4}
.lang-link:hover{background:rgba(138,109,59,.12)}
.lang-link.active{background:var(--accent,#6E2B2B);color:#fff}

/* ── 理念 / About ── */
.about-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(220px,1fr));
  gap:1rem;margin-top:1.2rem}
.about-card{display:flex;flex-direction:column;gap:.45rem;padding:1.05rem 1.15rem;
  background:var(--surface,#FBF6EB);border:1px solid rgba(0,0,0,.08);
  border-radius:.6rem;text-decoration:none;color:inherit;transition:border-color .15s}
.about-card:hover{border-color:var(--accent-2,#8A6D3B)}
.about-card .an{font-size:.8rem;color:var(--accent-2,#8A6D3B);font-weight:700;letter-spacing:.04em}
.about-card .atitle{font-size:1.05rem;font-weight:600;line-height:1.35}
.about-doc{max-width:46rem;margin:0 auto}

/* ---- 詞典 nara 預覽 ---- */
.preview-btn {
  margin-top: .45rem;
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .22rem .6rem;
  font-family: var(--sans);
  font-size: .78rem;
  color: var(--accent);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  transition: background .12s, border-color .12s, color .12s;
}
.preview-btn:hover { background: var(--surface); border-color: var(--accent); }

.pv-overlay {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(46,42,35,.46);
  display: flex; align-items: center; justify-content: center;
  padding: 4vh 4vw;
}
.pv-overlay[hidden] { display: none; }
.pv-modal {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: min(680px, 100%);
  max-height: 88vh;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.pv-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 1rem; padding: 1rem 1.2rem .7rem;
  border-bottom: 1px solid var(--line-soft);
}
.pv-title { font-family: var(--font-body); font-size: 1.05rem; color: var(--ink); font-weight: 600; }
.pv-sub   { font-size: .82rem; color: var(--muted); margin-top: .25rem; }
.pv-close {
  flex: none; width: 30px; height: 30px; line-height: 1;
  border: 1px solid var(--line); border-radius: 8px;
  background: transparent; color: var(--ink-soft); cursor: pointer; font-size: .95rem;
}
.pv-close:hover { background: var(--bg); border-color: var(--accent); color: var(--accent); }
.pv-note {
  margin: .7rem 1.2rem 0; padding: .5rem .7rem;
  font-size: .82rem; color: var(--st-review);
  background: #fbf1dc; border: 1px solid #ecdcbb; border-radius: 8px;
}
.pv-frame {
  border: 0; width: 100%; flex: 1 1 auto; min-height: 320px;
  background: var(--surface); margin-top: .5rem;
}

/* ---- 解析閱讀 Reader ---- */
.rd-input-block { margin: 1rem 0 .4rem; }
.rd-label { display:block; font-family:var(--sans); font-size:.8rem; color:var(--muted); margin-bottom:.35rem; }
.rd-text {
  width:100%; box-sizing:border-box; padding:.7rem .85rem;
  font-family:var(--font-body); font-size:1.08rem; line-height:1.7; color:var(--ink);
  background:var(--surface); border:1px solid var(--line); border-radius:var(--radius); resize:vertical;
}
.rd-text:focus { outline:none; border-color:var(--accent); }
.rd-toolbar { display:flex; gap:.5rem; align-items:center; margin-top:.55rem; }
.rd-verbnote {
  font-size:.8rem; color:var(--st-review); background:#fbf1dc;
  border:1px solid #ecdcbb; border-radius:8px; padding:.5rem .7rem; margin:.2rem 0 1rem;
}
.rd-main { display:grid; grid-template-columns: 1fr 360px; gap:1.4rem; align-items:start; }
@media (max-width: 820px) { .rd-main { grid-template-columns:1fr; } }

.rd-passage {
  font-family:var(--font-body); font-size:1.25rem; line-height:2.1; color:var(--ink);
  background:var(--surface); border:1px solid var(--line); border-radius:var(--radius);
  padding:1.1rem 1.25rem; min-height:160px;
}
.rd-line { margin-bottom:.25rem; }
.rd-empty, .rd-panel-empty { color:var(--muted); font-family:var(--sans); font-size:.9rem; }
.rd-word {
  cursor:pointer; padding:0 .06em; border-radius:4px;
  transition:background .1s, box-shadow .1s;
}
.rd-word:hover { background:#efe4cc; }
.rd-word.on { background:var(--accent); color:#fbf3e6; }

.rd-panel {
  position:sticky; top:1rem;
  background:var(--surface); border:1px solid var(--line); border-radius:var(--radius);
  padding:1rem 1.1rem; max-height:78vh; overflow:auto;
}
.rd-head { border-bottom:1px solid var(--line-soft); padding-bottom:.5rem; margin-bottom:.6rem; }
.rd-surface { font-family:var(--font-body); font-size:1.4rem; color:var(--accent); font-weight:600; }
.rd-sec-t { font-family:var(--sans); font-size:.72rem; letter-spacing:.05em; text-transform:uppercase;
            color:var(--muted); margin:.8rem 0 .35rem; }
.rd-analyses { list-style:none; margin:0; padding:0; }
.rd-analyses li { display:flex; justify-content:space-between; gap:.6rem; align-items:baseline;
                  padding:.28rem 0; border-bottom:1px dotted var(--line-soft); }
.rd-lem { font-family:var(--font-body); font-size:1.05rem; color:var(--ink); }
.rd-gram { font-family:var(--sans); font-size:.8rem; color:var(--ink-soft); text-align:right; }
.rd-note { font-size:.86rem; color:var(--muted); line-height:1.55; }
.rd-loading { color:var(--muted); font-size:1.4rem; text-align:center; padding:1rem; }

.rd-gloss { margin:.5rem 0 .7rem; }
.rd-gloss-h { display:flex; justify-content:space-between; align-items:baseline; gap:.5rem; margin-bottom:.18rem; }
.rd-gloss-lem { font-family:var(--font-body); font-size:1.02rem; color:var(--ink); font-weight:600; }
.rd-gloss-d { font-family:var(--sans); font-size:.7rem; color:var(--muted); }
.rd-gloss-b { font-family:var(--font-body); font-size:.95rem; line-height:1.55; color:var(--ink-soft); }
/* dict.sqlite body 用 CDSL 原始標記，給最小樣式 */
.rd-gloss-b s { font-style:italic; color:var(--accent); text-decoration:none; }
.rd-gloss-b lex { font-size:.85em; color:var(--muted); font-style:italic; }
.rd-gloss-b ls { font-size:.82em; color:var(--st-review); }
.rd-gloss-b ab { color:var(--muted); }
.rd-gloss-b hom { font-weight:700; color:var(--accent); }
.rd-gloss-b pb, .rd-gloss-b .pb { display:none; }

/* ---- Reader 面板：Heritage 譯本 HTML 樣式 ---- */
.rd-gloss-b .sense { display:block; margin:.15rem 0; }
.rd-gloss-b .sense + .sense { padding-top:.15rem; }
.rd-gloss-b .lex { font-size:.85em; color:var(--muted); font-style:italic; }
.rd-gloss-b .iast { font-style:italic; }
.rd-gloss-b .deva { font-family:var(--serif-deva); }
.rd-gloss-b .sub-anchor { font-weight:600; color:var(--accent); }
.rd-gloss-b .xref { color:var(--link); text-decoration:none; }
.rd-gloss-b .xref:hover { text-decoration:underline; }
.rd-gloss-b a.cgi-decl { color:var(--muted); text-decoration:none; font-style:italic; }
.rd-gloss-b .ex, .rd-gloss-b .example { color:var(--ink-soft); }

/* ---- 頁腳署名 ---- */
.site-footer {
  margin-top: 3rem;
  border-top: 1px solid var(--line);
  background: var(--surface);
  padding: 1.4rem 1rem 2rem;
  text-align: center;
  font-family: var(--sans);
}
.foot-inner {
  display: flex; flex-wrap: wrap; gap: .5rem;
  align-items: center; justify-content: center;
  font-size: .86rem; color: var(--ink-soft);
}
.foot-inner strong { color: var(--accent); font-weight: 600; }
.foot-sep { color: var(--line); }
.site-footer a { color: var(--link); text-decoration: none; }
.site-footer a:hover { text-decoration: underline; }
.foot-upstream {
  margin-top: .6rem; font-size: .76rem; color: var(--muted);
  max-width: 46rem; margin-left: auto; margin-right: auto; line-height: 1.5;
}

/* ---- 引用與致謝頁 ---- */
.cite-box {
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius);
  padding: .9rem 1.1rem; font-family: var(--serif-latin), serif; font-size: .95rem;
  line-height: 1.6; color: var(--ink); white-space: pre-wrap; word-break: break-word;
}
.credit-list { margin: 0; padding-left: 1.1rem; }
.credit-list li { margin: .55rem 0; line-height: 1.6; color: var(--ink-soft); }
.copy-line { color: var(--muted); font-size: .9rem; margin-top: .6rem; }

/* ================= 手機適配（≤640px）================= */
@media (max-width: 640px) {
  /* 頂欄：品牌與導航豎排，導航換行居中 */
  .site-header { position: static; }
  .site-header .bar {
    flex-direction: column; align-items: stretch;
    gap: .5rem; padding: .6rem 1rem;
  }
  .brand { justify-content: center; }
  .brand .logo { font-size: 1.2rem; }
  .nav {
    margin-left: 0; flex-wrap: wrap; justify-content: center;
    gap: .55rem 1rem; font-size: .92rem;
    border-top: 1px solid var(--line-soft); padding-top: .5rem;
  }

  /* 容器內邊距、標題收一收 */
  .wrap { padding: 1.3rem 1rem 3rem; }
  .page-head h1 { font-size: 1.5rem; }
  .page-head .lede { font-size: .95rem; }

  /* 詞典表格 → 卡片：表頭隱藏，每行成卡，單元格帶字段名 */
  .dict-table thead { display: none; }
  .dict-table, .dict-table tbody, .dict-table tr, .dict-table td { display: block; width: 100%; }
  .dict-table tr {
    border: 1px solid var(--line); border-radius: 10px;
    margin-bottom: .85rem; padding: .7rem .85rem; background: var(--surface);
  }
  .dict-table tr:hover td { background: transparent; }
  .dict-table td { border: 0; padding: .22rem 0; }
  .dict-table td.col-title, .dict-table td:first-child { padding-bottom: .4rem; }
  .dict-table .col-title, .dict-table .col-author,
  .dict-table .col-year, .dict-table .col-dl, .dict-table .col-src { width: auto; }
  .dict-table td[data-label]::before {
    content: attr(data-label) "：";
    color: var(--muted); font-size: .8rem; font-family: var(--sans); margin-right: .35rem;
  }
  .dict-table td.dl-cell { display: inline-block; width: auto; margin-right: 1.2rem; }
  .dict-table td.dl-cell::before { display: block; margin-bottom: .15rem; }

  /* 文獻閱讀裡的寬表格（範式表等）改橫向滾動，不撐破版面 */
  .prose table { display: block; overflow-x: auto; max-width: 100%; }

  /* 統計格已在 520 處理；解析閱讀面板不再 sticky，省高度 */
  .rd-panel { position: static; max-height: none; }
  .rd-passage { font-size: 1.15rem; line-height: 1.95; }
}
