/* =====================================================================
   mlr3HTE 文档站样式
     版式参照 tidyverse / pkgdown 站点：深色顶栏 navbar + 中央正文 +
     右侧 sticky「On this page」目录 + 多行页脚。
     主题通过 [data-theme] 切换 CSS 变量；默认跟随系统，用户可手动覆盖并存 localStorage。
   ===================================================================== */

/* 1 变量：亮色（默认） ------------------------------------------------- */
:root {
  --bg:            #ffffff;
  --bg-soft:       #f6f8fa;
  --bg-code:       #f8f8f8;
  --fg:            #1f2328;
  --fg-muted:      #5a636c;
  --fg-faint:      #8c959f;
  --border:        #dfe4ea;
  --border-soft:   #eaeef2;
  --accent:        #1266b5;
  --accent-soft:   #e8f2fb;
  --accent-fg:     #ffffff;
  --warn-bg:       #fff8e5;
  --warn-border:   #d4a72c;
  --ok-bg:         #e8f7ec;
  --ok-border:     #1a7f37;
  --danger-bg:     #fdeceb;
  --danger-border: #cf222e;
  --shadow:        0 1px 3px rgba(31, 35, 40, .08);
  --shadow-lg:     0 8px 24px rgba(31, 35, 40, .16);
  --radius:        6px;
  --nav-bg:        #2c3e50;
  --nav-fg:        #ffffff;
  --nav-fg-dim:    rgba(255, 255, 255, .72);
  --nav-hover:     rgba(255, 255, 255, .12);
  --nav-active:    rgba(255, 255, 255, .18);
  --nav-h:         56px;
  --font:          -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue",
                   "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-mono:     ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
                   "Liberation Mono", monospace;
}

/* 2 变量：暗色 --------------------------------------------------------- */
[data-theme="dark"] {
  --bg:            #0d1117;
  --bg-soft:       #161b22;
  --bg-code:       #161b22;
  --fg:            #e6edf3;
  --fg-muted:      #9198a1;
  --fg-faint:      #6e7681;
  --border:        #30363d;
  --border-soft:   #21262d;
  --accent:        #58a6ff;
  --accent-soft:   #121d2f;
  --accent-fg:     #ffffff;
  --warn-bg:       #2b2000;
  --warn-border:   #9e6a03;
  --ok-bg:         #0f2913;
  --ok-border:     #238636;
  --danger-bg:     #2d1214;
  --danger-border: #f85149;
  --shadow:        0 1px 3px rgba(0, 0, 0, .5);
  --shadow-lg:     0 8px 24px rgba(0, 0, 0, .7);
  --nav-bg:        #10161d;
  --nav-fg:        #e6edf3;
  --nav-fg-dim:    rgba(230, 237, 243, .68);
  --nav-hover:     rgba(255, 255, 255, .08);
  --nav-active:    rgba(255, 255, 255, .14);
}

/* 3 基础 --------------------------------------------------------------- */
* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* 4 顶栏（pkgdown navbar）---------------------------------------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 10px;
  height: var(--nav-h);
  padding: 0 20px;
  background: var(--nav-bg);
  color: var(--nav-fg);
  border-bottom: none;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 17px;
  letter-spacing: .01em;
  color: var(--nav-fg);
  white-space: nowrap;
}
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 24px; height: 24px;
  border-radius: 5px;
  display: block;
  flex: none;
}

/* 导航项 */
.navbar { display: flex; align-items: center; gap: 2px; margin-left: 10px; }
.nav-link {
  display: inline-block;
  padding: 6px 11px;
  border-radius: var(--radius);
  color: var(--nav-fg-dim);
  font-size: 14px;
  white-space: nowrap;
}
.nav-link:hover { background: var(--nav-hover); color: var(--nav-fg); text-decoration: none; }
.nav-link.active {
  background: var(--nav-active);
  color: var(--nav-fg);
  font-weight: 600;
}

/* 带下拉子菜单的导航项（dplyr 官网风格） */
.nav-item { position: relative; display: inline-flex; align-items: center; }
.nav-item > .nav-link { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.nav-caret {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 30px;
  width: 20px;
  margin-left: -3px;
  padding: 0 4px 0 0;
  border: 0;
  border-radius: 0 var(--radius) var(--radius) 0;
  background: none;
  color: var(--nav-fg-dim);
  cursor: pointer;
}
.nav-item.open > .nav-link,
.nav-item.open > .nav-caret,
.nav-caret:hover { background: var(--nav-hover); color: var(--nav-fg); }
.nav-caret:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

/* 小三角：用 border 画，不依赖字体 */
.caret-tri {
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 4.5px solid currentColor;
}

.nav-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 70;
  display: none;
  min-width: 250px;
  max-width: 340px;
  padding: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}
