/* 精通比特幣繁體中文版：線上閱讀樣式 */

/* ---------- 色彩與字體 ---------- */

:root {
  --fs: 18px;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang TC", "Noto Sans TC", "Noto Sans CJK TC",
    "Microsoft JhengHei", "Heiti TC", system-ui, sans-serif;
  --serif: "Iowan Old Style", Georgia, "Songti TC", "Noto Serif TC", "Noto Serif CJK TC", "Source Han Serif TC",
    "PMingLiU", serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --body-font: var(--sans);

  --bg: #fbfaf7;
  --bg-soft: #f3f1eb;
  --bg-raised: #ffffff;
  --text: #24221e;
  --text-2: #5c584f;
  --text-3: #6f6a60;
  --border: #e4e0d6;
  --link: #a8510a;
  --link-hover: #7d3a04;
  --accent: #f7931a;
  --accent-soft: #fdf0dc;
  --code-bg: #f4f2ec;
  --mark: #ffe5a3;
  --tip: #276b4d;
  --note: #2f63a8;
  --warn: #a24a15;
  --shadow: 0 10px 30px rgba(40, 30, 10, 0.12), 0 2px 6px rgba(40, 30, 10, 0.06);

  --topbar-h: 56px;
  --sidebar-w: 288px;
  --rail-w: 232px;
  --measure: 42em;
  color-scheme: light;
}

:root[data-theme="sepia"] {
  --bg: #f4ecd8;
  --bg-soft: #ebe1c9;
  --bg-raised: #f9f3e3;
  --text: #3b2f1e;
  --text-2: #645640;
  --text-3: #6e6250;
  --border: #dccfb2;
  --link: #9a4a0b;
  --link-hover: #6f3204;
  --accent-soft: #f1dcb5;
  --code-bg: #ece2c9;
  --mark: #f6d58a;
}

:root[data-theme="dark"] {
  --bg: #16161a;
  --bg-soft: #1d1d22;
  --bg-raised: #222228;
  --text: #dedbd4;
  --text-2: #a7a297;
  --text-3: #9a958b;
  --border: #303037;
  --link: #f2a654;
  --link-hover: #ffc785;
  --accent-soft: #3a2a17;
  --code-bg: #1f1f25;
  --mark: #6b4c12;
  --tip: #5fbf93;
  --note: #78a6e8;
  --warn: #ec9157;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.5), 0 2px 6px rgba(0, 0, 0, 0.3);
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg: #16161a;
    --bg-soft: #1d1d22;
    --bg-raised: #222228;
    --text: #dedbd4;
    --text-2: #a7a297;
    --text-3: #9a958b;
    --border: #303037;
    --link: #f2a654;
    --link-hover: #ffc785;
    --accent-soft: #3a2a17;
    --code-bg: #1f1f25;
    --mark: #6b4c12;
    --tip: #5fbf93;
    --note: #78a6e8;
    --warn: #ec9157;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.5), 0 2px 6px rgba(0, 0, 0, 0.3);
    color-scheme: dark;
  }
}

:root[data-font="serif"] { --body-font: var(--serif); }

/* ---------- 基礎 ---------- */

*, *::before, *::after { box-sizing: border-box; }

html {
  font-size: var(--fs);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: calc(var(--topbar-h) + 16px);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.85;
  font-kerning: normal;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  overflow-wrap: break-word;
}

a { color: var(--link); text-decoration-color: color-mix(in srgb, var(--link) 35%, transparent); text-underline-offset: 0.2em; }
a:hover { color: var(--link-hover); text-decoration-color: currentColor; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
img { max-width: 100%; height: auto; }
button { font: inherit; color: inherit; }
kbd {
  font-family: var(--mono);
  font-size: 0.75em;
  padding: 0.1em 0.4em;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--bg-raised);
}

.skip-link {
  position: absolute;
  left: 12px;
  top: -48px;
  z-index: 100;
  padding: 8px 14px;
  background: var(--text);
  color: var(--bg);
  border-radius: 6px;
}
.skip-link:focus { top: 12px; }

