/* ========= 變數 ========= */
:root {
  --bg: #FBF8F1;
  --bg-card: #FFFFFF;
  --bg-soft: #F5F1E8;
  --primary: #2E5E3E;
  --primary-light: #4A8060;
  --primary-soft: rgba(46, 94, 62, 0.08);
  --accent: #8B6F47;
  --text: #2D2D2D;
  --text-soft: #5A5A5A;
  --text-mute: #999999;
  --border: #E6DDD0;
  --shadow: 0 2px 8px rgba(46, 94, 62, 0.08);
  --shadow-lg: 0 4px 20px rgba(46, 94, 62, 0.12);
  --shadow-xl: 0 8px 30px rgba(46, 94, 62, 0.2);
  --radius: 12px;
  --radius-sm: 8px;
  --content-font: 16px;  /* 動態字級 */
}

[data-font="small"] { --content-font: 14px; }
[data-font="normal"] { --content-font: 16px; }
[data-font="large"] { --content-font: 18px; }
[data-font="xlarge"] { --content-font: 21px; }

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  padding: 0;
  font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", "思源黑體 TC", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}

button { cursor: pointer; font-family: inherit; border: none; background: none; color: inherit; padding: 0; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ========= 測試版 banner ========= */
.test-banner {
  background: linear-gradient(90deg, #FFF3CD 0%, #FFE5A0 100%);
  border-bottom: 1px solid #F0CD7B;
  padding: 8px 16px;
  position: relative;
  z-index: 110;
}
.test-banner[hidden] { display: none; }
.test-banner-content {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: #6B4F00;
}
.test-banner-icon { font-size: 16px; flex-shrink: 0; }
.test-banner-text { flex: 1; line-height: 1.5; }
.test-banner-text strong { color: #8B4513; }
.test-banner-text a { color: #8B4513; font-weight: 700; text-decoration: underline; }
.test-banner-close {
  background: rgba(0,0,0,0.08);
  color: #6B4F00;
  width: 26px; height: 26px;
  border-radius: 50%;
  font-size: 18px;
  line-height: 1;
  flex-shrink: 0;
}
.test-banner-close:hover { background: rgba(0,0,0,0.15); }

/* ========= 頂部 ========= */
.top-bar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow);
}

.menu-btn { display: none; font-size: 26px; padding: 6px 10px; color: var(--primary); }

.brand { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.brand .logo { font-size: 32px; line-height: 1; flex-shrink: 0; }
.brand-text { min-width: 0; }
.brand h1 { margin: 0; font-size: 17px; color: var(--primary); font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-sub { margin: 1px 0 0; font-size: 12px; color: var(--text-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.top-actions { display: flex; gap: 4px; flex-shrink: 0; }
.top-actions button, .top-actions .btn-pdf {
  padding: 8px 12px;
  background: var(--bg-soft);
  border-radius: var(--radius-sm);
  font-size: 15px;
  color: var(--text);
  transition: all 0.2s;
  min-width: 38px;
  text-align: center;
}
.top-actions button:hover, .top-actions .btn-pdf:hover { background: var(--primary); color: white; text-decoration: none; }

/* ========= 佈局 ========= */
.layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  max-width: 1400px;
  margin: 0 auto;
  min-height: calc(100vh - 60px);
}

/* ========= 側邊欄 ========= */
.sidebar {
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  position: sticky;
  top: 60px;
  height: calc(100vh - 60px);
  overflow-y: auto;
  padding: 14px;
}

.sidebar-head { display: none; justify-content: space-between; align-items: center; padding-bottom: 12px; border-bottom: 1px solid var(--border); margin-bottom: 12px; font-weight: 700; color: var(--primary); }
.sidebar-close { font-size: 28px; color: var(--text-mute); padding: 0 8px; }

.overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 90; }
.overlay.show { display: block; }

.search-box { position: sticky; top: 0; background: var(--bg-card); padding-bottom: 10px; margin-bottom: 6px; z-index: 2; }
.search-box input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  background: var(--bg-soft);
  font-family: inherit;
  color: var(--text);
}
.search-box input:focus { outline: none; border-color: var(--primary); background: white; }

#nav .nav-group { margin-bottom: 14px; }
#nav .nav-cat { font-size: 11px; font-weight: 700; color: var(--accent); letter-spacing: 0.5px; margin: 6px 8px 4px; }
#nav .nav-item {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 10px; margin: 2px 0; border-radius: var(--radius-sm);
  cursor: pointer; font-size: 14px; color: var(--text);
  transition: all 0.15s; border: none; background: none;
  width: 100%; text-align: left;
}
#nav .nav-item:hover { background: var(--bg-soft); }
#nav .nav-item.active { background: var(--primary); color: white; }
#nav .nav-item .nav-icon { font-size: 18px; flex-shrink: 0; }
#nav .nav-item .nav-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#nav .nav-item .nav-pages { font-size: 11px; color: var(--text-mute); flex-shrink: 0; }
#nav .nav-item.active .nav-pages { color: rgba(255,255,255,0.75); }

/* ========= 主內容 ========= */
.content { padding: 28px 40px 80px; max-width: 1000px; }

/* ========= 歡迎頁 ========= */
.welcome-cover { text-align: center; padding: 28px 12px; }

/* 教會 logo */
.welcome-logo {
  max-width: 480px;
  margin: 0 auto 24px;
}
.welcome-logo svg { width: 100%; height: auto; }

/* ========= 封面章節（cover） ========= */
.cover-page { text-align: center; padding: 24px 12px; }
.cover-page .cover-logo {
  max-width: 520px;
  margin: 0 auto 28px;
}
.cover-page .cover-logo svg { width: 100%; height: auto; }
.cover-page .cover-h1 {
  font-size: 32px;
  color: var(--primary);
  font-weight: 700;
  margin: 12px 0 6px;
}
.cover-page .cover-h1-en {
  font-size: 15px;
  letter-spacing: 2px;
  color: var(--text-soft);
  margin: 0 0 24px;
}
.cover-page .cover-theme {
  background: var(--bg-soft);
  padding: 18px;
  border-radius: var(--radius);
  margin: 18px auto;
  max-width: 460px;
  border-left: 4px solid var(--accent);
  border-right: 4px solid var(--accent);
}
.cover-page .cover-fellowship {
  margin: 24px auto;
  max-width: 460px;
}
.cover-page .cover-line {
  font-size: 22px;
  color: var(--primary);
  margin: 6px 0;
  letter-spacing: 3px;
}
.cover-page .cover-line strong { font-weight: 700; }
.cover-page .cover-line-en {
  font-size: 14px;
  color: var(--text-soft);
  letter-spacing: 1.5px;
  margin: 2px 0;
}
.cover-page .cover-date {
  font-size: 17px;
  color: var(--accent);
  margin-top: 32px;
  font-weight: 600;
  letter-spacing: 2px;
}

/* ========= 目錄章節（toc） ========= */
.toc-page { padding: 12px 0; }
.toc-h2 {
  font-size: 22px;
  color: var(--primary);
  margin: 0 0 6px;
  font-weight: 700;
}
.toc-hint {
  color: var(--text-soft);
  font-size: 13px;
  margin: 0 0 20px;
}
.toc-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.toc-row {
  display: flex;
  align-items: center;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
  background: var(--bg-card);
  border: 1px solid var(--border);
  gap: 10px;
}
.toc-row:hover {
  background: var(--primary);
  color: white;
  transform: translateX(4px);
}
.toc-row:hover .toc-pages { color: rgba(255,255,255,0.85); }
.toc-row:hover .toc-dots { border-color: rgba(255,255,255,0.5); }
.toc-icon { font-size: 20px; flex-shrink: 0; width: 26px; text-align: center; }
.toc-title { font-size: 15px; font-weight: 500; flex-shrink: 0; }
.toc-dots {
  flex: 1;
  border-bottom: 1px dotted var(--text-mute);
  margin: 0 8px;
  transform: translateY(-3px);
}
.toc-pages { color: var(--text-soft); font-size: 13px; font-weight: 500; flex-shrink: 0; min-width: 50px; text-align: right; }
.cover-banner { display: inline-block; padding: 10px 28px; border-top: 2px solid var(--accent); border-bottom: 2px solid var(--accent); margin-bottom: 22px; }
.cover-en { margin: 0; font-size: 17px; letter-spacing: 3px; color: var(--accent); }
.cover-zh { margin: 4px 0 0; font-size: 21px; letter-spacing: 7px; color: var(--primary); font-weight: 500; }
.welcome-cover h2 { font-size: 34px; color: var(--primary); margin: 10px 0; font-weight: 700; }
.welcome-cover .subtitle { font-size: 14px; color: var(--text-soft); letter-spacing: 2px; margin: 0 0 20px; }
.meeting-date { font-size: 16px; color: var(--accent); margin-bottom: 28px; }
.theme-card {
  background: linear-gradient(135deg, #2E5E3E 0%, #4A8060 100%);
  color: white;
  padding: 26px 22px;
  border-radius: var(--radius);
  margin: 28px auto;
  max-width: 600px;
  box-shadow: var(--shadow-lg);
}
.theme-zh { font-size: 30px; font-weight: 700; margin-bottom: 8px; letter-spacing: 4px; }
.theme-en { font-size: 15px; opacity: 0.9; letter-spacing: 1px; }
.quick-actions {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px; max-width: 700px; margin: 28px auto;
}
.qa-card {
  background: white; border: 1px solid var(--border);
  padding: 18px 14px; border-radius: var(--radius);
  cursor: pointer; transition: all 0.2s;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.qa-card:hover { border-color: var(--primary); transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.qa-icon { font-size: 30px; }
.qa-title { font-size: 15px; color: var(--primary); font-weight: 600; }
.qa-desc { font-size: 12px; color: var(--text-soft); }
.welcome-stats { display: flex; justify-content: center; gap: 16px; margin: 32px 0; flex-wrap: wrap; }
.stat { text-align: center; padding: 14px 22px; background: var(--bg-card); border-radius: var(--radius); border: 1px solid var(--border); min-width: 110px; }
.stat .num { font-size: 26px; font-weight: 700; color: var(--primary); }
.stat .lbl { font-size: 12px; color: var(--text-soft); margin-top: 4px; }
.welcome-hint { text-align: center; color: var(--text-mute); font-size: 13px; margin-top: 28px; padding: 0 12px; }

/* ========= 章節頁 ========= */
.chapter { animation: fadeIn 0.3s ease-out; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.chapter-header {
  border-bottom: 3px solid var(--primary);
  padding-bottom: 14px;
  margin-bottom: 20px;
}
.chapter-title { font-size: 26px; color: var(--primary); margin: 0 0 6px; display: flex; align-items: center; gap: 10px; line-height: 1.3; }
.chapter-title .ch-icon { font-size: 30px; flex-shrink: 0; }
.chapter-meta { font-size: 12px; color: var(--text-soft); display: flex; gap: 10px; flex-wrap: wrap; }
.chapter-meta .meta-badge { background: var(--bg-soft); padding: 2px 10px; border-radius: 10px; color: var(--accent); font-weight: 500; }

.chapter-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.chapter-tab {
  padding: 10px 16px;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  font-size: 14px;
  color: var(--text-soft);
  border: 1px solid transparent;
  border-bottom: none;
  background: none;
  transition: all 0.15s;
}
.chapter-tab.active { background: var(--bg-card); color: var(--primary); font-weight: 600; border-color: var(--border); }
.chapter-tab:hover:not(.active) { background: var(--bg-soft); color: var(--primary); }

.chapter-content { padding: 8px 0 24px; }

/* ========= 結構化文字 ========= */
.chapter-page {
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 1px dashed var(--border);
}
.chapter-page:last-child { border-bottom: none; }

.page-tag {
  display: inline-block;
  font-size: 11px;
  background: var(--accent);
  color: white;
  padding: 3px 10px;
  border-radius: 10px;
  margin-bottom: 12px;
  font-weight: 500;
}

/* 結構化排版 */
.content-block { font-size: var(--content-font); line-height: 1.85; color: var(--text); }

.content-block h2.ch-title {
  font-size: 1.55em;
  font-weight: 800;
  color: var(--primary);
  margin: 22px 0 10px;
  padding-bottom: 6px;
  border-bottom: 2px solid var(--primary-soft);
}
.content-block h3.l1 {
  font-size: 1.18em;
  font-weight: 800;
  color: var(--primary);
  margin: 24px 0 10px;
  padding: 8px 12px;
  background: linear-gradient(90deg, var(--primary-soft), transparent);
  border-left: 4px solid var(--primary);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.content-block h4.l2 {
  font-size: 1.05em;
  font-weight: 700;
  color: var(--accent);
  margin: 16px 0 6px;
  padding-left: 8px;
}
.content-block p {
  margin: 6px 0 10px;
  padding-left: 4px;
}
.content-block .bullet {
  margin: 4px 0 4px 14px;
  padding-left: 18px;
  position: relative;
  line-height: 1.7;
}
.content-block .bullet::before {
  content: "•";
  color: var(--accent);
  font-weight: 700;
  position: absolute;
  left: 4px;
}
.content-block .role-line {
  background: var(--bg-soft);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  margin: 4px 0;
  display: inline-block;
  font-size: 0.92em;
}
.content-block strong { color: var(--primary); }
.content-block .amount { color: var(--accent); font-weight: 700; }
.content-block .note { color: var(--text-soft); font-size: 0.92em; font-style: italic; }

/* 表格區塊 */
.content-block table {
  border-collapse: collapse;
  width: 100%;
  margin: 12px 0;
  font-size: 0.94em;
}
.content-block th, .content-block td {
  border: 1px solid var(--border);
  padding: 8px 12px;
  text-align: left;
}
.content-block th {
  background: var(--primary);
  color: white;
  font-weight: 600;
}

/* 章節導航（上一章/下一章） */
.chapter-nav { display: flex; justify-content: space-between; gap: 12px; margin-top: 32px; padding-top: 20px; border-top: 1px solid var(--border); }
.chapter-nav button {
  flex: 1;
  padding: 12px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--primary);
  text-align: left;
  transition: all 0.15s;
}
.chapter-nav button:hover:not(:disabled) { background: var(--primary); color: white; border-color: var(--primary); }
.chapter-nav button:disabled { opacity: 0.4; cursor: not-allowed; }
.chapter-nav button .arrow { font-size: 16px; margin: 0 4px; }
.chapter-nav button .nav-label { display: block; font-size: 10px; opacity: 0.7; margin-bottom: 2px; }

/* 原始頁面圖 */
.chapter-images { display: flex; flex-direction: column; gap: 16px; }
.chapter-images img { max-width: 100%; border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow); }
.page-num-label { text-align: center; font-size: 12px; color: var(--text-mute); margin-top: 6px; }

/* ========= 回頂部 ========= */
.back-top {
  position: fixed;
  bottom: 100px;
  right: 24px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--bg-card);
  color: var(--primary);
  font-size: 20px;
  font-weight: 700;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  z-index: 150;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.back-top.show { opacity: 1; pointer-events: auto; }

/* ========= AI Toggle 按鈕 ========= */
.ai-widget { position: fixed; bottom: 24px; right: 24px; z-index: 180; }
.ai-toggle {
  background: var(--primary);
  color: white;
  padding: 14px 20px;
  border-radius: 28px;
  box-shadow: var(--shadow-xl);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 600;
  transition: transform 0.2s;
}
.ai-toggle:hover { transform: scale(1.05); }
.ai-toggle:active { transform: scale(0.95); }
.ai-toggle-icon { font-size: 22px; }

/* ========= AI 浮窗 ========= */
.ai-modal { position: fixed; inset: 0; z-index: 300; pointer-events: none; }
.ai-modal[data-state="open"] { pointer-events: auto; }
.ai-modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.4);
  opacity: 0;
  transition: opacity 0.2s;
}
.ai-modal[data-state="open"] .ai-modal-backdrop { opacity: 1; }
.ai-panel {
  position: absolute;
  bottom: 90px;
  right: 24px;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 540px;
  max-height: calc(100vh - 140px);
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xl);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--border);
  transform: translateY(20px) scale(0.95);
  opacity: 0;
  transition: all 0.25s cubic-bezier(.34,1.56,.64,1);
}
.ai-modal[data-state="open"] .ai-panel {
  transform: translateY(0) scale(1);
  opacity: 1;
}
.ai-header {
  padding: 14px 18px;
  background: var(--primary);
  color: white;
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.ai-header button { font-size: 28px; color: white; padding: 0 6px; line-height: 1; }
.ai-info { padding: 12px 16px; background: var(--bg-soft); font-size: 13px; color: var(--text-soft); line-height: 1.7; border-bottom: 1px solid var(--border); }
.ai-example { color: var(--primary); cursor: pointer; text-decoration: underline dotted; }
.ai-example:hover { color: var(--accent); }
.ai-messages { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.ai-msg { max-width: 88%; padding: 10px 14px; border-radius: 14px; font-size: 14px; line-height: 1.65; word-wrap: break-word; white-space: pre-wrap; }
.ai-msg.user { background: var(--primary); color: white; align-self: flex-end; border-bottom-right-radius: 4px; }
.ai-msg.bot { background: var(--bg-soft); color: var(--text); align-self: flex-start; border-bottom-left-radius: 4px; }
.ai-msg.bot.thinking { color: var(--text-mute); font-style: italic; }
.ai-input-row { padding: 12px; border-top: 1px solid var(--border); display: flex; gap: 8px; }
.ai-input-row input {
  flex: 1; padding: 10px 14px;
  border: 1px solid var(--border); border-radius: 20px;
  font-size: 14px; font-family: inherit;
}
.ai-input-row input:focus { outline: none; border-color: var(--primary); }
.ai-input-row button { background: var(--primary); color: white; width: 40px; height: 40px; border-radius: 50%; font-size: 18px; font-weight: 700; }
.ai-input-row button:hover { background: var(--primary-light); }
.ai-input-row button:disabled { background: var(--text-mute); cursor: not-allowed; }
.ai-footer { margin: 0; padding: 6px 14px; font-size: 11px; color: var(--text-mute); text-align: center; background: var(--bg-soft); border-top: 1px solid var(--border); }

/* ========= 通用 Modal ========= */
.modal, .font-modal { position: fixed; inset: 0; z-index: 250; pointer-events: none; }
.modal[data-state="open"], .font-modal[data-state="open"] { pointer-events: auto; }
.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.4);
  opacity: 0;
  transition: opacity 0.2s;
}
.modal[data-state="open"] .modal-backdrop, .font-modal[data-state="open"] .modal-backdrop { opacity: 1; }

.modal-content, .font-content {
  position: relative;
  margin: 60px auto 0;
  background: var(--bg-card);
  border-radius: var(--radius);
  width: calc(100% - 40px);
  max-width: 700px;
  max-height: calc(100vh - 120px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-xl);
  transform: translateY(20px);
  opacity: 0;
  transition: all 0.22s;
}
.modal[data-state="open"] .modal-content, .font-modal[data-state="open"] .font-content {
  transform: translateY(0);
  opacity: 1;
}

.modal-header { padding: 14px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; }
.modal-header input { flex: 1; padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 16px; font-family: inherit; }
.modal-header input:focus { outline: none; border-color: var(--primary); }
.modal-header button { font-size: 26px; color: var(--text-mute); padding: 0 8px; }

.modal-results { flex: 1; overflow-y: auto; padding: 14px; }
.modal-results .hint { text-align: center; color: var(--text-mute); font-size: 14px; padding: 24px 8px; }

.search-result {
  padding: 12px 14px;
  margin: 6px 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border-left: 3px solid var(--accent);
  background: var(--bg-soft);
}
.search-result:hover { background: var(--bg-card); border-color: var(--primary); }
.search-result .sr-title { font-weight: 600; color: var(--primary); margin-bottom: 4px; font-size: 14px; }
.search-result .sr-context { font-size: 13px; color: var(--text-soft); line-height: 1.5; }
.search-result mark { background: rgba(139, 111, 71, 0.25); color: var(--accent); font-weight: 600; padding: 0 2px; }

/* ========= 字級調整 ========= */
.font-content { max-width: 360px; }
.font-header { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; font-weight: 600; color: var(--primary); }
.font-header button { font-size: 24px; color: var(--text-mute); }
.font-options { padding: 16px; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.font-options button {
  padding: 12px;
  background: var(--bg-soft);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text);
  border: 2px solid transparent;
}
.font-options button:hover { background: var(--bg-card); border-color: var(--primary); }
.font-options button.active { background: var(--primary); color: white; border-color: var(--primary); }
.font-options button:nth-child(1) { font-size: 13px; }
.font-options button:nth-child(2) { font-size: 15px; }
.font-options button:nth-child(3) { font-size: 17px; }
.font-options button:nth-child(4) { font-size: 19px; }

/* ========= 響應式：平板 ========= */
@media (max-width: 1024px) {
  .content { padding: 22px 28px 80px; }
}

/* ========= 響應式：手機 ========= */
@media (max-width: 768px) {
  body { line-height: 1.7; }

  .test-banner { padding: 6px 10px; }
  .test-banner-content { font-size: 11px; gap: 6px; }
  .test-banner-icon { font-size: 14px; }
  .test-banner-close { width: 22px; height: 22px; font-size: 15px; }

  .welcome-logo { max-width: 320px; margin-bottom: 16px; }
  .cover-page .cover-logo { max-width: 320px; }
  .cover-page .cover-h1 { font-size: 26px; }
  .cover-page .cover-line { font-size: 18px; letter-spacing: 2px; }
  .cover-page .cover-line-en { font-size: 13px; }
  .cover-page .cover-date { font-size: 15px; margin-top: 24px; }

  .toc-row { padding: 12px 14px; }
  .toc-row:hover { transform: none; }
  .toc-title { font-size: 14px; }
  .toc-dots { display: none; }
  .toc-pages { font-size: 12px; }

  .top-bar { padding: 8px 10px; gap: 6px; }
  .menu-btn { display: block; }
  .brand .logo { font-size: 26px; }
  .brand h1 { font-size: 14px; }
  .brand-sub { font-size: 11px; }
  .top-actions button, .top-actions .btn-pdf { padding: 6px 9px; font-size: 14px; min-width: 32px; }

  .layout { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    width: 80vw;
    max-width: 320px;
    height: 100vh;
    z-index: 100;
    transform: translateX(-100%);
    transition: transform 0.25s ease-out;
    border-right: 1px solid var(--border);
    padding-top: 16px;
  }
  .sidebar.show { transform: translateX(0); }
  .sidebar-head { display: flex; padding: 0 4px 12px; }

  .content { padding: 16px 14px 80px; max-width: 100%; }

  /* 歡迎頁手機版 */
  .welcome-cover { padding: 16px 4px; }
  .cover-banner { padding: 8px 18px; margin-bottom: 16px; }
  .cover-en { font-size: 14px; letter-spacing: 2px; }
  .cover-zh { font-size: 17px; letter-spacing: 4px; }
  .welcome-cover h2 { font-size: 26px; margin: 8px 0; }
  .welcome-cover .subtitle { font-size: 12px; letter-spacing: 1px; }
  .meeting-date { font-size: 14px; margin-bottom: 20px; }
  .theme-card { padding: 20px 16px; margin: 20px 0; }
  .theme-zh { font-size: 22px; letter-spacing: 2px; }
  .theme-en { font-size: 13px; }
  .quick-actions { grid-template-columns: 1fr 1fr; gap: 10px; margin: 20px 0; }
  .qa-card { padding: 14px 8px; }
  .qa-icon { font-size: 26px; }
  .qa-title { font-size: 13px; }
  .qa-desc { font-size: 11px; }
  .welcome-stats { gap: 8px; margin: 24px 0; }
  .stat { padding: 10px 14px; min-width: 75px; flex: 1; }
  .stat .num { font-size: 20px; }
  .stat .lbl { font-size: 11px; }
  .welcome-hint { font-size: 12px; margin-top: 20px; }

  /* 章節頁手機版 */
  .chapter-title { font-size: 21px; }
  .chapter-title .ch-icon { font-size: 26px; }
  .chapter-meta { font-size: 11px; gap: 6px; }
  .chapter-tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .chapter-tab { padding: 9px 14px; font-size: 13px; flex-shrink: 0; }

  .content-block { font-size: var(--content-font); }
  .content-block h3.l1 { font-size: 1.1em; padding: 7px 10px; margin: 18px 0 8px; }
  .content-block h4.l2 { font-size: 1.0em; margin: 12px 0 4px; }

  .chapter-nav { flex-direction: column; gap: 8px; }

  /* AI 浮窗手機版（全屏） */
  .ai-widget { bottom: 16px; right: 16px; }
  .ai-toggle { padding: 12px 16px; font-size: 14px; }
  .ai-toggle-icon { font-size: 20px; }
  .ai-panel {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    max-width: 100%;
    height: 85vh;
    max-height: 85vh;
    border-radius: var(--radius) var(--radius) 0 0;
  }
  .ai-header { padding: 16px 18px; font-size: 15px; }
  .ai-header button { font-size: 32px; padding: 0 8px; }
  .ai-info { padding: 12px 14px; font-size: 12px; }
  .ai-messages { padding: 12px; }
  .ai-msg { font-size: 14px; max-width: 92%; }
  .ai-input-row input { font-size: 16px; }  /* iOS 防 zoom */

  /* Modal 手機版 */
  .modal-content, .font-content { width: calc(100% - 20px); margin: 32px auto 0; max-height: calc(100vh - 64px); }
  .modal-header input { font-size: 16px; }

  .back-top { bottom: 88px; right: 16px; width: 40px; height: 40px; }
}

/* ========= 列印 ========= */
@media print {
  .top-bar, .sidebar, .ai-widget, .ai-modal, .chapter-tabs, .quick-actions, .welcome-stats, .welcome-hint, .back-top, .chapter-nav, .modal, .font-modal, .test-banner { display: none !important; }
  .layout { grid-template-columns: 1fr; }
  .content { padding: 0; max-width: 100%; }
  body { background: white; }
  .content-block h3.l1 { background: none; border-left: 3px solid #000; }
  .theme-card { background: white; color: black; border: 2px solid var(--primary); }
}
