/* 重點節錄（閱讀頁 /read/<slug>）的樣式。
   來源：private/notes/<slug>.html 原稿的 <style>（book-highlight-notes 產生的版面），照原樣搬過來，只改三件事：
   1. 每條規則都收進 .notes 底下：節錄是插進網站頁面裡的，不能讓 body、h1、table、.card、.tag、.wrap 這些
      通用選擇器影響網站本身的頂列與其他元件（網站也有 .card、.tag、.wrap）。
   2. 夜間模式：原稿用 @media (prefers-color-scheme: dark)，這裡改成跟網站的 ☀ 切換（:root[data-theme="dark"]），
      兩邊才不會一個亮一個暗。
   3. 置頂的章節列（nav.top）要停在網站頂列下面（top: var(--topbar-h)），不然會被蓋住。
   CSP：style-src 有 'unsafe-inline'，所以原稿表格欄寬的 style="width:NN%" 可以保留，不用改成 class。 */

.notes {
  --bg: #f7f6f2; --card: #fff; --ink: #1f2328; --mute: #6b6f76; --line: #e4e2dc;
  --blue: #2f6fde; --blue-bg: #eaf1fd; --purple: #7c4ddb; --purple-bg: #f1ebfc; --green: #1f8a5b; --green-bg: #e7f5ee;
  --orange: #c76a12; --orange-bg: #fdf1e4; --red: #c0392b; --red-bg: #fbeaea; --gold: #b8860b; --gray-bg: #f1f0ec; --accent: #2f6fde;
  background: var(--bg); color: var(--ink);
  font-family: "Noto Sans TC", system-ui, sans-serif; line-height: 1.75; font-size: 16px;
}
:root[data-theme="dark"] .notes {
  --bg: #16181c; --card: #1f2228; --ink: #e8e6e1; --mute: #9aa0a6; --line: #33373e;
  --blue: #7aa7f7; --blue-bg: #1d2a40; --purple: #b394f2; --purple-bg: #2a2140; --green: #5cc995; --green-bg: #183026;
  --orange: #f0a35c; --orange-bg: #3a2a18; --red: #f08a7e; --red-bg: #3a1f1d; --gold: #e6c35c; --gray-bg: #262a30; --accent: #7aa7f7;
}
/* 閱讀頁整頁用節錄的底色（外殼的狀態訊息也一樣） */
body.read-page { background: #f7f6f2; }
:root[data-theme="dark"] body.read-page { background: #16181c; }
html:has(body.read-page) { scroll-behavior: smooth; scroll-padding-top: calc(var(--topbar-h) + 64px); }

.notes *, .notes *::before, .notes *::after { box-sizing: border-box; }
.notes .wrap { max-width: 880px; margin: 0 auto; padding: 0 16px 80px; }
.notes nav.top { position: sticky; top: var(--topbar-h); z-index: 10; background: var(--bg); border-bottom: 1px solid var(--line); padding: 8px 0; display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.notes nav.top::-webkit-scrollbar { display: none; }
.notes nav.top a, .notes nav.top button { flex: none; font: inherit; font-size: 13px; color: var(--ink); background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 3px 11px; text-decoration: none; cursor: pointer; }
.notes nav.top button.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.notes header.book { padding: 28px 0 8px; }
.notes h1 { font-size: 28px; margin: 0 0 4px; line-height: 1.3; }
.notes h2 { font-size: 21px; margin: 36px 0 12px; padding-bottom: 6px; border-bottom: 2px solid var(--line); }
.notes h3 { font-size: 17px; margin: 0 0 8px; }
.notes .sub { color: var(--mute); font-size: 14px; }
.notes .meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.notes .meta span { font-size: 12px; background: var(--gray-bg); border-radius: 6px; padding: 2px 8px; color: var(--mute); }
.notes .card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; margin: 12px 0; box-shadow: none; }
.notes .qa { display: grid; grid-template-columns: 1fr; gap: 10px; }
.notes .qa .k { font-size: 13px; color: var(--mute); margin-bottom: 2px; }
.notes .qa .v { font-weight: 600; }
.notes .chain { counter-reset: s; list-style: none; padding: 0; margin: 4px 0 0; }
.notes .chain li { counter-increment: s; position: relative; padding: 7px 0 7px 40px; border-left: 2px dashed var(--line); margin-left: 14px; }
.notes .chain li::before { content: counter(s); position: absolute; left: -14px; top: 8px; width: 26px; height: 26px; border-radius: 50%; background: var(--blue); color: #fff; font-size: 13px; display: flex; align-items: center; justify-content: center; font-weight: 700; }
.notes .chain .chn { font-size: 12px; color: var(--blue); font-weight: 700; margin-right: 6px; }
.notes .top5 { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.notes .top5 li { background: var(--gray-bg); border-radius: 10px; padding: 10px 12px; }
.notes .top5 b { color: var(--gold); }
.notes table { width: 100%; border-collapse: collapse; font-size: 14px; }
.notes th, .notes td { border-bottom: 1px solid var(--line); padding: 7px 6px; text-align: left; vertical-align: top; }
.notes th { color: var(--mute); font-weight: 600; }
.notes .map td a { color: var(--ink); font-weight: 600; text-decoration: none; }
.notes details.ch { background: var(--card); border: 1px solid var(--line); border-radius: 16px; margin: 14px 0; padding: 0 18px; }
.notes details.ch > summary { cursor: pointer; list-style: none; padding: 16px 0; }
.notes details.ch > summary::-webkit-details-marker { display: none; }
.notes details.ch > summary .no { display: inline-block; background: var(--blue); color: #fff; border-radius: 8px; padding: 0 9px; margin-right: 8px; font-weight: 700; }
.notes details.ch > summary .t { font-size: 18px; font-weight: 700; }
.notes details.ch > summary .pg { color: var(--mute); font-size: 13px; margin-left: 6px; }
.notes details.ch > summary::after { content: "展開 ▾"; float: right; color: var(--mute); font-size: 13px; margin-top: 4px; }
.notes details.ch[open] > summary::after { content: "收合 ▴"; }
.notes .hook { background: var(--orange-bg); border-radius: 12px; padding: 12px 14px; margin: 0 0 12px; font-size: 15px; }
.notes .hook::before { content: "🪝 "; }
.notes .pos { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.notes .pos div { flex: 1; min-width: 150px; border-radius: 10px; padding: 9px 11px; font-size: 14px; background: var(--gray-bg); }
.notes .pos .now { background: var(--blue-bg); border: 2px solid var(--blue); }
.notes .claim { font-weight: 700; margin: 6px 0 10px; }
.notes .smap { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.notes .smap span { background: var(--gray-bg); border-radius: 999px; padding: 2px 11px; font-size: 13px; }
.notes .smap span.k { background: var(--orange-bg); color: var(--orange); font-weight: 600; }
.notes .lbl { font-size: 13px; color: var(--mute); margin: 12px 0 4px; font-weight: 600; }
.notes .pt { padding: 11px 0; border-top: 1px solid var(--line); }
.notes .pt:first-of-type { border-top: 0; }
.notes .star { color: var(--gold); font-size: 13px; margin-right: 6px; white-space: nowrap; }
.notes .tag { display: inline-block; font-size: 12px; border-radius: 6px; padding: 0 7px; margin-right: 4px; vertical-align: 1px; border: 0; line-height: inherit; }
.notes .t-auth { background: var(--blue-bg); color: var(--blue); }
.notes .t-res { background: var(--purple-bg); color: var(--purple); }
.notes .t-idea { background: var(--gray-bg); color: var(--mute); }
.notes .t-method { background: var(--green-bg); color: var(--green); }
.notes .src-in { color: var(--purple); font-size: 13px; }
.notes blockquote { margin: 8px 0; padding: 8px 14px; background: var(--gray-bg); border-left: 4px solid var(--mute); border-radius: 8px; font-size: 15px; }
.notes .ex { background: var(--green-bg); border-left: 4px solid var(--green); border-radius: 8px; padding: 10px 14px; margin: 8px 0; font-size: 15px; }
.notes .from { color: var(--mute); font-size: 12px; white-space: nowrap; margin-left: 4px; }
.notes details.crit { border: 1px dashed var(--line); border-radius: 12px; margin: 14px 0; padding: 0 14px; background: var(--bg); }
.notes details.crit > summary { cursor: pointer; padding: 10px 0; font-weight: 600; }
.notes .value { background: var(--blue-bg); border-radius: 8px; padding: 8px 12px; font-size: 14px; margin: 4px 0 10px; }
.notes .cb { border-left: 4px solid var(--line); padding: 4px 0 4px 12px; margin: 10px 0; }
.notes .c-strong { border-color: var(--green); } .notes .c-assume { border-color: var(--orange); } .notes .c-old { border-color: var(--red); } .notes .c-apply { border-color: var(--blue); }
.notes .cb h4 { margin: 0 0 6px; font-size: 15px; }
.notes .verdict { font-size: 12px; font-weight: 700; border-radius: 6px; padding: 1px 7px; white-space: nowrap; }
.notes .v-ok { background: var(--green-bg); color: var(--green); } .notes .v-mid { background: var(--orange-bg); color: var(--orange); } .notes .v-bad { background: var(--red-bg); color: var(--red); }
.notes .src { font-size: 12px; color: var(--mute); margin-top: 3px; }
.notes .src a { color: var(--blue); }
.notes textarea { width: 100%; min-height: 70px; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; font: inherit; font-size: 15px; background: var(--card); color: var(--ink); }
.notes .todo h3 { margin-top: 14px; }
.notes .todo label { display: flex; gap: 8px; align-items: flex-start; padding: 5px 0; font-size: 15px; border-bottom: 1px dotted var(--line); }
.notes .todo input { margin-top: 6px; flex: none; }
.notes .todo .from { display: block; margin-left: 0; }
.notes .quiz { border-top: 1px solid var(--line); padding: 12px 0; }
.notes .quiz .qt { font-size: 12px; border-radius: 6px; padding: 0 7px; background: var(--purple-bg); color: var(--purple); margin-right: 6px; }
.notes .conf { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.notes .conf button, .notes .grade button, .notes .ctl button { font: inherit; font-size: 13px; border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 999px; padding: 3px 12px; cursor: pointer; }
.notes .conf button.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.notes .ans { display: none; background: var(--gray-bg); border-radius: 10px; padding: 10px 12px; margin-top: 6px; font-size: 15px; }
.notes .ans.show { display: block; }
.notes .grade { display: flex; gap: 6px; margin-top: 8px; }
.notes .warn { display: none; margin-top: 6px; font-size: 14px; color: var(--orange); font-weight: 600; }
.notes .warn.show { display: block; }
.notes .term { border-bottom: 1px dashed var(--purple); cursor: help; }
.notes .ctl { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0; }
.notes .hidden-by-filter { display: none !important; }
.notes ul { padding-left: 20px; margin: 6px 0; }
.notes footer { margin-top: 40px; color: var(--mute); font-size: 13px; }
.notes a { color: var(--blue); }
.notes :focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
/* 手機：表格太寬時可以左右滑，不撐破版面 */
.notes .table-scroll { overflow-x: auto; }

/* ── 閱讀頁外殼（載入中／請先登入／準備中／錯誤）── */
.reader { padding: 2.5rem 1rem; max-width: 880px; }
.reader-state h1 { font-size: 1.3rem; margin: 0 0 .6rem; }
.reader-state p { margin: .4rem 0; }
.reader-state .head-actions { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: 1rem; }
.reader[hidden], .reader-state[hidden], .notes[hidden] { display: none; }
.topbar.is-slim .slim-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-soft); font-size: .92rem; }
@media (max-width: 560px) { .topbar.is-slim .slim-title { display: none; } }