/* ---------- 頂部列 ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 8px;
  height: var(--topbar-h);
  padding: 0 12px;
  padding-left: max(12px, env(safe-area-inset-left));
  padding-right: max(12px, env(safe-area-inset-right));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--border);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 40px;
  height: 40px;
  padding: 0 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
}
.icon-btn:hover { background: var(--bg-soft); color: var(--text); }
.icon-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn[aria-expanded="true"] { background: var(--bg-soft); color: var(--text); }

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  text-decoration: none;
  font-weight: 650;
  white-space: nowrap;
}
.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: var(--accent);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  transform: rotate(-8deg);
}

.topbar-title {
  flex: 1;
  min-width: 0;
  margin: 0 0 0 12px;
  padding-left: 14px;
  border-left: 1px solid var(--border);
  color: var(--text-2);
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0;
  transition: opacity 0.2s;
}
.topbar-title.is-visible { opacity: 1; }
.topbar-label { color: var(--text-3); margin-right: 0.6em; }
.is-home .topbar-actions, .is-404 .topbar-actions { margin-left: auto; }
.topbar-actions { display: flex; align-items: center; gap: 4px; }

.search-btn {
  border: 1px solid var(--border);
  background: var(--bg-raised);
  padding: 0 8px 0 10px;
  font-size: 0.8rem;
}
.search-btn svg { width: 18px; height: 18px; }
.search-btn kbd { margin-left: 10px; color: var(--text-3); }

.progress { position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; pointer-events: none; }
.progress span { display: block; height: 100%; width: 100%; background: var(--accent); transform-origin: 0 50%; transform: scaleX(0); }

/* ---------- 閱讀設定 ---------- */

.settings {
  position: fixed;
  z-index: 60;
  top: calc(var(--topbar-h) + 8px);
  right: 12px;
  width: 300px;
  max-width: calc(100vw - 24px);
  padding: 16px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  font-size: 15px;
}
.settings[hidden] { display: none; }
.settings-group + .settings-group { margin-top: 14px; }
.settings-label { display: block; margin-bottom: 6px; color: var(--text-3); font-size: 13px; }
.seg { display: flex; align-items: center; padding: 3px; gap: 3px; background: var(--bg-soft); border-radius: 10px; }
.seg button {
  flex: 1;
  height: 34px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
}
.seg button:hover { color: var(--text); }
.seg button[aria-pressed="true"] { background: var(--bg-raised); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12); font-weight: 600; }
.size-value { flex: 1; text-align: center; font-variant-numeric: tabular-nums; color: var(--text); }
[data-font-set="serif"] { font-family: var(--serif); }

/* ---------- 版面 ---------- */

.shell { display: flex; align-items: flex-start; min-height: calc(100vh - var(--topbar-h)); }

.sidebar {
  position: sticky;
  top: var(--topbar-h);
  flex: 0 0 var(--sidebar-w);
  width: var(--sidebar-w);
  height: calc(100vh - var(--topbar-h));
  height: calc(100dvh - var(--topbar-h));
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 20px 12px 24px 16px;
  border-right: 1px solid var(--border);
  font-size: 15px;
  line-height: 1.5;
  scrollbar-width: thin;
}
.sidebar-head { padding: 0 8px 14px; margin-bottom: 8px; border-bottom: 1px solid var(--border); }
.sidebar-book { display: block; color: var(--text); font-weight: 650; text-decoration: none; }
.sidebar-sub { color: var(--text-3); font-size: 13px; }

