/* ===== 心外專科參考書 — 全域樣式 ===== */
:root {
  --ink: #1a1a1a;
  --paper: #fafaf7;
  --accent: #9a3412;        /* 棕紅 — 章節標題 */
  --accent-soft: #fff8f3;
  --rule: #d4d4d4;
  --keynote-bg: #fffbea;
  --keynote-border: #facc15;
  --keynote-fg: #854d0e;
  --trap-bg: #fef2f2;
  --trap-border: #fca5a5;
  --trap-fg: #991b1b;
  --clinical-bg: #f0f9ff;
  --clinical-border: #7dd3fc;
  --clinical-fg: #075985;
  --note-bg: #f5f3ff;
  --note-border: #c4b5fd;
  --note-fg: #5b21b6;
}

body {
  font-family: "Noto Serif TC", "PingFang TC", "Helvetica Neue", serif;
  color: var(--ink);
  background: var(--paper);
  margin: 0;
}

/* ===== 排版（中文 prose）===== */
.prose-zh { line-height: 1.85; letter-spacing: 0.02em; }
.prose-zh p { text-indent: 2em; margin-bottom: 1em; }
.prose-zh p.no-indent { text-indent: 0; }
.prose-zh ul, .prose-zh ol { line-height: 1.8; }

.book-title { font-family: "Times New Roman", serif; }
.section-num { font-family: "Times New Roman", serif; font-weight: 700; color: var(--accent); }

/* ===== 標題層級（spec: 所有 §1-§N 統一用 h2.section）===== */
h1.page-title { font-size: 2.25rem; font-weight: 700; line-height: 1.2; }
h2.section {
  color: var(--accent);
  border-left: 4px solid var(--accent);
  padding-left: 0.6em;
  margin-top: 2em;
  font-size: 1.4rem;
  font-weight: 700;
}
h2.section .section-num { margin-right: 0.5em; }
h3.subsection {
  font-size: 1.15rem;
  font-weight: 700;
  margin-top: 1.5em;
  color: var(--ink);
}

/* ===== Pull quote（章節導讀心法）===== */
.pull-quote {
  border-left: 4px solid var(--accent);
  padding: 0.6em 1.2em;
  background: var(--accent-soft);
  font-style: italic;
  margin: 1em 0;
  border-radius: 0 4px 4px 0;
}

/* ===== Callout boxes ===== */
.keynote, .trap, .clinical, .nuance {
  border-radius: 6px;
  padding: 1em 1.2em;
  margin: 1.5em 0;
  border: 1px solid;
}
.keynote  { background: var(--keynote-bg);   border-color: var(--keynote-border); }
.keynote  h4 { font-weight: 700; color: var(--keynote-fg);  margin: 0 0 0.5em; }
.trap     { background: var(--trap-bg);      border-color: var(--trap-border); }
.trap     h4 { font-weight: 700; color: var(--trap-fg);     margin: 0 0 0.5em; }
.clinical { background: var(--clinical-bg);  border-color: var(--clinical-border); }
.clinical h4 { font-weight: 700; color: var(--clinical-fg); margin: 0 0 0.5em; }
.nuance   { background: var(--note-bg);      border-color: var(--note-border); }
.nuance   h4 { font-weight: 700; color: var(--note-fg);     margin: 0 0 0.5em; }

