/* 全站設計 tokens：請放在其他 CSS 之後載入，統一覆蓋舊變數。 */
:root {
  --paper: #f7f5ee;
  --surface: #fffefa;
  --surface-2: #efede4;
  --ink: #20231f;
  --ink-2: #535950;
  --rule: #d7d6c9;
  --accent: #873b29;
  --accent-soft: #f3e6df;
  --olive: #415c49;
  --olive-soft: #e3ebe4;
  --warn: #9a6a00;
  --warn-soft: #fbf1d6;
  --danger: #a3281f;
  --danger-soft: #f8e1de;
  --focus: #873b29;

  --font-serif: "Noto Serif TC", "Source Han Serif TC", "Songti TC", "PMingLiU", serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, monospace;

  --fs-xs: .8125rem; --fs-sm: .875rem; --fs-base: 1rem; --fs-md: 1.125rem;
  --fs-lg: 1.375rem; --fs-xl: 1.75rem; --fs-2xl: 2.25rem; --fs-3xl: 3rem;

  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 24px;
  --sp-6: 32px; --sp-7: 48px; --sp-8: 64px; --sp-9: 96px;

  --radius-sm: 4px; --radius: 8px; --radius-lg: 12px;
  --shadow: 0 1px 2px rgb(32 35 31 / .06), 0 8px 24px -12px rgb(32 35 31 / .18);
  --wrap: 1240px; --wrap-read: 800px; --wrap-catalog: 1060px;
  --header-h: 64px;

  /* 舊變數別名：讓 learning.css / content-layout.css 跟著統一 */
  --paper-light: var(--surface);
  --muted: var(--ink-2);
  --accent-dark: #6e2f20;
  --pale: #e8eadf;
  --warm: #f2e8dc;
  --link: var(--accent);
  --serif: var(--font-serif);
  --sans: var(--font-sans);
}

html { scroll-padding-top: calc(var(--header-h) + 16px); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

/* V2：圖表色與程式碼區塊色 */
:root {
  --chart-1: #873b29; --chart-2: #415c49; --chart-3: #9a6a00;
  --chart-4: #4a5a6a; --chart-5: #b98a7c; --chart-6: #8fa696;
  --code-bg: #1f2320; --code-ink: #f1efe6;
}


/* ===== 水墨版（2026-11）：書齋（白天）與宮廟（夜晚）共用一套 tokens ===== */
:root {
  --paper: #f4f1e8; --surface: #f9f6ee; --surface-2: #ebe7db;
  --ink: #1c1b19; --ink-2: #5a5750; --rule: #d6d1c4;
  --accent: #a8322a; --accent-soft: #f0e2dc; --accent-dark: #8a261f;
  --olive: #1c1b19; --olive-soft: #ebe7db;
  --gold: #7a5f2a;
  --focus: #a8322a;
  --pale: #ebe7db; --warm: #ebe7db;
  --radius-sm: 2px; --radius: 3px; --radius-lg: 4px;
  --shadow: 0 1px 2px rgb(28 27 25 / .05), 0 10px 28px -16px rgb(28 27 25 / .22);
  --font-serif: "Noto Serif TC", "Source Han Serif TC", "Songti TC", "PMingLiU", serif;
  --code-bg: #1c1b19; --code-ink: #efe9dc;
}
html[data-theme="night"] {
  color-scheme: dark;
  --paper: #14110f; --surface: #1b1714; --surface-2: #241f1a;
  --ink: #efe9dc; --ink-2: #a59d8e; --rule: #3a342c;
  --accent: #e0705f; --accent-soft: #2e1c18; --accent-dark: #f08c7c;
  --seal: #b82a1c;
  --olive: #c9a86a; --olive-soft: #2a241a;
  --gold: #c9a86a;
  --focus: #c9a86a;
  --pale: #241f1a; --warm: #241f1a;
  --paper-light: #1b1714; --muted: #a59d8e; --link: #e0705f;
  --code-bg: #0c0a09; --code-ink: #efe9dc;
  --shadow: 0 1px 2px rgb(0 0 0 / .4), 0 10px 28px -16px rgb(0 0 0 / .8);
}
:root { --seal: #a8322a; }
html { background: var(--paper); }
body { transition: background-color .9s ease, color .9s ease; }
h1, h2 { letter-spacing: .04em; }
::selection { background: var(--accent-soft); color: var(--ink); }
@media (prefers-reduced-motion: reduce) { body { transition: none; } }

/* 夜版：蓋掉舊樣式裡寫死的淺色 */
html[data-theme="night"] input, html[data-theme="night"] textarea, html[data-theme="night"] select, html[data-theme="night"] #free-prompt { background: var(--surface); color: var(--ink); border-color: var(--rule); }
html[data-theme="night"] .mechanism, html[data-theme="night"] .completion, html[data-theme="night"] .route-section { background: var(--surface-2); }
html[data-theme="night"] .token-pieces span, html[data-theme="night"] .token-strip span, html[data-theme="night"] .token-output span { color: #1c1b19; }
html[data-theme="night"] .lab-golden-quote, html[data-theme="night"] .blindspot-card-quote { background: var(--surface-2); color: var(--ink); }
html[data-theme="night"] img.concept-figure, html[data-theme="night"] .concept-illustration img, html[data-theme="night"] main svg:not(.vd-smoke):not(.sf-hills) { }
html[data-theme="night"] [class*="jitong"] input, html[data-theme="night"] [class*="jitong"] textarea { background: #fffdf8; color: #1c1b19; border-color: #d6d1c4; }