.book-toc, .section-toc { list-style: none; margin: 0; padding: 0; }
.book-toc > li > a {
  display: block;
  padding: 7px 10px;
  border-radius: 8px;
  color: var(--text-2);
  text-decoration: none;
}
.book-toc > li > a:hover { background: var(--bg-soft); color: var(--text); }
.toc-label { display: inline-block; min-width: 4.3em; color: var(--text-3); font-size: 0.87em; font-variant-numeric: tabular-nums; }
.book-toc > li.is-current > a { background: var(--accent-soft); color: var(--text); font-weight: 600; }
.book-toc > li.is-current .toc-label { color: var(--link); }
.section-toc { margin: 4px 0 8px 18px; padding-left: 12px; border-left: 1px solid var(--border); font-size: 14px; }
.section-toc a { display: block; padding: 4px 8px; color: var(--text-2); text-decoration: none; border-radius: 6px; }
.section-toc a:hover { color: var(--text); background: var(--bg-soft); }
.section-toc a.is-active, .rail a.is-active { color: var(--link); font-weight: 600; }
.sidebar-foot { display: grid; gap: 4px; margin-top: 16px; padding: 14px 10px 0; border-top: 1px solid var(--border); font-size: 14px; }
.sidebar-foot a { color: var(--text-2); }

.main { flex: 1 1 auto; min-width: 0; padding: 40px clamp(20px, 5vw, 64px) 64px; outline: none; }

.rail {
  position: sticky;
  top: var(--topbar-h);
  flex: 0 0 var(--rail-w);
  max-height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  padding: 40px 20px 24px 0;
  font-size: 13.5px;
  line-height: 1.5;
  scrollbar-width: thin;
}
.rail-title { margin: 0 0 10px; color: var(--text-3); font-size: 12px; letter-spacing: 0.08em; }
.rail ol { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--border); }
.rail a { display: block; margin-left: -1px; padding: 5px 0 5px 14px; border-left: 2px solid transparent; color: var(--text-2); text-decoration: none; }
.rail a:hover { color: var(--text); }
.rail a.is-active { border-left-color: var(--accent); }

.scrim { display: none; }

/* 寬螢幕：右側小節目錄出現時，左側不再重複列出本章小節 */
@media (min-width: 1280px) {
  .is-chapter .section-toc { display: none; }
}
@media (max-width: 1279px) {
  .rail { display: none; }
}

