/* Only night colors are overridden; light colors come from the original theme. */
:root { color-scheme: light; }
:root[data-theme="dark"] {
  color-scheme: dark;
  --blog-accent: #39c5bb;
  --blog-bg: #202124;
  --blog-surface: #292a2d;
  --blog-text: #c4c7cc;
  --blog-heading: #e3e5e8;
  --blog-muted: #9b9fa7;
  --blog-link: #83c9bf;
  --blog-border: #3c4045;
  --blog-nav: rgba(32, 33, 36, .97);
  --blog-banner: #bcbcbc;
  --blog-control-bg: #34363b;
  --blog-control-hover: #41444a;
  --blog-control-text: #d5d8dd;
  --blog-active-bg: #2d4240;
  --blog-active-text: #95d6cc;
  --blog-code-bg: #27282c;
  --blog-code-bar: #303136;
  --blog-code-text: #c9ccd4;
  --blog-code-comment: #9b9fa7;
  --blog-code-red: #ef9ca8;
  --blog-code-orange: #e9b18e;
  --blog-code-yellow: #d9c88e;
  --blog-code-green: #acd3a2;
  --blog-code-aqua: #7ed6cc;
  --blog-code-blue: #a4c5e8;
  --blog-code-purple: #cbb1df;
  --blog-addition: #294d3e;
  --blog-deletion: #58353d;
}
html[data-theme="dark"], html[data-theme="dark"] body { background: var(--blog-bg); color: var(--blog-text); }
html[data-theme="dark"] h1, html[data-theme="dark"] h2, html[data-theme="dark"] h3, html[data-theme="dark"] h4, html[data-theme="dark"] h5, html[data-theme="dark"] h6 { color: var(--blog-heading); }
html[data-theme="dark"] a { color: var(--blog-link); }
html[data-theme="dark"] a:hover { color: var(--blog-link); }
html[data-theme="dark"] :focus-visible { outline: 2px solid var(--blog-link); outline-offset: 4px; }
html[data-theme="dark"] hr { border-color: var(--blog-border); background: var(--blog-bg); }
html[data-theme="dark"] details, html[data-theme="dark"] table th, html[data-theme="dark"] table td, html[data-theme="dark"] .not-code { border-color: var(--blog-border); }
html[data-theme="dark"] table thead { background: var(--blog-surface); }
html[data-theme="dark"] blockquote { color: var(--blog-text); background: var(--blog-surface); border-left-color: var(--blog-accent); }

