/* ============================================================
   夜神 NOCTURNE·DEV — 高级编程圣殿
   Theme: night sky · neon purple/cyan · glassmorphism
   ============================================================ */

:root {
  --bg: #070818;
  --bg-2: #0b0d24;
  --bg-card: rgba(20, 24, 52, 0.62);
  --border: rgba(140, 150, 255, 0.16);
  --text: #e8ecff;
  --text-dim: #9aa3d0;
  --text-faint: #8f9ac9;   /* 原 #6b74a8：落在 hero 紫光上只有 2.8:1，抬到 AA（仍暗于 --text-dim，层级不乱） */
  --purple: #7c6cff;
  --cyan: #38e1ff;
  --pink: #ff5c8a;
  --gold: #ffd166;
  --grad-brand: linear-gradient(120deg, #38e1ff 0%, #7c6cff 50%, #ff5c8a 100%);
  --radius: 18px;
  --mono: "JetBrains Mono", "Fira Code", "SF Mono", Consolas, "Courier New", monospace;
  --sans: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  overflow-x: hidden;
}

::selection { background: rgba(124, 108, 255, 0.45); color: #fff; }

/* ---------- 无障碍：跳转链接 / noscript 提示 ---------- */
.skip-link {
  position: fixed;
  top: -52px; left: 16px;
  z-index: 500;
  background: var(--purple);
  color: #06070f;
  padding: 10px 18px;
  border-radius: 0 0 12px 12px;
  text-decoration: none;
  font-size: 13px;
  transition: top 0.2s ease;
}
.skip-link:focus { top: 0; }
.noscript-warn {
  margin: 0;
  padding: 14px 20px;
  text-align: center;
  background: #2b1d10;
  color: #ffd166;
  border-bottom: 1px solid rgba(255, 209, 102, 0.4);
  font-size: 14px;
}

/* ---------- 导航 ---------- */
.nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  background: rgba(7, 8, 24, 0.72);
  border-bottom: 1px solid var(--border);
  transition: box-shadow 0.3s ease;
}
.nav.scrolled { box-shadow: 0 10px 40px rgba(0, 0, 0, 0.55); }

.nav-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 28px;
}

.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); }
.brand-mark { font-size: 22px; filter: drop-shadow(0 0 10px rgba(124, 108, 255, 0.8)); }
.brand-name { font-size: 19px; font-weight: 800; letter-spacing: 2px; }
.brand-name em {
  display: block;
  font-size: 10px; font-style: normal;
  letter-spacing: 4px;
  color: var(--text-faint);
  font-family: var(--mono);
}

.nav-links { display: flex; gap: 26px; margin-left: auto; }
.nav-links a {
  color: var(--text-dim);
  text-decoration: none;
  font-size: 14.5px;
  letter-spacing: 1px;
  position: relative;
  padding: 4px 0;
  transition: color 0.25s;
}
.nav-links a::after {
  content: "";
  position: absolute;
  left: 0; bottom: 0;
  width: 0; height: 2px;
  background: var(--grad-brand);
  border-radius: 2px;
  transition: width 0.3s ease;
}
.nav-links a:hover { color: var(--text); }
.nav-links a:hover::after { width: 100%; }

.nav-cta {
  font-size: 14px;
  padding: 9px 22px;
  border-radius: 999px;
  color: #fff;
  text-decoration: none;
  background: linear-gradient(120deg, rgba(56, 225, 255, 0.16), rgba(124, 108, 255, 0.28));
  border: 1px solid rgba(124, 108, 255, 0.45);
  transition: box-shadow 0.25s, transform 0.25s;
}
.nav-cta:hover {
  box-shadow: 0 0 24px rgba(124, 108, 255, 0.45);
  transform: translateY(-1px);
}

.nav-burger { display: none; flex-direction: column; gap: 5px; background: none; border: none; cursor: pointer; padding: 6px; }
.nav-burger span { width: 24px; height: 2px; background: var(--text-dim); border-radius: 2px; transition: 0.3s; }

/* ---------- Hero ---------- */
.hero {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 120px 24px 80px;
  background:
    radial-gradient(ellipse 80% 55% at 50% -10%, rgba(124, 108, 255, 0.22), transparent 60%),
    radial-gradient(ellipse 60% 40% at 85% 30%, rgba(56, 225, 255, 0.10), transparent 60%),
    var(--bg);
  overflow: hidden;
}

#starfield {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.hero-glow {
  position: absolute;
  width: 640px; height: 640px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(124, 108, 255, 0.16), transparent 65%);
  top: -160px; left: 50%;
  transform: translateX(-50%);
  pointer-events: none;
  animation: breathe 7s ease-in-out infinite;
}
@keyframes breathe { 0%, 100% { opacity: 0.65; } 50% { opacity: 1; } }

.hero-inner {
  position: relative;
  max-width: 860px;
  text-align: center;
  z-index: 2;
}

.hero-kicker {
  font-family: var(--mono);
  font-size: 12.5px;
  letter-spacing: 6px;
  color: var(--cyan);
  margin-bottom: 18px;
  text-transform: uppercase;
}

.hero-title {
  font-size: clamp(44px, 8vw, 84px);
  font-weight: 900;
  line-height: 1.15;
  letter-spacing: 4px;
}
.grad {
  background: var(--grad-brand);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 28px rgba(124, 108, 255, 0.35));
}

.hero-sub {
  margin: 26px auto 8px;
  max-width: 560px;
  color: var(--text-dim);
  font-size: 17px;
}

