/* ==========================================================================
   黑夜模式
   ========================================================================== */

:root {
  color-scheme: light;
}

.theme-icon {
  width: 15px;
  height: 15px;
}
.theme-icon-sun {
  display: none;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --pink: #f29aa4;
  --pink-deep: #e7838e;
  --pink-ink: #f2a6af;
  --pink-soft: rgba(240, 145, 153, 0.14);
  --pink-wash: rgba(240, 145, 153, 0.08);

  --ink: #f0ece9;
  --ink-2: #cec7c2;
  --muted: #a7a0a8;
  --faint: #8a828a;
  --paper: #111014;
  --surface: #1b191f;
  --surface-2: #151318;
  --line: rgba(255, 255, 255, 0.09);
  --line-strong: rgba(255, 255, 255, 0.17);

  --green: #83be9d;
  --amber: #d8a760;

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-sm: 0 6px 18px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 16px 40px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 30px 90px rgba(0, 0, 0, 0.55);
}

html[data-theme="dark"] body {
  background:
    radial-gradient(1100px 520px at 88% -12%, rgba(143, 65, 91, 0.24), transparent 62%),
    radial-gradient(900px 480px at -8% 24%, rgba(42, 56, 72, 0.32), transparent 58%),
    var(--paper);
}

html[data-theme="dark"] ::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.16);
  border: 3px solid transparent;
  border-radius: 99px;
  background-clip: content-box;
}
html[data-theme="dark"] ::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.26);
  border: 3px solid transparent;
  background-clip: content-box;
}

html[data-theme="dark"] .topbar {
  background: rgba(17, 16, 20, 0.82);
  border-bottom-color: rgba(255, 255, 255, 0.07);
}
html[data-theme="dark"] .icon-btn:hover,
html[data-theme="dark"] .search-clear:hover {
  background: rgba(255, 255, 255, 0.07);
}
html[data-theme="dark"] .search-box {
  background: rgba(255, 255, 255, 0.055);
  border-color: rgba(255, 255, 255, 0.09);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}
html[data-theme="dark"] .search-box:focus-within {
  background: #1d1a21;
  border-color: rgba(240, 145, 153, 0.45);
  box-shadow: 0 0 0 4px rgba(240, 145, 153, 0.1);
}
html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] textarea::placeholder,
html[data-theme="dark"] .search-box input::placeholder {
  color: var(--faint);
}
html[data-theme="dark"] .search-box kbd {
  background: #1d1a21;
  border-bottom-color: rgba(255, 255, 255, 0.16);
}

