/* ==========================================================================
   Shared Design Tokens & Base CSS for PPTBits Showcase
   ========================================================================== */

:root {
  /* 6 theme tokens — 取自 jimu.chat 后台层（--dash-*）实测值。
     选后台层而非官网首页层：后台层亮色为默认，与本站固定浅色一致；
     官网首页层默认暗色（data-theme=dark 写死在 html 上），与本站规定冲突。 */
  --bg: #f5f8fd;                        /* jimu --dash-bg 微蓝灰底（原 oklch(100% 0 0) 纯白） */
  --surface: #ffffff;                   /* jimu --dash-surface-solid 卡片面（原 98.5%，面比底暗；现面比底亮） */
  --fg: #0f172a;                        /* jimu --dash-text 正文，slate-900（原 oklch(15% 0.01 240)） */
  --muted: #64748b;                     /* jimu --dash-text-muted 次级文字，slate-500（原 48%） */
  --border: rgba(188, 204, 228, 0.68);  /* jimu --dash-border 半透带蓝调（原 oklch(91.5%) 实色） */
  /* 品牌蓝，在 jimu --dash-primary（#2557b4）基础上加深一档。
     依据：原值对白字对比度 6.77:1，只过 WCAG AA（4.5:1）不过 AAA（7:1）；
     本值 8.35:1 过 AAA。同色相往深走，仍是同一支蓝而非海军蓝。
     对比度按 WCAG 2.1 相对亮度公式实测，非估算。 */
  --accent: #1e4a9c;

  /* 3 baseline tokens for global geometry */
  --radius: 12px;
  --font-size-base: 15px;
  --space-scale: 0.65;

  /* Font families */
  --font-display: -apple-system, BlinkMacSystemFont, 'SF Pro Display', system-ui, sans-serif;
  --font-body: -apple-system, BlinkMacSystemFont, 'SF Pro Text', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'IBM Plex Mono', ui-monospace, Menlo, monospace;

  /* Status Colors — jimu --dash-{success,info,warning,danger} 亮色档 */
  --status-success: #10b981;
  --status-info: #3b82f6;
  --status-warning: #f59e0b;
  --status-danger: #ef4444;

  /* 以下两个变量被 src/scripts/home.js 的缩略图占位块引用
     （var(--surface-2,#f4f4f5) / var(--text-muted,#71717a)），
     但此前 CSS 从未定义它们，所以一直落到那两个硬编码兜底值 ——
     结果是占位块配色不跟随主题。这里补上定义使其生效。 */
  --surface-2: #edf4ff;                 /* jimu --dash-bg-soft 次级底色 */
  --text-muted: #94a3b8;                /* jimu --dash-text-subtle 弱化文字，slate-400 */
}

/* Dark Theme Overrides (exposes tokens to Tweak panel theme-switching)
   取值取自 jimu.chat --dash-* 暗色档（[data-theme=dark] 覆盖块）。 */
[data-theme="dark"] {
  --bg: #07111f;                        /* jimu --dash-bg 暗底 */
  --surface: #101a2d;                   /* jimu --dash-surface-solid 暗面 */
  --fg: #f8fafc;                        /* jimu --dash-text，slate-50 */
  --muted: #cbd5e1;                     /* jimu --dash-text-muted，slate-300 */
  --border: rgba(148, 163, 184, 0.18);  /* jimu --dash-border 暗色边框 */
  --accent: #7eabdf;                    /* jimu --dash-primary 暗色主色 */

  /* 状态色此前没有暗色覆盖，会继承亮色档的 500 级取值，在深底上对比度不足。
     jimu 的做法是暗色下整体升一阶（500 → 400），照此对齐。 */
  --status-success: #34d399;
  --status-info: #60a5fa;
  --status-warning: #fbbf24;
  --status-danger: #f87171;

  --surface-2: #0f172a;                 /* jimu --dash-bg-soft 暗色次级底 */
  --text-muted: #94a3b8;                /* jimu --dash-text-subtle（亮暗同值） */
}

/* ==========================================================================
   Base Styles & Reset
   ========================================================================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: var(--font-size-base);
  scroll-behavior: smooth;
}

body {
  background-color: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Scrollbar Customization */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--bg);
}
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--muted);
}

/* Typography Defaults */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

p {
  color: var(--muted);
  max-width: 65ch;
}

a {
  color: inherit;
  text-decoration: none;
}

/* Keyboard Focus Ring */
*:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ==========================================================================
   Layout & Grid
   ========================================================================== */
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 calc(2rem * var(--space-scale));
}

/* Custom Grid Columns with Space Scale */
.grid {
  display: grid;
  gap: calc(1.5rem * var(--space-scale));
}
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 900px) {
  .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

/* Bento Grid System */
.bento-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: calc(1.5rem * var(--space-scale));
}
.bento-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: calc(1.5rem * var(--space-scale));
  position: relative;
  overflow: hidden;
}

