body[data-map-theme="night"] {
  color-scheme: dark;
  --night-ink: #f4f1ee;
  --night-copy: #d7d2d0;
  --night-muted: #b1a9a9;
  --night-red: #d4141c;
  --night-accent: #ff4545;
  --night-active: #471f21;
  --night-border: #ffffff24;
  --night-surface: #1b1a20;
  --night-search-surface: #1d1b22f5;
  --night-wash: #ffffff0d;
  --night-hover: #ff3a2818;
  --night-glass: linear-gradient(153deg, #292329f7 0%, #1a191fef 42%, #15151bed 100%);
  --night-shadow: 0 18px 55px #0006, 0 2px 9px #0004;
  background: #181b22;
  color: var(--night-ink);
}

/* Filter only the raster tiles; keep photos, network vectors and controls intact. */
body[data-map-theme="night"] #map,
body[data-map-theme="night"] #map.network-view { background: #1b2028; }
body[data-map-theme="night"] #map .leaflet-tile-pane {
  filter: grayscale(1) invert(1) brightness(.86) contrast(.83) sepia(.23) hue-rotate(158deg) saturate(1.23) !important;
}
#map .leaflet-control-zoom { border: 1px solid var(--night-border); box-shadow: 0 5px 18px #0005; border-radius: 11px; overflow: hidden; }
#map .leaflet-control-zoom a { color: var(--night-ink); background: #1a191fec; border-color: var(--night-border); }
#map .leaflet-control-zoom a:is(:hover, :focus-visible) { background: #3b3038; }
#map .leaflet-control-zoom a.leaflet-disabled { color: #8f858b; background: #221f26; }
#map .leaflet-control-attribution { background: #15161dd9; color: var(--night-muted); }
#map .leaflet-control-attribution a { color: #bdd2e2; }
#map .singer-avatar-main { border-color: #b3b5b9; box-shadow: 0 3px 10px #0009; }
#map .singer-custom-marker.is-profile-selected .singer-avatar-main { border-color: #fff5ef; box-shadow: 0 0 0 2px var(--night-red), 0 4px 22px #000a; }
.map-profile-marker .network-node-name {
  left: 60%; top: calc(132% + 6px); width: max-content;
}
@media (min-width: 481px) {
  .map-profile-marker:focus-visible .network-node-name { opacity: 1; }
}
@media (min-width: 481px) and (hover: hover) {
  #map .map-profile-marker:not(.is-profile-selected):hover { z-index: 8000 !important; }
  .map-profile-marker:hover .network-node-name { opacity: 1; }
  .map-profile-marker:not(.is-profile-selected):has(.singer-marker-container:hover) .network-node-name { left: 66%; }
}
#map :is(.leaflet-popup-content-wrapper, .leaflet-popup-tip, .network-node-name),
:is(#exit-network-btn, #network-switch-dock).network-dock,
#exit-network-btn.network-dock:hover {
  background: var(--night-glass); color: var(--night-ink); border-color: var(--night-border); box-shadow: var(--night-shadow);
}
#map .leaflet-popup-content :is(.singer-card, .singer-card.label-card) { background: transparent; color: var(--night-ink); }
#map .leaflet-popup-content .singer-card-name { color: var(--night-ink); }
#map .leaflet-popup-content :is(.singer-card-fans, .singer-card-desc, .singer-card-members-title, .singer-card-members-list) { color: var(--night-muted); }
#map .leaflet-popup-content :is(.singer-card-close-btn, .singer-card-btn.network-icon-btn) { background: var(--night-hover); color: var(--night-ink); }
.network-dock :is(.network-dock-count, .network-dock-number) { color: var(--night-accent); }
.network-dock-avatar, .network-avatar-fallback { background: #353039; color: var(--night-copy); }

body[data-map-theme="night"] #desktop-map-rail button {
  background: var(--night-search-surface); color: var(--night-ink); border-color: var(--night-border);
}
body[data-map-theme="night"] #desktop-map-rail button[aria-expanded="false"]:hover { border-color: var(--night-accent); color: var(--night-accent); }
body[data-map-theme="night"] #desktop-map-rail button[aria-expanded="true"] { color: #fff; background: var(--night-red); border-color: var(--night-red); }
#desktop-map-rail button[aria-expanded="true"]:focus-visible { outline-color: #fff; }