/* 收合側欄（桌面）／抽屜側欄（手機） */
@media (min-width: 1024px) {
  [data-action="toggle-nav"] { display: none; }
  .nav-collapsed .sidebar { display: none; }
}
@media (max-width: 1023px) {
  .sidebar {
    position: fixed;
    z-index: 50;
    top: 0;
    left: 0;
    height: 100vh;
    height: 100dvh;
    width: min(320px, 86vw);
    background: var(--bg);
    border-right: 1px solid var(--border);
    box-shadow: var(--shadow);
    transform: translateX(-105%);
    transition: transform 0.25s ease;
    visibility: hidden;
    padding-top: max(20px, env(safe-area-inset-top));
  }
  .nav-open .sidebar { transform: none; visibility: visible; }
  .nav-open .scrim { display: block; position: fixed; inset: 0; z-index: 45; background: rgba(0, 0, 0, 0.35); }
  .nav-open { overflow: hidden; }
  .topbar-title { margin-left: 4px; padding-left: 10px; }
}
@media (max-width: 640px) {
  .brand-text { display: none; }
  .search-btn { border: 0; background: transparent; padding: 0 8px; }
  .search-btn-text, .search-btn kbd { display: none; }
  .main { padding: 24px 18px 48px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}

/* ---------- 章節內容 ---------- */

.chapter, .not-found { max-width: var(--measure); margin: 0 auto; }

.breadcrumb { display: flex; gap: 8px; margin-bottom: 28px; color: var(--text-3); font-size: 14px; }
.breadcrumb a { color: var(--text-3); text-decoration: none; }
.breadcrumb a:hover { color: var(--link); }

.chapter-head { margin-bottom: 2.4em; padding-bottom: 1.6em; border-bottom: 1px solid var(--border); }
.chapter-label { margin: 0 0 0.3em; color: var(--link); font-size: 0.9rem; font-weight: 600; letter-spacing: 0.12em; }
.chapter-head h1, .not-found h1 { margin: 0; font-size: clamp(1.9rem, 4.5vw, 2.6rem); line-height: 1.3; letter-spacing: 0.02em; font-weight: 700; }
.chapter-head h1 .keep-together { display: block; margin-top: 0.3em; color: var(--text-2); font-size: 0.5em; font-weight: 500; }
.chapter-meta { margin: 0.8em 0 0; color: var(--text-3); font-size: 0.85rem; }

.prose { font-family: var(--body-font); }
.prose p { margin: 0 0 1.15em; text-align: start; }
.prose h2, .prose h3, .prose h4, .prose h5 {
  position: relative;
  font-family: var(--sans);
  line-height: 1.4;
  letter-spacing: 0.01em;
  scroll-margin-top: calc(var(--topbar-h) + 16px);
}
.prose h2 { margin: 2.6em 0 0.9em; padding-top: 0.2em; font-size: 1.5rem; font-weight: 700; }
.prose h3 { margin: 2.1em 0 0.8em; font-size: 1.22rem; font-weight: 650; }
.prose h4 { margin: 1.8em 0 0.7em; font-size: 1.06rem; font-weight: 650; }
.prose h5 { margin: 1.6em 0 0.6em; font-size: 1rem; font-weight: 650; color: var(--text-2); }
.prose .anchor {
  position: absolute;
  left: -1.1em;
  width: 1em;
  color: var(--text-3);
  text-decoration: none;
  opacity: 0;
  transition: opacity 0.15s;
}
.prose .anchor::before { content: "#"; }
.prose :is(h2, h3, h4, h5):hover .anchor, .prose .anchor:focus-visible { opacity: 1; }
:target { animation: target-flash 1.6s ease-out; }
@keyframes target-flash { from { background: var(--accent-soft); } to { background: transparent; } }

.prose ul, .prose ol { margin: 0 0 1.2em; padding-left: 1.6em; }
.prose li { margin: 0.35em 0; }
.prose li > p { margin: 0; }
.prose li::marker { color: var(--text-3); }
.prose dl { margin: 0 0 1.3em; }
.prose dt { margin-top: 0.9em; font-weight: 650; }
.prose dd { margin: 0.25em 0 0 1.4em; }
.prose dd > p { margin-bottom: 0.4em; }
/* 中文字型沒有斜體，避免瀏覽器硬拗出變形的假斜體；英文仍維持斜體 */
.prose em { font-style: italic; font-synthesis: none; }
.prose strong { font-weight: 700; }
.prose sup, .prose sub { line-height: 0; }
.prose hr { border: 0; border-top: 1px solid var(--border); margin: 2.4em 0; }

/* 程式碼 */
.prose code, .prose pre { font-family: var(--mono); }
.prose :not(pre) > code {
  padding: 0.12em 0.4em;
  border-radius: 5px;
  background: var(--code-bg);
  font-size: 0.86em;
  overflow-wrap: anywhere;
}
.listingblock, .literalblock { position: relative; margin: 0 0 1.4em; }
.listingblock > .title, .literalblock > .title { margin-bottom: 6px; color: var(--text-2); font-size: 0.85rem; font-weight: 600; }
.prose pre {
  margin: 0;
  padding: 14px 18px;
  overflow-x: auto;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 0.8rem;
  line-height: 1.65;
  tab-size: 4;
  white-space: pre;
  overflow-wrap: normal;
}
.prose pre code { background: none; padding: 0; font-size: inherit; }
.prose pre.highlight { background: var(--code-bg); }
.copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 3px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-raised);
  color: var(--text-2);
  font-size: 12px;
  line-height: 1.6;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
}
.listingblock:hover .copy-btn, .copy-btn:focus-visible { opacity: 1; }
@media (hover: none) { .copy-btn { opacity: 0.85; } }