/* ==========================================================================
   Header Navigation
   ========================================================================== */
.header {
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  background-color: rgba(255, 255, 255, 0.86);  /* jimu --dash-surface 半透表面 */
}
[data-theme="dark"] .header {
  background-color: rgba(15, 23, 42, 0.86);  /* jimu 暗色 --dash-surface */
}

.header-container {
  display: flex;
  height: calc(4.5rem * var(--space-scale));
  align-items: center;
  justify-content: space-between;
}

.logo-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
}
.logo-icon {
  /* 承载积木 logo 图片。刻意不设 background-color 与 border-radius：
     logo 自带圆形浅蓝底，再叠一层强调色方块底会盖住图案、四角还会露出方块边缘。
     尺寸比原先的纯色字母块（24px）略大一点 —— 图案有内部结构，等尺寸下观感偏小。 */
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.logo-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;   /* 保持比例，不裁切 */
  display: block;
}

/* 导航栏的「logo 图标 + 站名」整块，点击回首页。
   Pro 徽章刻意留在这个链接之外 —— 可点击范围只含图标与站名。
   颜色显式写回 --fg：否则会被全局 a 规则染成链接色，破坏导航栏观感。 */
.logo-home {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--fg);
  text-decoration: none;
  transition: opacity 0.16s ease;
}
.logo-home:hover {
  opacity: 0.72;          /* 克制的可点击反馈，不做位移以免带动整行 */
  text-decoration: none;
  color: var(--fg);
}
.logo-home:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

.nav-links {
  display: flex;
  list-style: none;
  gap: 1.5rem;
  align-items: center;
}

.nav-link {
  font-weight: 500;
  color: var(--muted);
  font-size: 0.95rem;
  padding: 0.25rem 0.5rem;
  transition: color 0.15s ease;
  position: relative;
}

.nav-link:hover, .nav-link.active {
  color: var(--fg);
}

.nav-link[aria-current="page"]::after {
  content: "";
  position: absolute;
  bottom: -20px;
  left: 0;
  right: 0;
  height: 2px;
  background-color: var(--accent);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 0.95rem;
  padding: calc(0.6rem * var(--space-scale)) calc(1.2rem * var(--space-scale));
  border-radius: var(--radius);
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease;
  gap: 0.5rem;
}

.btn-primary {
  background-color: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}
.btn-primary:hover {
  opacity: 0.9;
}

.btn-secondary {
  background-color: var(--surface);
  color: var(--fg);
  border-color: var(--border);
}
.btn-secondary:hover {
  background-color: var(--border);
}

/* 禁用态：用 muted 文字色而非 opacity 表达不可用，避免文字对比度掉到不可辨识 */
.btn-disabled,
.btn[aria-disabled="true"] {
  color: var(--muted);
  background-color: var(--bg);
  border-color: var(--border);
  cursor: not-allowed;
  pointer-events: none;
}

/* Semantic Status Badge */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 9999px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
}
.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}
.badge-dot.success { background-color: var(--status-success); }
.badge-dot.info { background-color: var(--status-info); }
.badge-dot.warning { background-color: var(--status-warning); }
.badge-dot.danger { background-color: var(--status-danger); }

/* ==========================================================================
   Footer
   ========================================================================== */
.footer {
  border-top: 1px solid var(--border);
  padding: calc(4rem * var(--space-scale)) 0;
  background-color: var(--bg);
  margin-top: auto;
}

.footer-top {
  display: grid;
  grid-template-columns: 2fr repeat(3, 1fr);
  gap: calc(3rem * var(--space-scale));
  margin-bottom: calc(3rem * var(--space-scale));
}

@media (max-width: 768px) {
  .footer-top {
    grid-template-columns: 1fr;
    gap: calc(2rem * var(--space-scale));
  }
}

.footer-logo-desc {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.footer-links-col {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.footer-links-col h4 {
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--fg);
}
.footer-links {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.footer-link {
  font-size: 0.9rem;
  color: var(--muted);
  transition: color 0.15s ease;
}
.footer-link:hover {
  color: var(--fg);
}

.footer-bottom {
  border-top: 1px solid var(--border);
  padding-top: calc(2rem * var(--space-scale));
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  color: var(--muted);
}
@media (max-width: 600px) {
  .footer-bottom {
    flex-direction: column;
    gap: 1rem;
    text-align: center;
  }
}

/* ==========================================================================
   Detail / Playground Page Specific Components
   ========================================================================== */
.playground-layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr) 260px;
  gap: calc(1.5rem * var(--space-scale));
  padding: calc(2rem * var(--space-scale)) 0;
  border-bottom: 1px solid var(--border);
  min-height: 600px;
}
@media (max-width: 1024px) {
  .playground-layout {
    grid-template-columns: 200px minmax(0, 1fr);
  }
  .tweak-panel-sidebar {
    grid-column: span 2;
  }
}
@media (max-width: 768px) {
  .playground-layout {
    grid-template-columns: 1fr;
  }
  .tweak-panel-sidebar {
    grid-column: span 1;
  }
}