html[data-theme="dark"] .btn {
  background: rgba(255, 255, 255, 0.055);
  border-color: var(--line);
  color: var(--ink-2);
  box-shadow: var(--shadow-xs);
}
html[data-theme="dark"] .btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--line-strong);
}
html[data-theme="dark"] .btn.ghost {
  background: transparent;
  border-color: transparent;
}
html[data-theme="dark"] .btn.ghost:hover {
  background: rgba(255, 255, 255, 0.07);
  border-color: var(--line);
}
html[data-theme="dark"] .btn.primary {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(135deg, #ef9aa2, #d96c78);
}
html[data-theme="dark"] .btn.primary:hover {
  background: linear-gradient(135deg, #f4a6ad, #e07580);
}

html[data-theme="dark"] .nav-item:hover {
  background: rgba(255, 255, 255, 0.055);
  color: var(--ink);
}
html[data-theme="dark"] .nav-item.active {
  color: var(--ink);
  background: #211e25;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}
html[data-theme="dark"] .nav-count {
  background: rgba(255, 255, 255, 0.07);
  color: var(--muted);
}
html[data-theme="dark"] .nav-item.active .nav-count {
  background: var(--pink-soft);
  color: var(--pink-ink);
}
html[data-theme="dark"] .tag-chip {
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.045);
  color: var(--muted);
}
html[data-theme="dark"] .tag-chip:hover {
  color: var(--pink-ink);
  border-color: rgba(240, 145, 153, 0.3);
  background: rgba(255, 255, 255, 0.08);
}
html[data-theme="dark"] .select-wrap select,
html[data-theme="dark"] .order-btn,
html[data-theme="dark"] .select-mode-btn,
html[data-theme="dark"] .icon-toggle-group,
html[data-theme="dark"] .pager button {
  background: rgba(255, 255, 255, 0.055);
  border-color: var(--line);
  color: var(--ink-2);
}
html[data-theme="dark"] .select-wrap select:hover,
html[data-theme="dark"] .order-btn:hover,
html[data-theme="dark"] .select-mode-btn:hover,
html[data-theme="dark"] .pager button:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--line-strong);
}
html[data-theme="dark"] .select-wrap select option {
  background: #1d1a21;
  color: var(--ink);
}
html[data-theme="dark"] .segmented {
  background: rgba(255, 255, 255, 0.06);
}
html[data-theme="dark"] .segmented button.active {
  background: #211e25;
  color: var(--ink);
  box-shadow: 0 2px 7px rgba(0, 0, 0, 0.25);
}
html[data-theme="dark"] .filter-pill,
html[data-theme="dark"] .state-btn {
  background: rgba(255, 255, 255, 0.055);
  border-color: var(--line);
}
html[data-theme="dark"] .filter-pill:hover,
html[data-theme="dark"] .state-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}
html[data-theme="dark"] .filter-pill.active,
html[data-theme="dark"] .state-btn.favorite-toggle.active {
  background: var(--pink-wash);
  border-color: rgba(240, 145, 153, 0.35);
}
html[data-theme="dark"] .watch-switch {
  background: rgba(255, 255, 255, 0.065);
}
html[data-theme="dark"] .watch-btn.active {
  background: #211e25;
  color: var(--ink);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}
html[data-theme="dark"] .watch-btn.active.watching {
  background: rgba(93, 137, 203, 0.2);
  color: #9fc0ec;
}
html[data-theme="dark"] .watch-btn.active.watched {
  background: rgba(92, 154, 120, 0.2);
  color: #9bd0b0;
}
html[data-theme="dark"] .favorite-stat:hover,
html[data-theme="dark"] .favorite-stat.active {
  background: var(--pink-wash);
}
html[data-theme="dark"] .favorites-summary {
  background:
    radial-gradient(circle at 0% 0%, rgba(240, 145, 153, 0.1), transparent 45%),
    rgba(255, 255, 255, 0.035);
  border-color: rgba(240, 145, 153, 0.18);
}
html[data-theme="dark"] .favorites-summary-card,
html[data-theme="dark"] .fs-icon,
html[data-theme="dark"] .drawer-personal {
  background: rgba(255, 255, 255, 0.045);
  border-color: var(--line);
}
html[data-theme="dark"] .favorites-summary-card:hover {
  background: rgba(255, 255, 255, 0.08);
}
html[data-theme="dark"] .favorites-summary-card.active {
  background: var(--pink-wash);
  border-color: rgba(240, 145, 153, 0.3);
}
html[data-theme="dark"] .btn.subtle {
  background: transparent;
  border-color: var(--line);
}
html[data-theme="dark"] .icon-toggle.active {
  background: #211e25;
  color: var(--ink);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}
html[data-theme="dark"] .select-mode-btn.active {
  color: var(--pink-ink);
  border-color: rgba(240, 145, 153, 0.35);
  background: var(--pink-wash);
}
html[data-theme="dark"] .chip button:hover {
  background: rgba(240, 145, 153, 0.18);
}

html[data-theme="dark"] .search-scope-hint {
  border-color: rgba(240, 145, 153, 0.22);
  background: linear-gradient(135deg, rgba(240, 145, 153, 0.1), rgba(255, 255, 255, 0.035));
}
html[data-theme="dark"] .search-scope-copy strong {
  color: var(--ink);
}
html[data-theme="dark"] .search-scope-copy span {
  color: var(--ink-2);
}
html[data-theme="dark"] .search-scope-btn {
  background: rgba(255, 255, 255, 0.06);
}
html[data-theme="dark"] .search-scope-btn:hover {
  background: rgba(255, 255, 255, 0.11);
  border-color: rgba(240, 145, 153, 0.5);
}