/* 圖片 */
.imageblock { margin: 2em 0; text-align: center; }
.imageblock .content { display: inline-block; max-width: 100%; }
.imageblock img {
  display: block;
  margin: 0 auto;
  border-radius: 6px;
  background: #fff;
  cursor: zoom-in;
}
:root[data-theme="dark"] .imageblock img { filter: brightness(0.9); }
@media (prefers-color-scheme: dark) { :root:not([data-theme]) .imageblock img { filter: brightness(0.9); } }
.imageblock.width-50 img { max-width: 50%; }
.imageblock.width-60 img { max-width: 60%; }
.imageblock.width-70 img { max-width: 70%; }
.imageblock.width-90 img { max-width: 90%; }
@media (max-width: 640px) { .imageblock[class*="width-"] img { max-width: 100%; } }
.imageblock > .title, .exampleblock > .title, .prose caption {
  margin-top: 0.7em;
  color: var(--text-2);
  font-family: var(--sans);
  font-size: 0.85rem;
  line-height: 1.6;
  text-align: center;
}

/* 表格 */
.table-wrap { margin: 1.6em 0; overflow-x: auto; border: 1px solid var(--border); border-radius: 10px; }
.table-wrap > table { width: 100%; border-collapse: collapse; font-size: 0.88rem; line-height: 1.6; }
.prose caption { caption-side: top; margin: 0; padding: 10px 14px; text-align: left; font-weight: 600; border-bottom: 1px solid var(--border); }
.table-wrap th, .table-wrap td { padding: 9px 14px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.table-wrap th { background: var(--bg-soft); font-weight: 650; white-space: nowrap; }
.table-wrap tbody tr:last-child td { border-bottom: 0; }
.table-wrap td > p, .table-wrap td .paragraph p { margin: 0; }
.table-wrap td code { white-space: nowrap; }

/* 提示、注意、警告 */
.admonitionblock { margin: 1.6em 0; }
.admonitionblock > table { width: 100%; border-collapse: separate; border-spacing: 0; }
.admonitionblock > table, .admonitionblock > table > tbody, .admonitionblock > table > tbody > tr,
.admonitionblock td { display: block; }
.admonitionblock > table {
  padding: 14px 18px;
  border-radius: 10px;
  border-left: 4px solid var(--adm, var(--note));
  background: color-mix(in srgb, var(--adm, var(--note)) 8%, var(--bg));
}
.admonitionblock.tip { --adm: var(--tip); }
.admonitionblock.note { --adm: var(--note); }
.admonitionblock.warning, .admonitionblock.caution, .admonitionblock.important { --adm: var(--warn); }
.admonitionblock td.icon .title { margin-bottom: 4px; color: var(--adm); font-family: var(--sans); font-size: 0.85rem; font-weight: 700; letter-spacing: 0.1em; }
.admonitionblock td.content { font-size: 0.95rem; }
.admonitionblock td.content > :last-child, .admonitionblock td.content > :last-child > :last-child { margin-bottom: 0; }

/* 側欄方塊與範例 */
.sidebarblock { margin: 2em 0; padding: 20px 22px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg-soft); }
.sidebarblock > .content > .title { margin: 0 0 0.6em; font-family: var(--sans); font-size: 1.05rem; font-weight: 700; }
.sidebarblock > .content > :last-child { margin-bottom: 0; }
.sidebarblock .paragraph p { font-size: 0.95rem; }
.exampleblock { margin: 1.8em 0; }
.exampleblock > .title { margin: 0 0 0.6em; text-align: left; font-weight: 600; }
.exampleblock > .content > :last-child { margin-bottom: 0; }

.quoteblock { margin: 1.6em 0; padding: 4px 0 4px 20px; border-left: 3px solid var(--border); color: var(--text-2); }
.quoteblock blockquote { margin: 0; }
.quoteblock .attribution { margin-top: 0.4em; color: var(--text-3); font-size: 0.9rem; }
.quoteblock a.bare { overflow-wrap: anywhere; }