body[data-map-theme="night"] #singer-search,
#mobile-control-dialog #singer-search {
  background: var(--night-search-surface); color: var(--night-ink); border-color: #ffffff30; box-shadow: 0 4px 18px #0005;
}
body[data-map-theme="night"] :is(#singer-search, #mobile-control-dialog #singer-search):focus { border-color: var(--night-accent); }
body[data-map-theme="night"] #singer-search::placeholder { color: var(--night-muted); }
body[data-map-theme="night"] #search-btn { background: var(--night-red); color: #fff; box-shadow: 0 5px 20px #a90a3850; }
body[data-map-theme="night"] #search-btn:hover { background: #b60e17; }
#search-mode-switch {
  --search-switch-padding: 3px;
  position: relative; isolation: isolate; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  box-sizing: border-box; width: 174px; height: 40px; flex: 0 0 auto; padding: var(--search-switch-padding);
  border-radius: 999px; background: #15141b; box-shadow: inset 0 0 0 1px var(--night-border);
}
#search-mode-switch button {
  position: relative; min-width: 0; border: 0; border-radius: 999px; padding: 0;
  color: var(--night-copy); background: transparent; font: inherit; font-size: 12px;
  font-weight: 650; line-height: 1.2; white-space: nowrap; cursor: pointer;
}
#search-mode-switch button:is(:hover, [aria-pressed="true"]) { color: #fff; }
#search-mode-switch .search-mode-slider {
  position: absolute; z-index: -1; top: var(--search-switch-padding); bottom: var(--search-switch-padding);
  left: var(--search-switch-padding); width: calc((100% - 2 * var(--search-switch-padding)) / 3);
  border-radius: inherit; background: var(--night-red);
  transform: translateX(calc(var(--search-mode-position, 0) * 100%));
  transition: transform .2s ease, opacity .15s ease;
}
#search-mode-switch[data-has-selection="false"] .search-mode-slider { opacity: 0; }
@media (max-width: 480px) {
  #mobile-control-dialog #singer-search { padding-left: 26px; font-size: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  #search-mode-switch .search-mode-slider { transition: none; }
}
#search-input-wrap #index-btn { color: var(--night-copy); background: transparent; }
#search-input-wrap #index-btn:is(:hover, .active) { color: var(--night-accent); background: var(--night-hover); }
#search-inner, #search-input-inner { color: var(--night-copy); }
#search-input-inner::before { border-color: var(--night-muted); }
#search-input-inner::after, #search-clear-btn { background: #747078; }
.suggestion-item mark { background: transparent; color: var(--night-accent); }
.suggestion-album-artist { color: var(--night-muted); }
body[data-map-theme="night"] .suggestion-item.city-type { color: var(--night-copy); }
.city-tag { background: var(--night-active); color: var(--night-accent); }
body[data-map-theme="night"] :is(#search-suggestions, #index-panel, #mobile-history-section.desktop-history-open),
#mobile-control-dialog #search-suggestions {
  background: var(--night-glass); color: var(--night-ink); border-color: var(--night-border); box-shadow: var(--night-shadow);
}

