/* 全站主题 — 默认白天（白底），可选夜间模式 */
html[data-theme="light"],
html:not([data-theme]) {
  --theme-bg: #ffffff;
  --theme-surface: #ffffff;
  --theme-surface2: #f6f6f6;
  --theme-border: #ebebeb;
  --theme-text: #121212;
  --theme-muted: #646e82;
  --theme-accent: #0066ff;
  --theme-accent-hover: #0052cc;
  --theme-green: #10b981;
  --theme-success: #16a34a;
  --theme-danger: #ef4444;
  --theme-warn: #f59e0b;
  --theme-radius: 12px;
  --theme-nav-bg: #ffffff;
  --theme-nav-border: #ebebeb;
  --theme-nav-text: #8590a6;
  --theme-nav-text-active: #121212;
  --theme-nav-title: #0066ff;
  --theme-shadow: rgba(15, 23, 42, 0.08);
  --theme-hero-grad: linear-gradient(135deg, #121212, #0066ff);
  --theme-page-glow: none;
  --code-bg: #f6f8fa;
  --code-surface: #eef1f4;
  --code-text: #1f2937;
  --code-muted: #57606a;
  --code-border: #d0d7de;
  --code-blank-bg: #fff8c5;
  --code-blank-fg: #9a6700;
  --code-step-bg: #f3f4f6;
  --code-answer-bg: #ecfdf5;
  --code-answer-text: #047857;
  --code-console-err: #cf222e;
  --code-console-ok: #116329;
  --code-console-info: #57606a;
}

html[data-theme="dark"] {
  --theme-bg: #0f1419;
  --theme-surface: #1a2332;
  --theme-surface2: #243044;
  --theme-border: #2d3f56;
  --theme-text: #e8edf4;
  --theme-muted: #8b9cb3;
  --theme-accent: #3b82f6;
  --theme-accent-hover: #2563eb;
  --theme-green: #10b981;
  --theme-success: #22c55e;
  --theme-danger: #ef4444;
  --theme-warn: #f59e0b;
  --theme-radius: 12px;
  --theme-nav-bg: #1a2332;
  --theme-nav-border: #2d3f56;
  --theme-nav-text: #8b9cb3;
  --theme-nav-text-active: #e8edf4;
  --theme-nav-title: #93c5fd;
  --theme-shadow: rgba(0, 0, 0, 0.35);
  --theme-hero-grad: linear-gradient(135deg, #e8edf4, #93c5fd);
  --theme-page-glow:
    radial-gradient(ellipse 80% 50% at 50% -20%, #3b82f612, transparent),
    radial-gradient(ellipse 60% 40% at 100% 0%, #10b9810a, transparent);
  --code-bg: #0d1117;
  --code-surface: #161b22;
  --code-text: #c9d1d9;
  --code-muted: #8b949e;
  --code-border: #30363d;
  --code-blank-bg: #f59e0b33;
  --code-blank-fg: #fcd34d;
  --code-step-bg: #0d111788;
  --code-answer-bg: #0f1f1a;
  --code-answer-text: #a7f3d0;
  --code-console-err: #f87171;
  --code-console-ok: #4ade80;
  --code-console-info: #8b949e;
}

/* 通用别名（quiz / practice 等页面） */
html {
  --bg: var(--theme-bg);
  --surface: var(--theme-surface);
  --surface2: var(--theme-surface2);
  --border: var(--theme-border);
  --text: var(--theme-text);
  --muted: var(--theme-muted);
  --accent: var(--theme-accent);
  --accent-hover: var(--theme-accent-hover);
  --success: var(--theme-success);
  --danger: var(--theme-danger);
  --warn: var(--theme-warn);
  --radius: var(--theme-radius);
  --sl-bg: var(--theme-bg);
  --sl-surface: var(--theme-surface);
  --sl-surface2: var(--theme-surface2);
  --sl-border: var(--theme-border);
  --sl-text: var(--theme-text);
  --sl-muted: var(--theme-muted);
  --sl-accent: var(--theme-accent);
  --sl-green: var(--theme-green);
  --sl-radius: var(--theme-radius);
}

html,
body {
  background: var(--theme-bg);
  color: var(--theme-text);
}

/* 顶栏主题 */
.app-nav {
  background: var(--theme-nav-bg) !important;
  border-bottom-color: var(--theme-nav-border) !important;
  box-shadow: 0 1px 3px var(--theme-shadow) !important;
}
.app-nav .nav-title { color: var(--theme-nav-title) !important; }
.app-nav .nav-brand-sub {
  color: var(--theme-muted) !important;
  -webkit-text-fill-color: var(--theme-muted) !important;
}
html[data-theme="dark"] .app-nav .nav-brand-main {
  background: linear-gradient(135deg, #93c5fd, #60a5fa);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.app-nav .nav-links a { color: var(--theme-nav-text) !important; }
.app-nav .nav-links a:hover,
.app-nav .nav-links a.active { color: var(--theme-nav-text-active) !important; }
.app-nav .nav-search {
  border-color: var(--theme-border) !important;
  background: var(--theme-surface2) !important;
}
html[data-theme="light"] .app-nav .nav-search:focus-within,
html:not([data-theme]) .app-nav .nav-search:focus-within {
  background: #fff !important;
}
html[data-theme="dark"] .app-nav .nav-search:focus-within {
  background: var(--theme-surface) !important;
  border-color: var(--theme-accent) !important;
}
.app-nav .nav-search input { color: var(--theme-text) !important; }
.app-nav .nav-search input::placeholder { color: var(--theme-muted) !important; }

/* 搜索按钮：夜间提高对比度 */
.app-nav .nav-search .nav-search-submit,
.app-nav .nav-search-inner .nav-search-submit {
  color: var(--theme-accent) !important;
  font-weight: 700 !important;
}
html[data-theme="dark"] .app-nav .nav-search .nav-search-submit,
html[data-theme="dark"] .app-nav .nav-search-inner .nav-search-submit {
  color: #93c5fd !important;
  background: rgba(59, 130, 246, 0.22) !important;
  border-radius: 999px !important;
  margin: 3px 4px 3px 0 !important;
  padding: 0 12px !important;
  height: 28px !important;
}
html[data-theme="dark"] .app-nav .nav-search-zh .nav-search-submit {
  color: #93c5fd !important;
  background: rgba(59, 130, 246, 0.28) !important;
}

.app-nav .nav-status {
  color: var(--theme-muted) !important;
  background: var(--theme-surface2) !important;
  border-color: var(--theme-border) !important;
  max-width: 7.5rem !important;
}
html[data-theme="dark"] .app-nav .nav-status.premium {
  color: #6ee7b7 !important;
  border-color: #065f46 !important;
  background: #064e3b66 !important;
}
.app-nav .btn-nav-account,
.app-nav .btn-theme-toggle {
  border-color: var(--theme-border) !important;
  background: var(--theme-surface) !important;
  color: var(--theme-text) !important;
}
.app-nav .btn-nav-account:hover,
.app-nav .btn-theme-toggle:hover {
  border-color: var(--theme-accent) !important;
  color: var(--theme-accent) !important;
}
.app-nav .nav-panel {
  background: var(--theme-surface) !important;
  border-color: var(--theme-border) !important;
  box-shadow: 0 12px 40px var(--theme-shadow) !important;
}
.app-nav .nav-panel h3 { color: var(--theme-text) !important; }
.app-nav .nav-panel p { color: var(--theme-muted) !important; }
.app-nav .nav-panel .acts a {
  border-color: var(--theme-border) !important;
  background: var(--theme-surface2) !important;
  color: var(--theme-text) !important;
}

.app-nav .btn-theme-toggle {
  padding: 6px 10px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  line-height: 1.2;
}

html[data-theme="dark"] body.site-page::before {
  content: "";
  position: fixed;
  inset: 0;
  background: var(--theme-page-glow);
  pointer-events: none;
  z-index: 0;
}

html[data-theme="light"] body.site-page::before,
html:not([data-theme]) body.site-page::before {
  content: none;
}

html[data-theme="light"] .site-hero h1,
html:not([data-theme]) .site-hero h1 {
  background: var(--theme-hero-grad);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

html[data-theme="dark"] .site-hero h1 {
  background: var(--theme-hero-grad);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

html[data-theme="light"] .site-module:hover,
html:not([data-theme]) .site-module:hover {
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}

html[data-theme="light"] .site-section-range,
html:not([data-theme]) .site-section-range {
  background: var(--theme-surface2);
}

html[data-theme="dark"] .site-section-range {
  background: #00000018;
}

html[data-theme="light"] .site-module .mod-tag.hot,
html:not([data-theme]) .site-module .mod-tag.hot {
  background: #fef3c7;
  color: #b45309;
}

/* 刷题页 — 白天模式文字对比度 */
html[data-theme="light"] .learn-concept,
html:not([data-theme]) .learn-concept {
  background: #eff6ff;
  border-color: #93c5fd;
  color: #1e3a8a;
}

html[data-theme="dark"] .learn-concept {
  background: #3b82f612;
  border-color: #3b82f640;
  color: #bfdbfe;
}

html[data-theme="light"] .learn-warn,
html:not([data-theme]) .learn-warn {
  background: #fffbeb;
  border-color: #fcd34d;
  color: #92400e;
}

html[data-theme="dark"] .learn-warn {
  color: #fbbf24;
}

html[data-theme="light"] .exam-tip,
html:not([data-theme]) .exam-tip {
  background: #fffbeb;
  border-color: #fde68a;
  color: #92400e;
}

html[data-theme="dark"] .exam-tip {
  color: #fbbf24;
}

html[data-theme="light"] .explain-box,
html:not([data-theme]) .explain-box {
  background: #f8fafc;
  color: var(--theme-text);
}

html[data-theme="dark"] .explain-box {
  background: #00000025;
}

html[data-theme="light"] .explain-summary,
html:not([data-theme]) .explain-summary {
  color: var(--theme-text);
}

html[data-theme="light"] .review-summary,
html:not([data-theme]) .review-summary {
  background: #f1f5f9;
  color: var(--theme-text);
}

html[data-theme="dark"] .review-summary {
  background: #00000030;
}

html[data-theme="light"] .explain-table th,
html:not([data-theme]) .explain-table th {
  background: #f1f5f9;
  color: #475569;
}

html[data-theme="light"] .tag-s,
html:not([data-theme]) .tag-s {
  background: #dbeafe;
  color: #1d4ed8;
}

html[data-theme="light"] .tag-j,
html:not([data-theme]) .tag-j {
  background: #ede9fe;
  color: #6d28d9;
}

html[data-theme="light"] .tag-m,
html:not([data-theme]) .tag-m {
  background: #d1fae5;
  color: #047857;
}

/* 操作题「Python / 论述」标签 — 白天模式提高对比度 */
html[data-theme="light"] .tag-jupyter,
html:not([data-theme]) .tag-jupyter,
html[data-theme="light"] .site-type-jupyter,
html:not([data-theme]) .site-type-jupyter {
  background: #dbeafe !important;
  color: #1d4ed8 !important;
}
html[data-theme="light"] .tag-doc,
html:not([data-theme]) .tag-doc,
html[data-theme="light"] .site-type-doc,
html:not([data-theme]) .site-type-doc {
  background: #ede9fe !important;
  color: #5b21b6 !important;
}
html[data-theme="light"] .tag-sheet,
html:not([data-theme]) .tag-sheet,
html[data-theme="light"] .site-type-sheet,
html:not([data-theme]) .site-type-sheet {
  background: #d1fae5 !important;
  color: #047857 !important;
}

/* 操作题 — 答题指引 / 参考答案（白天模式去深色渐变） */
.guide-card {
  background: var(--theme-surface) !important;
  border: 1px solid var(--theme-border) !important;
}
html[data-theme="light"] .guide-card,
html:not([data-theme]) .guide-card {
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.04);
}
html[data-theme="dark"] .guide-card {
  background: var(--theme-surface) !important;
}

html[data-theme="light"] .guide-note,
html:not([data-theme]) .guide-note {
  background: #eff6ff;
  color: #1e40af;
}
html[data-theme="dark"] .guide-note {
  background: #3b82f622;
  color: #93c5fd;
}

html[data-theme="light"] .answer-methodology,
html:not([data-theme]) .answer-methodology {
  background: #f8fafc !important;
  color: #475569 !important;
  border-color: var(--theme-border) !important;
}
html[data-theme="dark"] .answer-methodology {
  background: #243044 !important;
}

html[data-theme="light"] .path-box,
html:not([data-theme]) .path-box {
  background: #f1f5f9 !important;
  color: #475569 !important;
}

html[data-theme="light"] .warn-box,
html:not([data-theme]) .warn-box {
  background: #fffbeb !important;
  color: #92400e !important;
  border-color: #fde68a !important;
}
html[data-theme="dark"] .warn-box {
  color: #fcd34d;
}

html[data-theme="light"] .excel-table th,
html:not([data-theme]) .excel-table th {
  background: #eef1f4 !important;
  color: #374151 !important;
}
html[data-theme="dark"] .excel-table th {
  background: #243044;
}

html[data-theme="light"] .guide-summary,
html:not([data-theme]) .guide-summary {
  color: var(--theme-text);
}
html[data-theme="light"] .guide-steps li,
html:not([data-theme]) .guide-steps li {
  color: var(--theme-text);
}
html[data-theme="light"] .step-detail,
html:not([data-theme]) .step-detail {
  color: var(--theme-muted);
}