.nav-item.open > .nav-dropdown { display: block; }
/* 桌面端 hover 即展开；触屏/窄屏走 .open（JS 点击） */
@media (hover: hover) and (min-width: 901px) {
  .nav-item:hover > .nav-dropdown { display: block; }
  .nav-item:hover > .nav-caret { background: var(--nav-hover); color: var(--nav-fg); }
}
.nav-dropdown .nav-link {
  display: block;
  padding: 7px 10px;
  border-radius: var(--radius);
  color: var(--fg);
  font-size: 13.5px;
  line-height: 1.35;
  white-space: normal;
}
.nav-dropdown .nav-link:hover { background: var(--bg-soft); color: var(--accent); text-decoration: none; }
.nav-dropdown .nav-link.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

/* 窄屏：下拉在抽屉里静态展开，不再悬浮 */
@media (max-width: 900px) {
  .nav-item { display: block; }
  .nav-caret { display: none; }
  .nav-item > .nav-link { border-radius: var(--radius); }
  .nav-dropdown {
    position: static;
    display: none;
    min-width: 0;
    max-width: none;
    padding: 2px 0 4px 14px;
    border: 0;
    border-left: 2px solid var(--border);
    border-radius: 0;
    box-shadow: none;
    background: none;
  }
  .nav-item.open > .nav-dropdown { display: block; }
  .nav-item:hover > .nav-dropdown { display: none; }
  .nav-item.open:hover > .nav-dropdown { display: block; }
}

.topbar .spacer { flex: 1; }

/* 顶栏上的按钮：深色底上要反色 */
.topbar .btn {
  height: 32px;
  border-color: rgba(255, 255, 255, .28);
  background: rgba(255, 255, 255, .08);
  color: var(--nav-fg);
  font-size: 13px;
}
.topbar .btn:hover { border-color: var(--nav-fg); color: var(--nav-fg); }
.topbar .btn.icon { width: 32px; padding: 0; }
.gh-link { display: inline-flex; align-items: center; justify-content: center; }
#lang-toggle { font-weight: 600; min-width: 62px; }

/* 首页 hero 封面图 */
.hero {
  margin: 0 0 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-soft);
  line-height: 0;
}
.hero img { width: 100%; height: auto; display: block; }

/* 首页介绍区的包图标 */
.logo-block {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 4px 0 16px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-soft);
}
.logo-block img { flex: none; border-radius: 8px; }
.logo-caption { margin: 0; font-size: 13px; color: var(--fg-muted); line-height: 1.6; }
@media (max-width: 640px) {
  .logo-block { flex-direction: column; text-align: center; }
}

/* 5 搜索框 ------------------------------------------------------------- */
.search-wrap {
  position: relative;
  flex: 0 1 300px;
  min-width: 150px;
}
#search-input {
  width: 100%;
  height: 32px;
  padding: 0 30px 0 30px;
  border: 1px solid rgba(255, 255, 255, .28);
  border-radius: 999px;
  background: rgba(255, 255, 255, .10);
  color: var(--nav-fg);
  font-family: var(--font);
  font-size: 13.5px;
  outline: none;
}
#search-input::placeholder { color: var(--nav-fg-dim); }
#search-input:focus {
  background: rgba(255, 255, 255, .16);
  border-color: var(--nav-fg);
}
.search-icon {
  position: absolute; left: 10px; top: 50%;
  transform: translateY(-50%);
  color: var(--nav-fg-dim); font-size: 12px; pointer-events: none;
}
.search-kbd {
  position: absolute; right: 9px; top: 50%;
  transform: translateY(-50%);
  font-size: 11px; color: var(--nav-fg-dim);
  border: 1px solid rgba(255, 255, 255, .3); border-radius: 4px;
  padding: 0 5px; pointer-events: none;
}