/* Dim the photograph gently in night mode, keeping the original soft shadows. */
html[data-theme="dark"] #nav, html[data-theme="dark"] #top-container, html[data-theme="dark"] footer.footer-bg {
  background-color: var(--blog-banner);
  background-blend-mode: multiply;
}
html[data-theme="dark"] #nav.no-bg, html[data-theme="dark"] #top-container.no-bg, html[data-theme="dark"] #top-container.plain, html[data-theme="dark"] footer:not(.footer-bg) { background-color: var(--blog-control-bg); }
html[data-theme="dark"] #page-header.fixed, html[data-theme="dark"] .search-dialog { background: var(--blog-nav); }
html[data-theme="dark"] #page-header.fixed a, html[data-theme="dark"] #page-header.fixed .toggle-menu, html[data-theme="dark"] #page-header.fixed #site-name {
  color: var(--blog-text);
}
html[data-theme="dark"] #page-header.fixed a:hover { color: var(--blog-link); }
.blog-theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  margin: 0 0 0 12px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, .28);
  border-radius: 50%;
  background: rgba(22, 36, 38, .24);
  color: #f2f7f6;
  cursor: pointer;
}
.blog-theme-toggle[hidden] { display: none; }
.blog-theme-toggle:hover { background: rgba(22, 36, 38, .48); }
.blog-theme-toggle:focus-visible { outline-color: #a5eee6; }
.theme-icon-sun, html[data-theme="dark"] .theme-icon-moon { display: none; }
html[data-theme="dark"] .theme-icon-sun { display: block; }
#page-header.fixed .blog-theme-toggle {
  background: var(--blog-surface, #f6f8fa);
  border-color: var(--blog-border, #eee);
  color: var(--blog-link, #39c5bb);
}
html[data-theme="dark"] #sidebar { background: var(--blog-surface); box-shadow: inset -1px 0 var(--blog-border); }
html[data-theme="dark"] #sidebar .author-info-articles .article-meta .pull-right { background: var(--blog-bg); color: var(--blog-link); }
html[data-theme="dark"] #sidebar .author-info-articles .article-meta .pull-right::before { border-right-color: var(--blog-bg); }
html[data-theme="dark"] #sidebar .author-info__description { color: var(--blog-muted); }
html[data-theme="dark"] #sidebar .author-info .follow-button a, html[data-theme="dark"] #sidebar .toggle-sidebar-info span, html[data-theme="dark"] #sidebar .author-info-articles .article-meta, html[data-theme="dark"] #sidebar .author-info-links__name, html[data-theme="dark"] .recent-post-item .more {
  background: var(--blog-control-bg);
  color: var(--blog-control-text);
}
html[data-theme="dark"] .recent-post-item .more:hover, html[data-theme="dark"] #sidebar .author-info .follow-button a:hover { background: var(--blog-control-hover); }
html[data-theme="dark"] #pagination .page-number.current, html[data-theme="dark"] #sidebar .sidebar-toc .toc-link.active {
  background: var(--blog-active-bg);
  color: var(--blog-active-text);
}
html[data-theme="dark"] .recent-post-item .article-title, html[data-theme="dark"] .article-sort-item__title, html[data-theme="dark"] .category-list a {
  color: var(--blog-heading);
}
html[data-theme="dark"] .recent-post-item .article-title, html[data-theme="dark"] #post-title.plain, html[data-theme="dark"] .post-copyright { border-color: var(--blog-border); }
html[data-theme="dark"] .recent-post-item .article-title:hover { color: var(--blog-link); border-color: var(--blog-accent); }
html[data-theme="dark"] .recent-post-item .article-meta, html[data-theme="dark"] .recent-post-item time, html[data-theme="dark"] #post #post-meta, html[data-theme="dark"] .article-sort-item__time, html[data-theme="dark"] .category-list-count, html[data-theme="dark"] .post-qr-code__desc { color: var(--blog-muted); }
html[data-theme="dark"] .post-meta__tags { background: var(--blog-surface); color: var(--blog-link); border-color: var(--blog-link); }
html[data-theme="dark"] .post-meta__tags:hover { background: var(--blog-control-bg); color: var(--blog-control-text); }
html[data-theme="dark"] .post-copyright-meta { color: var(--blog-link); }
html[data-theme="dark"] .post-copyright:hover, html[data-theme="dark"] .content img:hover, html[data-theme="dark"] #post img:hover, html[data-theme="dark"] #sidebar img:hover { box-shadow: none; }
html[data-theme="dark"] .content img, html[data-theme="dark"] #post img, html[data-theme="dark"] #sidebar img { border-color: var(--blog-border); }
html[data-theme="dark"] .tag-cloud a { color: var(--blog-link) !important; }
html[data-theme="dark"] #content-inner h1::before, html[data-theme="dark"] #content-inner h2::before, html[data-theme="dark"] #content-inner h3::before, html[data-theme="dark"] #content-inner h4::before, html[data-theme="dark"] #content-inner h5::before, html[data-theme="dark"] #content-inner h6::before { color: var(--blog-link); }
html[data-theme="dark"] .article-sort { border-left-color: var(--blog-border); }
html[data-theme="dark"] .article-sort-title::before, html[data-theme="dark"] .article-sort-item::before, html[data-theme="dark"] #content-inner ul > li::before {
  background: var(--blog-bg);
  border-color: var(--blog-link);
}
html[data-theme="dark"] .article-sort-title::after { background: var(--blog-border); }
html[data-theme="dark"] #content-inner ol > li::before { background: var(--blog-control-bg); color: var(--blog-control-text); }

/* Override every highlight surface, including nested table cells and toolbar. */
html[data-theme="dark"] .article-container code { background: var(--blog-surface); color: var(--blog-code-text); }
html[data-theme="dark"] .article-container pre, html[data-theme="dark"] .article-container .highlight, html[data-theme="dark"] .article-container .highlight .code pre, html[data-theme="dark"] .article-container .highlight .gutter pre { background: var(--blog-code-bg); color: var(--blog-code-text); }
html[data-theme="dark"] .article-container pre code { background: none; color: var(--blog-code-text); }
html[data-theme="dark"] .article-container .highlight .gutter pre { color: var(--blog-code-comment); }
html[data-theme="dark"] .article-container .highlight::after, html[data-theme="dark"] .article-container .highlight table::after, html[data-theme="dark"] .copy-notice { background: var(--blog-code-bar); }
html[data-theme="dark"] .code-area-wrap .codeblock-language { color: var(--blog-code-text); }
html[data-theme="dark"] .fa-clipboard, html[data-theme="dark"] .copy-notice { color: var(--blog-link); }
html[data-theme="dark"] .article-container pre .comment { color: var(--blog-code-comment); }
html[data-theme="dark"] .article-container pre :is(.variable, .attribute, .regexp, .tag .name, .css .class, .css .pseudo) { color: var(--blog-code-red); }
html[data-theme="dark"] .article-container pre :is(.preprocessor, .literal, .params, .constant, .command) { color: var(--blog-code-orange); }
html[data-theme="dark"] .article-container pre .built_in { color: var(--blog-code-yellow); }
html[data-theme="dark"] .article-container pre :is(.string, .value, .inheritance, .header, .symbol, .cdata, .special, .number, .formula) { color: var(--blog-code-green); }
html[data-theme="dark"] .article-container pre :is(.keyword, .title, .tag, .css .hexcolor) { color: var(--blog-code-aqua); }
html[data-theme="dark"] .article-container pre :is(.function, .python .decorator, .python .title, .javascript .title) { color: var(--blog-code-blue); }
html[data-theme="dark"] .article-container pre :is(.tag .attr, .javascript .function, .meta) { color: var(--blog-code-purple); }
html[data-theme="dark"] .article-container pre .addition { background: var(--blog-addition); }
html[data-theme="dark"] .article-container pre .deletion { background: var(--blog-deletion); }
html[data-theme="dark"] .article-container .highlight .line::selection, html[data-theme="dark"] .article-container pre *::selection { background: var(--blog-active-bg); color: var(--blog-active-text); }

