.header-theme-toggle {
  position: relative;
  justify-self: end;
  display: grid;
  width: 44px;
  min-width: 44px;
  height: 44px;
  min-height: 44px;
  max-height: 44px;
  aspect-ratio: 1;
  padding: 0;
  place-items: center;
  border: 1px solid rgba(8,142,67,.3);
  border-radius: 12px;
  background: linear-gradient(145deg,rgba(255,255,255,.96) 16%,rgba(232,248,239,.94) 100%);
  color: #f39800;
  box-shadow:0 4px 12px rgba(7,133,62,.13),inset 0 0 4px rgba(21,186,91,.18),inset 0 0 13px rgba(21,186,91,.1),inset 0 1px 0 rgba(255,255,255,.98);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  cursor: pointer;
}
.header-theme-toggle:focus-visible { outline: 3px solid rgba(246,160,0,.5); outline-offset: 2px; }
.header-theme-icon { grid-area: 1 / 1; width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; transition: opacity .18s ease,transform .22s ease; }
.header-theme-sun circle { fill: currentColor; stroke: none; }
.header-theme-moon { opacity: 0; transform: rotate(-24deg) scale(.62); }
.header-theme-toggle[aria-pressed="true"] .header-theme-sun { opacity: 0; transform: rotate(28deg) scale(.62); }
.header-theme-toggle[aria-pressed="true"] .header-theme-moon { opacity: 1; transform: rotate(0) scale(1); }