/* 6 搜索结果浮层 ------------------------------------------------------- */
#search-results {
  position: absolute;
  top: 40px; left: 0; right: 0;
  max-height: 70vh;
  overflow-y: auto;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  display: none;
}
#search-results.open { display: block; }
.sr-item {
  display: block;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border-soft);
  color: var(--fg);
  cursor: pointer;
}
.sr-item:last-child { border-bottom: none; }
.sr-item:hover, .sr-item.active { background: var(--accent-soft); text-decoration: none; }
.sr-title { font-weight: 600; font-size: 13.5px; }
.sr-path  { font-size: 11.5px; color: var(--fg-faint); margin-left: 6px; }
.sr-snip  { font-size: 12.5px; color: var(--fg-muted); margin-top: 2px;
            overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-snip mark { background: var(--warn-bg); color: inherit; padding: 0 1px; }
.sr-empty { padding: 14px; color: var(--fg-muted); font-size: 13px; }

/* 7 按钮（非顶栏处）---------------------------------------------------- */
.btn {
  height: 34px;
  padding: 0 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-soft);
  color: var(--fg);
  font-family: var(--font);
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.icon { width: 34px; padding: 0; font-size: 15px; }

/* 8 布局：中央正文 + 右侧目录 ------------------------------------------ */
.layout {
  display: flex;
  align-items: flex-start;
  gap: 40px;
  max-width: 1360px;
  margin: 0 auto;
  padding: 0 24px;
}

/* 9 正文 --------------------------------------------------------------- */
.content {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 900px;
  padding: 34px 0 96px;
}
.content h1 { font-size: 32px; margin: 0 0 8px; line-height: 1.3; letter-spacing: -.01em; }
.content h2 {
  font-size: 24px;
  margin: 44px 0 14px;
  padding-bottom: 7px;
  border-bottom: 1px solid var(--border-soft);
  scroll-margin-top: 72px;
}
.content h3 { font-size: 18px; margin: 30px 0 10px; scroll-margin-top: 72px; }
.content h4 { font-size: 15px; margin: 20px 0 8px; color: var(--fg-muted); }
.content p  { margin: 0 0 15px; }
.content ul, .content ol { margin: 0 0 15px; padding-left: 24px; }
.content li { margin-bottom: 5px; }

.lede { font-size: 17px; color: var(--fg-muted); margin-bottom: 26px; line-height: 1.7; }

/* 9b 右侧「本页目录」--------------------------------------------------- */
.toc {
  flex: 0 0 216px;
  position: sticky;
  top: var(--nav-h);
  height: calc(100vh - var(--nav-h));
  overflow-y: auto;
  padding: 34px 0 60px;
  border-left: 1px solid var(--border-soft);
  display: none;
}
.toc.shown { display: block; }
.toc-title {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--fg-faint);
  padding-left: 14px;
  margin-bottom: 8px;
}
.toc-link {
  display: block;
  padding: 4px 12px 4px 14px;
  border-left: 2px solid transparent;
  color: var(--fg-muted);
  font-size: 13px;
  line-height: 1.5;
}
.toc-link:hover { color: var(--fg); text-decoration: none; }
.toc-link.toc-sub { padding-left: 26px; font-size: 12.5px; }
.toc-link.active {
  color: var(--accent);
  border-left-color: var(--accent);
  font-weight: 600;
}

/* 10 代码 -------------------------------------------------------------- */
code {
  font-family: var(--font-mono);
  font-size: 13px;
  background: var(--bg-code);
  border: 1px solid var(--border-soft);
  border-radius: 4px;
  padding: 1px 5px;
}
pre {
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  overflow-x: auto;
  margin: 0 0 18px;
  line-height: 1.6;
}
pre code {
  background: none; border: none; padding: 0; font-size: 13px;
}

/* 11 参考文献列表（博士论文式：分节 + 全局连续编号 + 用途一行）--------- */
.ref-list {
  margin: 0 0 24px;
  padding-left: 46px;
  font-size: 14px;
}
.ref-list li {
  margin-bottom: 20px;
  padding-left: 6px;
  scroll-margin-top: calc(var(--nav-h) + 16px);
}
.ref-list li::marker {
  color: var(--fg-faint);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.ref-cite { margin-bottom: 5px; line-height: 1.65; }
.ref-links { margin-bottom: 5px; font-size: 13px; }
.ref-links a { margin-right: 4px; }
.ref-note { color: var(--fg-faint); font-style: italic; }
.ref-use {
  color: var(--fg-muted);
  font-size: 13px;
  line-height: 1.65;
  border-left: 2px solid var(--border);
  padding-left: 10px;
}
.ref-use strong { color: var(--fg); }

/* 11 表格 -------------------------------------------------------------- */
.table-wrap { overflow-x: auto; margin: 0 0 20px; }
table {
  border-collapse: collapse;
  width: 100%;
  font-size: 14px;
}
th, td {
  border: 1px solid var(--border);
  padding: 8px 11px;
  text-align: left;
  vertical-align: top;
}
th { background: var(--bg-soft); font-weight: 600; }
tbody tr:nth-child(even) { background: var(--bg-soft); }

/* 12 提示框（pkgdown callout 风格：左侧色条 + 图标）-------------------- */
.callout {
  position: relative;
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  background: var(--bg-soft);
  border-radius: var(--radius);
  padding: 12px 16px 12px 42px;
  margin: 0 0 20px;
}
.callout::before {
  content: "ℹ";
  position: absolute;
  left: 16px; top: 12px;
  font-size: 15px;
  color: var(--accent);
}
.callout.warn   { border-left-color: var(--warn-border);   background: var(--warn-bg); }
.callout.warn::before   { content: "⚠"; color: var(--warn-border); }
.callout.ok     { border-left-color: var(--ok-border);     background: var(--ok-bg); }
.callout.ok::before     { content: "✓"; color: var(--ok-border); }
.callout.danger { border-left-color: var(--danger-border); background: var(--danger-bg); }
.callout.danger::before { content: "✕"; color: var(--danger-border); }
.callout p:last-child { margin-bottom: 0; }
.callout-title { font-weight: 700; margin-bottom: 4px; }

/* 13 图片 / 公式块 ----------------------------------------------------- */
.fig { margin: 0 0 20px; text-align: center; }
.fig img {
  max-width: 100%;
  height: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
}
.fig figcaption { margin-top: 6px; font-size: 13px; color: var(--fg-faint); }
.fig-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 14px;
  margin: 0 0 20px;
}
.formula {
  font-family: var(--font-mono);
  background: var(--bg-soft);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin: 0 0 10px;
  font-size: 13.5px;
  overflow-x: auto;
}

