/* ═══════════════════════════════════════════════════════
   YR 運動研究室 — Global Stylesheet
   ═══════════════════════════════════════════════════════ */

/* ── 變數 ─────────────────────────────────────────────── */
:root {
  --c-bg:          #F7F4ED;
  --c-bg-rgb:      247, 244, 237;   /* 同 --c-bg，供 hero 漸層 rgba 使用 */
  --c-surface:     #ffffff;
  --c-text:        #1e293b;
  --c-muted:       #64748b;
  --c-border:      #e2e8f0;
  --c-accent:      #2563eb;
  --c-accent-dark: #1d4ed8;
  --c-header-bg:   #111111;
  --c-header-fg:   #f1f5f9;
  --c-hero-bg:     #111111;
  --c-footer-bg:   #1a1a1a;
  --c-footer-fg:   #94a3b8;

  --content-width: 820px;
  --max-width:     1320px;
  --radius:        10px;
  --shadow:        0 2px 16px rgba(0, 0, 0, .08);
  --shadow-hover:  0 6px 28px rgba(0, 0, 0, .15);
  --transition:    .22s ease;

  --font-sans: system-ui, -apple-system, 'Segoe UI', 'Helvetica Neue', sans-serif;
  --font-serif: Georgia, 'Noto Serif TC', 'Source Han Serif TC', serif;
  --font-mono:  'Fira Code', 'Cascadia Code', Consolas, monospace;
}

/* ── Reset ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html {
  scroll-behavior: smooth;
  /* 關閉行動版瀏覽器字體自動放大：橫向捲動表格（nowrap）會觸發 iOS/Android
     的 font boosting，導致同一表格左右欄字級不一致 */
  -webkit-text-size-adjust: 100%;
  -moz-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body {
  font-family: var(--font-sans);
  background: var(--c-bg);
  color: var(--c-text);
  line-height: 1.7;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;       /* 舊版瀏覽器 fallback */
  overflow-x: clip;         /* iOS 16+ / 現代瀏覽器：不破壞 position: sticky */
}
main { flex: 1; }
a { color: var(--c-accent); text-decoration: none; }
a:hover { text-decoration: underline; color: var(--c-accent-dark); }
img { max-width: 100%; height: auto; display: block; }

/* ── 版型 ──────────────────────────────────────────────── */
.container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1.5rem;
}
.content-wrapper {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
}
/* 限制圖片最大寬度為內容區 */
.content-width {
  max-width: var(--content-width);
  margin: 0 auto;
}

/* ── 站台 Header ────────────────────────────────────────── */
.site-header {
  background: var(--c-header-bg);
  color: var(--c-header-fg);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 12px rgba(0,0,0,.45);
}
.site-header .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 58px;
  gap: 1.25rem;
}
/* Logo 圖示 */
.site-logo {
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  display: inline-block;
  vertical-align: middle;
}
.site-title {
  display: flex;
  align-items: center;
  gap: .55rem;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--c-header-fg);
  letter-spacing: .02em;
  flex-shrink: 0;
}
.site-title:hover { text-decoration: none; color: white; }

/* 頁籤導覽（首頁用）— 靠左 */
.header-tabs {
  display: flex;
  gap: .2rem;
  flex: 0 0 auto;
  overflow-x: auto;
  scrollbar-width: none;
}
.header-tabs::-webkit-scrollbar { display: none; }

/* 彈性空白（tabs 與右側按鈕之間） */
.header-spacer { flex: 1; }
.tab-btn {
  background: transparent;
  border: 1px solid transparent;
  color: #94a3b8;
  padding: .3rem .9rem;
  border-radius: 999px;
  cursor: pointer;
  font-size: .88rem;
  font-weight: 500;
  font-family: var(--font-sans);
  transition: all .18s ease;
  white-space: nowrap;
}
.tab-btn:hover {
  color: #e2e8f0;
  border-color: rgba(255,255,255,.2);
}
.tab-btn.active {
  color: #ffffff;
  background: rgba(34,211,238,.18);
  border-color: rgba(34,211,238,.45);
}

.site-stats {
  font-size: .88rem;
  font-weight: 500;
  color: #94a3b8;
  white-space: nowrap;
  flex-shrink: 0;
}
.back-link {
  font-size: .9rem;
  color: #94a3b8;
  white-space: nowrap;
  flex-shrink: 0;
}
.back-link:hover { color: white; text-decoration: none; }

/* 搜尋按鈕（右上角） */
.search-toggle {
  background: transparent;
  border: 1px solid transparent;
  color: #94a3b8;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: color .18s, border-color .18s, background .18s;
}
.search-toggle:hover,
.search-toggle.active {
  color: #ffffff;
  border-color: rgba(34,211,238,.4);
  background: rgba(34,211,238,.12);
}

