/* 共用主題：色票（深/淺）、基礎元素與共用元件。各頁再載入自己的版面 CSS。 */
:root {
  color-scheme: light;
  --bg: #f4f5f7; --fg: #111827; --mut: #6b7280; --card: #fff; --field: #fff;
  --line: #e5e7eb; --line2: #eef0f3; --accent: #2563eb; --accent-fg: #fff;
  --code: #f3f4f6; --ring: rgba(37, 99, 235, .22); --hdr: rgba(244, 245, 247, .85);
  --shadow: 0 12px 36px rgba(17, 24, 39, .13); --warn: #b45309; --ok: #059669;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e1013; --fg: #e6e8ec; --mut: #98a1ad; --card: #191c22; --field: #14171c;
  --line: #2b313a; --line2: #232830; --accent: #4f8cff; --accent-fg: #fff;
  --code: #20242c; --ring: rgba(79, 140, 255, .30); --hdr: rgba(14, 16, 19, .85);
  --shadow: 0 18px 52px rgba(0, 0, 0, .6); --warn: #fbbf24; --ok: #34d399;
}
* { box-sizing: border-box }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 15px/1.65 -apple-system, "Segoe UI", "Microsoft JhengHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}
::-webkit-scrollbar { width: 10px; height: 10px }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 9px; border: 2px solid var(--bg) }
::-webkit-scrollbar-thumb:hover { background: var(--mut) }
a { color: var(--accent); text-underline-offset: 2px; overflow-wrap: anywhere }
code { background: var(--code); padding: 1px 6px; border-radius: 6px; font-size: .92em }
pre.code { background: var(--code); padding: 12px 14px; border-radius: 10px; overflow: auto; border: 1px solid var(--line); white-space: pre-wrap }
/* pre 內的 code 是區塊，不是行內程式碼：行內樣式的 padding-left 只作用在換行前的第一行，
   會讓程式碼區塊首行比其餘行多縮 6px。 */
pre.code > code { padding: 0; background: none; border-radius: 0 }
.muted { color: var(--mut) }
small { color: var(--mut) }