.playground-sidebar {
  border-right: 1px solid var(--border);
  padding-right: 1rem;
}

.playground-main {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  min-width: 0;
}

.preview-stage-container {
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: var(--radius);
  height: 400px;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.preview-grid-back {
  position: absolute;
  inset: 0;
  background-image: 
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 24px 24px;
  opacity: 0.35;
  pointer-events: none;
}

/* Tweak Control Panel (Right Sidebar) */
.tweak-panel-sidebar {
  border-left: 1px solid var(--border);
  padding-left: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}
@media (max-width: 1024px) {
  .tweak-panel-sidebar {
    border-left: none;
    border-top: 1px solid var(--border);
    padding-left: 0;
    padding-top: 1.5rem;
  }
}

.tweak-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: calc(1rem * var(--space-scale));
}

.tweak-title {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--fg);
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.5rem;
}

.tweak-control-item {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}
.tweak-control-item:last-child {
  margin-bottom: 0;
}
.tweak-control-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--fg);
  display: flex;
  justify-content: space-between;
}
.tweak-control-label span.value-badge {
  font-family: var(--font-mono);
  color: var(--fg);
  font-size: 0.78rem;
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 0.05rem 0.35rem;
  border-radius: 3px;
  letter-spacing: 0.02em;
}

.tweak-slider {
  width: 100%;
  accent-color: var(--accent);
  cursor: pointer;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  outline: none;
}

.tweak-toggle-group {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) * 0.75);
  overflow: hidden;
  background: var(--bg);
}
.tweak-toggle-btn {
  background: none;
  border: none;
  padding: 0.4rem 0;
  font-size: 0.85rem;
  color: var(--muted);
  cursor: pointer;
  font-weight: 500;
  transition: all 0.15s ease;
}
.tweak-toggle-btn.active {
  background: var(--accent);
  color: var(--bg);
  font-weight: 600;
}

/* Code Preview panel */
.code-container {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}
.code-header {
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  display: flex;
  padding: 0 1rem;
  height: 40px;
  align-items: center;
  justify-content: space-between;
}
.code-tabs {
  display: flex;
  gap: 1rem;
}
.code-tab-btn {
  background: none;
  border: none;
  height: 40px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  position: relative;
}
.code-tab-btn.active {
  color: var(--fg);
  font-weight: 600;
}
.code-tab-btn.active::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--accent);
}
.code-body {
  padding: 1rem 1.25rem;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  overflow-x: auto;
  white-space: pre;
  color: var(--fg);
  max-height: 220px;
  line-height: 1.6;
}

/* Actual Live Interactive Render Components */
.ppt-render-wrapper {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  transition: all 0.2s ease;
}

/* Bento render */
.render-bento-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: calc(1rem * var(--space-scale));
  width: 100%;
  max-width: 600px;
}
.render-bento-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: calc(1.2rem * var(--space-scale));
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 110px;
  transition: all 0.2s ease;
}
.render-bento-card.wide {
  grid-column: span 2;
}

/* Timeline render */
.render-timeline {
  display: flex;
  flex-direction: column;
  gap: calc(2rem * var(--space-scale));
  width: 85%;
  max-width: 500px;
  position: relative;
}
.render-timeline::before {
  content: "";
  position: absolute;
  left: 7px;
  top: 8px;
  bottom: 8px;
  width: 2px;
  background: var(--border);
}
.render-timeline-item {
  display: flex;
  gap: 1.5rem;
  opacity: 0;
  transform: translateY(15px);
  animation: slideInReveal 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
.render-timeline-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--bg);
  border: 2px solid var(--accent);
  position: relative;
  z-index: 1;
  flex-shrink: 0;
}
.render-timeline-content h4 {
  font-size: 1rem;
  margin-bottom: 0.25rem;
}
.render-timeline-content p {
  font-size: 0.85rem;
}

