/* 主恢復信息文字閱讀
   佈景、字型、綱目排版（.d-*）沿用「主恢復信息逐字稿與會議記錄生成器」v0.41.0 的 css/app.css；
   閱讀工具列參考生命讀經網頁（A+／A−、下方固定工具列、小標錨點）。 */
:root {
  --bg: #FAF6EE; --bg2: #F0E9DB; --card: #FFFDF8; --fg: #2F3343; --fg2: #4A4F63; --muted: #67645F;
  --line: #E4DCCC; --edge: #8E8574; --accent: #8A6431; --accent-soft: rgba(196, 147, 86, .16);
  --chrome: #2F3343; --chrome-fg: #F7F1E4; --gold: #D9A466; --logo: #9C733D; --wm-opacity: .06;
  --danger: #B03A2E;
  --verse: #8B1E1E;            /* 綱目經文出處與引用經文：暗紅（生成器 VERSE_COLOR） */
  --ink: #000;                 /* 綱目文字：黑 */
  --surface-raised: #fff;
  --serif-zh: "Noto Serif TC", "Noto Serif CJK TC", "Source Han Serif TC", "Songti TC", "PMingLiU", "MingLiU", serif;
  --kai: "BiauKai", "DFKai-SB", "標楷體", "Kaiti TC", "STKaiti", "LXGW WenKai TC", var(--serif-zh);
  --ui: system-ui, -apple-system, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  --r: 14px;
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
  --read-size: 19px; --read-lh: 1.85;
  --palette-alpha-23: rgba(255, 253, 248, .94); --palette-alpha-24: rgba(47, 51, 67, .12);
  --palette-alpha-25: rgba(47, 51, 67, .22); --palette-alpha-35: rgba(47, 51, 67, .35); --palette-alpha-36: rgba(47, 51, 67, .2);
}
:root[data-theme="white"] { --bg: #F4F4F2; --card: #fff; --surface-raised: #fff; --line: #E2E2DE; }
:root[data-theme="sepia"] { --bg: #EFE4C8; --bg2: #E6D8B6; --card: #F8EED5; --surface-raised: #F8EED5; --line: #DCCDA6; --fg: #4A3A28; --ink: #3B2D1E; --verse: #8E2A1A; }
:root[data-theme="night"] {
  --bg: #15171C; --bg2: #232733; --card: #1D2028; --surface-raised: #1D2028; --fg: #DCD6C8; --fg2: #C4BEB0; --muted: #9A958A;
  --line: #333846; --edge: #6B6658; --accent: #D9A466; --accent-soft: rgba(217, 164, 102, .16); --ink: #E2DCCD; --verse: #E39A8E;
  --chrome: #0E1014; --logo: #D9A466; --wm-opacity: .035;
  --palette-alpha-23: rgba(29, 32, 40, .94); --palette-alpha-24: rgba(0, 0, 0, .4);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--fg); }
body { font: 16px/1.7 var(--ui); min-height: 100vh; display: flex; flex-direction: column; -webkit-text-size-adjust: 100%; }
a { color: var(--accent); }
button { font: inherit; color: inherit; }
.hint { color: var(--muted); font-size: 14px; }

/* 浮水印與徽章（生成器同一個 emblem） */
.watermark, .hero-logo, .brand-logo { background: var(--logo); -webkit-mask: url(../icons/emblem.svg) center / contain no-repeat; mask: url(../icons/emblem.svg) center / contain no-repeat; }
.watermark { position: fixed; z-index: 0; left: 50%; top: 54%; width: min(78vw, 520px); aspect-ratio: 1; transform: translate(-50%, -50%); opacity: var(--wm-opacity); pointer-events: none; }

.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; padding: calc(var(--safe-t) + 8px) 16px 8px; background: var(--chrome); color: var(--chrome-fg); }
.brand { display: flex; align-items: center; gap: 8px; color: var(--gold); text-decoration: none; font: 600 16px var(--serif-zh); letter-spacing: .06em; }
.brand-logo { width: 28px; height: 28px; background: var(--gold); }
.page { position: relative; z-index: 1; width: 100%; max-width: 760px; margin: 0 auto; padding: 18px 16px 40px; flex: 1; }
.foot { position: relative; z-index: 1; text-align: center; color: var(--muted); font-size: 13px; padding: 18px 12px calc(18px + var(--safe-b)); border-top: 1px solid var(--line); }
.foot .ver { display: block; margin-top: 4px; }
body.reader .foot { padding-bottom: calc(78px + var(--safe-b)); }