/* 文件分類色票（dev.css 的群組標題與 file.css 的文件頁 badge 共用）。 */
.color-blue { --doc-color: #3b82f6 } .color-green { --doc-color: #10b981 }
.color-amber { --doc-color: #f59e0b } .color-violet { --doc-color: #8b5cf6 }
.color-rose { --doc-color: #f43f5e } .color-cyan { --doc-color: #06b6d4 }
.color-slate { --doc-color: #64748b }

/* 語法上色（檔案檢視、差異檢視共用）：深色預設，淺色主題再覆寫。 */
.tok-k { color: #c586c0 } /* 關鍵字 */
.tok-t { color: #4ec9b0 } /* 型別 */
.tok-f { color: #dcdcaa } /* 函式 */
.tok-s { color: #ce9178 } /* 字串 */
.tok-c { color: #6a9955 } /* 註釋 */
.tok-n { color: #b5cea8 } /* 數字 */
.tok-a { color: #d7ba7d } /* 屬性／前置 */
:root[data-theme="light"] .tok-k { color: #af00db }
:root[data-theme="light"] .tok-t { color: #267f99 }
:root[data-theme="light"] .tok-f { color: #795e26 }
:root[data-theme="light"] .tok-s { color: #a31515 }
:root[data-theme="light"] .tok-c { color: #008000 }
:root[data-theme="light"] .tok-n { color: #098658 }
:root[data-theme="light"] .tok-a { color: #795e26 }

input, select, textarea, button { font: inherit; color: var(--fg) }
input, select, textarea {
  padding: 9px 11px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--field); width: 100%; transition: border-color .15s, box-shadow .15s;
}
input:hover, select:hover, textarea:hover { border-color: var(--mut) }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring) }
::placeholder { color: var(--mut); opacity: .8 }
button {
  cursor: pointer; padding: 9px 13px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--card); transition: background .15s, border-color .15s, transform .05s;
}
button:hover { background: var(--line2) }
button:active { transform: translateY(1px) }
button.primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent) }
button.primary:hover { filter: brightness(1.07); background: var(--accent) }

/* 頂列與共用卡片／標籤 */
.appbar {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap; row-gap: 8px;
  padding: 12px 16px; border-bottom: 1px solid var(--line); position: sticky; top: 0;
  background: var(--hdr); backdrop-filter: blur(10px); z-index: 5;
}
.appbar h1 { font-size: 16px; font-weight: 700; margin: 0 10px 0 0; white-space: nowrap }
.appbar input, .appbar select { width: auto }
.appbar .spacer { flex: 1 }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 18px; margin: 12px 0 }
.chip {
  font-size: 12px; padding: 3px 10px; border: 1px solid var(--line); border-radius: 20px;
  cursor: pointer; background: var(--bg); color: var(--mut);
}
.chip:hover { border-color: var(--accent); color: var(--accent) }
/* 語系列（關於頁）：可點擊切換，目前生效者高亮。 */
.lchips { display: flex; flex-wrap: wrap; gap: 6px }
.lchip {
  font-size: 12px; padding: 3px 10px; border: 1px solid var(--line); border-radius: 20px;
  cursor: pointer; background: var(--bg); color: var(--mut);
}
.lchip:hover { border-color: var(--accent); color: var(--accent) }
.lchip.on { background: var(--accent); color: var(--accent-fg); border-color: var(--accent) }
/* 語系下拉選單（#locale 展開）：垂直清單，目前生效者高亮。 */
.locale-menu {
  position: fixed; z-index: 20; display: flex; flex-direction: column; gap: 2px;
  padding: 6px; min-width: 120px; background: var(--card); border: 1px solid var(--line);
  border-radius: 10px; box-shadow: 0 8px 24px rgba(0, 0, 0, .25);
}
.locale-menu[hidden] { display: none }
.locale-menu .lchip {
  border: none; border-radius: 6px; background: transparent; color: var(--fg);
  text-align: left; width: 100%; padding: 6px 12px;
}
.locale-menu .lchip:hover { background: var(--line2); color: var(--fg) }
.locale-menu .lchip.on { background: var(--accent); color: var(--accent-fg) }
.empty { color: var(--mut); padding: 30px; text-align: center }
@media (max-width: 640px) { .appbar { gap: 6px } }

/* 靜態頁尾：標示來源 commit 與產生時間。 */
footer.built {
  max-width: 960px; margin: 22px auto 0; padding: 14px 24px 30px;
  border-top: 1px solid var(--line); color: var(--mut); font-size: 12px;
}

/* Markdown 排版內容（共用；外框版面交由各頁 CSS，例如 .rendered 的 max-width 在 file.css）。 */
.rendered h1, .rendered h2, .rendered h3, .rendered h4 { line-height: 1.3; margin: 1.4em 0 .5em; scroll-margin-top: calc(var(--appbar-h, 53px) + 12px) }
.rendered h1 { font-size: 1.7em; border-bottom: 1px solid var(--line); padding-bottom: .3em }
.rendered h2 { font-size: 1.35em; border-bottom: 1px solid var(--line); padding-bottom: .25em }
.rendered h3 { font-size: 1.15em }
.rendered p, .rendered ul, .rendered ol, .rendered table, .rendered pre, .rendered blockquote, .rendered .alert { margin: .7em 0 }
.rendered ul, .rendered ol { padding-left: 1.6em }
.rendered li { margin: .2em 0 }
.rendered img { max-width: 100%; border-radius: 8px }
.rendered hr { border: 0; border-top: 1px solid var(--line); margin: 1.4em 0 }
.rendered table { border-collapse: collapse; width: 100%; display: block; overflow-x: auto }
.rendered th, .rendered td { border: 1px solid var(--line); padding: 6px 10px; text-align: left }
.rendered th { background: var(--code) }
.rendered blockquote { border-left: 3px solid var(--line); margin-left: 0; padding: .2em 0 .2em 1em; color: var(--mut) }

/* GitHub 提示框（> [!NOTE] 等） */
.rendered .alert { border: 1px solid var(--line); border-left-width: 4px; border-radius: 8px; padding: 10px 14px }
.rendered .alert-title { margin: 0 0 .3em; font-weight: 600; display: flex; align-items: center; gap: .4em }
.rendered .alert p:last-child { margin-bottom: 0 }
.alert-note { border-left-color: #3b82f6; background: rgba(59, 130, 246, .10) }
.alert-tip { border-left-color: #10b981; background: rgba(16, 185, 129, .10) }
.alert-important { border-left-color: #8b5cf6; background: rgba(139, 92, 246, .10) }
.alert-warning { border-left-color: #f59e0b; background: rgba(245, 158, 11, .12) }
.alert-caution { border-left-color: #ef4444; background: rgba(239, 68, 68, .10) }
.alert-note .alert-title { color: #3b82f6 }
.alert-tip .alert-title { color: #10b981 }
.alert-important .alert-title { color: #8b5cf6 }
.alert-warning .alert-title { color: #f59e0b }
.alert-caution .alert-title { color: #ef4444 }

/* 社群與開發交流（關於頁；由 Docs/community.md 產生）。 */
.community { margin-top: 34px }
.community .section-title { font-size: 20px; margin: 0 0 18px }
.community .cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 18px }
.community .card { display: flex; flex-direction: column; padding: 22px; background: var(--card); border: 1px solid var(--line); border-radius: 14px }
.community .card h3 { margin: 0 0 8px; font-size: 18px }
.community .card .rendered { margin: 0; color: var(--mut) }
.community .card .rendered > :first-child { margin-top: 0 }
.community .card .rendered > :last-child { margin-bottom: 0 }
.community .action { margin-top: auto; padding-top: 14px }
.community .action p { margin: 0 }
.community .action a { font-weight: 650 }

/* Markdown GFM task list：唯讀 checkbox 與完成樣式（歷史／文件／檔案檢視共用）。 */
.rendered li.task { list-style: none; margin-left: -1.2em }
.rendered li.task > input[type="checkbox"] { width: 15px; height: 15px; margin: 0 6px 0 0; padding: 0; border: 0; border-radius: 3px; background: none; box-shadow: none; accent-color: var(--accent); vertical-align: -2px }
.rendered li.task.done .task-label { color: var(--mut); text-decoration: line-through }
