/* MCJF 主站深浅色主题：只覆盖颜色，不动布局。
   浅色为默认；html[data-theme="dark"] 时切到深色。 */

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1216;
  --bg-card: #171b21;
  --bg-soft: #1c2129;
  --bg-sunken: #12161c;
  --bg-tint: #241a13;
  --line: #282e37;
  --line-strong: #3a424e;
  --ink: #e7ecf2;
  --ink-2: #c2cad5;
  --muted: #909aa8;
  --accent: #ff7a33;
  --accent-strong: #ff8f52;
  --accent-soft: rgba(255, 122, 51, .16);
  --shadow-sm: 0 4px 16px rgba(0, 0, 0, .45);
  --shadow-md: 0 12px 34px rgba(0, 0, 0, .6);
}

html[data-theme="dark"] body { background: var(--bg); color: var(--ink); }
html[data-theme="dark"] ::selection { background: var(--accent); color: #0b0d10; }
html[data-theme="dark"] img { filter: none; }

/* 顶栏 */
html[data-theme="dark"] .top { background: rgba(15, 18, 22, .94); border-bottom-color: var(--line); }
html[data-theme="dark"] .nav a:hover { color: var(--ink); }
html[data-theme="dark"] .brand em { color: var(--muted); }

/* 首屏 */
html[data-theme="dark"] .hero {
  background:
    radial-gradient(ellipse at 75% 32%, rgba(255, 122, 51, .10), transparent 55%),
    linear-gradient(180deg, #131922, #0f1216);
  border-bottom-color: var(--line);
}
html[data-theme="dark"] .hero .veil {
  background: linear-gradient(180deg, rgba(15, 18, 22, .35), rgba(26, 18, 10, .55) 52%, rgba(15, 18, 22, .94));
}
html[data-theme="dark"] .hero .bg { filter: saturate(.45) brightness(.5); }
html[data-theme="dark"] .hero-window {
  background: #191c21;
  border-color: rgba(255, 255, 255, .08);
  box-shadow: 0 20px 45px -27px #000e, 0 0 0 1px #262c35;
}
html[data-theme="dark"] .hero-scene::after { background: #1b1410; border-color: #5a3a22; }
html[data-theme="dark"] .eyebrow { color: #ff9a63; }
html[data-theme="dark"] .scene-caption,
html[data-theme="dark"] .scene-caption span:first-child,
html[data-theme="dark"] .scene-coordinate { color: #8b9199; }

/* 按钮 */
html[data-theme="dark"] .btn.ghost { background: #171b21; border-color: #2a3039; color: var(--ink); }
html[data-theme="dark"] .btn.ghost:hover { background: #20262f; border-color: #3a424e; }
html[data-theme="dark"] .btn.primary { background: var(--accent); border-color: var(--accent); color: #0b0d10; }

/* 内容卡片 */
html[data-theme="dark"] .post .ph { background: #12161c; }
html[data-theme="dark"] .post .bdg { background: #1c2129; color: var(--ink-2); }
html[data-theme="dark"] .post .bdg.pin,
html[data-theme="dark"] .post .bdg.feat { background: #241a13; color: #ff9a63; }
html[data-theme="dark"] .sk .a,
html[data-theme="dark"] .sk .l { background: linear-gradient(90deg, #181d24 25%, #20262f 50%, #181d24 75%); }
html[data-theme="dark"] .entry .ic { background: #1f242c; }
html[data-theme="dark"] .entry:hover .ic { background: #241a13; }
html[data-theme="dark"] .about { background: linear-gradient(180deg, #12161c, #0f1216); }

/* 弹出菜单与账号面板 */
html[data-theme="dark"] .mega { background: #171b21; border-color: #2a3039; box-shadow: 0 24px 60px -20px #000; }
html[data-theme="dark"] .mega a.mi:hover { background: #20262f; }
html[data-theme="dark"] .mega a.mi .ico { background: #241a13; color: var(--accent); }
html[data-theme="dark"] .acct { background: #171b21; border-color: #2a3039; }
html[data-theme="dark"] .acct-tabs button.on { background: #241a13; color: var(--accent); }
html[data-theme="dark"] #mcjfCookieBar { background: #171b21; border-color: #2a3039; color: var(--ink); }
html[data-theme="dark"] .ck-btn.primary { background: var(--accent); color: #0b0d10; }

/* 数字街区 */
html[data-theme="dark"] #mcjf-district {
  --paper: #0f1216;
  --ink: #e7ecf2;
  --muted: #9aa4b1;
  --orange: #ff7a33;
  --line: #282e37;
  color-scheme: dark;
  background: var(--paper);
}
html[data-theme="dark"] #mcjf-district .site-header { background: rgba(15, 18, 22, .92); border-color: #282e37; }
html[data-theme="dark"] #mcjf-district .nav-ai { background: #241a13; color: #ff9a63; }
html[data-theme="dark"] #mcjf-district .portal,
html[data-theme="dark"] #mcjf-district .forum-portal,
html[data-theme="dark"] #mcjf-district .game-portal,
html[data-theme="dark"] #mcjf-district .ai-portal { background: #171b21; border-color: #282e37; }
html[data-theme="dark"] #mcjf-district .ai-badge { background: #241a13; color: #ff9a63; }
html[data-theme="dark"] #mcjf-district .prompt-form { background: #12161c; border-color: #282e37; }
html[data-theme="dark"] #mcjf-district .send-button { background: #20262f; border-color: #2f3742; color: var(--ink); }
html[data-theme="dark"] #mcjf-district .suggestions button:hover { background: #20262f; }
html[data-theme="dark"] #mcjf-district .tool-dock { background: #171b21; border-color: #282e37; }
html[data-theme="dark"] #mcjf-district .tool-entry:hover,
html[data-theme="dark"] #mcjf-district .tool-entry:focus-visible { background: #20262f; }
html[data-theme="dark"] #mcjf-district .tool-icon { background: #1c2129; }
html[data-theme="dark"] #mcjf-district .entry-dialog { background: #171b21; border-color: #282e37; }
html[data-theme="dark"] #mcjf-district .close-dialog { background: #20262f; border-color: #2f3742; color: var(--ink); }
html[data-theme="dark"] #mcjf-district .question-bubble { background: #1c2129; color: var(--ink); }
html[data-theme="dark"] #mcjf-district .dialog-back { background: rgba(9, 11, 14, .72); }
html[data-theme="dark"] #mcjf-district .title-mark::before,
html[data-theme="dark"] #mcjf-district .title-mark::after,
html[data-theme="dark"] #mcjf-district .spatial-field::before { background: #1c2129; }

/* 切换按钮 */
.theme-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  min-height: 38px;
  padding: 0;
  margin-left: 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg-card);
  color: var(--muted);
  cursor: pointer;
  transition: color .2s, background .2s, border-color .2s, transform .2s;
}
.theme-btn:hover { color: var(--accent); border-color: var(--accent); }
.theme-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.theme-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; }
.theme-btn[aria-pressed="true"] svg { transform: rotate(-18deg) scale(.96); }
.theme-btn .theme-sun { display: block; }
.theme-btn .theme-moon { display: none; }
html[data-theme="dark"] .theme-btn .theme-sun { display: none; }
html[data-theme="dark"] .theme-btn .theme-moon { display: block; }

/* 切换时的过渡（只在切换瞬间挂上，避免影响其它动画） */
html.theme-fading,
html.theme-fading * {
  transition: background-color .28s ease, color .28s ease, border-color .28s ease, box-shadow .28s ease !important;
}

/* ============================================================
   子页面：AI 系列 / 搜索 / 论坛 / 404 / 游戏列表
   它们各自有一套同名变量，这里统一给出深色值
   ============================================================ */
html[data-theme="dark"] {
  --sub: #a9b3c0;
  --glass: rgba(23, 27, 33, .86);
  --glass-strong: rgba(19, 23, 28, .97);
  --accent-hover: #ff8f52;
  --accent-soft: #241a13;
  --accent-line: rgba(255, 122, 51, .3);
  --accent-ink: #ffb08a;
  --c-text: #e7ecf2;
  --c-hint: #9aa4b1;
  --amber: #ff7a33;
  --blue: #ff7a33;
  --shadow: 0 8px 24px -16px rgba(0, 0, 0, .55);
}
html[data-theme="dark"] body { background: var(--bg, #0f1216); }

/* ---- AI 主页与 AI 工具页 ---- */
html[data-theme="dark"] body::before {
  background: radial-gradient(ellipse at 50% -10%, rgba(255, 122, 51, .08), transparent 60%) !important;
}
html[data-theme="dark"] .sidebar { background: #151a20; border-color: #282e37; }
html[data-theme="dark"] .menu { background: #171b21; border-color: #2a3039; box-shadow: 0 18px 40px -18px #000; }
html[data-theme="dark"] .session-row:hover,
html[data-theme="dark"] .histbar button:hover { background: #20262f; }
html[data-theme="dark"] .histbar button { background: #1c2129; border-color: #2a3039; color: var(--ink); }
html[data-theme="dark"] .msg.user .bubble { background: #241a13; color: #ffd9c2; }
html[data-theme="dark"] .msg.user .bubble code { background: rgba(255, 255, 255, .08); color: #ffd9c2; }
html[data-theme="dark"] .msg.ai .bubble.work-bubble { background: #1c2129; border-color: #2a3039; }
html[data-theme="dark"] .bubble .tbl { background: #12161c; border-color: #2a3039; }
html[data-theme="dark"] .bubble tbody tr:hover { background: #1c2129; }
html[data-theme="dark"] .bubble .acts button,
html[data-theme="dark"] .bubble .acts button:hover { background: #1c2129; border-color: #2a3039; color: var(--ink); }
html[data-theme="dark"] .sitemenu { background: #171b21; border-color: #2a3039; box-shadow: 0 18px 40px -18px #000; }
html[data-theme="dark"] .work-toggle[aria-pressed="true"],
html[data-theme="dark"] .work-toggle[aria-pressed="true"][aria-disabled="true"] { background: #241a13; color: #ffb08a; }
html[data-theme="dark"] .mode-tag { background: #241a13; color: #ff9a63; }
html[data-theme="dark"] .work-file-card,
html[data-theme="dark"] .work-file-icon,
html[data-theme="dark"] .ufile,
html[data-theme="dark"] .thumbs .fchip,
html[data-theme="dark"] .thumbs .t b { background: #1c2129; border-color: #2a3039; color: var(--ink); }
html[data-theme="dark"] .ufile:hover { background: #20262f; }
html[data-theme="dark"] #saveModal .smbox,
html[data-theme="dark"] #switchModal .smbox { background: #171b21; border-color: #2a3039; box-shadow: 0 30px 60px -20px #000; }
html[data-theme="dark"] #saveModal button,
html[data-theme="dark"] #switchModal button { background: #20262f; border-color: #2f3742; color: var(--ink); }
html[data-theme="dark"] #toast { background: #1c2129; border-color: #2a3039; color: var(--ink); }
html[data-theme="dark"] .fb-open { background: #1c2129; border-color: #2a3039; color: var(--ink); }

/* ---- 聚合搜索 ---- */
html[data-theme="dark"] .bg::after { background: linear-gradient(180deg, rgba(15, 18, 22, .55), #0f1216) !important; }
html[data-theme="dark"] .searchbar { background: #171b21; border-color: #2a3039; box-shadow: 0 18px 40px -22px #000; }
html[data-theme="dark"] .go { background: #20262f; color: var(--ink); }
html[data-theme="dark"] .cands { background: #171b21; border-color: #2a3039; box-shadow: 0 18px 40px -18px #000; }
html[data-theme="dark"] .cand.on { background: #20262f; }
html[data-theme="dark"] .mode.sel { background: #241a13; color: #ff9a63; }
html[data-theme="dark"] .qk { background: #1c2129; border-color: #2a3039; color: var(--ink); }
html[data-theme="dark"] .qk:hover { background: #20262f; }
html[data-theme="dark"] .chip { background: #1c2129; border-color: #2a3039; color: var(--ink); }
html[data-theme="dark"] .scrollhint,
html[data-theme="dark"] #wallTag { color: #8f99a6; }
html[data-theme="dark"] .peek::before,
html[data-theme="dark"] .peek-b { background: #171b21; border-color: #2a3039; }
html[data-theme="dark"] .cargo-blocked-inner,
html[data-theme="dark"] #jtOpen,
html[data-theme="dark"] #shellBar,
html[data-theme="dark"] #shell iframe { background: #171b21; border-color: #2a3039; }
html[data-theme="dark"] #backBtn:hover { background: #20262f; }

/* ---- 论坛（含发帖、帖子页、上传页、游戏列表） ---- */
html[data-theme="dark"] .btn { background: #171b21; border-color: #2a3039; color: var(--ink); }
html[data-theme="dark"] .btn.primary { background: var(--accent); border-color: var(--accent); color: #0b0d10; }
html[data-theme="dark"] input[type=text], html[data-theme="dark"] textarea, html[data-theme="dark"] select { background: #12161c; border-color: #2a3039; color: var(--ink); }
html[data-theme="dark"] select option { background: #171b21; color: var(--ink); }
html[data-theme="dark"] .seg button.on { background: #241a13; color: #ff9a63; }
html[data-theme="dark"] .imgs button { background: #1c2129; border-color: #2a3039; }
html[data-theme="dark"] .post.pinned { background: #171b21; }
html[data-theme="dark"] .badge.pin,
html[data-theme="dark"] .badge.feat,
html[data-theme="dark"] .badge.art { background: #241a13; color: #ff9a63; }
html[data-theme="dark"] .act.liked { background: #241a13; color: #ff9a63; }
html[data-theme="dark"] .toast { background: #1c2129; border-color: #2a3039; color: var(--ink); }
html[data-theme="dark"] .sk-line,
html[data-theme="dark"] .sk-dot,
html[data-theme="dark"] .skel-card .cover { background: linear-gradient(90deg, #181d24 25%, #20262f 50%, #181d24 75%); }
html[data-theme="dark"] .forum-heading { background: #12161c; border-color: #282e37; }

/* ---- 404 ---- */
html[data-theme="dark"] .illustration { background: #12161c; border-color: #282e37; }

/* ---- 通用悬浮切换按钮（页面自身没有按钮时由脚本注入） ---- */
.theme-fab {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 90;
  width: 42px;
  height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line, #e3e6ea);
  border-radius: 999px;
  background: var(--bg-card, #fff);
  color: var(--muted, #6b7480);
  cursor: pointer;
  box-shadow: 0 8px 24px -12px rgba(0, 0, 0, .45);
  opacity: .82;
  transition: opacity .2s, color .2s, border-color .2s, background .2s;
}
.theme-fab:hover { opacity: 1; color: var(--accent, #ff6a1f); border-color: var(--accent, #ff6a1f); }
.theme-fab svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; }
.theme-fab .theme-sun { display: block; }
.theme-fab .theme-moon { display: none; }
html[data-theme="dark"] .theme-fab .theme-sun { display: none; }
html[data-theme="dark"] .theme-fab .theme-moon { display: block; }