body[data-map-theme="night"] :is(#map-home-panel, #rank-panel),
body[data-map-theme="night"] .mobile-panel-sheet {
  color: var(--night-ink); background: var(--night-glass); border-color: var(--night-border);
  box-shadow: var(--night-shadow); backdrop-filter: blur(18px);
  isolation: isolate;
}
body[data-map-theme="night"] :is(.home-panel-scroll, #rank-panel-body, #index-list, #search-suggestions, #mobile-view-filter) {
  scrollbar-color: #ffffff45 transparent;
}
.rank-card-toolbar { color: var(--night-ink); }
body[data-map-theme="night"] #artist-profile-panel:not([data-profile-type="album"]) {
  --profile-paper: #221e26;
  --profile-ink: var(--night-ink);
  --profile-muted: var(--night-muted);
  --profile-red: var(--night-red);
  color: var(--profile-ink); background: var(--night-glass); border-color: var(--night-border);
  box-shadow: var(--night-shadow); backdrop-filter: blur(18px);
  isolation: isolate;
}
body[data-map-theme="night"] #artist-profile-panel[data-profile-type="album"] {
  box-shadow: var(--night-shadow);
}
body[data-map-theme="night"] :is(#map-home-panel[aria-label="主页"], #mobile-control-dialog[data-panel="recommend"] .mobile-panel-sheet):has(#home-topics:not([data-topic-view="detail"])) {
  background: var(--night-search-surface);
}
:is(#artist-profile-panel:not([data-profile-type="album"]), #map-home-panel[aria-label="主页"]:has([data-topic-view="detail"]), #mobile-control-dialog[data-panel="recommend"] .mobile-panel-sheet:has([data-topic-view="detail"]))::before {
  content: ''; position: absolute; z-index: -1; inset: -55px; pointer-events: none;
  background: linear-gradient(165deg, #0908104a 0%, #141319b8 43%, #131217 100%),
    var(--night-artwork, none) center 10% / cover no-repeat;
  filter: blur(46px) saturate(.9); opacity: .73;
}
#map-home-panel .home-release-carousel { width: calc(100% - 12px); margin: 0 6px 6px; border-radius: 16px; }

.artist-profile-panel:not([data-profile-type="album"]) .profile-hero-cover {
  width: calc(100% - 12px); margin: 6px 6px 0; border-radius: 18px 18px 15px 15px;
  background: #2e2831;
}
.artist-profile-panel:not([data-profile-type="album"]) .profile-hero-cover::after {
  background: var(--cover-top-shade), linear-gradient(180deg, #0c0a1000 15%, #100c1240 53%, #0c090de8 100%);
}
.artist-profile-panel:not([data-profile-type="album"]) .profile-section {
  margin: 0 16px; padding: 17px 5px; border-radius: 0; background: transparent;
}
.artist-profile-panel:not([data-profile-type="album"]) .profile-section + .profile-section { border-top: 1px solid var(--night-border); }
.artist-profile-panel .profile-membership-inline { margin: 0 16px; padding: 12px 5px; border-top: 1px solid var(--night-border); }
.artist-profile-panel .profile-membership-inline + .profile-section { border-top: 1px solid var(--night-border); }
.artist-profile-panel:not([data-profile-type="album"]) :is(.profile-biography, .profile-member, .profile-collaborator) { color: var(--night-copy); }
.artist-profile-panel :is(.profile-song-artists, .profile-section-count, .profile-sheet-meta, .profile-sheet-hint) { color: var(--night-muted); }
.artist-profile-panel :is(.profile-song, .profile-hero-avatar) { border-color: var(--night-border); }
.artist-profile-panel :is(.profile-avatar-frame, .profile-song-cover, .profile-album-cover) { background: #38323d; }
.artist-profile-panel .profile-avatar-fallback { color: var(--night-copy); }
.artist-profile-panel .profile-cover-avatar { background: #39343e; }
.artist-profile-panel .profile-cover-loading-text { color: #e4dce2; }
.artist-profile-panel .profile-relation { background: var(--night-wash); color: var(--night-copy); }
.artist-profile-panel button.profile-member:is(:hover, :focus-visible),
.artist-profile-panel a.profile-member:is(:hover, :focus-visible),
.artist-profile-panel .profile-relation:is(:hover, :focus-visible) { background: var(--night-hover); }
.artist-profile-panel :is(.profile-album-card, .profile-relation, .profile-collaborator:not(.is-static)):is(:hover, :focus-visible) :is(.profile-album-name, .profile-person-name),
.artist-profile-panel .profile-biography-toggle { color: var(--night-accent); }
.artist-profile-panel .profile-close { background: #0e0c1348; color: #fff; }
.artist-profile-panel .profile-close:is(:hover, :focus-visible) { background: #151018bd; color: #fff; }
.artist-profile-panel .profile-scrollbar-thumb { background: #f8ece86b; }

body[data-map-theme="night"] :is(.desktop-rail-toolbar button, #mobile-panel-close, .singer-card-close-btn, .rank-network-btn) {
  background: var(--night-wash); color: var(--night-ink);
}
body[data-map-theme="night"] :is(.desktop-rail-toolbar button, #mobile-panel-close, .singer-card-close-btn, .rank-network-btn):hover { background: var(--night-hover); color: var(--night-accent); }
body[data-map-theme="night"] :is(#rank-tab-bar, #index-tab-bar, #map-home-panel #mode-filter-tabs, #mobile-control-dialog #mode-filter-tabs, .fan-threshold-track) {
  background: #100f17b3; border-color: var(--night-border);
}
body[data-map-theme="night"] :is(.rank-name, .index-name, .suggestion-item, .mobile-history-item, .dropdown-item, .dots-only-option, .fan-threshold-heading, .rank-tab, .index-tab) {
  color: var(--night-copy);
}
body[data-map-theme="night"] :is(.rank-tab.active, .index-tab.active) { color: #fff; }
body[data-map-theme="night"] :is(.rank-row, .index-row, .suggestion-item, .mobile-history-item, .dots-only-option, .fan-threshold-control, .dropdown-item, .dropdown-category-label) { border-color: var(--night-border); }
body[data-map-theme="night"] :is(.rank-row, .index-row, .suggestion-item, .mobile-history-item, .dropdown-item:not(.active)):hover { background: var(--night-hover); }
body[data-map-theme="night"] :is(.rank-row:hover .rank-name, .index-row:hover .index-name, .rank-val, .fan-threshold-value) { color: var(--night-accent); }
body[data-map-theme="night"] .rank-no { color: var(--night-muted); }
body[data-map-theme="night"] :is(#rank-panel-subtitle, .index-section-header, .index-letter-header, .dropdown-category-label, .fan-threshold-labels,
  .mobile-sheet-title, #mobile-history-clear, .mobile-history-empty, #mobile-search-empty) { color: var(--night-muted); }
body[data-map-theme="night"] #mobile-history-section:is(.desktop-history-open, #mobile-control-dialog *) {
  background: var(--night-search-surface); color: #fff; border: 1px solid #ffffff29;
  border-radius: 16px; padding: 12px 14px;
}
body[data-map-theme="night"] #mobile-history-section :is(.mobile-sheet-title, #mobile-history-clear, .mobile-history-empty) { color: #fff; }
body[data-map-theme="night"] #mobile-history-section .mobile-history-item { background: #131313; color: #fff; border-color: #ffffff29; }
body[data-map-theme="night"] #mobile-history-section .mobile-history-item:is(:hover, :focus-visible) { background: #2a2a2a; color: #fff; }
body[data-map-theme="night"] #mobile-history-section .city-tag { background: #292929; color: #fff; }
body[data-map-theme="night"] .rank-no.gold { color: #ffcd70; }
body[data-map-theme="night"] .rank-no.silver { color: #d3dbe9; }
body[data-map-theme="night"] .rank-no.bronze { color: #e4a881; }
body[data-map-theme="night"] :is(.rank-avatar, .index-avatar) { border-color: #ffffff53; background: #302b35; }
body[data-map-theme="night"] .index-avatar { color: var(--night-copy); }
body[data-map-theme="night"] :is(#map-home-panel, #mobile-control-dialog) #mode-filter-tabs .filter-btn { color: var(--night-copy); }
body[data-map-theme="night"] :is(#map-home-panel, #mobile-control-dialog) #mode-filter-tabs .filter-btn.active {
  color: #fff; background: var(--night-red);
}
body[data-map-theme="night"] :is(#map-home-panel, #mobile-control-dialog) #more-options-dropdown { background: transparent; }
body[data-map-theme="night"] :is(#map-home-panel, #mobile-control-dialog) #more-options-dropdown :is(.dots-only-option, .fan-threshold-control, .dropdown-item) {
  color: var(--night-copy); border-color: var(--night-border);
}
body[data-map-theme="night"] :is(#map-home-panel, #mobile-control-dialog) #more-options-dropdown :is(.dropdown-category-label, .fan-threshold-labels) { color: var(--night-muted); }
body[data-map-theme="night"] :is(#map-home-panel, #mobile-control-dialog) #more-options-dropdown .dropdown-item:not(.active):hover {
  background: var(--night-hover); color: var(--night-ink);
}
body[data-map-theme="night"] :is(#map-home-panel, #mobile-control-dialog) .dropdown-item.active {
  background: var(--night-active) !important; color: var(--night-accent) !important;
}
body[data-map-theme="night"] :focus-visible { outline-color: var(--night-accent); }

@media (min-width: 481px) {
  body[data-map-theme="night"][data-desktop-rail="true"] :is(#map-home-panel, #rank-panel, #artist-profile-panel) {
    max-height: calc(var(--map-card-width) * 3);
  }
}

@media (max-width: 480px) {
  body[data-map-theme="night"]:has(#artist-profile-panel[data-profile-sheet="peek"]:not([hidden])) #search-tip {
    bottom: calc(var(--mobile-profile-peek) + 14px);
  }
  body[data-map-theme="night"]:has(#artist-profile-panel[data-profile-sheet="expanded"]:not([hidden])) #search-tip {
    bottom: calc(min(76dvh, calc(100dvh - var(--mobile-tools-offset) - 8px)) + 14px);
  }
  body[data-map-theme="night"] #mobile-control-dialog {
    --mobile-ink: var(--night-ink);
    --mobile-muted: var(--night-muted);
    --mobile-red: var(--night-red);
  }
  #mobile-map-tools :is(.mobile-map-search, .mobile-map-tool-rail) {
    background: #1f1d25f0; color: var(--night-ink); border-color: var(--night-border); box-shadow: 0 5px 18px #0005;
  }
  #mobile-map-tools button { color: var(--night-copy); }
  #mobile-map-tools .mobile-map-search svg { color: var(--night-accent); }
  #mobile-map-tools button:is([aria-expanded="true"], :active) { color: var(--night-accent); background: var(--night-active); }
  .mobile-panel-handle, #artist-profile-panel[data-profile-sheet] .profile-sheet-handle::before { background: #e7dade6b; }
  body[data-map-theme="night"] #mobile-control-dialog :is(#rank-panel, #index-panel) { background: transparent; box-shadow: none; backdrop-filter: none; }
  body[data-map-theme="night"] #mobile-control-dialog :is(.rank-row, .index-row, .suggestion-item, .mobile-history-item) { border-color: var(--night-border); }
  body[data-map-theme="night"] #mobile-control-dialog .suggestion-item:hover { background: var(--night-hover); }
  #artist-profile-panel[data-profile-sheet]:not([data-profile-type="album"]) :is(.profile-back, .profile-close) { color: var(--night-ink); background: transparent; }
}