.stemblock { margin: 1.6em 0; text-align: center; }
.stemblock .katex-display { margin: 0; padding: 0.3em 0; overflow-x: auto; overflow-y: hidden; }
.katex { font-size: 1.08em; }
.math-wrap { margin: 1.4em 0; overflow-x: auto; overflow-y: hidden; }

/* 註腳 */
.prose sup.footnote a, .prose sup.footnoteref a { text-decoration: none; font-weight: 600; padding: 0 1px; }
.footnotes { margin-top: 3.4em; padding-top: 1.2em; border-top: 1px solid var(--border); color: var(--text-2); font-size: 0.85rem; line-height: 1.7; }
.footnotes h2 { margin: 0 0 0.8em; font-family: var(--sans); font-size: 0.95rem; letter-spacing: 0.1em; color: var(--text-3); }
.footnotes ol { padding-left: 1.8em; }
.footnotes li { margin: 0.5em 0; }
.footnotes a { overflow-wrap: anywhere; }
.fn-back { margin-left: 4px; text-decoration: none; }

/* 上一章／下一章 */
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 4em; }
.pager-link {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  text-decoration: none;
  transition: border-color 0.15s, background 0.15s;
}
.pager-link:hover { border-color: var(--accent); background: var(--bg-soft); color: var(--text); }
.pager-link.next { text-align: right; }
.pager-dir { color: var(--text-3); font-size: 0.8rem; }
.pager-title { font-weight: 600; line-height: 1.45; }
@media (max-width: 560px) { .pager { grid-template-columns: 1fr; } }
.edit-link { margin-top: 2em; text-align: center; font-size: 0.8rem; }
.edit-link a { color: var(--text-3); }

/* ---------- 首頁 ---------- */

.home { max-width: 1040px; margin: 0 auto; }
.hero { display: grid; grid-template-columns: minmax(180px, 300px) 1fr; gap: clamp(28px, 5vw, 64px); align-items: center; padding: 16px 0 56px; }
.hero-cover { width: 100%; height: auto; border-radius: 6px; box-shadow: var(--shadow); background: #fff; }
.hero-kicker { margin: 0 0 12px; color: var(--link); font-size: 0.8rem; font-weight: 600; letter-spacing: 0.12em; }
.hero h1 { margin: 0; font-size: clamp(2.4rem, 6vw, 3.6rem); line-height: 1.15; letter-spacing: 0.04em; }
.hero-sub { display: block; margin-top: 0.35em; color: var(--text-2); font-size: 0.45em; font-weight: 500; letter-spacing: 0.08em; }
.hero-authors { margin: 1.2em 0 0; color: var(--text-2); font-size: 0.95rem; line-height: 1.7; }
.hero-lead { margin: 1.2em 0 0; font-size: 1.02rem; line-height: 1.9; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 1.6em; }
.hero-facts { margin: 1.2em 0 0; color: var(--text-3); font-size: 0.85rem; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 20px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-raised);
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 600;
  text-decoration: none;
}
.btn:hover { border-color: var(--text-3); color: var(--text); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #1c1307; }
.btn-primary:hover { background: #ffa53d; border-color: #ffa53d; color: #1c1307; }
.btn-resume { border-color: var(--accent); }
.btn[hidden] { display: none; }

.home h2 { margin: 0 0 20px; font-size: 1.4rem; }
.home-toc { padding-top: 40px; border-top: 1px solid var(--border); }
.toc-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; margin: 0; padding: 0; list-style: none; }
.toc-cards a {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 18px 20px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-raised);
  color: var(--text);
  text-decoration: none;
  transition: border-color 0.15s, transform 0.15s;
}
.toc-cards a:hover { border-color: var(--accent); transform: translateY(-2px); }
.card-label { color: var(--link); font-size: 0.78rem; font-weight: 600; letter-spacing: 0.1em; }
.card-title { margin-top: 2px; font-size: 1.1rem; font-weight: 700; line-height: 1.45; }
.card-desc { flex: 1; margin-top: 8px; color: var(--text-2); font-size: 0.85rem; line-height: 1.7; }
.card-meta { margin-top: 10px; color: var(--text-3); font-size: 0.78rem; }
.home-about { margin-top: 56px; padding-top: 40px; border-top: 1px solid var(--border); max-width: var(--measure); }
.home-about p { color: var(--text-2); }