/* 14 卡片网格 ---------------------------------------------------------- */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(258px, 1fr));
  gap: 14px;
  margin: 0 0 26px;
}
.card {
  display: block;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  background: var(--bg);
  color: var(--fg);
}
.card:hover {
  border-color: var(--accent);
  text-decoration: none;
  box-shadow: var(--shadow);
}
.card-title { font-weight: 700; margin-bottom: 5px; }
.card-desc  { font-size: 13.5px; color: var(--fg-muted); }

/* 14b 文章目录列表（pkgdown / dplyr Articles 风格）---------------------- */
.article-list {
  list-style: none;
  margin: 18px 0 26px;
  padding: 0;
  border-top: 1px solid var(--border);
}
.article-list > li { border-bottom: 1px solid var(--border); }
.article-list > li > a {
  display: flex;
  gap: 14px;
  padding: 13px 6px;
  color: inherit;
  transition: background .12s ease;
}
.article-list > li > a:hover {
  background: var(--bg-soft);
  text-decoration: none;
}
.article-list .art-num {
  flex: 0 0 26px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--fg-faint);
  line-height: 1.55;
}
.article-list .art-body { display: block; min-width: 0; }
.article-list .art-body strong {
  display: block;
  font-size: 15.5px;
  color: var(--accent);
}
.article-list .art-body em {
  display: block;
  margin-top: 3px;
  font-style: normal;
  font-size: 13.5px;
  line-height: 1.62;
  color: var(--fg-muted);
}

/* 15 API 函数块 -------------------------------------------------------- */
.fn {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin: 0 0 22px;
  background: var(--bg);
}
.fn-name {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 700;
  color: var(--accent);
  word-break: break-all;
}
.fn-sig {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--fg-muted);
  background: var(--bg-code);
  border: 1px solid var(--border-soft);
  border-radius: 4px;
  padding: 6px 9px;
  margin: 8px 0 12px;
  overflow-x: auto;
  white-space: pre;
}
.fn-args { width: 100%; }

/* 16 徽章 -------------------------------------------------------------- */
.badge {
  display: inline-block;
  font-size: 11.5px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  margin-left: 7px;
  vertical-align: middle;
}
.badge.grey { background: var(--bg-soft); color: var(--fg-muted); }

/* 16b 首页同屏双语 ---------------------------------------------------- */
.lang-divider { margin: 3rem 0 1.25rem; border: none; border-top: 2px solid var(--border); }
.lang-block-title {
  color: var(--fg-muted);
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: .02em;
  margin-top: 0;
}

/* 17 页脚 -------------------------------------------------------------- */
.footer {
  border-top: 1px solid var(--border);
  background: var(--bg-soft);
  margin-top: 24px;
  padding: 30px 24px 26px;
  color: var(--fg-muted);
  font-size: 13.5px;
}
.footer-inner {
  max-width: 1360px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 2.2fr) minmax(0, 1fr) minmax(0, 1fr);
  gap: 32px;
}
.footer-col { min-width: 0; }
.footer-col a { display: block; color: var(--fg-muted); margin-bottom: 4px; }
.footer-col a:hover { color: var(--accent); }
.footer-col p { margin: 6px 0 0; line-height: 1.7; max-width: 52ch; }
.footer-title {
  font-weight: 700;
  font-size: 12px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--fg);
  margin-bottom: 8px;
}
.footer-ver { font-weight: 500; color: var(--fg-faint); letter-spacing: 0; }
.footer-bottom {
  max-width: 1360px;
  margin: 22px auto 0;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  color: var(--fg-faint);
  font-size: 12.5px;
}