html[data-theme="dark"] .grid.list-view .card {
  background: rgba(255, 255, 255, 0.035);
}
html[data-theme="dark"] .grid.list-view .card:hover {
  background: rgba(255, 255, 255, 0.065);
}
html[data-theme="dark"] .grid.list-view .card-actions .card-action {
  background: rgba(255, 255, 255, 0.06);
}
html[data-theme="dark"] .grid.list-view .card-actions .card-action:hover {
  background: rgba(255, 255, 255, 0.11);
}
html[data-theme="dark"] .card-tag {
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
}
html[data-theme="dark"] .card:hover .card-tag {
  background: rgba(240, 145, 153, 0.16);
  color: var(--pink-ink);
}
html[data-theme="dark"] .rank-badge {
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(24, 21, 26, 0.86);
  color: #f0cd8d;
}
html[data-theme="dark"] .card-action {
  background: rgba(28, 25, 32, 0.92);
  color: var(--ink);
}
html[data-theme="dark"] .card-action:hover {
  background: rgba(40, 36, 46, 0.98);
}
html[data-theme="dark"] .card-action.remove {
  color: #f2a3ab;
  background: rgba(74, 34, 42, 0.92);
}
html[data-theme="dark"] .card-action.remove:hover {
  background: rgba(94, 42, 52, 0.98);
}
html[data-theme="dark"] .card-action.restore {
  color: #8fcaa8;
  background: rgba(30, 58, 44, 0.92);
}
html[data-theme="dark"] .card-action.restore:hover {
  background: rgba(38, 74, 56, 0.98);
}
html[data-theme="dark"] .select-toggle {
  background: rgba(28, 25, 32, 0.92);
}
html[data-theme="dark"] .select-toggle input {
  border-color: rgba(255, 255, 255, 0.3);
  background: #1b191f;
}
html[data-theme="dark"] .select-toggle input:checked {
  border-color: var(--pink-deep);
  background: var(--pink-deep);
  box-shadow: inset 0 0 0 2px #1b191f;
}
html[data-theme="dark"] .poster,
html[data-theme="dark"] .drawer-cover,
html[data-theme="dark"] .online-cover {
  background: linear-gradient(145deg, #2a252f, #1a171d);
}
html[data-theme="dark"] .poster-fallback {
  color: rgba(255, 255, 255, 0.82);
  background:
    radial-gradient(circle at 30% 20%, rgba(255, 255, 255, 0.12), transparent 40%),
    linear-gradient(145deg, #4b3745, #241e2a);
}

html[data-theme="dark"] .empty-art::before {
  background: radial-gradient(ellipse, rgba(0, 0, 0, 0.62), rgba(0, 0, 0, 0.2) 48%, transparent 72%);
}
html[data-theme="dark"] .empty-art::after {
  background: linear-gradient(145deg, #f6d3d7, #db8f98 52%, #7f454f);
  box-shadow:
    0 4px 12px rgba(0, 0, 0, 0.5),
    0 0 16px rgba(240, 145, 153, 0.3),
    -84px 58px 0 -2px rgba(240, 145, 153, 0.35),
    -74px 68px 0 -3px rgba(240, 145, 153, 0.18);
}
html[data-theme="dark"] .empty-art .ring {
  border-color: rgba(240, 145, 153, 0.24);
  background:
    radial-gradient(circle at 31% 24%, rgba(255, 255, 255, 0.16), transparent 30%),
    radial-gradient(circle at 72% 82%, rgba(240, 145, 153, 0.18), transparent 54%),
    linear-gradient(150deg, #37313d 0%, #25202b 54%, #17131b 100%);
  box-shadow:
    0 22px 38px -14px rgba(0, 0, 0, 0.78),
    0 6px 14px rgba(0, 0, 0, 0.35),
    inset 0 1px 2px rgba(255, 255, 255, 0.16),
    inset 0 -14px 24px rgba(0, 0, 0, 0.45);
}
html[data-theme="dark"] .empty-art .ring::before {
  border-color: rgba(240, 145, 153, 0.24);
}
html[data-theme="dark"] .empty-art .ring::after {
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 0 18px rgba(240, 145, 153, 0.1);
}
html[data-theme="dark"] .empty-art svg {
  color: #e4a3aa;
  filter: drop-shadow(0 5px 9px rgba(0, 0, 0, 0.65));
}
html[data-theme="dark"] .progress-backdrop {
  background: rgba(5, 4, 7, 0.72);
}
html[data-theme="dark"] .progress-ring {
  background:
    radial-gradient(circle at 32% 26%, rgba(255, 255, 255, 0.14), transparent 42%),
    linear-gradient(145deg, #332c38, #17141b);
  box-shadow:
    0 16px 28px -12px rgba(0, 0, 0, 0.7),
    inset 0 1px 2px rgba(255, 255, 255, 0.14);
}
html[data-theme="dark"] .progress-illustration svg {
  filter: drop-shadow(0 5px 9px rgba(0, 0, 0, 0.55));
}
html[data-theme="dark"] .btn.purge-all-btn {
  color: #f2a6af;
  background: rgba(201, 79, 91, 0.14);
  border-color: rgba(240, 145, 153, 0.2);
  box-shadow: none;
}
html[data-theme="dark"] .btn.purge-all-btn:hover {
  color: #ffc2c8;
  background: rgba(201, 79, 91, 0.24);
  border-color: rgba(240, 145, 153, 0.34);
}
html[data-theme="dark"] .skel {
  background: linear-gradient(
    100deg,
    rgba(255, 255, 255, 0.05) 20%,
    rgba(255, 255, 255, 0.1) 36%,
    rgba(255, 255, 255, 0.05) 52%
  );
}

html[data-theme="dark"] .modal-foot {
  background: rgba(255, 255, 255, 0.03);
}
html[data-theme="dark"] .modal-close {
  background: rgba(255, 255, 255, 0.06);
}
html[data-theme="dark"] .modal-close:hover {
  background: rgba(255, 255, 255, 0.11);
}
html[data-theme="dark"] .online-form input,
html[data-theme="dark"] .reason-input input,
html[data-theme="dark"] .tag-modal-search {
  border-color: var(--line);
  background: #1d1a21;
  color: var(--ink);
}
html[data-theme="dark"] .online-item {
  background: rgba(255, 255, 255, 0.035);
}
html[data-theme="dark"] .online-item:hover {
  border-color: rgba(240, 145, 153, 0.24);
  background: rgba(255, 255, 255, 0.075);
}
html[data-theme="dark"] .confirm-note {
  background: rgba(255, 255, 255, 0.05);
}
html[data-theme="dark"] .drawer-hero::after {
  background: linear-gradient(
    180deg,
    rgba(8, 7, 10, 0.12) 0%,
    rgba(8, 7, 10, 0.5) 55%,
    var(--surface-2) 100%
  );
}
html[data-theme="dark"] .fact,
html[data-theme="dark"] .collection-stat,
html[data-theme="dark"] .infobox {
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.04);
}
html[data-theme="dark"] .deleted-banner {
  background: rgba(255, 255, 255, 0.05);
}
html[data-theme="dark"] .info-row {
  border-bottom-color: rgba(255, 255, 255, 0.07);
}
html[data-theme="dark"] .drawer-note {
  border-color: rgba(240, 145, 153, 0.2);
}

html[data-theme="dark"] .loading-overlay {
  background: rgba(10, 9, 13, 0.66);
}
html[data-theme="dark"] .loading-card {
  border-color: var(--line);
  background: rgba(24, 21, 28, 0.96);
}
html[data-theme="dark"] .loading-track {
  background: rgba(255, 255, 255, 0.08);
}

html[data-theme="dark"] .sidebar-close {
  background: rgba(255, 255, 255, 0.06);
}
html[data-theme="dark"] .sidebar-close:hover {
  background: rgba(255, 255, 255, 0.11);
}
html[data-theme="dark"] .modal-backdrop {
  background: rgba(5, 4, 7, 0.62);
}
html[data-theme="dark"] .drawer-backdrop {
  background: rgba(5, 4, 7, 0.52);
}
html[data-theme="dark"] .sidebar-backdrop.open {
  background: rgba(5, 4, 7, 0.54);
}
html[data-theme="dark"] .theme-icon-moon {
  display: none;
}
html[data-theme="dark"] .theme-icon-sun {
  display: block;
}

@media (max-width: 960px) {
  .theme-btn {
    width: 38px;
    padding: 0;
  }
  .theme-btn span {
    display: none;
  }
}

/* ==========================================================================
   暗色主题：状态 / 变体补齐
   上面的暗色规则多写在基础类上（如 html[dark] .btn，特异性 0,2,1），会盖过
   亮色的变体规则（如 .btn.danger，0,2,0）。这里为这些变体补上暗色版本；
   选择器都比被覆盖的规则更具体，不依赖样式表加载顺序。
   ========================================================================== */
html[data-theme="dark"] .btn.danger,
html[data-theme="dark"] .btn.danger:hover {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(135deg, #c95f69, #b44652);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
}
html[data-theme="dark"] .btn:disabled {
  box-shadow: none;
}
html[data-theme="dark"] .btn.subtle:hover {
  background: var(--pink-wash);
  border-color: rgba(240, 145, 153, 0.22);
}

/* 排行榜前三名：保留金银铜底色，深色数字才有对比。 */
html[data-theme="dark"] .ranking-rank.medal-1 {
  background: linear-gradient(145deg, #f6d36f, #dfa93a);
}
html[data-theme="dark"] .ranking-rank.medal-2 {
  background: linear-gradient(145deg, #e5e7ec, #b9bec8);
}
html[data-theme="dark"] .ranking-rank.medal-3 {
  background: linear-gradient(145deg, #edc4a2, #cf9569);
}

/* 关系图：中心连线按角色分色，与 .graph-legend 的三色图例一致。 */
html[data-theme="dark"] .graph-edge.center.lead {
  stroke: rgba(240, 145, 153, 0.5);
}
html[data-theme="dark"] .graph-edge.center.support {
  stroke: rgba(211, 164, 92, 0.42);
}
html[data-theme="dark"] .graph-edge.center.other {
  stroke: rgba(127, 155, 192, 0.42);
}

html[data-theme="dark"] .cmp-tag.shared {
  background: var(--pink-soft);
}
/* 角色图标按钮浮在头像上，激活色叠在不透明底上，避免透出图片。 */
html[data-theme="dark"] .char-icon-btn.active {
  background: linear-gradient(var(--pink-soft), var(--pink-soft)), rgba(38, 33, 42, 0.92);
}
html[data-theme="dark"] .grid.list-view .card-actions .card-action.remove {
  background: rgba(74, 34, 42, 0.92);
}
html[data-theme="dark"] .grid.list-view .card-actions .card-action.remove:hover {
  background: rgba(94, 42, 52, 0.98);
}

/* 悬停反馈 */
html[data-theme="dark"] .pager-jump button:hover,
html[data-theme="dark"] .strip-toggle:hover {
  background: rgba(255, 255, 255, 0.09);
  border-color: var(--line-strong);
  color: var(--ink);
}
html[data-theme="dark"] .compare-change:hover {
  background: rgba(48, 42, 56, 0.96);
}

/* 聚焦反馈：与暗色 .search-box:focus-within 同一组颜色。 */
html[data-theme="dark"] .online-form input:focus,
html[data-theme="dark"] .reason-input input:focus {
  border-color: rgba(240, 145, 153, 0.45);
}
html[data-theme="dark"] .tag-modal-search:focus-within {
  border-color: rgba(240, 145, 153, 0.45);
  box-shadow: 0 0 0 3px rgba(240, 145, 153, 0.1);
}

/* 骨架屏扫光与对比页封面占位：去掉只适合亮底的米白 / 浅灰。 */
html[data-theme="dark"] .skel::after {
  background: linear-gradient(
    100deg,
    transparent 20%,
    rgba(255, 255, 255, 0.07) 38%,
    transparent 56%
  );
}
html[data-theme="dark"] .compare-poster,
html[data-theme="dark"] .compare-pick-cover {
  background: linear-gradient(150deg, var(--pink-soft), #26222b);
}
