/* =========================================================
   基礎樣式：重設、排版、課文（.prose）
   ========================================================= */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--topbar-h) + 16px); }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

img, svg { max-width: 100%; }
[hidden] { display: none !important; }

a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { line-height: 1.3; margin: 0; color: var(--ink); letter-spacing: -0.01em; }
h1 { font-size: var(--fs-xl); font-weight: 800; }
h2 { font-size: var(--fs-lg); font-weight: 750; }
h3 { font-size: 1.25rem; font-weight: 700; }      /* 20px */
h4 { font-size: var(--fs-md); font-weight: 700; } /* 18px */

p { margin: 0 0 1em; }
/* 關閉程式字型連字：避免 >= 被畫成 ≥，初學者照抄會打錯 */
code, pre, kbd, .CodeMirror, .CodeMirror-hints { font-family: var(--font-mono); font-variant-ligatures: none; font-feature-settings: "liga" 0, "calt" 0; }

button { font: inherit; color: inherit; }
:focus-visible { outline: 2.5px solid var(--brand); outline-offset: 2px; border-radius: 4px; }

.icon { display: inline-flex; align-items: center; justify-content: center; line-height: 0; flex-shrink: 0; }
.icon svg { width: 1.05em; height: 1.05em; }

.muted { color: var(--muted); }
.spacer { flex: 1; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- 啟動畫面 ---------- */
.boot { min-height: 80vh; display: grid; place-content: center; justify-items: center; gap: 16px; color: var(--muted); padding: 24px; text-align: center; }
.boot .brand-mark { width: 56px; height: 56px; font-size: 1rem; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.45; } }

/* ---------- 課文 ---------- */
.prose { font-size: 1.0625rem; line-height: 1.8; color: var(--ink); } /* 17px */
.prose > * + * { margin-top: 1rem; }
.prose h2 {
  font-size: var(--fs-lg);
  margin-top: 2.6rem;
  padding-top: 1.6rem;
  border-top: 1px solid var(--line);
}
.prose > h2:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.prose h3 { font-size: 1.25rem; margin-top: 2rem; }
.prose h4 { margin-top: 1.5rem; }
.prose p { margin: 0; }
.prose ul, .prose ol { margin: 0; padding-left: 1.4em; }
.prose li + li { margin-top: 0.35em; }
.prose strong { font-weight: 700; color: var(--ink); }
.prose code {
  font-size: 0.88em;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.1em 0.4em;
  color: var(--accent);
  word-break: break-word;
}
.prose blockquote { margin: 0; padding: 0.4rem 1rem; border-left: 4px solid var(--line-2); color: var(--ink-2); }

/* 程式碼區塊（深色） */
pre.code {
  margin: 0;
  background: var(--code-bg);
  color: var(--code-ink);
  font-size: 0.875rem;  /* 14px */
  line-height: 1.7;
  padding: 16px 18px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  white-space: pre;
  tab-size: 2;
}
.prose pre.code code { all: unset; }

/* Markdown 表格 */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); }
.md-table { width: 100%; border-collapse: collapse; font-size: 0.9375rem; line-height: 1.6; } /* 15px */
.md-table th, .md-table td { padding: 10px 14px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
.md-table th { background: var(--surface-2); font-size: var(--fs-sm); font-weight: 700; color: var(--ink-2); white-space: nowrap; }
.md-table tr:last-child td { border-bottom: 0; }
.md-table code { font-size: 0.85em; }

/* 提示框 */
.callout {
  border: 1px solid var(--line);
  border-left: 4px solid var(--c, var(--brand));
  background: var(--cbg, var(--surface));
  border-radius: var(--radius-sm);
  padding: 14px 18px;
}
.callout-label { font-size: var(--fs-xs); font-weight: 800; letter-spacing: 0.06em; color: var(--c, var(--brand)); text-transform: uppercase; }
.callout-title { font-weight: 700; margin-top: 2px; }
.callout-body { margin-top: 6px; font-size: 1rem; }
.callout-body > * + * { margin-top: 0.6rem; }
.callout-tip { --c: var(--ok); --cbg: var(--ok-soft); }
.callout-warn { --c: var(--err); --cbg: var(--err-soft); }
.callout-biz { --c: var(--accent); --cbg: var(--accent-soft); }
.callout-dialect { --c: var(--info); --cbg: var(--info-soft); }
.callout-note { --c: var(--brand); --cbg: var(--brand-soft); }
.callout .table-wrap { background: var(--surface); }