/* 18 移动端 ------------------------------------------------------------ */
.menu-btn { display: none; }

/* 顶栏空间紧张时先收搜索快捷键提示，给下拉三角让位 */
@media (max-width: 1180px) {
  .search-kbd { display: none; }
  .nav-link { padding: 6px 9px; font-size: 13.5px; }
}

@media (max-width: 1080px) {
  .toc { display: none !important; }
  .layout { padding: 0 20px; gap: 0; }
  .content { max-width: none; }
}

@media (max-width: 900px) {
  .navbar {
    position: fixed;
    top: var(--nav-h); left: 0;
    z-index: 50;
    width: 250px;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    margin: 0;
    padding: 12px;
    background: var(--bg);
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    transform: translateX(-100%);
    transition: transform .2s ease;
  }
  .navbar.open { transform: translateX(0); }
  .nav-link { color: var(--fg-muted); padding: 8px 10px; }
  .nav-link:hover { background: var(--bg-soft); color: var(--fg); }
  .nav-link.active { background: var(--accent-soft); color: var(--accent); }
  .menu-btn { display: inline-flex; align-items: center; justify-content: center; }
  .search-wrap { flex: 1 1 auto; }
  .search-kbd { display: none; }
  .content { padding: 26px 0 80px; }
  .footer-inner { grid-template-columns: 1fr; gap: 20px; }
}

@media (max-width: 560px) {
  .topbar { padding: 0 12px; gap: 6px; }
  .brand { font-size: 15px; }
  .gh-link { display: none; }
  .layout { padding: 0 14px; }
}

/* 10b 代码块增强：R 语法高亮 + 复制按钮（版式参照 dplyr 官网）------- */
.code-block {
  position: relative;
  margin: 0 0 18px;
}
.code-block > pre {
  margin: 0;                 /* 外边距交给 .code-block，避免重复 */
}
.code-block:hover > pre {
  border-color: var(--border);
}

/* 复制按钮：默认半透明，鼠标进入代码块后变实 */
.copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 28px;
  padding: 0 9px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--bg);
  color: var(--fg-muted);
  font-family: var(--font);
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity .15s ease, color .15s ease, border-color .15s ease;
}
.code-block:hover .copy-btn,
.copy-btn:focus-visible { opacity: 1; }
.copy-btn:hover { color: var(--accent); border-color: var(--accent); }
.copy-btn.copied {
  color: var(--ok-border);
  border-color: var(--ok-border);
  opacity: 1;
}
.copy-btn svg { display: block; }
@media (hover: none) {          /* 触屏设备没有 hover，按钮常显 */
  .copy-btn { opacity: 1; }
}

/* 输出块：不注入复制按钮，右上角只放一个「输出」角标 */
.code-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 2px 7px;
  border-radius: 4px;
  background: var(--bg-soft);
  border: 1px solid var(--border-soft);
  color: var(--fg-faint);
  font-size: 11px;
  letter-spacing: .02em;
  user-select: none;
}
.code-block.is-output > pre {
  background: var(--bg-soft);
  border-left: 3px solid var(--border);
}

/* 高亮配色：亮色 */
pre code.language-r { color: var(--fg); }
.tok-com  { color: #6a737d; font-style: italic; }
.tok-str  { color: #0a7d3f; }
.tok-num  { color: #0550ae; }
.tok-kw   { color: #cf222e; }
.tok-const{ color: #8250df; }
.tok-fn   { color: #6639ba; }
.tok-op   { color: #0550ae; }
.tok-br   { color: #57606a; }

/* 高亮配色：暗色（对比度按 WCAG AA 调过） */
[data-theme="dark"] .tok-com  { color: #8b949e; }
[data-theme="dark"] .tok-str  { color: #7ee787; }
[data-theme="dark"] .tok-num  { color: #79c0ff; }
[data-theme="dark"] .tok-kw   { color: #ff7b72; }
[data-theme="dark"] .tok-const{ color: #d2a8ff; }
[data-theme="dark"] .tok-fn   { color: #d2a8ff; }
[data-theme="dark"] .tok-op   { color: #79c0ff; }
[data-theme="dark"] .tok-br   { color: #8b949e; }