/* 代码卡片 */
.hero-code {
  margin: 44px auto 0;
  max-width: 620px;
  text-align: left;
  border-radius: var(--radius);
  background: rgba(10, 12, 32, 0.85);
  border: 1px solid var(--border);
  box-shadow:
    0 30px 80px rgba(0, 0, 0, 0.5),
    0 0 0 1px rgba(124, 108, 255, 0.06) inset;
  overflow: hidden;
  animation: float 6s ease-in-out infinite;
}
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.code-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: rgba(16, 19, 44, 0.9);
  border-bottom: 1px solid var(--border);
}
.dot { width: 11px; height: 11px; border-radius: 50%; }
.dot.r { background: #ff5f56; } .dot.y { background: #ffbd2e; } .dot.g { background: #27c93f; }
.code-title { margin-left: 10px; font-family: var(--mono); font-size: 12px; color: var(--text-faint); }

.code-body {
  font-family: var(--mono);
  font-size: 15px;
  line-height: 1.75;
  padding: 22px 24px;
  min-height: 172px;
  white-space: pre-wrap;
  color: #c9d2ff;
}
.caret {
  display: inline-block;
  width: 9px; height: 18px;
  margin-left: 2px;
  vertical-align: -3px;
  background: var(--cyan);
  box-shadow: 0 0 12px rgba(56, 225, 255, 0.8);
  animation: blink 0.85s step-end infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* 代码高亮 token 色 */
.tk-kw { color: #c792ea; }
.tk-str { color: #a5e075; }
.tk-fn { color: #82aaff; }
.tk-num { color: #f78c6c; }
.tk-cm { color: #8b96c4; font-style: italic; }  /* 原 #5c6791 在深底上仅 3.5:1，注释也要读得清 */
.tk-cls { color: #ffcb6b; }
.tk-pn { color: #89ddff; }

.hero-actions { margin-top: 36px; display: flex; gap: 18px; justify-content: center; flex-wrap: wrap; }

.btn {
  font-family: var(--sans);
  font-size: 15.5px;
  letter-spacing: 1px;
  padding: 13px 30px;
  border-radius: 999px;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid transparent;
  transition: transform 0.25s, box-shadow 0.25s, background 0.25s;
}
.btn-primary {
  color: #06070f;   /* 白字压在 #38e1ff 起点上只有 1.6:1；近黑墨让三档色标都到 5:1 以上，霓虹底色不动 */
  background: linear-gradient(120deg, #38e1ff, #7c6cff 60%, #ff5c8a);
  background-size: 200% 200%;
  box-shadow: 0 10px 32px rgba(124, 108, 255, 0.4);
}
.btn-primary:hover { transform: translateY(-3px); box-shadow: 0 16px 44px rgba(124, 108, 255, 0.55); background-position: 100% 0; }
.btn-ghost { color: var(--text-dim); border-color: rgba(140, 150, 255, 0.3); background: rgba(20, 24, 52, 0.4); }
.btn-ghost:hover { color: var(--text); border-color: rgba(140, 150, 255, 0.6); transform: translateY(-3px); }

.hero-stats {
  margin-top: 58px;
  display: flex;
  justify-content: center;
  gap: clamp(20px, 6vw, 72px);
  list-style: none;
  flex-wrap: wrap;
}
.hero-stats b {
  display: block;
  font-size: 30px;
  font-weight: 800;
  background: var(--grad-brand);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero-stats span { font-size: 13px; color: var(--text-faint); letter-spacing: 1px; }

/* ---------- 通用 Section ---------- */
.section { padding: 110px 24px; max-width: 1180px; margin: 0 auto; }
.section-alt {
  max-width: none;
  background:
    radial-gradient(ellipse 60% 50% at 10% 20%, rgba(56, 225, 255, 0.06), transparent 60%),
    radial-gradient(ellipse 50% 50% at 90% 80%, rgba(255, 92, 138, 0.05), transparent 60%);
}
.section-alt > * { max-width: 1180px; margin-left: auto; margin-right: auto; }

.section-head { text-align: center; margin-bottom: 60px; }
.section-kicker { font-family: var(--mono); letter-spacing: 6px; font-size: 12px; color: var(--cyan); text-transform: uppercase; }
.section-title { font-size: clamp(30px, 4vw, 44px); font-weight: 800; letter-spacing: 3px; margin: 10px 0 14px; }
.section-desc { color: var(--text-dim); max-width: 620px; margin: 0 auto; }

/* 滚动浮现 */
.reveal { opacity: 0; transform: translateY(36px); transition: opacity 0.7s ease, transform 0.7s ease; }
.reveal.on { opacity: 1; transform: none; }

/* ---------- 语言圣殿 ---------- */
.lang-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 26px;
}

.lang-card {
  position: relative;
  padding: 26px 26px 22px;
  border-radius: var(--radius);
  background: var(--bg-card);
  border: 1px solid var(--border);
  backdrop-filter: blur(14px);
  transition: transform 0.35s ease, border-color 0.35s ease, box-shadow 0.35s ease;
  cursor: default;
  overflow: hidden;
}
.lang-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(140deg, rgba(124, 108, 255, 0.12), transparent 45%);
  opacity: 0;
  transition: opacity 0.35s;
}
.lang-card:hover {
  transform: translateY(-8px);
  border-color: rgba(124, 108, 255, 0.45);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45), 0 0 40px rgba(124, 108, 255, 0.12);
}
.lang-card:hover::before { opacity: 1; }

.lang-card header { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; position: relative; }
.lang-glyph { font-size: 26px; }
.lang-card h3 { font-size: 20px; letter-spacing: 1px; }
.tag {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--cyan);
  border: 1px solid rgba(56, 225, 255, 0.35);
  border-radius: 999px;
  padding: 3px 10px;
  letter-spacing: 1px;
  white-space: nowrap;
}
.lang-quote { color: var(--text-faint); font-family: var(--mono); font-size: 12.5px; margin: 4px 0 14px; }
.code-mini {
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.7;
  background: rgba(7, 8, 24, 0.75);
  border: 1px solid rgba(140, 150, 255, 0.1);
  border-radius: 12px;
  padding: 14px 16px;
  overflow-x: auto;
  white-space: pre;
  color: #c9d2ff;
}

/* ---------- 算法神域 ---------- */
.algo-lab {
  background: rgba(10, 12, 32, 0.75);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
}

.algo-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  align-items: flex-end;
  margin-bottom: 22px;
}
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-dim); }
.field b { color: var(--cyan); font-family: var(--mono); }

select {
  font-family: var(--sans);
  font-size: 14px;
  color: var(--text);
  background: rgba(20, 24, 52, 0.8);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 14px;
  outline: none;
  cursor: pointer;
}
select:focus { border-color: var(--purple); }

input[type="range"] {
  -webkit-appearance: none;
  width: 170px;
  height: 5px;
  border-radius: 5px;
  background: linear-gradient(90deg, var(--cyan), var(--purple));
  cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 12px rgba(124, 108, 255, 0.9);
}

#sortCanvas {
  width: 100%;
  height: 360px;
  display: block;
  border-radius: 12px;
  background:
    radial-gradient(ellipse 70% 100% at 50% 100%, rgba(124, 108, 255, 0.10), transparent 70%),
    rgba(7, 8, 24, 0.9);
  border: 1px solid rgba(140, 150, 255, 0.1);
}

.algo-meta { margin-top: 14px; font-size: 13.5px; color: var(--text-dim); text-align: center; font-family: var(--mono); }
.algo-meta b { color: var(--gold); }
.algo-meta code { color: var(--pink); }

/* ---------- 编辑器 ---------- */
.editor-wrap {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 22px;
}
.editor-pane, .preview-pane {
  background: rgba(10, 12, 32, 0.75);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  min-height: 460px;
}

.editor-tabs { display: flex; border-bottom: 1px solid var(--border); background: rgba(16, 19, 44, 0.7); }
.tab {
  flex: 1;
  padding: 13px 0;
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 1px;
  color: var(--text-faint);
  background: none;
  border: none;
  cursor: pointer;
  transition: color 0.25s, background 0.25s, box-shadow 0.25s;
}
.tab:hover { color: var(--text-dim); }
.tab.active {
  color: var(--cyan);
  background: rgba(56, 225, 255, 0.06);
  box-shadow: inset 0 -2px 0 var(--cyan);
}

.editor-area {
  flex: 1;
  width: 100%;
  resize: none;
  border: none;
  outline: none;
  padding: 20px 22px;
  background: rgba(7, 8, 24, 0.6);
  color: #c9d2ff;
  font-family: var(--mono);
  font-size: 13.5px;
  line-height: 1.7;
  tab-size: 2;
}
.hidden { display: none !important; }

.preview-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  background: rgba(16, 19, 44, 0.7);
}
.preview-label { font-family: var(--mono); font-size: 12.5px; color: var(--cyan); letter-spacing: 1px; }
.btn-run {
  font-size: 13.5px;
  padding: 8px 20px;
  border-radius: 999px;
  color: #06070f;   /* 同 .btn-primary：霓虹底上白字不达标 */
  cursor: pointer;
  border: none;
  background: linear-gradient(120deg, #38e1ff, #7c6cff);
  box-shadow: 0 6px 20px rgba(124, 108, 255, 0.4);
  transition: transform 0.2s, box-shadow 0.2s;
}
.btn-run:hover { transform: translateY(-2px); box-shadow: 0 10px 30px rgba(124, 108, 255, 0.55); }

.preview-actions { display: flex; align-items: center; gap: 12px; }
.autorun-toggle { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; user-select: none; }
.autorun-toggle input { display: none; }
.autorun-track { position: relative; width: 34px; height: 18px; border-radius: 999px; background: rgba(255, 255, 255, 0.12); border: 1px solid var(--border); transition: background 0.2s, border-color 0.2s; }
.autorun-thumb { position: absolute; top: 1px; left: 1px; width: 14px; height: 14px; border-radius: 50%; background: #c9d2ff; transition: transform 0.2s, background 0.2s; }
.autorun-toggle input:checked + .autorun-track { background: linear-gradient(120deg, #38e1ff, #7c6cff); border-color: transparent; }
.autorun-toggle input:checked + .autorun-track .autorun-thumb { transform: translateX(16px); background: #fff; }
.autorun-label { font-family: var(--mono); font-size: 11.5px; color: var(--text-dim); letter-spacing: 0.5px; transition: color 0.2s; }
.autorun-toggle input:checked ~ .autorun-label { color: var(--cyan); }

#preview { flex: 1; width: 100%; border: none; background: #fff; }

/* ---------- 输出 Console 面板 ---------- */
.console-panel {
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--border);
  background: rgba(5, 6, 18, 0.9);
  flex: 0 0 170px;
  min-height: 120px;
}
.console-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 14px;
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: 1px;
  color: var(--text-faint);
  background: rgba(16, 19, 44, 0.6);
  border-bottom: 1px solid var(--border);
}
.console-bar button {
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}
.console-bar button:hover { color: var(--cyan); border-color: var(--cyan); }
.console-out {
  flex: 1;
  overflow-y: auto;
  padding: 10px 14px;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.65;
  color: #c9d2ff;
}
.console-out::-webkit-scrollbar { width: 6px; }
.console-out::-webkit-scrollbar-thumb { background: rgba(124, 108, 255, 0.4); border-radius: 3px; }
.console-line { white-space: pre-wrap; word-break: break-word; padding: 1px 0; }
.console-line.log { color: #d4dbff; }
.console-line.info { color: #7fd4ff; }
.console-line.warn { color: #ffd166; }
.console-line.error { color: #ff6b8a; }
.console-line.result { color: #38e1ff; font-weight: 600; }
.console-hint { color: var(--text-faint); font-size: 11.5px; }

/* ---------- 深夜道场 ---------- */
.roadmap {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 22px;
}
.road {
  position: relative;
  padding: 30px 26px;
  border-radius: var(--radius);
  background: var(--bg-card);
  border: 1px solid var(--border);
  backdrop-filter: blur(12px);
  transition: transform 0.3s, border-color 0.3s;
}
.road:hover { transform: translateY(-6px); border-color: rgba(56, 225, 255, 0.4); }
.road-no {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--gold);
  letter-spacing: 2px;
}
.road h3 { margin: 12px 0 10px; font-size: 19px; letter-spacing: 1px; }
.road p { color: var(--text-dim); font-size: 14px; }

/* ---------- 关于 ---------- */
.about-card {
  text-align: center;
  max-width: 720px;
  margin: 0 auto;
  padding: 54px 40px;
  border-radius: var(--radius);
  background: var(--bg-card);
  border: 1px solid var(--border);
  backdrop-filter: blur(14px);
  position: relative;
  overflow: hidden;
}
.about-card::before {
  content: "夜神";
  position: absolute;
  font-size: 190px;
  font-weight: 900;
  color: rgba(124, 108, 255, 0.045);
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
}
.about-card h2 { font-size: 28px; letter-spacing: 3px; margin-bottom: 18px; }
.about-card p { color: var(--text-dim); }
.about-sig { margin-top: 22px; color: var(--purple) !important; font-family: var(--mono); font-size: 14px; }

/* ---------- 页脚 ---------- */
.footer {
  border-top: 1px solid var(--border);
  padding: 34px 24px;
  text-align: center;
  background: rgba(7, 8, 24, 0.9);
}
.footer-inner p { font-size: 14px; letter-spacing: 1px; }
.footer-dim { color: var(--text-faint); font-size: 12.5px !important; margin-top: 8px; }

/* ---------- 等级奖励系统 UI ---------- */
.nav-right { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.nav-links { margin-left: 0; }

.checkin-btn {
  padding: 9px 16px;
  border-radius: 999px;
  border: 1px solid rgba(255, 209, 102, 0.4);
  background: rgba(255, 209, 102, 0.08);
  color: var(--gold);
  cursor: pointer;
  font-size: 13px;
  letter-spacing: 1px;
  font-family: var(--sans);
  white-space: nowrap;
  transition: box-shadow 0.25s, transform 0.25s;
}
.checkin-btn:hover { box-shadow: 0 0 18px rgba(255, 209, 102, 0.35); transform: translateY(-1px); }
.checkin-btn.done { border-color: rgba(140, 150, 255, 0.2); color: var(--text-faint); background: transparent; box-shadow: none; cursor: default; }

.level-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid rgba(124, 108, 255, 0.4);
  background: rgba(124, 108, 255, 0.08);
  cursor: pointer;
  font-family: var(--sans);
  transition: box-shadow 0.25s;
}
.level-chip:hover { box-shadow: 0 0 20px rgba(124, 108, 255, 0.35); }
.chip-lv { font-family: var(--mono); font-weight: 800; color: var(--cyan); font-size: 13px; white-space: nowrap; }
.chip-meta { display: flex; flex-direction: column; gap: 3px; min-width: 88px; }
.chip-name { font-size: 11.5px; color: var(--text-dim); line-height: 1; }
.chip-bar { width: 100%; height: 4px; background: rgba(255, 255, 255, 0.1); border-radius: 4px; overflow: hidden; }
.chip-fill { display: block; height: 100%; background: var(--grad-brand); border-radius: 4px; transition: width 0.6s; width: 0; }
.chip-xp { font-family: var(--mono); font-size: 10px; color: var(--text-faint); line-height: 1; }

/* ---------- Toast ---------- */
#toasts {
  position: fixed;
  right: 18px; bottom: 18px;
  z-index: 400;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}
.toast {
  min-width: 210px;
  max-width: 320px;
  padding: 12px 16px;
  border-radius: 12px;
  background: rgba(14, 17, 44, 0.96);
  border: 1px solid rgba(124, 108, 255, 0.4);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 13px;
  transform: translateX(130%);
  opacity: 0;
  transition: transform 0.4s cubic-bezier(0.21, 1.02, 0.73, 1), opacity 0.4s;
}
.toast.show { transform: none; opacity: 1; }
.toast b { color: #c9d2ff; font-size: 13.5px; }
.toast span { color: #9aa3d0; font-size: 11.5px; }
.toast.xp b {
  font-size: 15px;
  background: var(--grad-brand);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.toast.ach { border-color: rgba(255, 209, 102, 0.55); background: linear-gradient(140deg, rgba(30, 26, 16, 0.97), rgba(14, 17, 44, 0.97)); }
.toast.ach b { color: var(--gold); }
.toast.ach .ach-ico { font-style: normal; font-size: 20px; margin-bottom: 2px; }
.toast.level { border-color: rgba(255, 92, 138, 0.6); }
.toast.level b { color: var(--pink); font-size: 14.5px; }

/* ---------- 弹窗 ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(4, 5, 16, 0.72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 300;
  padding: 20px;
}
/* 原生 <dialog>：由 showModal()/close() 控制 [open]，保留 .open 作旧兜底 */
.modal-overlay[open], .modal-overlay.open { display: flex; }
dialog.modal-overlay { border: 0; color: var(--text); }
.modal-card {
  width: min(600px, 100%);
  max-height: 88vh;
  overflow-y: auto;
  background: #0e1130;
  border: 1px solid rgba(140, 150, 255, 0.28);
  border-radius: 20px;
  padding: 28px;
  position: relative;
  animation: pop 0.35s cubic-bezier(0.21, 1.02, 0.73, 1);
}
@keyframes pop { from { transform: scale(0.9); opacity: 0; } }
.modal-close { position: absolute; top: 14px; right: 16px; background: none; border: none; color: #9aa3d0; font-size: 18px; cursor: pointer; padding: 4px; }
.modal-close:hover { color: #fff; }
.modal-title { font-size: 20px; letter-spacing: 3px; margin-bottom: 20px; }

.rank-hero { display: flex; gap: 20px; align-items: center; margin-bottom: 20px; }
.rank-badge {
  width: 84px; height: 84px;
  flex: 0 0 84px;
  border-radius: 22px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 900; font-size: 20px;
  font-family: var(--mono);
  color: var(--cyan);
  background: linear-gradient(135deg, rgba(56, 225, 255, 0.15), rgba(124, 108, 255, 0.3));
  border: 1px solid rgba(124, 108, 255, 0.5);
  box-shadow: 0 0 30px rgba(124, 108, 255, 0.35);
}
body.gold-glow .rank-badge { color: var(--gold); border-color: rgba(255, 209, 102, 0.5); }
.rank-info h3 { font-size: 22px; letter-spacing: 1px; }
.rank-en { font-family: var(--mono); font-size: 11px; letter-spacing: 3px; color: var(--text-faint); }
.progress { height: 8px; background: rgba(255, 255, 255, 0.08); border-radius: 6px; overflow: hidden; margin: 10px 0 5px; }
.progress-fill { height: 100%; width: 0; background: var(--grad-brand); border-radius: 6px; transition: width 0.6s; }
.progress-text { font-family: var(--mono); font-size: 11.5px; color: var(--text-faint); }

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 18px 0; }
.stat { background: rgba(20, 24, 52, 0.6); border: 1px solid rgba(140, 150, 255, 0.12); border-radius: 12px; padding: 12px 6px; text-align: center; }
.stat b { display: block; font-size: 20px; color: var(--cyan); font-family: var(--mono); }
.stat span { font-size: 11px; color: var(--text-faint); }

.badge-title { margin: 14px 0 10px; font-size: 15px; letter-spacing: 2px; color: var(--gold); }
.badge-title span { font-family: var(--mono); color: var(--text-faint); font-weight: 400; font-size: 12px; }
.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; }
.badge {
  text-align: center;
  padding: 14px 8px 12px;
  border-radius: 12px;
  background: rgba(20, 24, 52, 0.5);
  border: 1px solid rgba(140, 150, 255, 0.1);
}
.badge .ach-ico { font-style: normal; font-size: 24px; display: block; }
.badge b { display: block; font-size: 12.5px; margin: 7px 0 3px; color: var(--text); font-weight: 600; }
.badge span { font-size: 10.5px; color: var(--text-faint); line-height: 1.45; display: block; }
.badge.earned {
  border-color: rgba(255, 209, 102, 0.5);
  background: rgba(255, 209, 102, 0.06);
  box-shadow: 0 0 18px rgba(255, 209, 102, 0.12);
}
.badge.earned .ach-ico { filter: drop-shadow(0 0 10px rgba(255, 209, 102, 0.6)); }
.badge.locked { opacity: 0.45; filter: grayscale(0.8); }

.reset-btn {
  margin-top: 20px;
  width: 100%;
  padding: 11px;
  background: none;
  border: 1px dashed rgba(255, 92, 138, 0.4);
  color: var(--pink);
  border-radius: 10px;
  cursor: pointer;
  font-size: 13px;
  font-family: var(--sans);
  transition: background 0.25s;
}
.reset-btn:hover { background: rgba(255, 92, 138, 0.07); }

/* ---------- 升阶弹窗 ---------- */
.levelup-card { text-align: center; border-color: rgba(255, 209, 102, 0.5); overflow: hidden; }
.levelup-glow {
  position: absolute;
  width: 420px; height: 420px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 209, 102, 0.16), transparent 65%);
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  animation: breathe 2.5s ease-in-out infinite;
}
.levelup-kicker { font-family: var(--mono); letter-spacing: 6px; font-size: 11px; color: var(--gold); position: relative; }
.levelup-lv {
  font-size: 68px;
  font-weight: 900;
  letter-spacing: 2px;
  background: linear-gradient(120deg, #ffd166, #ff5c8a);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 30px rgba(255, 209, 102, 0.4));
  line-height: 1.1;
  position: relative;
  margin: 8px 0 0;
}
.levelup-name { font-size: 26px; letter-spacing: 4px; position: relative; margin-bottom: 4px; }
.levelup-en { font-family: var(--mono); font-size: 11px; letter-spacing: 4px; color: var(--text-faint); position: relative; }
.levelup-reward {
  margin: 18px 0 24px;
  padding: 10px 18px;
  display: inline-block;
  border-radius: 999px;
  border: 1px solid rgba(255, 209, 102, 0.4);
  color: var(--gold);
  font-size: 14px;
  position: relative;
}
.levelup-card .btn { position: relative; }

/* ---------- 等阶之路 ---------- */
.xp-sources {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
  margin-bottom: 42px;
}
.xp-src { text-align: center; padding: 16px 8px; border-radius: 12px; background: var(--bg-card); border: 1px solid rgba(140, 150, 255, 0.12); }
.xp-src b { display: block; font-size: 19px; color: var(--cyan); font-family: var(--mono); }
.xp-src span { font-size: 12px; color: var(--text-faint); }

.rank-road { display: flex; flex-direction: column; gap: 14px; }
.rank-step {
  display: flex;
  gap: 18px;
  align-items: center;
  padding: 16px 22px;
  border-radius: 14px;
  background: rgba(20, 24, 52, 0.5);
  border: 1px solid rgba(140, 150, 255, 0.12);
  transition: border-color 0.3s, box-shadow 0.3s;
}
.rank-no { font-family: var(--mono); font-weight: 800; font-size: 17px; width: 72px; flex: 0 0 72px; color: var(--text-faint); }
.rank-info { flex: 1; }
.rank-info h4 { font-size: 16.5px; letter-spacing: 1px; }
.rank-info h4 em { font-style: normal; font-family: var(--mono); font-size: 10.5px; letter-spacing: 2px; color: var(--text-faint); margin-left: 8px; }
.rank-info p { font-family: var(--mono); font-size: 11.5px; color: var(--text-faint); }
.rank-reward { font-size: 12.5px; color: var(--text-dim); text-align: right; max-width: 320px; }
.rank-step.done { opacity: 0.65; border-color: rgba(56, 225, 255, 0.22); }
.rank-step.done .rank-no { color: var(--cyan); }
.rank-step.now {
  border-color: rgba(124, 108, 255, 0.55);
  box-shadow: 0 0 30px rgba(124, 108, 255, 0.15);
  animation: rankPulse 2.4s ease-in-out infinite;
}
@keyframes rankPulse { 50% { box-shadow: 0 0 44px rgba(124, 108, 255, 0.28); } }
.rank-step.now .rank-no { color: var(--pink); font-size: 19px; }
.rank-step.future { opacity: 0.55; }

/* ---------- 成就殿堂 ---------- */
.badge-wall { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 16px; }
.badge-wall .badge { padding: 20px 12px; }

/* ---------- 试炼场 ---------- */
.quiz-lab {
  background: rgba(10, 12, 32, 0.75);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
}
.quiz-diff { display: flex; gap: 12px; margin-bottom: 24px; }
.qtab {
  flex: 1;
  padding: 13px;
  border-radius: 12px;
  border: 1px solid rgba(140, 150, 255, 0.25);
  background: rgba(20, 24, 52, 0.6);
  color: var(--text-dim);
  cursor: pointer;
  font-size: 14px;
  font-family: var(--sans);
  letter-spacing: 1px;
  transition: all 0.25s;
}
.qtab:hover { border-color: rgba(124, 108, 255, 0.5); }
.qtab.active { color: var(--cyan); border-color: rgba(56, 225, 255, 0.5); background: rgba(56, 225, 255, 0.07); }
.qtab.locked { opacity: 0.5; }

.quiz-start { text-align: center; padding: 26px 0 10px; }
.quiz-intro { color: var(--text-dim); font-size: 15px; line-height: 2; margin-bottom: 26px; }
.quiz-progress { font-family: var(--mono); color: var(--text-faint); font-size: 13px; margin-bottom: 6px; }
.quiz-progress b { color: var(--cyan); }
.quiz-q { font-size: 20px; line-height: 1.6; margin: 8px 0 22px; min-height: 64px; }
.quiz-opts { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.opt {
  padding: 14px 18px;
  border-radius: 12px;
  border: 1px solid rgba(140, 150, 255, 0.2);
  background: rgba(20, 24, 52, 0.5);
  color: var(--text);
  cursor: pointer;
  text-align: left;
  font-size: 14.5px;
  font-family: var(--sans);
  line-height: 1.55;
  transition: transform 0.2s, border-color 0.2s;
}
.opt:hover { border-color: rgba(124, 108, 255, 0.55); transform: translateY(-2px); }
.opt:disabled { cursor: default; transform: none; }
.opt.right { border-color: rgba(56, 225, 255, 0.75); background: rgba(56, 225, 255, 0.1); }
.opt.wrong { border-color: rgba(255, 92, 138, 0.75); background: rgba(255, 92, 138, 0.08); }
.quiz-why {
  margin-top: 18px;
  padding: 13px 16px;
  border-radius: 10px;
  background: rgba(124, 108, 255, 0.08);
  border: 1px solid rgba(124, 108, 255, 0.22);
  color: var(--text-dim);
  font-size: 13.5px;
  line-height: 1.7;
}
.quiz-play .btn { margin-top: 18px; }
.quiz-result { text-align: center; padding: 20px 0 6px; }
.quiz-score {
  font-size: 54px;
  font-weight: 900;
  background: var(--grad-brand);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.quiz-rating { color: var(--gold); letter-spacing: 1px; margin: 10px 0 4px; }
.quiz-xp { font-family: var(--mono); color: var(--cyan); font-size: 14px; margin-bottom: 22px; }

/* ---------- 语言筛选 & 收录 ---------- */
.filter-tabs { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-bottom: 34px; }
.ftab {
  padding: 8px 18px;
  border-radius: 999px;
  border: 1px solid rgba(140, 150, 255, 0.25);
  background: rgba(20, 24, 52, 0.5);
  color: var(--text-dim);
  cursor: pointer;
  font-size: 13.5px;
  font-family: var(--sans);
  letter-spacing: 1px;
  transition: all 0.25s;
}
.ftab:hover { color: var(--text); border-color: rgba(140, 150, 255, 0.5); }
.ftab.active {
  color: #fff;
  background: linear-gradient(120deg, rgba(56, 225, 255, 0.2), rgba(124, 108, 255, 0.35));
  border-color: rgba(124, 108, 255, 0.6);
}
.lang-card.seen { border-color: rgba(255, 209, 102, 0.35); }
.lang-card.seen::after {
  content: "✓ 已收录 +3";
  position: absolute;
  top: 14px; right: 14px;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--gold);
  letter-spacing: 1px;
}

/* ---------- 等级解锁特效 ---------- */
body.editor-light .editor-area { background: #f2f4ff; color: #2a2f55; }
body.editor-light .editor-tabs { background: rgba(240, 242, 252, 0.92); }
body.editor-light .editor-tabs .tab.active { background: rgba(124, 108, 255, 0.08); }
/* 护眼模式是暗页里的一块亮底：亮底必须换深墨，否则 #38e1ff 的选中态在这里只有 1.1:1 */
body.editor-light .editor-tabs .tab { color: #3a4272; }
body.editor-light .editor-tabs .tab:hover { color: #212748; }
body.editor-light .editor-tabs .tab.active {
  color: #0a4f74;
  box-shadow: inset 0 -2px 0 #0a4f74;
}

body.gold-glow .section-title,
body.gold-glow .brand-name { text-shadow: 0 0 26px rgba(255, 209, 102, 0.35); }
body.gold-glow .rank-step.now { border-color: rgba(255, 209, 102, 0.55); }

body.god-mode::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 90;
  background: radial-gradient(circle at 50% 0%, rgba(255, 209, 102, 0.09), transparent 55%);
}
body.god-mode .grad {
  background: linear-gradient(120deg, #ffd166, #ff5c8a, #ffd166);
  background-size: 200% 200%;
  animation: shimmer 3s linear infinite;
}
@keyframes shimmer { to { background-position: 200% 0; } }
body.god-mode .nav { background: rgba(20, 16, 8, 0.8); border-bottom: 1px solid rgba(255, 209, 102, 0.3); }

/* ---------- 无障碍：原生 dialog 遮罩 / 焦点可见 ---------- */
dialog.modal-overlay::backdrop { background: rgba(4, 5, 16, 0.72); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
dialog.modal-overlay .modal-card { animation: none; }   /* open 事件后再触发 pop，避免 display:none→flex 期间动画丢失 */
dialog.modal-overlay[open] .modal-card { animation: pop 0.35s cubic-bezier(0.21, 1.02, 0.73, 1); }
dialog.modal-overlay[open]::backdrop { animation: fade-in 0.25s ease; }
@keyframes fade-in { from { opacity: 0; } }

:where(a, button, select, input, textarea, [tabindex]):focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}
dialog.modal-overlay:focus { outline: none; }   /* dialog 自身仅作容器，焦点应落在内部控件 */

/* ---------- 动效降级：尊重系统「减少动态效果」 ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
  .reveal { opacity: 1; transform: none; }
  .caret { opacity: 1; }
  dialog.modal-overlay[open] .modal-card, dialog.modal-overlay[open]::backdrop { animation: none; }
}

/* ---------- 响应式 ---------- */
@media (max-width: 1180px) {
  .nav-cta { display: none; }
}
@media (max-width: 900px) {
  .editor-wrap { grid-template-columns: 1fr; }
  .nav-links {
    position: fixed;
    top: 62px; right: -260px;
    flex-direction: column;
    gap: 0;
    width: 240px;
    background: rgba(10, 12, 32, 0.97);
    border-left: 1px solid var(--border);
    padding: 20px;
    transition: right 0.35s ease;
    z-index: 99;
  }
  .nav-links.open { right: 0; }
  .nav-links a { padding: 12px 6px; border-bottom: 1px solid rgba(140, 150, 255, 0.08); }
  .nav-burger { display: flex; }
  .chip-meta { display: none; }
  .checkin-btn { padding: 8px 12px; }
  .quiz-opts { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .rank-step { flex-wrap: wrap; }
  .rank-reward { text-align: left; max-width: none; width: 100%; }
  .hero-stats { gap: 26px; }
}

/* ============================================================
   v5 新增 · 组件
   ============================================================ */

/* ---------- 主题切换按钮 ---------- */
.theme-btn {
  padding: 9px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(20, 24, 52, 0.5);
  color: var(--text-dim);
  cursor: pointer;
  font-size: 12.5px;
  letter-spacing: 1px;
  font-family: var(--sans);
  white-space: nowrap;
  transition: box-shadow 0.25s, transform 0.25s, color 0.25s;
}
.theme-btn:hover { color: var(--text); box-shadow: 0 0 16px rgba(124, 108, 255, 0.3); transform: translateY(-1px); }

/* ---------- 每日一题 ---------- */
.daily {
  max-width: 1180px;
  margin: 0 auto 28px;
  padding: 20px 24px;
  border-radius: var(--radius);
  border: 1px solid rgba(255, 209, 102, 0.24);
  background: rgba(255, 209, 102, 0.045);
}
.daily-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.daily-kicker { font-family: var(--mono); font-size: 12px; letter-spacing: 2px; color: var(--gold); }
.daily-streak { font-family: var(--mono); font-size: 12px; color: var(--text-faint); }
.daily-q { font-size: 16.5px; line-height: 1.65; margin-bottom: 14px; }
.daily-opts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.daily-why {
  margin-top: 14px;
  padding: 12px 15px;
  border-radius: 10px;
  background: rgba(255, 209, 102, 0.07);
  border: 1px solid rgba(255, 209, 102, 0.2);
  color: var(--text-dim);
  font-size: 13.5px;
  line-height: 1.7;
}
.daily.done { opacity: 0.85; }

/* ---------- 试炼连击 ---------- */
.quiz-combo {
  margin-left: 10px;
  padding: 2px 10px;
  border-radius: 999px;
  background: linear-gradient(120deg, rgba(56, 225, 255, 0.16), rgba(255, 209, 102, 0.2));
  border: 1px solid rgba(255, 209, 102, 0.4);
  color: var(--gold);
  font-size: 12px;
  letter-spacing: 1px;
}
.quiz-combo-max { font-family: var(--mono); font-size: 13px; color: var(--text-dim); margin-top: 6px; }

/* ---------- 停止运行 ---------- */
.btn-stop {
  background: linear-gradient(120deg, #ff5c8a, #7c6cff);
  box-shadow: 0 6px 20px rgba(255, 92, 138, 0.35);
}

/* ---------- 今日修行笺 ---------- */
.slip-card { text-align: center; }
.slip-kicker { font-family: var(--mono); font-size: 12px; letter-spacing: 4px; color: var(--gold); margin-bottom: 16px; }
.slip-quote { font-size: 18px; line-height: 1.9; font-weight: 600; margin-bottom: 16px; }
.slip-xp { font-family: var(--mono); font-size: 26px; color: var(--cyan); }
.slip-streak { font-size: 13px; color: var(--text-dim); margin: 4px 0 18px; }
.slip-days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-bottom: 20px; }
.slip-day { padding: 8px 2px; border-radius: 10px; border: 1px solid var(--border); background: rgba(20, 24, 52, 0.4); }
.slip-day b { display: block; font-size: 14px; color: var(--text-faint); }
.slip-day em { display: block; font-style: normal; font-family: var(--mono); font-size: 10px; color: var(--text-faint); }
.slip-day.on { border-color: rgba(255, 209, 102, 0.45); background: rgba(255, 209, 102, 0.08); }
.slip-day.on b { color: var(--gold); }
.slip-day.on em { color: var(--text-dim); }

/* ---------- 等阶经验说明 ---------- */
.xp-note {
  margin: 18px auto 0;
  max-width: 840px;
  text-align: center;
  font-size: 12.5px;
  line-height: 1.9;
  color: var(--text-faint);
}

/* ============================================================
   v5 新增 · 月白主题（浅色）
   只改颜色，不动布局与暗色路径；强调色按 WCAG AA 在浅底上重新取值。
   代码窗（.hero-code / .code-mini）保持暗底 —— .tk-* 语法色是为深底配的，
   翻浅要重算 12 个颜色且极易踩对比度，收益不值。
   ============================================================ */
:root[data-theme="moon"] {
  --bg: #f4f5ff;
  --bg-2: #e9ebfb;
  --bg-card: rgba(255, 255, 255, 0.82);
  --border: rgba(60, 68, 140, 0.22);
  --text: #14173a;
  --text-dim: #414877;
  --text-faint: #4d5486;   /* hero 渐变最浅处叠底为 #dad7ff，#5a618f 在其上只有 4.28:1 */
  --purple: #5b48e8;
  --cyan: #06607f;         /* 同上：#08688f 在渐变高光处 4.47:1，差一点点 */
  --pink: #b8285c;
  --gold: #7d5600;
  --grad-brand: linear-gradient(120deg, #08688f 0%, #5b48e8 50%, #b8285c 100%);
}
:root[data-theme="moon"] .nav,
:root[data-theme="moon"] .footer { background: rgba(255, 255, 255, 0.86); }
:root[data-theme="moon"] .nav.scrolled { box-shadow: 0 8px 28px rgba(30, 34, 80, 0.12); }
:root[data-theme="moon"] .quiz-lab,
:root[data-theme="moon"] .algo-lab,
:root[data-theme="moon"] .editor-pane,
:root[data-theme="moon"] .preview-pane,
:root[data-theme="moon"] .modal-card {
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 24px 60px rgba(30, 34, 80, 0.14);
}
:root[data-theme="moon"] .editor-tabs,
:root[data-theme="moon"] .preview-bar,
:root[data-theme="moon"] .console-bar { background: rgba(240, 242, 254, 0.95); }
:root[data-theme="moon"] .editor-area { background: #fbfcff; color: #1c2145; }
:root[data-theme="moon"] .console-out,
:root[data-theme="moon"] .console-hint { background: #fbfcff; color: #414877; }
:root[data-theme="moon"] .console-line.log { color: #2a2f55; }
:root[data-theme="moon"] .console-line.info { color: #08688f; }
:root[data-theme="moon"] .console-line.warn { color: #7d5600; }
:root[data-theme="moon"] .console-line.error { color: #b3234a; }
:root[data-theme="moon"] .console-line.result { color: #0a5c9e; }
/* 用 :where() 把类名权重降为 0：只补「基底表面色」，
   .opt.right / .qtab.active / .badge.earned / .rank-step.now 这类状态着色
   必须仍然压得过它，否则答对高亮、当前等阶会被平铺成白底。 */
:root[data-theme="moon"] :where(.stat, .badge, .rank-step, .opt, .qtab,
                                 .ftab, .slip-day, .theme-btn, select, input) {
  background: rgba(245, 246, 255, 0.9);
}
:root[data-theme="moon"] .btn-ghost { background: rgba(255, 255, 255, 0.75); }
:root[data-theme="moon"] .chip-bar,
:root[data-theme="moon"] .progress,
:root[data-theme="moon"] .autorun-track { background: rgba(60, 68, 140, 0.16); }
:root[data-theme="moon"] .daily { background: rgba(125, 86, 0, 0.05); }
:root[data-theme="moon"] .quiz-why,
:root[data-theme="moon"] .daily-why { background: rgba(91, 72, 232, 0.06); }
:root[data-theme="moon"] .modal-overlay { background: rgba(120, 128, 180, 0.4); }
:root[data-theme="moon"] dialog.modal-overlay::backdrop { background: rgba(120, 128, 180, 0.4); }
:root[data-theme="moon"] .noscript-warn { background: #fff4d6; color: #6b4a00; }
:root[data-theme="moon"] .lang-card:hover { box-shadow: 0 22px 50px rgba(30, 34, 80, 0.16); }

/* 渐变按钮：#38e1ff 起点在白底上配白字只有 1.8:1，浅主题改用 AA 取值的高光位 */
:root[data-theme="moon"] .btn-primary,
:root[data-theme="moon"] .btn-run { background-image: linear-gradient(120deg, #08688f, #5b48e8 60%, #b8285c); }
:root[data-theme="moon"] .btn-stop { background-image: linear-gradient(120deg, #b8285c, #5b48e8); }
/* 墨色随底色反转：暗底配白字（5.9~6.2:1），夜神主题下则是霓虹底配近黑字 */
:root[data-theme="moon"] .btn-primary,
:root[data-theme="moon"] .btn-run,
:root[data-theme="moon"] .skip-link { color: #fff; }
:root[data-theme="moon"] .ftab.active {
  color: #fff;
  background: linear-gradient(120deg, #08688f, #5b48e8);
  border-color: rgba(91, 72, 232, 0.55);
}
:root[data-theme="moon"] .modal-close { color: #3d4478; }
:root[data-theme="moon"] .modal-close:hover { color: #14173a; }

/* 代码窗保持暗底，但要压实：半透明深底叠在白页上会糊成灰蓝，语法色对比全线掉到 2:1 */
:root[data-theme="moon"] .hero-code { background: #0a0c1e; box-shadow: 0 24px 60px rgba(30, 34, 80, 0.26); }
:root[data-theme="moon"] .code-head { background: #12152f; }
:root[data-theme="moon"] .code-mini { background: #0b0e22; }
/* 面板内文字不跟随全局浅色 token，否则深底配深字 */
:root[data-theme="moon"] .hero-code,
:root[data-theme="moon"] .code-mini { --text-faint: #9aa3d0; --cyan: #38e1ff; }
@media (max-width: 900px) {
  :root[data-theme="moon"] .nav-links { background: rgba(255, 255, 255, 0.98); }
}

/* ---------- 共建圣殿（GitHub 当后端） ---------- */
.gh-entry { text-align: center; margin-bottom: 46px; }
.gh-entry .btn { display: inline-block; margin: 0 7px 12px; font-size: 14.5px; padding: 12px 24px; }
.gh-note {
  max-width: 760px;
  margin: 18px auto 0;
  padding-top: 18px;
  border-top: 1px dashed var(--border);
  color: var(--text-faint);
  font-size: 12.5px;
  line-height: 1.8;
  text-align: left;
}
.comm-tabs { margin-bottom: 12px; }
.comm-status {
  text-align: center;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: .6px;
  color: var(--text-faint);
  margin: 0 0 32px;
}
.comm-status.err { color: var(--pink); }
.comm-status.ok { color: var(--cyan); }
.comm-retry {
  font-family: var(--sans);
  font-size: 12px;
  margin-left: 10px;
  padding: 4px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(20, 24, 52, .5);
  color: var(--text-dim);
  cursor: pointer;
}
.comm-retry:hover { color: var(--text); border-color: rgba(140, 150, 255, .5); }
.comm-panel { display: flex; flex-direction: column; gap: 16px; }

.log-item {
  padding: 24px 26px;
  border-radius: var(--radius);
  background: var(--bg-card);
  border: 1px solid var(--border);
  backdrop-filter: blur(12px);
}
.log-head { display: flex; align-items: baseline; gap: 16px; flex-wrap: wrap; margin-bottom: 12px; }
.log-date { font-family: var(--mono); font-size: 12px; letter-spacing: 1px; color: var(--cyan); }
.log-title { font-size: 17.5px; font-weight: 700; letter-spacing: 1px; margin: 0; color: var(--text); }
.log-list { margin: 0; padding-left: 20px; color: var(--text-dim); font-size: 13.5px; line-height: 1.9; }
.log-list li::marker { color: var(--purple); }
.log-thanks { margin: 14px 0 0; font-size: 12.5px; color: var(--text-faint); }
.thanks-chip {
  display: inline-block;
  margin: 0 3px;
  padding: 2px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 209, 102, .35);
  background: rgba(255, 209, 102, .07);
  color: var(--gold);
  font-family: var(--mono);
  font-size: 11.5px;
  text-decoration: none;
}

.idea-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.idea-card {
  padding: 20px 22px;
  border-radius: 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  backdrop-filter: blur(12px);
}
.idea-card.accepted { border-color: rgba(56, 225, 255, .38); }
.idea-title { display: block; font-size: 15px; font-weight: 600; color: var(--text); text-decoration: none; line-height: 1.5; }
a.idea-title:hover { color: var(--cyan); }
.idea-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.idea-meta span, .contrib-chip {
  font-size: 11.5px;
  font-family: var(--mono);
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid rgba(140, 150, 255, .22);
  color: var(--text-dim);
  background: rgba(20, 24, 52, .45);
}
.idea-status { border-color: rgba(124, 108, 255, .45); color: var(--purple); }
.idea-card.accepted .idea-status { border-color: rgba(56, 225, 255, .5); color: var(--cyan); }
.idea-sum { margin: 12px 0 0; font-size: 12.5px; line-height: 1.75; color: var(--text-faint); }
.idea-no { font-family: var(--mono); }

.handle-form {
  display: flex;
  align-items: flex-end;
  gap: 14px;
  flex-wrap: wrap;
  padding: 20px 22px;
  border-radius: 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
}
.handle-form .field { flex: 1 1 240px; }
.handle-form input[type="text"] {
  font-family: var(--mono);
  font-size: 14px;
  color: var(--text);
  background: rgba(20, 24, 52, .8);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 14px;
  outline: none;
}
.handle-form input[type="text"]:focus { border-color: var(--purple); }
.handle-note { flex: 1 1 100%; margin: 4px 0 0; font-size: 12px; line-height: 1.7; color: var(--text-faint); }

.contrib-grid { display: flex; flex-direction: column; gap: 10px; }
.contrib-row {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 16px 20px;
  border-radius: 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
}
.contrib-row.me { border-color: rgba(255, 209, 102, .45); background: rgba(255, 209, 102, .05); }
.contrib-mono {
  flex: none;
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: linear-gradient(120deg, rgba(56, 225, 255, .2), rgba(124, 108, 255, .35));
  color: var(--text);
  font-family: var(--mono);
  font-size: 15px;
}
.contrib-info { min-width: 0; }
.contrib-name { font-family: var(--mono); font-size: 14px; color: var(--text); text-decoration: none; }
a.contrib-name:hover { color: var(--cyan); }
.contrib-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 9px; }
.contrib-chip { display: inline-block; text-decoration: none; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
a.contrib-chip:hover { color: var(--text); border-color: rgba(140, 150, 255, .55); }
.contrib-note { margin: 6px 0 0; font-size: 12px; color: var(--text-faint); }
.contrib-note a { color: var(--cyan); }

.comm-empty {
  margin: 0;
  padding: 32px 22px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  text-align: center;
  font-size: 13px;
  line-height: 1.8;
  color: var(--text-faint);
}

.footer-links { margin-top: 10px; display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }
.footer-links a { color: var(--text-dim); text-decoration: none; font-size: 13px; letter-spacing: .5px; }
.footer-links a:hover { color: var(--cyan); text-decoration: underline; }
.footer-links span { color: var(--text-faint); }

/* 浅主题里深底半透明会糊成灰膜，卡片压实一层 */
:root[data-theme="moon"] .log-item,
:root[data-theme="moon"] .idea-card,
:root[data-theme="moon"] .contrib-row,
:root[data-theme="moon"] .handle-form { background: rgba(255, 255, 255, .78); }
:root[data-theme="moon"] .idea-meta span,
:root[data-theme="moon"] .comm-retry,
:root[data-theme="moon"] .handle-form input[type="text"] { background: rgba(240, 242, 254, .9); }
:root[data-theme="moon"] .handle-form input[type="text"] { color: #1c2145; }
:root[data-theme="moon"] .contrib-row.me { background: rgba(255, 244, 214, .8); }

/* ---------- 符阵秘境入口 ---------- */
.rune-card {
  padding: 30px 32px 26px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.rune-modes {
  list-style: none;
  margin: 0 0 24px;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 14px 20px;
}
.rune-modes li {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 16px;
  border-left: 2px solid rgba(124, 108, 255, .55);
  border-radius: 0 12px 12px 0;
  background: rgba(124, 108, 255, .07);
}
.rune-modes b { font-size: 15px; letter-spacing: .5px; color: var(--text); }
.rune-modes span { font-size: 12.5px; line-height: 1.75; color: var(--text-faint); }

.rune-foot { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
a.rune-cta { text-decoration: none; }
.rune-sync {
  margin: 0;
  font-family: var(--mono);
  font-size: 12.5px;
  letter-spacing: .3px;
  color: var(--text-dim);
}
.rune-sync.has-game { color: var(--gold); }
.rune-note { margin: 18px 0 0; font-size: 12px; line-height: 1.85; color: var(--text-faint); }
.rune-note code { font-family: var(--mono); font-size: 11.5px; color: var(--cyan); }

/* 秘境卡同样压实一层，避免浅主题下紫边糊成灰膜 */
:root[data-theme="moon"] .rune-card { background: rgba(255, 255, 255, .78); }
:root[data-theme="moon"] .rune-modes li { background: rgba(124, 108, 255, .08); }