/* ===== 題目卡 ===== */
.qcard {
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 1.2em 1.4em;
  margin: 1.2em 0;
  background: #fff;
}
.qcard-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85em;
  color: #666;
  margin-bottom: 0.8em;
  padding-bottom: 0.6em;
  border-bottom: 1px dashed var(--rule);
  flex-wrap: wrap;
  gap: 0.5em;
}
.qcard-head .badge {
  background: var(--accent);
  color: #fff;
  padding: 0.15em 0.7em;
  border-radius: 99px;
  font-size: 0.8em;
}
.opts { list-style: none; padding-left: 0; margin-top: 0.5em; }
.opts li { padding: 0.3em 0; }
.ans-block { margin-top: 1em; padding: 0.8em 1em; background: #f5f5f4; border-radius: 6px; }
.ans-block.hidden-content { display: none; }

/* ===== 表格 ===== */
table { border-collapse: collapse; width: 100%; margin: 1em 0; font-size: 0.92em; }
th, td { border: 1px solid var(--rule); padding: 0.5em 0.75em; text-align: left; }
th { background: #f5f5f4; font-weight: 700; }

/* ===== ASCII 圖 ===== */
.ascii-figure {
  font-family: "Menlo", "Consolas", monospace;
  white-space: pre;
  background: #f5f5f4;
  padding: 1em;
  border-radius: 6px;
  font-size: 0.85em;
  line-height: 1.4;
  overflow-x: auto;
}

/* ===== 全站 chrome (header/footer 由 app.js 注入) ===== */
.site-header {
  border-bottom: 1px solid var(--rule);
  background: #fff;
  padding: 0.7em 1em;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.9em;
  position: sticky;
  top: 0;
  z-index: 50;
}
.site-header a { color: var(--accent); text-decoration: none; }
.site-header a:hover { text-decoration: underline; }
.site-header .breadcrumb { color: #666; }
.site-header .toolbar { display: flex; gap: 0.5em; }
.site-header button {
  border: 1px solid var(--rule);
  background: #fff;
  padding: 0.3em 0.8em;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9em;
}
.site-header button:hover { background: #f5f5f4; }
.site-header button.primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.site-header button.primary:hover { background: #333; }

.site-footer {
  margin-top: 4em;
  padding: 1.5em 1em;
  border-top: 1px solid var(--rule);
  font-size: 0.85em;
  color: #666;
  text-align: center;
}

/* ===== 頁首 metadata 條 ===== */
.page-meta {
  font-size: 0.85em;
  color: #666;
  margin-top: 0.4em;
}
.page-meta code { background: #f5f5f4; padding: 0.1em 0.4em; border-radius: 3px; }
.priority-stars { color: var(--accent); font-weight: 700; }

/* ===== Dashboard ===== */
.dashboard {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5em 1em;
}
.topic-section { margin-bottom: 2.5em; }
.topic-header {
  display: flex;
  align-items: baseline;
  gap: 1em;
  margin-bottom: 0.8em;
  border-bottom: 2px solid var(--ink);
  padding-bottom: 0.3em;
}
.topic-header h2 { margin: 0; font-size: 1.3rem; }
.topic-header .progress { font-size: 0.85em; color: #666; }
.concept-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0.6em;
}
.concept-card {
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 0.7em 0.9em;
  background: #fff;
  text-decoration: none;
  color: inherit;
  display: block;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.concept-card:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 6px rgba(0,0,0,0.06);
}
.concept-card .top-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.3em;
}
.concept-card .display {
  font-size: 0.95em;
  font-weight: 600;
  line-height: 1.3;
}
.concept-card .meta {
  font-size: 0.75em;
  color: #888;
  margin-top: 0.3em;
}
.concept-card .freq-pill {
  display: inline-block;
  background: #f5f5f4;
  padding: 0.1em 0.5em;
  border-radius: 99px;
  font-size: 0.75em;
  color: #555;
}
.concept-card.todo  { opacity: 0.55; }
.concept-card.todo  .display::before { content: "□ "; color: #aaa; }
.concept-card.done  .display::before { content: "✓ "; color: #16a34a; }
.concept-card.draft .display::before { content: "⚠ "; color: #ea580c; }

.dashboard-toolbar {
  display: flex;
  gap: 0.7em;
  margin-bottom: 1.5em;
  align-items: center;
  flex-wrap: wrap;
}
.dashboard-toolbar input[type="search"] {
  flex: 1;
  min-width: 240px;
  padding: 0.5em 0.8em;
  border: 1px solid var(--rule);
  border-radius: 4px;
  font-size: 0.95em;
}
.dashboard-toolbar select, .dashboard-toolbar button {
  padding: 0.5em 0.8em;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
  font-size: 0.9em;
}

.summary-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.8em;
  margin-bottom: 1.5em;
}
.stat-card {
  background: #fff;
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 0.8em 1em;
  text-align: center;
}
.stat-card .num { font-size: 1.5em; font-weight: 700; color: var(--accent); }
.stat-card .lbl { font-size: 0.8em; color: #666; }

/* ===== Print CSS ===== */
@media print {
  body { background: #fff; font-size: 11pt; }
  .no-print, .site-header, .site-footer, .dashboard-toolbar { display: none !important; }
  .ans-block { display: block !important; background: transparent; border: 1px dashed #ccc; }
  .qcard { break-inside: avoid; }
  h2.section { break-after: avoid; }
  .keynote, .trap, .clinical, .nuance { break-inside: avoid; }
  a[href]::after { content: ""; }  /* don't print URLs */
}
