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

/* ── 變數 ─────────────────────────────────────────────── */
:root {
  --c-bg:          #F7F4ED;
  --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; }
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;
}

/* ── 文章 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; }
  .site-title { font-size: .95rem; }
  .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-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-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 的深色覆寫）────── */

/* 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; }
}

/* ==========================================================================
   文章共用 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: .75rem; }

/* 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; }