@keyframes slideInReveal {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Contrast split render */
.render-contrast-box {
  width: 100%;
  max-width: 550px;
  height: 250px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.render-contrast-panel {
  padding: calc(1.5rem * var(--space-scale));
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

/* Chevron Steps render */
.render-steps {
  display: flex;
  width: 100%;
  max-width: 550px;
  gap: calc(0.5rem * var(--space-scale));
}
.render-step-item {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: calc(1rem * var(--space-scale));
  text-align: center;
  position: relative;
  background: var(--bg);
}
.render-step-item.active {
  border-color: var(--accent);
  background: var(--surface);
}
.render-step-number {
  font-family: var(--font-mono);
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}
.render-step-title {
  font-size: 0.85rem;
  font-weight: 600;
}

.category-layout {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: calc(2rem * var(--space-scale));
  padding: calc(3rem * var(--space-scale)) 0;
  border-bottom: 1px solid var(--border);
}
@media (max-width: 768px) {
  .category-layout {
    grid-template-columns: 1fr;
  }
}

.category-sidebar {
  display: flex;
  flex-direction: column;
  gap: 2rem;
  position: sticky;
  top: calc(6.5rem * var(--space-scale));
  height: fit-content;
}

.sidebar-title {
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--fg);
  margin-bottom: 0.75rem;
  font-weight: 700;
}

.sidebar-menu {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.sidebar-menu-item a {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  color: var(--muted);
  font-weight: 500;
  font-size: 0.95rem;
  transition: all 0.15s ease;
}

.sidebar-menu-item a:hover {
  color: var(--fg);
  background-color: var(--surface);
}

.sidebar-menu-item.active a {
  color: var(--fg);
  background-color: var(--surface);
  font-weight: 600;
  border-left: 3px solid var(--accent);
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}

.sidebar-menu-item-count {
  font-size: 0.8rem;
  font-family: var(--font-mono);
  color: var(--muted);
}

/* ==========================================================================
   pb-select —— 自建下拉筛选组件
   替代原生 <select>。原生控件的两个硬限制促成这次自建：
     1. 展开面板高度与滚动完全由浏览器决定，无法限高 —— 主题下拉实测 36 项，
        原生面板会拉到几乎撑满视口。
     2. <option> 内不能放元素，装不下来源色点这类结构。
   本组件用 button + role="listbox" 面板实现，因此 aria-expanded、
   aria-selected、焦点与键盘导航都必须手写，见 category_main.js 的 makeSelect。
   ========================================================================== */
.pb-select {
  position: relative;
  flex-shrink: 0;
}

.pb-select-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.45rem 0.6rem 0.45rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--fg);
  font-size: 0.9rem;
  font-family: inherit;
  line-height: 1.4;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}
.pb-select-trigger:hover {
  border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
}
.pb-select-trigger:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent);
}
.pb-select[data-open="true"] .pb-select-trigger {
  border-color: var(--accent);
}

.pb-select-value {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pb-select-caret {
  flex-shrink: 0;
  color: var(--muted);
  transition: transform 0.18s ease;
}
.pb-select[data-open="true"] .pb-select-caret {
  transform: rotate(180deg);
}

.pb-select-panel {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  /* 面板比触发按钮宽：按钮定死 200/220px，而选项文字最长可达
     「Beautiful HTML Templates（351）」。右对齐 + max-width 双管
     防止在 .explorer-header 右端溢出视口。 */
  min-width: 100%;
  width: max-content;
  max-width: 340px;
  z-index: 60;
  padding: 0.3rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 12px 32px rgba(30, 74, 156, 0.14);
}

.pb-select-list {
  /* 限高 + 内部滚动，是本组件替代原生 select 的核心目的。
     288px = 8 行 × 36px，第 9 项起需滚动，面板不会无限拉长。 */
  max-height: 288px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}
.pb-select-list::-webkit-scrollbar { width: 8px; }
.pb-select-list::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

.pb-select-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 36px;
  padding: 0.4rem 0.55rem;
  border-radius: calc(var(--radius) - 5px);
  font-size: 0.875rem;
  color: var(--fg);
  cursor: pointer;
  user-select: none;
}
.pb-select-option:hover,
.pb-select-option[data-active="true"] {
  background: color-mix(in srgb, var(--accent) 8%, transparent);
}
.pb-select-option[aria-selected="true"] {
  color: var(--accent);
  font-weight: 600;
}

.pb-select-option-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pb-select-option-count {
  flex-shrink: 0;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--muted);
}
.pb-select-option[aria-selected="true"] .pb-select-option-count {
  color: color-mix(in srgb, var(--accent) 72%, var(--muted));
}

.pb-select-check {
  flex-shrink: 0;
  width: 14px;
  color: var(--accent);
  opacity: 0;
}
.pb-select-option[aria-selected="true"] .pb-select-check {
  opacity: 1;
}

/* 来源色点。SOURCES 数据里没有颜色字段，这 6 个色值是本组件为区分来源
   自行指定的展示属性，不进数据层 —— 它只服务于视觉辨识，换配色时改这里即可。 */