@media (max-width: 720px) {
  .hero { grid-template-columns: 1fr; text-align: center; padding-bottom: 40px; }
  .hero-cover { width: 180px; margin: 0 auto; }
  .hero-lead { text-align: left; }
  .hero-actions { justify-content: center; }
  .toc-cards { grid-template-columns: 1fr; }
}

/* 404 */
.plain-toc { list-style: none; padding: 0; margin: 1.6em 0; columns: 2 16em; }
.plain-toc a { display: block; padding: 4px 0; }

/* ---------- 頁尾 ---------- */

.site-footer {
  padding: 28px 24px 40px;
  border-top: 1px solid var(--border);
  color: var(--text-3);
  font-size: 13px;
  line-height: 1.8;
  text-align: center;
}
.site-footer p { margin: 0.2em auto; max-width: 60em; }
.site-footer a { color: var(--text-2); }

/* ---------- 搜尋 ---------- */

.search {
  width: min(680px, calc(100vw - 24px));
  max-height: min(78vh, 760px);
  margin: 9vh auto auto;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--bg-raised);
  color: var(--text);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.search[open] { display: flex; flex-direction: column; }
.search::backdrop { background: rgba(10, 8, 4, 0.45); }
.search-form { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.search-form svg { flex: none; width: 20px; height: 20px; fill: none; stroke: var(--text-3); stroke-width: 2; stroke-linecap: round; }
.search-form input { flex: 1; min-width: 0; height: 40px; border: 0; outline: 0; background: transparent; color: var(--text); font: inherit; font-size: 17px; }
.search-form input::-webkit-search-cancel-button { display: none; }
.search-close { padding: 2px 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg-soft); color: var(--text-3); font-size: 12px; cursor: pointer; }
.search-status { margin: 0; padding: 10px 18px 0; color: var(--text-3); font-size: 13px; }
.search-status:empty { display: none; }
.search-results { list-style: none; margin: 0; padding: 8px; overflow-y: auto; }
.search-results a { display: block; padding: 10px 12px; border-radius: 10px; color: var(--text); text-decoration: none; }
.search-results a:hover, .search-results a.is-selected { background: var(--accent-soft); }
.sr-chapter { display: block; color: var(--text-3); font-size: 12px; }
.sr-title { display: block; font-weight: 650; line-height: 1.5; }
.sr-snippet { display: block; margin-top: 2px; color: var(--text-2); font-size: 14px; line-height: 1.6; }
.search mark { background: var(--mark); color: inherit; border-radius: 2px; padding: 0 1px; }
@media (max-width: 640px) {
  .search { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; border: 0; border-radius: 0; }
}

/* 圖片放大檢視 */
.lightbox { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; padding: 0; border: 0; background: rgba(10, 8, 4, 0.88); cursor: zoom-out; }
.lightbox[open] { display: grid; place-items: center; }
.lightbox::backdrop { background: transparent; }
.lightbox img { max-width: 96vw; max-height: 92dvh; width: auto; height: auto; background: #fff; border-radius: 6px; }

/* ---------- 列印 ---------- */

@media print {
  :root { --fs: 11pt; --bg: #fff; --text: #000; --link: #000; }
  .topbar, .sidebar, .rail, .pager, .edit-link, .breadcrumb, .site-footer, .copy-btn, .scrim, .settings { display: none !important; }
  .shell { display: block; }
  .main { padding: 0; }
  .prose pre { white-space: pre-wrap; border-color: #ccc; }
  .prose a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 0.8em; color: #555; }
  .imageblock, .listingblock, .admonitionblock, .table-wrap { break-inside: avoid; }
}