/* 首頁 */
.hero { text-align: center; padding: 14px 4px 22px; }
.hero-logo { width: 64px; height: 64px; margin: 0 auto 6px; }
.kicker { font: 600 15px var(--serif-zh); color: var(--accent); letter-spacing: .3em; margin: 0; }
.hero h1 { font: 700 clamp(26px, 5vw, 36px)/1.3 var(--serif-zh); margin: 4px 0 10px; letter-spacing: .04em; }
.lead { color: var(--fg2); max-width: 36em; margin: 0 auto; text-align: left; }
.card { position: relative; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; margin: 0 0 14px; }
.sec { font: 700 18px var(--serif-zh); margin: 0 0 10px; }
details > summary.sec { cursor: pointer; margin: 0; }
details[open] > summary.sec { margin-bottom: 10px; }
.drop { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; text-align: center; border: 2px dashed var(--edge); border-radius: var(--r); padding: 26px 14px; cursor: pointer; background: rgba(196, 147, 86, .05); transition: background .15s, border-color .15s; }
.drop:hover, .drop.over { background: var(--accent-soft); border-color: var(--accent); }
.drop b { font: 700 18px var(--serif-zh); }
.row { display: flex; gap: 8px; align-items: center; }
.row.end { justify-content: flex-end; margin-top: 10px; }
input[type=url], textarea { width: 100%; font: 16px/1.6 var(--ui); color: var(--fg); background: var(--surface-raised); border: 1px solid var(--edge); border-radius: 10px; padding: 10px 12px; }
textarea { font-family: var(--serif-zh); resize: vertical; margin-bottom: 10px; }
.btn { border: 1px solid var(--edge); background: var(--card); border-radius: 10px; padding: 10px 18px; font-weight: 600; cursor: pointer; white-space: nowrap; min-height: 44px; }
.btn.primary { background: var(--chrome); border-color: var(--chrome); color: var(--chrome-fg); }
:root[data-theme="night"] .btn.primary { background: var(--accent); border-color: var(--accent); color: #15171C; }
.xbtn { border: 1px solid var(--line); background: var(--bg); border-radius: 99px; padding: 6px 14px; font-size: 14px; cursor: pointer; }
.prog { position: relative; display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; padding: 12px 14px; border-radius: 12px; background: var(--bg2); margin: 0 0 14px; }
.prog[hidden] { display: none; }
.prog .bar { flex-basis: 100%; height: 8px; border-radius: 99px; background: var(--line); overflow: hidden; }
.prog .bar i { display: block; height: 100%; width: 3%; background: var(--accent); transition: width .3s; }
.spin { display: inline-block; width: 1em; height: 1em; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.shelf-item { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.shelf-item:first-child { border-top: 0; }
.shelf-item a { flex: 1; min-width: 0; text-decoration: none; color: var(--fg); }
.shelf-item b { display: block; font: 600 17px var(--serif-zh); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.install-wrap { text-align: center; margin: 22px 0 0; }

/* 閱讀頁 */
.reader-head { display: flex; align-items: center; gap: 8px; margin: 0 0 12px; }
.reader-head .back { text-decoration: none; font-weight: 600; margin-right: auto; }
.chip { display: inline-block; font-size: 13px; line-height: 1.7; padding: 0 10px; border-radius: 99px; border: 1px solid var(--line); color: var(--muted); background: var(--card); white-space: nowrap; }
.reader-article { background: var(--surface-raised); border: 1px solid var(--line); border-radius: 16px; padding: 24px 18px 34px; box-shadow: 0 2px 10px rgba(67, 52, 33, .06); }
@media (min-width: 720px) { .reader-article { padding: 40px 52px 52px; } }
.src { margin: 12px 4px; word-break: break-all; }

/* ---- 文件排版（生成器 .doc / .d-* 規則，字級改成可調整的 --read-size） ---- */
.doc { font: var(--read-size)/var(--read-lh) var(--serif-zh); color: var(--ink); }
:root[data-font="kai"] .doc { font-family: var(--kai); }
.doc .vr { color: var(--verse); }
.d-doctitle { font: 700 .95em/1.5 var(--ui); text-align: center; margin: 0 0 6px; }
.d-subject { font: 1.2em/1.5 var(--kai); text-align: center; margin: 0 0 10px; }
.d-msgno { font: 1.05em/1.5 var(--kai); text-align: center; margin: 0; }
.d-msgtitle { font: 1.25em/1.5 var(--kai); text-align: center; margin: 0 0 14px; font-weight: 700; color: var(--ink); }
.d-reading { font-size: .82em; padding-left: 2em; margin: 0 0 16px; color: var(--verse); text-align: justify; }
.d-pt { display: flex; align-items: flex-start; text-align: justify; margin: .15em 0; }
.d-pt .lab { flex: 0 0 auto; white-space: nowrap; }
.d-pt .pt-body { flex: 1; min-width: 0; text-align: justify; }
.d-pt.l1 { padding-left: 0; margin-top: .55em; font-family: var(--kai); font-weight: 700; }
.d-pt.l2 { padding-left: 1em; }
.d-pt.l3 { padding-left: 2em; }
.d-pt.l4 { padding-left: 3em; }
.d-pt.l5 { padding-left: 4em; }
.d-pt.l3 .lab, .d-pt.l4 .lab { font-family: "Times New Roman", serif; }
.d-pt.l3 .lab, .d-pt.l4 .lab, .d-pt.l5 .lab { margin-right: .35em; }
.d-p, .d-text { text-align: justify; margin: .5em 0; }
.d-p { text-indent: 2em; }
.d-pt, .d-sec, .d-p { scroll-margin-top: calc(64px + var(--safe-t)); }
/* 信息小標（生命讀經的小標題）：置中、楷體、粗體 */
.d-sec { display: block; text-align: center; font: 700 1.08em/1.6 var(--kai); margin: 1.3em 0 .55em; padding: 0; color: var(--ink); }
.d-sec .lab, .d-sec .pt-body { display: inline; }
.d-sec.s2, .d-sec.s3 { text-align: left; font-size: 1em; margin: 1em 0 .35em; }
.d-sec.s3 { font-family: var(--serif-zh); }
.doc[data-mode="message"] .d-sec + .d-p { margin-top: .2em; }
.anc { border: 0; background: none; color: var(--muted); opacity: .45; cursor: pointer; padding: 0 0 0 .35em; font: 400 .7em var(--ui); vertical-align: .1em; }
.anc::before { content: "#"; }
.anc:hover, .anc:focus-visible { opacity: 1; color: var(--accent); }

/* 下方固定工具列（參考生命讀經的 A+／A−） */
#navbottom { position: fixed; z-index: 30; left: 0; right: 0; bottom: 0; display: flex; justify-content: center; gap: 2px; padding: 6px 8px calc(6px + var(--safe-b)); background: var(--palette-alpha-23); border-top: 1px solid var(--line); box-shadow: 0 -2px 10px rgba(0, 0, 0, .06); backdrop-filter: blur(8px); }
#navbottom button { flex: 1 1 0; max-width: 84px; min-height: 46px; border: 0; background: none; border-radius: 10px; font: 700 16px var(--ui); color: var(--fg); cursor: pointer; }
#navbottom button:hover, #navbottom button:focus-visible { background: var(--accent-soft); }
#navbottom [data-a="font"] { font-family: var(--kai); font-size: 18px; }
.onav-fab { bottom: calc(70px + var(--safe-b)) !important; }
.outline-nav { bottom: max(80px, calc(var(--safe-b) + 76px)) !important; }

#sheet { position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, .28); display: flex; align-items: flex-end; justify-content: center; }
#sheet[hidden] { display: none; }
.sheet-body { width: 100%; max-width: 560px; background: var(--card); border-radius: 18px 18px 0 0; padding: 16px 16px calc(16px + var(--safe-b)); max-height: 86vh; overflow: auto; }
.sheet-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.seg { display: inline-flex; gap: 4px; padding: 3px; border-radius: 12px; background: var(--bg2); }
.seg button { border: 0; background: none; border-radius: 9px; padding: 8px 14px; cursor: pointer; min-height: 40px; }
.seg button.on { background: var(--card); color: var(--accent); font-weight: 700; box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.sheet-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 14px 0; }
.sheet-grid button { min-height: 48px; border: 1px solid var(--line); background: var(--bg); border-radius: 12px; cursor: pointer; font-weight: 600; }
.sheet-grid button.danger { color: var(--danger); }
.sheet-close { width: 100%; }

.modal-wrap { position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, .35); display: flex; align-items: center; justify-content: center; padding: 12px; }
.modal { width: 100%; max-width: 820px; max-height: 92vh; display: flex; flex-direction: column; background: var(--card); border-radius: 16px; padding: 16px; }
.modal h3 { margin: 0 0 4px; font: 700 19px var(--serif-zh); }
.modal textarea.doc-edit { flex: 1; min-height: 50vh; font: 16px/1.7 var(--serif-zh); white-space: pre; overflow-wrap: normal; }

#toast { position: fixed; z-index: 60; left: 50%; bottom: calc(80px + var(--safe-b)); transform: translate(-50%, 20px); background: var(--chrome); color: var(--chrome-fg); padding: 10px 18px; border-radius: 99px; font-size: 15px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; max-width: 90vw; }
#toast.on { opacity: 1; transform: translate(-50%, 0); }

body.standalone { display: block; }

@media print {
  .top, .foot, #navbottom, #sheet, .watermark, .reader-head, .src, .anc, #toast { display: none !important; }
  html, body { background: #fff; }
  .page { max-width: none; padding: 0; }
  .reader-article { border: 0; box-shadow: none; padding: 0; background: #fff; }
  .doc { font-size: 12pt; line-height: 1.7; color: #000; font-family: "新細明體", "PMingLiU", "MingLiU", var(--serif-zh); }
  .d-subject, .d-msgno, .d-msgtitle, .d-pt.l1, .d-sec { font-family: "標楷體", "DFKai-SB", "BiauKai", "Kaiti TC", "STKaiti", "LXGW WenKai TC", serif; }
  .doc .vr, .d-reading { color: #c00000; }
  .d-pt, .d-sec { break-after: avoid-page; break-inside: avoid-page; }
  .d-p { widows: 2; orphans: 2; }
}

/* ---- 三種顏色（照逐字稿生成器：綱要黑、經文暗紅、其他敘述深藍 #1F3A68） ---- */
:root { --prose: #1F3A68; }
:root[data-theme="sepia"] { --prose: #24375C; }
:root[data-theme="night"] { --prose: #9FB9E6; }
.doc .d-p, .doc .d-text { color: var(--prose); }
.doc .d-p .vr, .doc .d-text .vr { color: var(--verse); }
/* 綱目附經文：一節一行，暗紅、字小一點，縮排跟著上面那一點（生成器 .d-verses） */
.d-verses { white-space: pre-wrap; font-size: .88em; color: var(--verse); margin: 2px 0 6px; text-align: left; }
.d-verses .vr, .d-verses span { color: var(--verse); }
.d-verses.l1 { padding-left: 2.3em; } .d-verses.l2 { padding-left: 3em; } .d-verses.l3 { padding-left: 4em; } .d-verses.l4 { padding-left: 5em; } .d-verses.l5 { padding-left: 6em; }
.doc[data-mode="message"] .d-verses { padding-left: 2em; }
/* 中文兩端對齊時，只在字和字之間平均分配，不把一行拉得太散 */
.doc .d-p, .doc .d-text, .doc .d-pt .pt-body { text-justify: inter-character; }
@media print { .doc .d-p, .doc .d-text { color: #1F3A68; } .d-verses { color: #c00000; font-size: 10.56pt; } }
.versenote { margin: -4px 4px 10px; }
.versenote[hidden] { display: none; }
/* 輸出與分享按鈕列 */
.actions { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 12px; }
.actions button { flex: 1 1 calc(33.3% - 6px); min-height: 44px; border: 1px solid var(--line); background: var(--card); border-radius: 10px; font-weight: 600; font-size: 15px; cursor: pointer; color: var(--fg); }
.actions button:hover, .actions button:focus-visible { border-color: var(--accent); color: var(--accent); }
.actions button.line { background: #06C755; border-color: #06C755; color: #fff; }
@media (min-width: 720px) { .actions button { flex: 1 1 0; } }
@page { size: A4; margin: 20mm 27mm; }
@media print { .actions, .versenote { display: none !important; } }
/* LINE 圖卡預覽（跟網頁圖卡平台同一個樣子） */
.share-page { max-width: 420px; margin: 0 auto; display: flex; flex-direction: column; gap: 12px; }
.share-page .btn { text-align: center; text-decoration: none; }
.btn.big { min-height: 52px; font-size: 17px; }
.lcard { background: #FFFDF8; border: 1px solid #E4DCCC; border-radius: 14px; overflow: hidden; box-shadow: 0 2px 10px rgba(0,0,0,.08); color: #2F3343; }
.lcard-hero { display: block; width: 100%; aspect-ratio: 1.91 / 1; object-fit: cover; }
.lcard-main { padding: 18px 20px 8px; }
.lcard-site { margin: 0; font-size: 12px; color: #67645F; }
.lcard h2 { margin: 4px 0 8px; font: 700 21px/1.4 var(--ui); }
.lcard-desc { margin: 0; font-size: 14px; color: #67645F; }
.lcard-stub { display: flex; flex-direction: column; gap: 8px; padding: 10px 16px 14px; }
.lbtn { display: block; text-align: center; border-radius: 8px; padding: 8px; font-weight: 600; font-size: 15px; }
.lbtn.primary { background: #2F3343; color: #fff; }
.lbtn.second { background: #E4DCCC; color: #2F3343; }
.lbtn.link { color: #67645F; font-weight: 400; }
/* 綱目點底下沒有編號的子項（保險：…、直銷：…）：綱目內容，黑色，從上一點的文字起點開始（生成器 TEXT_START） */
.d-ptext { color: var(--ink); text-align: justify; margin: .15em 0; text-justify: inter-character; }
.d-ptext.l1 { padding-left: 2.3em; } .d-ptext.l2 { padding-left: 3em; } .d-ptext.l3 { padding-left: 4em; } .d-ptext.l4 { padding-left: 5em; } .d-ptext.l5 { padding-left: 6em; }
