/* 全站主题层：保留各站暖色与人物插画，仅替换界面色彩；data-theme 在首帧前确定。 */
:root { color-scheme: light; --cs-panel: #fffaf3; --cs-text: #513e33; --cs-line: #dfcbbb; --cs-option: #fffdf9; --cs-selected: #f4e2d3; }
:root[data-theme="dark"] {
  color-scheme: dark;
  --cs-panel: #28232a; --cs-text: #f1e5dd; --cs-line: #5b4a50; --cs-option: #332b32; --cs-selected: #57404b;
  /* 首页、博客列表原有设计变量。 */
  --bg: #19181f; --bg-alt: #222029; --bg-warm-tint: #252129;
  --surface: #29252e; --surface-warm: #302832; --surface-glass: rgba(29,26,34,.78);
  --fg: #f2eae3; --fg-soft: #ded5d0; --muted: #b5a9b5; --muted-light: #a396a6;
  --border: rgba(242,234,227,.13); --border-warm: rgba(236,157,123,.25);
  --accent: #efa782; --accent-hover: #ffc3a1; --accent-soft: rgba(239,167,130,.12);
  --accent-glow: rgba(239,167,130,.10);
  /* 图库首页、相册、必应与图片详情共用同一组变量。 */
  --gallery-bg: #19191e; --gallery-bg-soft: #222128; --gallery-card: #29262e; --gallery-card-warm: #2e272d;
  --gallery-text: #efe5dd; --gallery-text-secondary: #bcb0a7; --gallery-text-hint: #a79a93;
  --gallery-accent: #efa782; --gallery-accent-hover: #ffc3a1; --gallery-gold: #e5b987;
  --gallery-border: rgba(239,229,221,.13); --gallery-border-warm: rgba(239,167,130,.22);
  --gallery-accent-bg: rgba(239,167,130,.12);
  /* 应用商店与人物笔记页共用的变量名，通过页面规则补充不同表面。 */
  --ink: #eee6df; --ink-soft: #c5bfb9; --paper: #211e25; --paper-warm: #28232b; --white: #2c2730;
  --line: rgba(238,230,223,.14); --coral: #efa084; --coral-deep: #f3ae91; --mint: #35483e; --pink: #e8a2b6;
  --color-bg: #19181f; --color-card: #29252e; --color-text-primary: #f2eae3; --color-text-secondary: #b5a9b5; --color-border: rgba(242,234,227,.13);
}
/* 无独立样式的占位/404 页同样具备可读的深色背景。 */
:root[data-theme="dark"] body { background-color: #19181f; color: #f2eae3; }
/* 统一主题入口和原生弹窗，样式与地球入口一致，键盘焦点清晰可见。 */
.cs-theme-button { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 38px; width: 38px; height: 38px; margin: 0; padding: 0; border: 1px solid rgba(128,95,75,.25); border-radius: 50%; background: transparent; color: inherit; cursor: pointer; }
.cs-theme-button:hover { background: rgba(176,117,87,.14); }
.cs-theme-button svg { flex-shrink: 0; }
.cs-theme-button:focus-visible, .cs-theme-dialog button:focus-visible { outline: 2px solid #c88769; outline-offset: 3px; }
.cs-display-actions { display: flex; justify-self: end; align-items: center; gap: 8px; }
/* 应用导航原先以语言按钮推到右侧，主题按钮与它相邻；详情页单独右对齐。 */
.detail-page .nav > .cs-theme-button, .blog-article-navbar > .cs-theme-button { margin-left: auto; }
.cs-theme-dialog { box-sizing: border-box; position: fixed; inset: 0; width: min(380px, calc(100vw - 32px)); max-height: calc(100dvh - 40px); margin: auto; padding: 24px; overflow: auto; border: 1px solid var(--cs-line); border-radius: 20px; color: var(--cs-text); background: var(--cs-panel); box-shadow: 0 20px 80px #0003; font: 14px/1.6 system-ui,sans-serif; }
.cs-theme-dialog::backdrop { background: #201b2466; backdrop-filter: blur(6px); }
.cs-theme-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.cs-theme-heading h2 { margin: 0; font: 600 21px/1.4 system-ui,sans-serif; }
.cs-theme-heading button { width: 32px; height: 32px; padding: 0; border: 0; background: transparent; color: inherit; font-size: 24px; cursor: pointer; }
.cs-theme-options { margin-top: 18px; display: grid; gap: 9px; }
.cs-theme-options button { min-height: 44px; padding: 9px; border: 1px solid var(--cs-line); border-radius: 10px; background: var(--cs-option); color: inherit; font: inherit; cursor: pointer; }
.cs-theme-options button:hover, .cs-theme-options button[aria-pressed="true"] { background: var(--cs-selected); border-color: #ba8565; }
.cs-theme-error { color: #d9716c; margin: 12px 0 0; }
/* 首页固定导航、移动展开菜单与语言弹窗同步替换半透明表面。 */
:root[data-theme="dark"] :is(.nav#nav, .nav-mobile-menu) { background: var(--surface-glass); }
:root[data-theme="dark"] .cs-language-dialog { background: var(--cs-panel); color: var(--cs-text); border-color: var(--cs-line); }
:root[data-theme="dark"] .cs-language-options button { background: var(--cs-option); border-color: var(--cs-line); }
:root[data-theme="dark"] .cs-language-options button:is(:hover,[aria-pressed="true"]) { background: var(--cs-selected); }
:root[data-theme="dark"] .cs-language-dialog p { color: #c4b3b7; }
/* 博客仍保留 dark-mode 兼容变量，此处保证弱化文字在深色下有足够对比。 */
:root[data-theme="dark"] body.dark-mode { --muted: #b5a9b5; --muted-light: #a396a6; --accent: #efa782; --accent-hover: #ffc3a1; --article-muted: #b7aaa4; }
/* 小晴笔记：深色纸张依旧保留纹理、圆孔和暖粉色便签，而非整页图像反色。 */
:root[data-theme="dark"] body:has(.notebook) { background-color: #211c24; background-image: radial-gradient(circle, #594553 1.25px, transparent 1.45px); }
:root[data-theme="dark"] .notebook { border-color: #5a434c; box-shadow: 5px 6px 0 #392c36, 9px 11px 0 #2c232d, 0 20px 65px #0005; }
:root[data-theme="dark"] .binding { background-image: radial-gradient(circle 7px at 9px 19px, #100e15 0 4px, #69535c 4.5px 5.5px, #42333b 6px 7px, transparent 7.5px); border-color: #5a434c; }
:root[data-theme="dark"] :is(.page-heading,.name-tags span,.section-title,.page-footer,dl div) { border-color: #5a434c; }
:root[data-theme="dark"] :is(.page-heading,.name-tags span,.small-note,dt,.scrap-index,.scrap .hand-note,.page-footer,h1 span,.scribble) { color: #cbb1a5; }
:root[data-theme="dark"] .note { background: #352c2b; border-color: #5a4841; }
:root[data-theme="dark"] .scrap-pink { background: #3c2937; }
:root[data-theme="dark"] .scrap-yellow { background: #3a3224; }
:root[data-theme="dark"] .scrap-green { background: #2b352e; }
:root[data-theme="dark"] .portrait-halo { background-color: #382b31; }
:root[data-theme="dark"] :is(.portrait figcaption,.book-tab) { background: #61433f; color: #f5e4d5; }
:root[data-theme="dark"] blockquote span { background: linear-gradient(transparent 66%, #665035 66%, #665035 90%, transparent 90%); }
:root[data-theme="dark"] .closing { background: #30252e; }
:root[data-theme="dark"] .postcard { border-color: #645047; }
:root[data-theme="dark"] :is(.gallery-card,.gallery-update) { background-color: #302730; border-color: #5a434c; }
:root[data-theme="dark"] :is(.gallery-controls button,.image-preview-actions button,.image-preview-navigation button) { background: #392c36; color: #f1e5dd; border-color: #5b4a50; }
:root[data-theme="dark"] .image-preview { background: #211d25; color: #f1e5dd; }
:root[data-theme="dark"] :is(.image-preview-heading,.image-preview-navigation) { border-color: #5b4a50; }
/* 应用页替换硬编码奶油表面；图标、应用截图与 CSS 绘制的示意屏幕保留原色。 */
:root[data-theme="dark"] .site-header { background: rgba(29,26,34,.9); border-color: var(--line); }
:root[data-theme="dark"] :is(.catalog-section,.detail-hero) { background: var(--paper); }
:root[data-theme="dark"] :is(.art-card,.catalog-bottom,.catalog-empty,.floating-date-card,.screenshot-image-frame,.screenshot-control,.channel-card,.download-empty) { background: var(--white); color: var(--ink); border-color: var(--line); }
:root[data-theme="dark"] :is(.channel-card:hover,.screenshot-control:hover) { background: #39323d; }
:root[data-theme="dark"] :is(.app-card-type,.app-card-category,.release-current) { background: #423139; color: #f1b89c; }
:root[data-theme="dark"] :is(.app-slogan,.catalog-bottom-title,.catalog-bottom-copy,.detail-stats strong,.channel-info strong,.app-facts dd,.release-content,.rich-text,.rich-text h2,.rich-text h3) { color: var(--ink); }
:root[data-theme="dark"] :is(.app-description,.app-card-meta,.breadcrumbs,.detail-kicker,.detail-slogan,.detail-stats span,.section-aside,.date-card-name,.channel-info span,.channel-hash-value,.app-facts dt,.release-meta,.release-empty,.about-empty,.screenshot-empty,.catalog-count,.catalog-subtitle,.hero-description,.site-footer,.back-top) { color: #b9b1af; }
/* 采用独立深色按钮表面，避免 ink 从深字变亮字后使原按钮变成白底白字。 */
:root[data-theme="dark"] :is(.button--dark,.nav-cta) { background: #534039; color: #fff3e9; }
:root[data-theme="dark"] :is(.button--dark:hover,.nav-cta:hover) { background: #705044; }
@media (max-width: 600px) {
  /* 两个入口并排保留居中标题；缩小间距，不改变导航折叠逻辑。 */
  .cs-display-actions { gap: 5px; }
  .topbar { gap: 8px; }
  .topbar :is(.cs-theme-button,.cs-language-button) { width: 34px; height: 34px; flex-basis: 34px; }
}
/* 图库磨砂导航使用同一深色玻璃，避免正文变暗后留下亮色横条。 */
:root[data-theme="dark"] .gallery-navbar { background: rgba(29,26,34,.88); }
/* 笔记轨道的更新卡和翻页按钮也属于纸张界面，跟随主题而保留图片原色。 */
:root[data-theme="dark"] .gallery-update { background: #332a30; }
:root[data-theme="dark"] .gallery-controls button { background: #392c36; border-color: #5b4a50; }
:root[data-theme="dark"] .gallery-controls button:hover:not(:disabled) { background: #57404b; }

/* 应用详情与列表的硬编码标题、摘要和链接补齐对比，装饰屏幕不参与覆盖。 */
:root[data-theme="dark"] :is(.detail-title-row h1,.catalog-bottom p,.text-link,.channel-info h3,.app-facts dd,.rich-text h1,.rich-text h4) { color: var(--ink); }
:root[data-theme="dark"] :is(.catalog-bottom p span,.art-card-subcaption,.art-card-caption,.detail-copy > p,.download-copy > p,.visual-orbit-label,.about-rich-text,.rich-text p,.rich-text li) { color: #c4b8b3; }
:root[data-theme="dark"] .kicker-separator { color: #ac9d97; }
/* 文章在 DOMContentLoaded 前也直接按根节点主题呈现，避免旧 body 变量造成亮色首帧。 */
:root[data-theme="dark"] .blog-article { --article-bg: #19181f; --article-card: #29252e; --article-fg: #ede6db; --article-secondary: #c5b9ae; --article-muted: #b7aaa4; --article-accent: #efa782; --article-soft: rgba(239,167,130,.12); --article-border: rgba(255,255,255,.13); --article-code: #15151c; }
:root[data-theme="dark"] .release-version strong { color: var(--ink); }

/* 应用详情的下载面板原用硬编码奶油渐变；深色下替换整块表面并明确文字层级。
   限定下载区域，保留截图和应用图标的原始色彩。 */
:root[data-theme="dark"] .download-panel {
  background: radial-gradient(ellipse at 2% 100%, rgba(239,167,130,.08), transparent 36%), linear-gradient(118deg, #2c2730, #242129);
  border-color: var(--line);
  box-shadow: 0 18px 45px #0003;
}
:root[data-theme="dark"] .download-copy h2 { color: #f2eae3; }
:root[data-theme="dark"] .download-copy > p:not(.eyebrow) { color: #c9bfb9; }
:root[data-theme="dark"] :is(.download-copy .eyebrow, .download-footnote) { color: #bcb4b0; }
:root[data-theme="dark"] .download-panel .secure-mark { color: #b2d3b7; background: rgba(126,170,130,.2); }