/* In night mode, keep the photograph and small teal marks as the color focus. */
html[data-theme="dark"] #sidebar .author-info-links__name {
  background: transparent;
  color: var(--blog-text);
}
html[data-theme="dark"] #sidebar .author-info-links__name:hover { color: var(--blog-link); }
html[data-theme="dark"] #sidebar .author-info-links__name::before { background: var(--blog-link); }
html[data-theme="dark"] #sidebar .author-info-articles .article-meta .pull-right { background: var(--blog-surface); }
html[data-theme="dark"] #sidebar .author-info-articles .article-meta .pull-right::before { border-right-color: var(--blog-surface); }
html[data-theme="dark"] #sidebar .author-info-articles .article-meta:hover { background: var(--blog-control-hover); }
html[data-theme="dark"] #sidebar .toggle-sidebar-info span:hover { background: var(--blog-control-hover); }
html[data-theme="dark"] #sidebar .sidebar-toc .toc-link.active { border-right-color: var(--blog-link); }
html[data-theme="dark"] #sidebar .sidebar-toc__progress { color: var(--blog-link); }
html[data-theme="dark"] hr::before { color: var(--blog-muted); }
html[data-theme="dark"] ::selection { background: var(--blog-active-bg); color: var(--blog-heading); }

/* Valine injects its own stylesheet; use scoped selectors to retain the palette. */
html[data-theme="dark"] #vcomment .vwrap, html[data-theme="dark"] #vcomment .vheader .vinput, html[data-theme="dark"] #vcomment .vcard .vh, html[data-theme="dark"] #vcomment .vbtn, html[data-theme="dark"] #vcomment .vpreview, html[data-theme="dark"] #vcomment .vpanel { border-color: var(--blog-border); }
html[data-theme="dark"] #vcomment .vinput, html[data-theme="dark"] #vcomment .vcontent, html[data-theme="dark"] #vcomment .vpreview, html[data-theme="dark"] #vcomment .vempty, html[data-theme="dark"] #vcomment .vcount, html[data-theme="dark"] #vcomment .vbtn, html[data-theme="dark"] #vcomment .vinfo, html[data-theme="dark"] #vcomment .vnick { color: var(--blog-text); }
html[data-theme="dark"] #vcomment .vinput::placeholder { color: var(--blog-muted); }
html[data-theme="dark"] #vcomment .vbtn, html[data-theme="dark"] #vcomment .vemoji-btn, html[data-theme="dark"] #vcomment .vpreview-btn, html[data-theme="dark"] #vcomment .vcard .vcontent pre, html[data-theme="dark"] #vcomment .vcard .vcontent code { background: var(--blog-surface); }
html[data-theme="dark"] #vcomment .vcard .vhead .vnick { color: var(--blog-link); }
html[data-theme="dark"] #vcomment .vcard .vhead .vsys { background: var(--blog-surface); color: var(--blog-muted); }
html[data-theme="dark"] #vcomment .vcard .vmeta .vtime, html[data-theme="dark"] #vcomment .vpower { color: var(--blog-muted); }
html[data-theme="dark"] .search-dialog input { background: var(--blog-bg); color: var(--blog-text); }
.mermaid { overflow-x: auto; }
html[data-theme="dark"] #local-search .local-search__hit-item a, html[data-theme="dark"] #algolia-search .algolia-hit-item a { color: var(--blog-text); }
.blog-theme-transition body, .blog-theme-transition #sidebar, .blog-theme-transition #page-header.fixed { transition: background-color .2s ease, color .2s ease; }
@media (max-width: 768px) {
.blog-theme-toggle { margin-right: 14px; }
html[data-theme="dark"] #page-header .menus { background: var(--blog-nav); }
html[data-theme="dark"] #page-header .menus a { color: var(--blog-text); }
html[data-theme="dark"] #post-title.plain { color: var(--blog-heading); }
}
@media (prefers-reduced-motion: reduce) {
.blog-theme-transition body, .blog-theme-transition #sidebar, .blog-theme-transition #page-header.fixed { transition: none; }
}