.pb-select-dot {
  flex-shrink: 0;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
}
.pb-select-dot[data-src="dashi"]    { background: #2f6fd0; }
.pb-select-dot[data-src="bht"]      { background: #10b981; }
.pb-select-dot[data-src="htmlppt"]  { background: #f59e0b; }
.pb-select-dot[data-src="guizang"]  { background: #8b5cf6; }
.pb-select-dot[data-src="pptmaster"]{ background: #ec4899; }
.pb-select-dot[data-src="kimi"]     { background: #14b8a6; }

@media (prefers-reduced-motion: reduce) {
  .pb-select-trigger,
  .pb-select-caret { transition: none; }
}

/* Category Grid & Cards */
.explorer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  /* 允许换行 + gap：右侧筛选栏是三个控件（搜索框固定 220px + 来源下拉 +
     主题下拉），窄屏下总宽超出可用空间。不允许换行时，带 flex-shrink:0 的
     筛选栏会把左侧标题块压到最小内容宽度 —— 实测「组件全览」被压成一列
     竖排单字，描述段落同样逐字换行。 */
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
/* 标题块吃掉剩余空间并允许收缩到 0：flex 项目默认 min-width:auto，
   即不小于最小内容宽度，但那个「最小内容宽度」对中文是单字宽，
   于是压缩时不换行而是竖排。 */
.explorer-header > :first-child {
  flex: 1 1 auto;
  min-width: 0;
}

.explorer-grid {
  grid-template-columns: repeat(3, 1fr);
}
@media (max-width: 1100px) {
  .explorer-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
@media (max-width: 600px) {
  .explorer-grid {
    grid-template-columns: 1fr;
  }
}

.component-explorer-card {
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.component-explorer-preview {
  height: 240px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

/* 缩放模拟容器 */
.card-render-scaler {
  transform: scale(0.38);
  transform-origin: center;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none; /* 禁止预览画布捕获点击事件 */
}

/* 卡片交互控制区 */
.card-controls-section {
  border-top: 1px solid var(--border);
  background: var(--bg);
  padding: calc(0.75rem * var(--space-scale));
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.card-control-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.card-control-row .tweak-control-label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 0;
  flex-shrink: 0;
  width: 85px;
}

.card-control-row .tweak-slider {
  flex-grow: 1;
}

.card-control-row .tweak-toggle-group {
  width: 100%;
}

.card-control-row select {
  width: 100%;
  font-size: 0.8rem;
  padding: 0.25rem;
}

.component-explorer-meta {
  padding: calc(1rem * var(--space-scale));
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.component-explorer-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--fg);
  margin-bottom: 0.25rem;
}
.component-explorer-desc {
  font-size: 0.85rem;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Category grid preview elements */
.grid-preview-box {
  width: 90%;
  height: 80%;
  border: 1px dashed var(--border);
  border-radius: 4px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
.grid-preview-badge {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  padding: 0.15rem 0.4rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--muted);
}

@media (prefers-reduced-motion: no-preference) {
  .btn, .nav-link, .footer-link {
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  }
  .card-hover-effect {
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.2s ease;
  }
  .card-hover-effect:hover {
    transform: translateY(-2px);
    border-color: var(--accent);
  }
}

/* ==========================================================================
   Homepage Specific Components
   ========================================================================== */
.hero-section {
  padding: calc(6rem * var(--space-scale)) 0 calc(4rem * var(--space-scale)) 0;
  text-align: center;
  border-bottom: 1px solid var(--border);
}
.hero-tagline {
  font-size: clamp(2.5rem, 5vw, 4.25rem);
  line-height: 1.1;
  font-weight: 800;
  color: var(--fg);
  margin-bottom: 1.5rem;
  letter-spacing: -0.02em;
}
.hero-sub {
  font-size: 1.25rem;
  color: var(--muted);
  max-width: 58ch;
  margin: 0 auto 2.5rem auto;
}

/* Stats Bar */
.stats-bar {
  border-bottom: 1px solid var(--border);
  padding: calc(2rem * var(--space-scale)) 0;
  background: var(--surface);
}
.stats-container {
  /* grid 四等分，不用 flex + space-between。
     实测 space-between 下四项宽度 89/116/111/80px，中心落在 64/421/790/1140，
     而等分应为 150/450/750/1050 —— 偏移 -86 ~ +90px，且首末两项贴住容器边缘。
     根因是 space-between 按剩余空间分配间隙，位置随内容宽度漂移；
     数字位数一变（如组件数上万）位置又会重排。grid 让位置与内容宽度脱钩。 */
  display: grid;
  grid-template-columns: repeat(4, 1fr);
}
.stat-item {
  text-align: center;
  padding: 0 1rem;
}
/* 分隔线由相邻选择器自动生成，天然只出现在项与项之间。
   此前是在 index.html 里给第 2 项写 border-left+border-right、第 3 项写 border-right，
   零散且容易漏 —— 加减一项就得重算哪几个该带线。 */
.stat-item + .stat-item {
  border-left: 1px solid var(--border);
}
@media (max-width: 768px) {
  .stats-container {
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem 0;
  }
  /* 两列时相邻选择器会给第 3 项（换行后的首项）也加上左边框，
     用 nth-child 精确保留竖线在每行的第 2 项左侧。 */
  .stat-item + .stat-item { border-left: none; }
  .stat-item:nth-child(even) { border-left: 1px solid var(--border); }
}
.stat-val {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  color: var(--fg);
  font-variant-numeric: tabular-nums;
  /* 大字号下默认字距偏松，收 -0.02em 才紧实 */
  letter-spacing: -0.02em;
  line-height: 1.15;
}
.stat-label {
  font-size: 0.85rem;
  color: var(--muted);
  /* 刻意不设 text-transform 与 letter-spacing：这四个 label 全是中文，
     uppercase 对中文无字形变换、letter-spacing 0.05em 只是把字距拉散。
     若将来加入英文 label 再单独处理，不要为此恢复全局规则。 */
  margin-top: 0.3rem;
}

/* Section Header */
.section-header {
  margin-bottom: calc(3rem * var(--space-scale));
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
}
.section-title-group h2 {
  font-size: 1.85rem;
  margin-bottom: 0.5rem;
}
.section-title-group p {
  font-size: 1rem;
}

/* Featured Showcase (Bento Grid Layouts) */
.showcase-section {
  padding: calc(5rem * var(--space-scale)) 0;
  border-bottom: 1px solid var(--border);
}

.bento-col-4 { grid-column: span 4; }
.bento-col-5 { grid-column: span 5; }
.bento-col-6 { grid-column: span 6; }
.bento-col-7 { grid-column: span 7; }
.bento-col-8 { grid-column: span 8; }
.bento-col-12 { grid-column: span 12; }

@media (max-width: 900px) {
  .bento-col-4, .bento-col-5, .bento-col-6, .bento-col-7, .bento-col-8 {
    grid-column: span 12;
  }
}

.showcase-card {
  height: 380px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.showcase-preview-area {
  flex-grow: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) * 0.75);
  margin-bottom: 1rem;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Mini Mockup Visuals */
.mockup-grid-lines {
  position: absolute;
  inset: 0;
  background-image: 
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 20px 20px;
  opacity: 0.4;
}

.mockup-stat {
  font-family: var(--font-display);
  font-size: 3.5rem;
  font-weight: 800;
  text-align: center;
  position: relative;
  z-index: 1;
}

.mockup-timeline {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  width: 80%;
  position: relative;
}
.mockup-timeline::before {
  content: "";
  position: absolute;
  left: 7px;
  top: 5px;
  bottom: 5px;
  width: 1px;
  background: var(--border);
}
.mockup-timeline-item {
  display: flex;
  gap: 1rem;
  align-items: center;
}
.mockup-timeline-dot {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--bg);
  border: 2px solid var(--accent);
  position: relative;
  z-index: 1;
}
.mockup-timeline-text {
  font-size: 0.9rem;
  font-weight: 500;
}

.mockup-bento {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  width: 85%;
  height: 80%;
}
.mockup-bento-cell {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 4px;
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.mockup-bento-cell.double {
  grid-column: span 2;
}

/* ==========================================================================
   Dashi PPT 10 Interactive Showcase Components CSS
   ========================================================================== */

/* Background Bokeh Decorator */
.bokeh-bg {
  position: absolute;
  inset: 0;
  overflow: hidden;
  z-index: 0;
  pointer-events: none;
}
.bokeh-circle {
  position: absolute;
  border-radius: 50%;
  filter: blur(40px);
  opacity: 0.15;
}
.bokeh-circle-1 {
  width: 120px;
  height: 120px;
  background: var(--accent);
  top: -20px;
  right: -20px;
}
.bokeh-circle-2 {
  width: 150px;
  height: 150px;
  background: var(--muted);
  bottom: -30px;
  left: -30px;
}

/* Glassmorphism sidebar for Cover Editorial */
.glass-sidebar {
  background: rgba(244, 248, 255, 0.82);  /* jimu --dash-surface-soft 柔化表面 */
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(188, 204, 228, 0.68);  /* jimu --dash-border */
  border-radius: var(--radius);
  padding: calc(1.5rem * var(--space-scale));
  z-index: 1;
}
[data-theme="dark"] .glass-sidebar {
  background: rgba(30, 41, 59, 0.72);           /* jimu 暗色 --dash-surface-soft */
  border: 1px solid rgba(148, 163, 184, 0.18);  /* jimu 暗色 --dash-border */
}

/* 01. Cover Editorial */
.ppt-cover-editorial {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: calc(2rem * var(--space-scale));
  width: 100%;
  max-width: 650px;
  position: relative;
  z-index: 1;
}

/* 02. Cover Minimal */
.ppt-cover-minimal {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  max-width: 500px;
  width: 100%;
  position: relative;
  z-index: 1;
}
.glass-orb {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.86), var(--accent) 70%);
  border: 1px solid rgba(188, 204, 228, 0.68);  /* jimu --dash-border（此处是描边，非表面色） */
  margin-bottom: 1.5rem;
  box-shadow: 0 8px 24px rgba(30, 74, 156, 0.10);  /* 蓝调阴影，对齐 jimu --dash-shadow-card 色相 */
}

/* 03. Cover Bento */
.ppt-cover-bento {
  display: grid;
  grid-template-columns: 2fr 1.2fr;
  gap: calc(1rem * var(--space-scale));
  width: 100%;
  max-width: 600px;
  position: relative;
  z-index: 1;
}
.ppt-bento-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: calc(1.2rem * var(--space-scale));
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

/* 04. Cover Masthead */
.ppt-cover-masthead {
  width: 100%;
  max-width: 600px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: calc(2rem * var(--space-scale));
  position: relative;
  overflow: hidden;
  z-index: 1;
}

/* 06. Big Num columns */
.ppt-bignum-row {
  display: flex;
  gap: calc(1.5rem * var(--space-scale));
  width: 100%;
  max-width: 600px;
  position: relative;
  z-index: 1;
}
.ppt-bignum-col {
  flex: 1;
  border-left: 1px solid var(--border);
  padding-left: calc(1rem * var(--space-scale));
}
.ppt-bignum-col:first-child {
  border-left: none;
  padding-left: 0;
}
.ppt-bignum-val {
  font-family: var(--font-display);
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--accent);
}

/* 07. Stat Grid */
.ppt-stat-grid {
  display: grid;
  gap: calc(1rem * var(--space-scale));
  width: 100%;
  max-width: 600px;
  position: relative;
  z-index: 1;
}
.ppt-stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: calc(1rem * var(--space-scale));
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* 09. Contents Page */
.ppt-contents-list {
  display: flex;
  flex-direction: column;
  gap: calc(0.75rem * var(--space-scale));
  width: 100%;
  max-width: 550px;
  position: relative;
  z-index: 1;
}
.ppt-contents-item {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius);
  padding: calc(0.8rem * var(--space-scale)) calc(1.2rem * var(--space-scale));
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.ppt-contents-num {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--accent);
}

/* 10. Quadrant Analysis */
.ppt-method-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: calc(1rem * var(--space-scale));
  width: 100%;
  max-width: 550px;
  position: relative;
  z-index: 1;
}
.ppt-method-block {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: calc(1rem * var(--space-scale));
  background: var(--surface);
}

/* ==========================================================================
   Homepage Enhancements — Hero Strip & Theme Matrix
   ========================================================================== */

/* 真实组件橱窗：无缝循环滚动的透视轮播带 */
.hero-strip {
  position: relative;
  height: 320px;
  margin: 0 calc(-1 * 2rem * var(--space-scale));
  overflow: hidden;
  -webkit-mask-image: linear-gradient(to bottom, transparent 0%, black 18%, black 82%, transparent 100%);
  mask-image: linear-gradient(to bottom, transparent 0%, black 18%, black 82%, transparent 100%);
}
.hero-strip-track {
  display: flex;
  width: max-content;
  justify-content: flex-start;
  align-items: flex-start;
  animation: heroMarquee 45s linear infinite;
}
.hero-strip:hover .hero-strip-track {
  animation-play-state: paused;
}
@keyframes heroMarquee {
  from { transform: perspective(1200px) rotateX(7deg) translateX(0); }
  to { transform: perspective(1200px) rotateX(7deg) translateX(-50%); }
}
.hero-strip-track img {
  width: 380px;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: 0 12px 32px rgba(30, 74, 156, 0.07);  /* jimu --dash-shadow-card */
  flex-shrink: 0;
  margin-right: calc(1.5rem * var(--space-scale));
}
.hero-strip-track img:nth-child(odd) {
  transform: translateY(22px);
}
.hero-strip-track img:nth-child(3n) {
  transform: translateY(-10px);
}
@media (prefers-reduced-motion: reduce) {
  .hero-strip-track {
    animation: none;
    transform: perspective(1200px) rotateX(7deg);
    justify-content: center;
  }
}
@media (max-width: 900px) {
  .hero-strip { height: 220px; }
  .hero-strip-track img { width: 260px; }
}

/* 主题风格矩阵卡片 */
.theme-card {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  overflow: hidden;
  text-decoration: none;
  color: inherit;
}
.theme-card img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  display: block;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.theme-card-meta {
  padding: calc(0.75rem * var(--space-scale)) calc(0.9rem * var(--space-scale));
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.theme-card-meta h3 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--fg);
}
.theme-card-meta span {
  font-size: 0.78rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
@media (max-width: 900px) {
  #theme-matrix { grid-template-columns: repeat(2, 1fr) !important; }
}
@media (max-width: 600px) {
  #theme-matrix { grid-template-columns: 1fr !important; }
}



/* ==========================================================================
   Detail Page — 两栏就地编辑布局
   左侧组件列表 + 右侧预览画布；样式参数收进画布右上角的折叠入口。
   ========================================================================== */
.editor-layout {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr) 250px;
  gap: calc(1.5rem * var(--space-scale));
  padding: calc(1.5rem * var(--space-scale)) 0;
  border-bottom: 1px solid var(--border);
  align-items: start;
}
@media (max-width: 1024px) {
  .editor-layout { grid-template-columns: 220px minmax(0, 1fr); }
  .style-sidebar { grid-column: span 2; }
}
@media (max-width: 768px) {
  .editor-layout { grid-template-columns: 1fr; }
  .style-sidebar { grid-column: span 1; }
}

.editor-sidebar {
  border-right: 1px solid var(--border);
  padding-right: 1rem;
  display: flex;
  flex-direction: column;
  /* 列表自身滚动，避免整页滚动 */
  max-height: calc(100vh - 130px);
  overflow-y: auto;
  position: sticky;
  top: 1rem;
}
@media (max-width: 768px) {
  .editor-sidebar {
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding-right: 0;
    padding-bottom: 1rem;
    position: static;
    max-height: 40vh;
  }
}

.editor-main {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-width: 0;
}

/* 画布容器：折叠面板绝对定位在它右上角 */
.editor-canvas {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  overflow: hidden;
  aspect-ratio: 16 / 9;
}
.editor-canvas > iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
  background: #fff;
}

/* 右侧样式参数栏（常驻） */
.style-sidebar {
  border-left: 1px solid var(--border);
  padding-left: 1rem;
  /* 参数多时自身滚动，避免顶高整页 */
  max-height: calc(100vh - 130px);
  overflow-y: auto;
  position: sticky;
  top: 1rem;
}
@media (max-width: 1024px) {
  .style-sidebar {
    border-left: none;
    border-top: 1px solid var(--border);
    padding-left: 0;
    padding-top: 1rem;
    position: static;
    max-height: none;
  }
}

/* 状态行 */
.editor-status {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  font-size: 0.8rem;
  color: var(--muted);
}
.editor-status .sep { color: var(--border); }

/* 纯图标按钮（复制类操作） */
.icon-btn {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--fg);
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  transition: background 0.16s ease, border-color 0.16s ease;
}
.icon-btn:hover { border-color: var(--fg); }
.icon-btn.done {
  background: var(--fg);
  color: var(--bg);
  border-color: var(--fg);
}

/* ==========================================================================
   回到顶部浮动按钮（组件库页）
   滚动发生在 window 上（.category-sidebar 是 sticky，页面没有内部滚动容器），
   所以按钮监听 window 并滚回 window 顶部。
   z-index 取 90：在内容之上、header（z-index:100）之下，避免盖住吸顶导航。
   ========================================================================== */
.back-to-top {
  position: fixed;
  /* 跟随内容区右边缘而非贴视口角落。
     实测 .container 固定 max-width:1200px 居中，右侧留白随视口变化：
     1280px 视口留 40px、1440px 留 120px、1680px 留 240px。
     若写死 right:20px，宽屏上按钮会离内容区一两百 px，孤零零挂在屏幕角。
     max() 两个分支：
       · 宽屏（≳1400px）走后者，按钮落在内容区右缘外侧一点，与正文呼应；
       · 窄屏走前者的 24px 兜底，避免算出负值或压住内容。 */
  right: max(24px, calc((100vw - 1200px) / 2 - 60px));
  bottom: 60px;
  width: 46px;
  height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  color: var(--fg);
  cursor: pointer;
  z-index: 90;
  box-shadow: 0 4px 14px rgba(30, 74, 156, 0.10);
  /* 默认隐藏：opacity 归零并摘掉指针事件，避免不可见时仍可点中 */
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: opacity 0.2s ease, transform 0.2s cubic-bezier(0.16, 1, 0.3, 1),
              visibility 0.2s ease, border-color 0.16s ease, box-shadow 0.2s ease;
}
.back-to-top.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
.back-to-top:hover {
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(30, 74, 156, 0.16);
}
/* 按钮内只有 SVG 图标、没有文字，键盘用户完全依赖焦点环定位，故显式给出 */
.back-to-top:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.back-to-top svg { display: block; }

@media (max-width: 768px) {
  .back-to-top {
    /* 小屏没有容器外留白，max() 必然落到兜底分支，直接写死更直观。
       40px 是为了触摸目标不低于常见可点下限。 */
    right: 16px;
    bottom: 20px;
    width: 40px;
    height: 40px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .back-to-top { transition: opacity 0.2s ease, visibility 0.2s ease; }
  .back-to-top,
  .back-to-top.is-visible,
  .back-to-top:hover { transform: none; }
}