html[data-theme="dark"] {
  color-scheme: dark;
  color: #edf3f0;
  background: #0b0f12;
  --line: #2d3833;
}
html[data-theme="dark"] body { color: #edf3f0; background: #0b0f12; }
html[data-theme="dark"] .site-page-header { border-color: #29342f; background: rgba(14,19,22,.96); box-shadow: 0 5px 18px rgba(0,0,0,.28); }
html[data-theme="dark"] .site-page-header .back-to-board { border-color:#3c4943; background:linear-gradient(145deg,#20282b,#151b1e); box-shadow:0 4px 12px rgba(0,0,0,.3); }
html[data-theme="dark"] .site-page-header .back-to-board::before { color:#65d493; }
html[data-theme="dark"] .header-theme-toggle { border-color: #3c4943; color: #ffd260; background: linear-gradient(145deg,#20282b,#151b1e); box-shadow: 0 4px 12px rgba(0,0,0,.3); }
html[data-board-context="stock"] .header-theme-toggle { border-color:rgba(10,55,94,.3);background:linear-gradient(145deg,rgba(255,255,255,.96) 16%,rgba(228,240,249,.94) 100%);box-shadow:0 4px 12px rgba(10,52,88,.14),inset 0 0 4px rgba(44,119,174,.13),inset 0 0 13px rgba(44,119,174,.08),inset 0 1px 0 rgba(255,255,255,.98); }
html[data-theme="dark"][data-board-context="stock"] .header-theme-toggle { border-color:rgba(69,128,174,.46);background:linear-gradient(145deg,#172735,#0d1924);box-shadow:0 4px 12px rgba(0,0,0,.34),inset 0 0 4px rgba(56,137,197,.16),inset 0 0 13px rgba(56,137,197,.08),inset 0 1px 0 rgba(255,255,255,.05); }
html[data-theme="dark"] main { border: 1px solid #283237; background: #111719; box-shadow: 0 10px 32px rgba(0,0,0,.3); }
html[data-theme="dark"] h1,
html[data-theme="dark"] h2,
html[data-theme="dark"] h3,
html[data-theme="dark"] strong { color: #f1f5f3; }
html[data-theme="dark"] a { color: #65d493; }
html[data-theme="dark"] .lead,
html[data-theme="dark"] .small,
html[data-theme="dark"] .updated,
html[data-theme="dark"] .feature-copy { color: #aeb8b3; }
html[data-theme="dark"] section,
html[data-theme="dark"] .faq,
html[data-theme="dark"] .faq details { border-color: #2d3833; }
html[data-theme="dark"] .panel,
html[data-theme="dark"] .value-grid article,
html[data-theme="dark"] .compare-grid article,
html[data-theme="dark"] .article-links a,
html[data-theme="dark"] .contact-card,
html[data-theme="dark"] .bitbank-partner { border-color: #2d3833; background: linear-gradient(145deg,#182023,#131a1d); }
html[data-theme="dark"] .bitbank-partner-disclosure { color:#aeb8b3; }
html[data-theme="dark"] .faq summary,
html[data-theme="dark"] .article-links a,
html[data-theme="dark"] .compare-grid span { color: #e9efec; }
html[data-theme="dark"] .faq details p,
html[data-theme="dark"] .value-grid p,
html[data-theme="dark"] .compare-grid p,
html[data-theme="dark"] .article-links span { color: #aeb8b3; }
html[data-theme="dark"] .page-nav a { color: #c1cbc6; background: #1b2421; }
html[data-theme="dark"] .page-nav a.current { color: #fff; background: #0b8e49; }
html[data-theme="dark"] .caution { color: #eadfc7; background: #2a2418; }
html[data-theme="dark"] .sub-button { color: #6bd999; background: #193027; }

html[data-theme="dark"] .guide-nav,
html[data-theme="dark"] .help-box { border-color: #303b3f; background: #171e21; }
html[data-theme="dark"] .guide-page section:not(.feature-section) { border-color: #303b3f; background: linear-gradient(180deg,#171e21,#13191c); }
html[data-theme="dark"] .guide-nav-title { color: #aeb8b3; }
html[data-theme="dark"] .guide-nav-swipe { color: #8f9b95; }
html[data-theme="dark"] .guide-nav a { border-color: #354044; color: #dfe7e3; background: #111719; }
html[data-theme="dark"] .guide-nav a:hover { border-color: #2f8f5b; box-shadow: 0 4px 12px rgba(0,0,0,.28); }
html[data-theme="dark"] .chart-guide { border-color: #344047; background: linear-gradient(180deg,#172024,#111719); }
html[data-theme="dark"] .pointer { color: #f4f7f5; filter: drop-shadow(0 0 2px #050708); }
html[data-theme="dark"] .legend div,
html[data-theme="dark"] .step,
html[data-theme="dark"] .feature-summary div,
html[data-theme="dark"] .sort-example { border-color: #313c40; background: #171e21; }
html[data-theme="dark"] .step p,
html[data-theme="dark"] .feature-summary span,
html[data-theme="dark"] .sort-example figcaption { color: #aeb8b3; }
html[data-theme="dark"] .mini-card,
html[data-theme="dark"] .install-icon,
html[data-theme="dark"] .add-home { border-color: #3a464a; color: #e7edea; background: #20282b; box-shadow: 0 3px 8px rgba(0,0,0,.3); }
html[data-theme="dark"] .sort-button { border-color: rgba(72,213,135,.4); color: #65d493; background: linear-gradient(145deg,#1e2a25,#142019); box-shadow: 0 4px 10px rgba(0,0,0,.3); }
html[data-theme="dark"] .ios-intro { background: linear-gradient(135deg,#192720,#172229); }
html[data-theme="dark"] .recommend { color: #ffd678; background: #3a2d12; }
html[data-theme="dark"] .note { color: #b8d5c4; background: #19271f; }
html[data-theme="dark"] .feature-section.demo { background: linear-gradient(180deg,#171e21,#241f16); }
html[data-theme="dark"] .feature-section.demo .feature-summary div { border-color: #4b412a; background: #252016; }
html[data-theme="dark"] .feature-section.demo .note { color: #decdaa; background: #2b2416; }
html[data-theme="dark"] .feature-section.portfolio { background: linear-gradient(180deg,#171e21,#132019); }
html[data-theme="dark"] .feature-section.my-chart { background: linear-gradient(135deg,#241f16 0%,#171e21 44%,#132019 100%); }
html[data-theme="dark"] .feature-section.my-chart .feature-summary div { border-color: #34423b; background: rgba(17,25,21,.9); }
html[data-theme="dark"] .feature-section.heatmap { background: linear-gradient(135deg,#241f16 0%,#171e21 45%,#132019 100%); }
html[data-theme="dark"] .feature-section.heatmap.stock-heatmap { background: linear-gradient(135deg,#14212b 0%,#171e21 48%,#132019 100%); }
html[data-theme="dark"] .my-chart-step-icon { border-color: #31513f; background: linear-gradient(145deg,#17231d,#1c3024); color: #65d493; }
html[data-theme="dark"] .my-chart-step-icon.star { border-color: #5b4724; background: linear-gradient(145deg,#241f16,#2d2515); color: #ffb12b; }
html[data-theme="dark"] .my-chart-preview { border-color: #34413b; background: #111719; box-shadow: 0 8px 24px rgba(0,0,0,.28); }
html[data-theme="dark"] .my-chart-preview figcaption { color: #aeb8b3; }
html[data-theme="dark"] .my-chart-actions span { color: #aeb8b3; }
html[data-theme="dark"] .feature-section.settings { background: linear-gradient(180deg,#171e21,#132019); }
html[data-theme="dark"] .setting-guide-card { border-color: #303d37; background: rgba(18,25,22,.82); }
html[data-theme="dark"] .setting-guide-visual { background: linear-gradient(145deg,#1c2923,#171f1c); }
html[data-theme="dark"] .setting-guide-card p { color: #adb8b2; }
html[data-theme="dark"] .setting-guide-kicker { color: #65d493 !important; }
html[data-theme="dark"] .theme-preview span:first-child,
html[data-theme="dark"] .currency-preview,
html[data-theme="dark"] .bgm-menu-preview { border-color: #3a4641; background: #202824; }
html[data-theme="dark"] .pair-example span { color: #76dda0; background: #193027; }
html[data-theme="dark"] .bgm-menu-preview span { color: #dce5e0; background: #2a3430; }
html[data-theme="dark"] .track-list { color: #9faaa4 !important; }
html[data-theme="dark"] .source-table { border-color: #354044; }
html[data-theme="dark"] .source-table div { border-color: #303a3e; }
html[data-theme="dark"] .source-table div:nth-child(odd) { background: #1b2326; }
html[data-theme="dark"] .source-table div:nth-child(even) { background: #141b1e; }
html[data-theme="dark"] .button { color: #fff; background: #273034; }
html[data-theme="dark"] .button.secondary { color: #6bd999; background: #193027; }
html[data-theme="dark"] .page-loading { background: rgba(7,10,12,.58); }
html[data-theme="dark"] .page-loading-card { border-color: rgba(68,213,132,.3); color: #70dda0; background: rgba(20,27,30,.97); box-shadow: 0 10px 30px rgba(0,0,0,.4); }

@media (max-width: 560px) {
  .header-theme-toggle { width: 40px; min-width: 40px; height: 40px; min-height: 40px; max-height: 40px; border-radius: 10px; }
  .header-theme-icon { width: 19px; height: 19px; }
}