/* ── 搜尋面板 ────────────────────────────────────────────── */
.search-panel {
  display: none;
  position: fixed;
  top: 58px;
  left: 0;
  right: 0;
  z-index: 200;
  background: #1a1a1a;
  box-shadow: 0 8px 32px rgba(0,0,0,.5);
  padding: 1.1rem 0 1.4rem;
  max-height: calc(100vh - 58px);
  overflow-y: auto;
}
.search-panel.open { display: block; }

.search-input-row {
  display: flex;
  align-items: center;
  gap: .75rem;
  background: #ffffff;
  border-radius: 8px;
  padding: .55rem 1rem;
}
.search-icon-svg { color: #64748b; flex-shrink: 0; }
.search-input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 1rem;
  background: transparent;
  color: #1e293b;
  font-family: var(--font-sans);
}
.search-input::placeholder { color: #94a3b8; }
.search-close-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: #94a3b8;
  font-size: 1.1rem;
  line-height: 1;
  padding: 0 .2rem;
  transition: color .15s;
}
.search-close-btn:hover { color: #1e293b; }

/* 結果區 */
.search-results { margin-top: 1rem; }
.search-count {
  font-size: .82rem;
  color: #94a3b8;
  margin-bottom: .75rem;
}
.search-count strong { color: #22d3ee; }
.search-empty {
  color: #64748b;
  font-size: .9rem;
  padding: .5rem 0;
}
.sr-list {
  display: flex;
  flex-direction: column;
  gap: .6rem;
}
.sr-card {
  display: flex;
  gap: .85rem;
  padding: .75rem;
  border-radius: 8px;
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.08);
  text-decoration: none;
  color: inherit;
  transition: background .15s;
}
.sr-card:hover {
  background: rgba(255,255,255,.1);
  text-decoration: none;
}
.sr-img {
  width: 90px;
  height: 60px;
  flex-shrink: 0;
  border-radius: 6px;
  overflow: hidden;
}
.sr-img img { width: 100%; height: 100%; object-fit: cover; }
.sr-img--empty { background: rgba(255,255,255,.1); }
.sr-body { flex: 1; display: flex; flex-direction: column; gap: .25rem; justify-content: center; }
.sr-meta { min-height: 1.1em; }
.sr-title {
  font-size: .9rem;
  font-weight: 600;
  color: #f1f5f9;
  line-height: 1.4;
}
.sr-title mark {
  background: rgba(34,211,238,.3);
  color: #ffffff;
  border-radius: 2px;
  padding: 0 .1em;
}
.sr-excerpt { font-size: .78rem; color: #94a3b8; line-height: 1.4; }

/* 搜尋面板的 cat-badge 改為深色背景配色 */
.search-panel .cat-badge {
  color: #e2e8f0;
  border-color: rgba(255,255,255,.3);
}

@media (max-width: 640px) {
  .search-panel { top: 50px; max-height: calc(100vh - 50px); }
  .sr-img { width: 68px; height: 48px; }
  .sr-excerpt { display: none; }
}

/* ── Hero 區塊 ──────────────────────────────────────────── */
.hero-section {
  background: var(--c-hero-bg);
  padding: 0;
  line-height: 0; /* 消除 inline-block 間隙 */
}
.hero-section .content-width {
  line-height: 0;
  max-width: var(--content-width);
  margin: 0 auto;
}
.hero-image {
  width: 100%;
  height: auto;
  display: block;
}

/* ── 文章全幅 Hero v2（左右滿版 + 主題感知漸層，標題疊在漸層內）── */
.post-hero {
  position: relative;
  min-height: 500px;                       /* 不支援 svh 的舊瀏覽器 fallback */
  min-height: clamp(420px, 62svh, 660px);
  display: flex;
  align-items: flex-end;
  overflow: hidden;
  background: var(--c-hero-bg);
}
.post-hero-bg { position: absolute; inset: 0; }
.post-hero-bg img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
/* 漸層跟著 --c-bg-rgb 走：淺色融入米白、深色融入深藍黑 */
.post-hero-veil {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg,
    rgba(var(--c-bg-rgb), 0)   0%,
    rgba(var(--c-bg-rgb), 0)   38%,
    rgba(var(--c-bg-rgb), .55) 64%,
    rgba(var(--c-bg-rgb), .92) 84%,
    rgb(var(--c-bg-rgb))       100%);
}
.post-hero-inner {
  position: relative;
  z-index: 2;
  width: min(var(--content-width), 100%);
  margin: 0 auto;
  padding: 180px 1.5rem 1.25rem;           /* 不支援 svh 的舊瀏覽器 fallback */
  padding: clamp(150px, 28svh, 260px) 1.5rem 1.25rem;
}
.post-hero-inner .article-meta {
  border-bottom: none;
  padding-bottom: 0;
  margin-bottom: .6rem;
}
.post-hero-inner .article-title {
  text-shadow: 0 1px 18px rgba(var(--c-bg-rgb), .9);
}
.post-hero-credit {
  position: absolute;
  top: 10px;
  right: 14px;
  z-index: 2;
  font-size: .64rem;
  letter-spacing: .04em;
  color: rgba(255, 255, 255, .72);
  text-shadow: 0 1px 4px rgba(0, 0, 0, .65);
}
@media (max-width: 640px) {
  .post-hero { min-height: 400px; min-height: clamp(340px, 54svh, 560px); }
  .post-hero-inner { padding-top: 130px; }
}

/* ── 文章 Meta ──────────────────────────────────────────── */
.article-header { margin-bottom: 2rem; }
.article-meta {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem .8rem;
  font-size: .84rem;
  color: var(--c-muted);
  margin-bottom: 1rem;
  padding-bottom: .75rem;
  border-bottom: 1px solid var(--c-border);
}
.meta-sep { color: var(--c-border); }
.cat-badge {
  display: inline-block;
  font-size: .72rem;
  font-weight: 600;
  color: #1e293b;
  background: transparent;
  border: 1.5px solid #1e293b;
  padding: .05em .5em;
  border-radius: 4px;
  letter-spacing: .04em;
  vertical-align: middle;
  margin-left: .3em;
}
.article-title {
  font-family: var(--font-serif);
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  font-weight: 700;
  line-height: 1.3;
  color: var(--c-text);
}

/* ── 通用 .lead 引言（文章頁 inline style 會覆寫，首頁用此全局樣式）*/
.lead {
  font-size: 1.1rem;
  color: #475569;
  line-height: 1.8;
  margin-bottom: 1.5rem;
  padding: 1rem 1.25rem;
  background: #f0f9ff;
  border-left: 4px solid #38bdf8;
  border-radius: 0 8px 8px 0;
}

/* ── 文章內容 ────────────────────────────────────────────── */
.article-content {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  line-height: 1.85;
  color: #2d3748;
}
.article-content h2,
.article-content h3,
.article-content h4 {
  font-family: var(--font-sans);
  margin: 2rem 0 .75rem;
  color: var(--c-text);
}
.article-content h2 { font-size: 1.5rem; border-bottom: 2px solid var(--c-border); padding-bottom: .3rem; }
.article-content h3 { font-size: 1.25rem; }
.article-content p  { margin-bottom: 1.25rem; }
.article-content ul,
.article-content ol { margin: 0 0 1.25rem 1.5rem; }
.article-content li { margin-bottom: .35rem; }
.article-content blockquote {
  border-left: 4px solid var(--c-accent);
  padding: .75rem 1.25rem;
  background: #eff6ff;
  border-radius: 0 var(--radius) var(--radius) 0;
  margin: 1.5rem 0;
  color: #334155;
  font-style: italic;
}
.article-content code {
  font-family: var(--font-mono);
  background: #f1f5f9;
  padding: .15em .4em;
  border-radius: 4px;
  font-size: .9em;
}
.article-content pre {
  background: #0f172a;
  color: #e2e8f0;
  padding: 1.25rem 1.5rem;
  border-radius: var(--radius);
  overflow-x: auto;
  margin: 1.5rem 0;
  font-size: .9rem;
}
.article-content pre code { background: none; padding: 0; color: inherit; }
.article-content a { color: var(--c-accent); text-decoration: underline; }
.article-content img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
  margin: 1.5rem auto;
}
.article-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: .95rem;
}
.article-content th,
.article-content td {
  padding: .6rem .9rem;
  border: 1px solid var(--c-border);
}
.article-content th { background: #f1f5f9; font-weight: 600; }
.article-content tr:nth-child(even) { background: #f8fafc; }

/* ── 首頁 ────────────────────────────────────────────────── */
.index-main { padding: 2.5rem 1.5rem; }
.index-header {
  display: flex;
  align-items: baseline;
  gap: .75rem;
  margin-bottom: 2rem;
}
.index-header h1 {
  font-size: 1.6rem;
  font-weight: 700;
}
.post-count {
  font-size: .85rem;
  color: var(--c-muted);
  background: var(--c-border);
  padding: .15em .6em;
  border-radius: 999px;
}
.no-posts {
  color: var(--c-muted);
  padding: 3rem;
  text-align: center;
  background: var(--c-surface);
  border-radius: var(--radius);
  border: 2px dashed var(--c-border);
}

/* ── 卡片格線 ────────────────────────────────────────────── */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.5rem;
}
.post-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: box-shadow var(--transition), transform var(--transition);
}
.post-card:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-3px);
}
.card-link {
  display: flex;
  flex-direction: column;
  height: 100%;
  color: inherit;
  text-decoration: none;
}
.card-link:hover { text-decoration: none; }
.card-image {
  width: 100%;
  height: 190px;
  overflow: hidden;
  background: #e2e8f0;
}
.card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--transition);
}
.post-card:hover .card-image img { transform: scale(1.04); }
.card-image-placeholder {
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #cbd5e1 0%, #94a3b8 100%);
}
.card-body {
  padding: 1.1rem 1.25rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  flex: 1;
}
.card-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--c-text);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-meta {
  display: flex;
  gap: .75rem;
  font-size: .78rem;
  color: var(--c-muted);
  flex-wrap: wrap;
}
.card-excerpt {
  font-size: .88rem;
  color: #475569;
  line-height: 1.55;
  flex: 1;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-footer {
  font-size: .8rem;
  color: var(--c-muted);
  padding-top: .5rem;
  border-top: 1px solid var(--c-border);
}
.card-views { display: flex; align-items: center; gap: .25rem; }

/* ── 計數器佔位動畫 ─────────────────────────────────────── */
.view-count-display:not([data-loaded]) {
  display: inline-block;
  width: 2.5em;
  height: .9em;
  background: linear-gradient(90deg, #e2e8f0 25%, #f1f5f9 50%, #e2e8f0 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: 3px;
  vertical-align: middle;
}
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── 延伸閱讀 ────────────────────────────────────────────── */
.related-posts {
  margin-top: 3.5rem;
  padding-top: 2rem;
  border-top: 2px solid var(--c-border);
}
.related-heading {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--c-text);
  margin-bottom: 1.25rem;
  letter-spacing: .02em;
}
.ri-grid {
  display: flex;
  flex-direction: column;
  gap: .85rem;
}
.ri-card {
  display: flex;
  gap: 1rem;
  padding: .85rem;
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  background: var(--c-surface);
  text-decoration: none;
  color: inherit;
  transition: box-shadow var(--transition), transform var(--transition);
}
.ri-card:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
  text-decoration: none;
}
.ri-img {
  width: 110px;
  height: 74px;
  flex-shrink: 0;
  border-radius: 6px;
  overflow: hidden;
  background: var(--c-border);
}
.ri-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.ri-img--empty {
  background: linear-gradient(135deg, #cbd5e1 0%, #94a3b8 100%);
}
.ri-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: .3rem;
  justify-content: center;
}
.ri-meta { min-height: 1.2em; }
.ri-title {
  font-size: .95rem;
  font-weight: 600;
  line-height: 1.4;
  color: var(--c-text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.ri-excerpt {
  font-size: .8rem;
  color: var(--c-muted);
  line-height: 1.5;
}
@media (max-width: 480px) {
  .ri-img { width: 80px; height: 56px; }
  .ri-title { font-size: .88rem; }
  .ri-excerpt { display: none; }
}

/* ── Footer ─────────────────────────────────────────────── */
.site-footer {
  background: var(--c-footer-bg);
  color: var(--c-footer-fg);
  margin-top: auto;
  padding: 2rem 0;
  font-size: .83rem;
  line-height: 1.8;
}
.site-footer .container {
  display: flex;
  flex-direction: column;
  gap: .75rem;
}
.image-credit a { color: #93c5fd; }
.image-credit a:hover { color: white; }
.footer-copy { color: #64748b; }

/* ── RWD ─────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .site-stats { display: none; }
  .header-tabs { justify-content: flex-start; }
}
@media (max-width: 640px) {
  .article-meta { font-size: .78rem; }
  .article-title { font-size: 1.5rem; }
  .cards-grid { grid-template-columns: 1fr; }
  .hero-image { max-height: none; }
  .site-header .container { height: auto; min-height: 50px; flex-wrap: wrap; padding-top: .4rem; padding-bottom: .4rem; gap: .5rem .75rem; }
  /* 第一列：標題靠左，明暗／搜尋按鈕靠右（同桌面版排列）；頁籤獨立換到第二列 */
  .site-title    { font-size: .95rem; order: 1; }
  .header-spacer { order: 2; }
  .lang-toggle   { order: 3; }
  .theme-toggle  { order: 3; }
  .search-toggle { order: 4; }
  .header-tabs   { order: 5; flex: 0 0 100%; width: 100%; }
  .back-link     { order: 6; }   /* 文章頁：返回連結留在按鈕之後 */
  .site-logo { width: 24px; height: 24px; }
  .content-wrapper { padding: 1.5rem 1rem 3rem; }
  .index-main { padding: 1.5rem 1rem; }
}

/* ═══════════════════════════════════════════════════════
   深色模式 Dark Mode
   ═══════════════════════════════════════════════════════ */

/* ── CSS 變數（JS inline script 同步設定，防 FOUC）────── */
:root[data-theme="dark"] {
  --c-bg:          #0f172a;
  --c-bg-rgb:      15, 23, 42;
  --c-surface:     #1e293b;
  --c-text:        #e2e8f0;
  --c-muted:       #94a3b8;
  --c-border:      #334155;
  --c-accent:      #38bdf8;
  --c-accent-dark: #0ea5e9;
  --shadow:        0 2px 16px rgba(0,0,0,.45);
  --shadow-hover:  0 6px 28px rgba(0,0,0,.65);
}
/* 無 JS 環境：依系統設定自動套用 */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --c-bg:          #0f172a;
    --c-bg-rgb:      15, 23, 42;
    --c-surface:     #1e293b;
    --c-text:        #e2e8f0;
    --c-muted:       #94a3b8;
    --c-border:      #334155;
    --c-accent:      #38bdf8;
    --c-accent-dark: #0ea5e9;
    --shadow:        0 2px 16px rgba(0,0,0,.45);
    --shadow-hover:  0 6px 28px rgba(0,0,0,.65);
  }
}

/* ── 硬碼顏色覆寫（深色模式）────────────────────────── */

/* 文章內文 */
[data-theme="dark"] .article-content                   { color: var(--c-text); }
[data-theme="dark"] .article-content h2,
[data-theme="dark"] .article-content h3,
[data-theme="dark"] .article-content h4                { color: var(--c-text); }
[data-theme="dark"] .article-content blockquote        { background: #162032; color: #cbd5e1; }
[data-theme="dark"] .article-content code              { background: #334155; color: #e2e8f0; }
[data-theme="dark"] .article-content th                { background: #1e3a5f; color: #e2e8f0; }
[data-theme="dark"] .article-content td                { color: #cbd5e1; border-color: var(--c-border); }
[data-theme="dark"] .article-content tr:nth-child(even){ background: rgba(255,255,255,.04); }

/* 首頁卡片 */
[data-theme="dark"] .card-excerpt  { color: var(--c-muted); }
[data-theme="dark"] .card-image    { background: #334155; }
[data-theme="dark"] .cat-badge     { color: var(--c-muted); border-color: var(--c-border); }

/* 搜尋面板輸入框（panel 本身已為深色）*/
[data-theme="dark"] .search-input-row         { background: #1e293b; border: 1px solid #334155; }
[data-theme="dark"] .search-input             { color: #e2e8f0; }
[data-theme="dark"] .search-close-btn         { color: #64748b; }
[data-theme="dark"] .search-close-btn:hover   { color: #e2e8f0; }

/* 計數器佔位動畫（Shimmer 深色版）*/
[data-theme="dark"] .view-count-display:not([data-loaded]) {
  background: linear-gradient(90deg, #334155 25%, #475569 50%, #334155 75%);
  background-size: 200% 100%;
}

/* ── 文章共用元件（各文章 inline style 的深色覆寫）────── */

/* FAQ 問題標題（§5-B）
   文章 inline <style> 多半把 .faq-q 寫死為 #0f172a，深色模式下與背景幾乎同色、
   整行看不見。這裡用 [data-theme="dark"] .faq-q（特異度 0,2,0）壓過 inline 的
   .faq-q（0,1,0），因此不受 style.css 先載入的影響，也涵蓋日後新文章。 */
[data-theme="dark"] .faq-q                    { color: #e2e8f0; }

/* section-title、lead、insight/warn box（所有文章共用）*/
[data-theme="dark"] .section-title            { color: #e2e8f0; border-color: var(--c-accent); }
[data-theme="dark"] .lead                     { background: #0c1f35; color: #cbd5e1; border-left-color: #38bdf8; }
[data-theme="dark"] .insight-box              { background: #0c1a35; color: #bfdbfe; border-color: #3b82f6; }
[data-theme="dark"] .insight-box h3           { color: #93c5fd; }
[data-theme="dark"] .insight-box strong       { color: #93c5fd; }
[data-theme="dark"] .insight-box a            { color: #38bdf8; }
[data-theme="dark"] .tactical-box             { background: #052e16; color: #bbf7d0; border-color: #16a34a; }
[data-theme="dark"] .tactical-box h3          { color: #86efac; }
[data-theme="dark"] .tactical-box strong      { color: #86efac; }
[data-theme="dark"] .tactical-box a           { color: #4ade80; }
[data-theme="dark"] .warn-box                 { background: #1c0505; color: #fecaca; border-color: #ef4444; }
[data-theme="dark"] .warn-box strong          { color: #fca5a5; }
[data-theme="dark"] .warn-box a               { color: #f87171; }

/* KPI stat 卡片 */
[data-theme="dark"] .stat-card                      { background: #1e293b; border-color: #334155; }
[data-theme="dark"] .stat-card .label               { color: #94a3b8; }
[data-theme="dark"] .stat-card .value               { color: #e2e8f0; }
[data-theme="dark"] .stat-card .unit                { color: #94a3b8; }
[data-theme="dark"] .stat-card.accent-blue   .value { color: #60a5fa; }
[data-theme="dark"] .stat-card.accent-amber  .value { color: #fbbf24; }
[data-theme="dark"] .stat-card.accent-green  .value { color: #4ade80; }
[data-theme="dark"] .stat-card.accent-red    .value { color: #f87171; }
[data-theme="dark"] .stat-card.accent-orange .value { color: #fb923c; }
[data-theme="dark"] .stat-lbl   { color: #94a3b8; }
[data-theme="dark"] .stat-src   { color: #64748b; }

/* 表格內標籤色 */
[data-theme="dark"] .tag-worst { color: #f87171; }
[data-theme="dark"] .tag-best  { color: #4ade80; }

/* 表格（共用 .data-table）*/
[data-theme="dark"] .table-scroll                         { border-color: #334155; }
[data-theme="dark"] .data-table tbody td                  { color: #cbd5e1; border-color: #2d3f52; }
[data-theme="dark"] .data-table tbody tr:nth-child(odd)  td { background: #1e293b; }
[data-theme="dark"] .data-table tbody tr:nth-child(even) td { background: #162032; }
[data-theme="dark"] .data-table tbody tr:hover           td { background: #1e3a5f; }

/* 互動面板（bjj-finishing-moves）*/
[data-theme="dark"] .interactive-panel        { background: #1a2744; border-color: #334155; }
[data-theme="dark"] .interactive-panel h3     { color: #e2e8f0; }
[data-theme="dark"] .toggle-btn               { background: #1e293b; border-color: #475569; color: #94a3b8; }
[data-theme="dark"] .toggle-btn.active        { background: var(--c-accent); border-color: var(--c-accent); color: #fff; }

/* 招式動畫卡片 */
[data-theme="dark"] .tech-card                { background: #1e293b; border-color: #334155; }
[data-theme="dark"] .tc-name-zh               { color: #e2e8f0; }
[data-theme="dark"] .tc-desc                  { color: #64748b; }

/* 預測公式 */
[data-theme="dark"] .formula-box              { background: #0f1e30; border-color: #334155; color: #93c5fd; }
[data-theme="dark"] .pred-list li             { border-color: #334155; }
[data-theme="dark"] .pred-name                { color: #cbd5e1; }
[data-theme="dark"] .pred-bar-wrap            { background: #334155; }
[data-theme="dark"] .ref-list                 { color: #94a3b8; }
[data-theme="dark"] .ref-list a               { color: #38bdf8; }

/* 腳趾傷害文章 */
[data-theme="dark"] .toe-card                 { background: #1e293b; border-color: #334155; }
[data-theme="dark"] .toe-card-body            { color: #cbd5e1; }
[data-theme="dark"] .toe-card-title           { color: #e2e8f0; }
[data-theme="dark"] .toe-1 .toe-card-header   { background: #2a1520; }
[data-theme="dark"] .toe-2 .toe-card-header   { background: #261510; }
[data-theme="dark"] .toe-3 .toe-card-header   { background: #221d05; }
[data-theme="dark"] .toe-4 .toe-card-header   { background: #0f2018; }
[data-theme="dark"] .toe-5 .toe-card-header   { background: #0c1a35; }

/* UTMB 抽籤文章 */
[data-theme="dark"] .race-card                { background: #1e293b; border-color: #334155; }
[data-theme="dark"] .race-name                { color: #e2e8f0; }
[data-theme="dark"] .race-dist                { color: #94a3b8; }

/* ── 深色模式切換按鈕 ─────────────────────────────────── */
.theme-toggle {
  background: transparent;
  border: 1px solid transparent;
  color: #94a3b8;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: color .18s, border-color .18s, background .18s;
}
.theme-toggle:hover {
  color: #ffffff;
  border-color: rgba(34,211,238,.4);
  background: rgba(34,211,238,.12);
}
/* 淺色模式顯示月亮；深色模式顯示太陽 */
.theme-toggle .icon-sun  { display: none; }
.theme-toggle .icon-moon { display: block; }
[data-theme="dark"] .theme-toggle .icon-sun  { display: block; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-sun  { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: none; }
}

/* ── 語言切換按鈕（中文 ⇄ English） ───────────────────── */
.lang-toggle {
  background: transparent;
  border: 1px solid transparent;
  color: #94a3b8;
  min-width: 36px;
  height: 36px;
  padding: 0 .55rem;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: .82rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-decoration: none;
  transition: color .18s, border-color .18s, background .18s;
}
.lang-toggle:hover {
  color: #ffffff;
  border-color: rgba(34,211,238,.4);
  background: rgba(34,211,238,.12);
  text-decoration: none;
}

/* ==========================================================================
   文章共用 dark mode 補完（2026-05 audit）
   救下列重複出現於多篇文章的元件，避免每個 inline <style> 都要寫一次
   ========================================================================== */

/* 所有文章段落間距：明顯的半行空白（站台標準）
   * { margin: 0 } 把瀏覽器預設 <p> margin 重置，必須在這裡補回來，
   否則文章正文連續 <p> 會擠在一起無法分段。
   .insight-box / .tactical-box 等方塊內部的 p + p 因 class 選擇器
   特異度較高，會繼續沿用自己的 .7rem 規則。 */
article p + p { margin-top: 1.2rem; }

/* BJJ 系列：.highlight-best / .highlight-worst td 用 !important 才能蓋住原本淺色版 */
[data-theme="dark"] .highlight-best td  { background: #052e16 !important; }
[data-theme="dark"] .highlight-worst td { background: #1c0505 !important; }

/* BJJ 系列：.struct-icon / .muscle-icon（機制與結構卡片圖示色） */
[data-theme="dark"] .struct-card .struct-icon,
[data-theme="dark"] .muscle-card .muscle-icon { color: #93c5fd; }
[data-theme="dark"] .struct-icon svg,
[data-theme="dark"] .muscle-icon svg { stroke: #60a5fa; }

/* 賽道分析系列：.chart-wrap / .run-card / .gear-item 三大白卡 */
[data-theme="dark"] .chart-wrap {
  background: #1e293b;
  border-color: #334155;
  box-shadow: 0 2px 16px rgba(0,0,0,.45);
}
[data-theme="dark"] .chart-title { color: #cbd5e1; }

[data-theme="dark"] .run-card { background: #1e293b; border-color: #334155; }
[data-theme="dark"] .run-card .rname,
[data-theme="dark"] .run-card .rval   { color: #e2e8f0; }
[data-theme="dark"] .run-card .rlabel,
[data-theme="dark"] .run-card .rpct   { color: #94a3b8; }

[data-theme="dark"] .gear-item       { background: #1e293b; border-color: #334155; }
[data-theme="dark"] .gear-item h4    { color: #e2e8f0; }
[data-theme="dark"] .gear-item p     { color: #cbd5e1; }

[data-theme="dark"] .map-legend { color: #94a3b8; }
[data-theme="dark"] .note       { color: #94a3b8; }

/* 賽道分析系列：.amber-box 米黃補充框（taojin 20K / 30K 共用） */
[data-theme="dark"] .amber-box {
  background: #1c1101;
  color: #fde68a;
  border-color: #d97706;
}
[data-theme="dark"] .amber-box h3,
[data-theme="dark"] .amber-box strong { color: #fbbf24; }

/* ══ 首頁分區（2026-10 起，sync-homepage.js 產生）══════════════
   所有卡片都在靜態 HTML 裡；「看更多」只用 CSS 收合（Googlebot 照樣讀得到連結）。
   收合規則只在 html.js 時生效：head 內聯腳本先加 class，避免版面跳動，
   無 JS 環境則全部展開。 */
.series-nav-home {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem .6rem;
  margin: .4rem 0 2.2rem;
}
.series-nav-label {
  font-size: .85rem;
  font-weight: 600;
  color: var(--c-muted);
  margin-right: .2rem;
}
.series-chip {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  padding: .4rem .85rem;
  border: 1.5px solid var(--c-border);
  border-radius: 999px;
  background: var(--c-surface);
  color: var(--c-text);
  font-size: .9rem;
  font-weight: 500;
  transition: border-color var(--transition), color var(--transition);
}
.series-chip:hover { text-decoration: none; border-color: var(--c-accent); color: var(--c-accent); }
.series-chip-count {
  font-size: .75rem;
  color: var(--c-muted);
  background: var(--c-border);
  padding: .05em .55em;
  border-radius: 999px;
}
.home-section { margin-bottom: 3rem; scroll-margin-top: 80px; }
.home-section .index-header { margin-bottom: .6rem; }
.home-section-desc { color: var(--c-muted); font-size: .92rem; margin: 0 0 1.2rem; }
.home-section .index-header + .cards-grid { margin-top: 1.2rem; }
.home-all-header { margin: 1rem 0 1.6rem; padding-top: 1.6rem; border-top: 1px solid var(--c-border); }
/* 6 張預覽固定 3 欄 × 2 列（避免 auto-fill 在 4 欄寬度產生 4+2） */
.home-grid { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 1024px) { .home-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px)  { .home-grid { grid-template-columns: 1fr; } }
.js .home-grid.is-collapsible:not(.is-expanded) > .post-card:nth-child(n+7) { display: none; }
.show-more-btn { display: none; }
.js .show-more-btn {
  display: block;
  margin: 1.4rem auto 0;
  padding: .6rem 1.6rem;
  border: 1.5px solid var(--c-accent);
  border-radius: 999px;
  background: transparent;
  color: var(--c-accent);
  font: 600 .92rem var(--font-sans);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}
.js .show-more-btn:hover { background: var(--c-accent); color: #fff; }
.js[data-theme="dark"] .show-more-btn:hover { color: #0f172a; }

/* ══ 文章頁互動元件（assets/engage.js 產生）══════════════════ */
/* 招式圖鑑導覽：上一招／下一招 + 同類型其他招式 */
.move-nav {
  margin: 2.6rem 0 1.4rem;
  padding: 1.2rem 1.4rem;
  border: 1.5px solid var(--c-border);
  border-radius: var(--radius);
  background: var(--c-surface);
}
.move-nav-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: .8rem;
  margin-bottom: .9rem;
}
.move-nav-title { font-size: 1rem; font-weight: 700; color: var(--c-text); margin: 0; }
.move-nav-all { font-size: .85rem; white-space: nowrap; }
.move-nav-pn { display: grid; grid-template-columns: repeat(2, 1fr); gap: .8rem; }
.move-nav-link {
  display: block;
  padding: .7rem .9rem;
  border: 1px solid var(--c-border);
  border-radius: 8px;
  color: var(--c-text);
  min-width: 0;
}
.move-nav-link:hover { text-decoration: none; border-color: var(--c-accent); }
.move-nav-link.is-next { text-align: right; }
.move-nav-link.is-empty { visibility: hidden; }
.move-nav-dir { display: block; font-size: .78rem; color: var(--c-muted); margin-bottom: .2rem; }
.move-nav-name {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: .92rem;
  font-weight: 600;
  line-height: 1.45;
}
.move-nav-sub { font-size: .85rem; color: var(--c-muted); margin: 1rem 0 .5rem; }
.move-nav-chips { display: flex; flex-wrap: wrap; gap: .45rem; }
.move-nav-chip {
  padding: .3rem .75rem;
  border: 1px solid var(--c-border);
  border-radius: 999px;
  font-size: .85rem;
  color: var(--c-text);
}
.move-nav-chip:hover { text-decoration: none; border-color: var(--c-accent); color: var(--c-accent); }
@media (max-width: 640px) {
  .move-nav { padding: 1rem; }
  .move-nav-pn { grid-template-columns: 1fr; }
  .move-nav-link.is-next { text-align: left; }
  .move-nav-link.is-empty { display: none; }
}

/* 分享列 */
.share-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .55rem;
  margin: 1.6rem 0 1rem;
  padding: 1rem 1.2rem;
  border: 1.5px solid #86efac;
  border-radius: var(--radius);
  background: #f0fdf4;
}
.share-label { flex: 1 1 100%; font-size: .92rem; font-weight: 600; color: #14532d; margin-bottom: .2rem; }
.share-btn {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .45rem .95rem;
  border: 1px solid transparent;
  border-radius: 999px;
  font: 600 .88rem var(--font-sans);
  line-height: 1.2;
  cursor: pointer;
  color: #fff;
}
.share-btn:hover { text-decoration: none; color: #fff; filter: brightness(1.08); }
.share-line   { background: #04883b; }   /* LINE 綠加深：白字對比 ≥ 4.5 */
.share-fb     { background: #1877f2; }
.share-copy,
.share-native { background: #fff; color: #14532d; border-color: #86efac; }
.share-copy:hover,
.share-native:hover { color: #14532d; }
.share-native[hidden] { display: none; }
[data-theme="dark"] .share-bar   { background: #052e16; border-color: #16a34a; }
[data-theme="dark"] .share-label { color: #bbf7d0; }
[data-theme="dark"] .share-copy,
[data-theme="dark"] .share-native { background: #0f172a; color: #bbf7d0; border-color: #16a34a; }

/* 同招式「技術圖鑑 ↔ 力學與傷害」對照連結（scripts/add-twin-links.cjs 寫入靜態 HTML） */
.twin-link {
  margin: 0 0 1.6rem;
  padding: .8rem 1.1rem;
  border: 1.5px solid #fcd34d;
  border-radius: 10px;
  background: #fffbeb;
  color: #78350f;
  font-size: .93rem;
  line-height: 1.7;
}
.twin-link strong { color: #92400e; }
.twin-link a { color: #b45309; font-weight: 600; }
[data-theme="dark"] .twin-link        { background: #1c1101; color: #fde68a; border-color: #d97706; }
[data-theme="dark"] .twin-link strong { color: #fbbf24; }
[data-theme="dark"] .twin-link a      { color: #fbbf24; }
