:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #eef1f7;
  --text: #1c2233;
  --muted: #5d6680;
  --border: #dde2ec;
  --accent: #3b6cf6;
  --accent-soft: #e4ebff;
  --physics: #e8833a;
  --geography: #2f9e6f;
  --biology: #c0498f;
  --chemistry: #7b5ce6;
  --math: #2b8bd6;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 30, 60, .06), 0 4px 16px rgba(20, 30, 60, .06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f131c;
    --surface: #171c28;
    --surface-2: #1f2534;
    --text: #e6e9f2;
    --muted: #9aa3ba;
    --border: #2a3144;
    --accent: #6d93ff;
    --accent-soft: #24304f;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, select, input { font: inherit; color: inherit; }

.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }

.topbar {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.topbar .wrap { display: flex; align-items: center; justify-content: space-between; height: 56px; gap: 12px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 18px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 28px; height: 28px; border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--chemistry));
  display: grid; place-items: center; color: #fff; font-size: 15px;
}
.nav { display: flex; align-items: center; gap: 16px; font-size: 14px; }
.nav a { color: var(--muted); }
.lang-btn {
  border: 1px solid var(--border); background: var(--surface); border-radius: 999px;
  padding: 4px 12px; cursor: pointer; font-size: 13px;
}
.lang-btn:hover { border-color: var(--accent); }

.hero {
  position: relative; overflow: hidden; color: #eef1fb;
  background: radial-gradient(120% 140% at 85% 20%, #2a2470 0%, #121a3d 45%, #090d1f 100%);
}
.hero::after { content: ''; position: absolute; inset: 0; z-index: 1; pointer-events: none; background: linear-gradient(90deg, rgba(9, 13, 31, .78) 0%, rgba(9, 13, 31, .35) 55%, rgba(9, 13, 31, 0) 80%); }
.hero-gl { position: absolute; inset: 0; z-index: 0; width: 100%; height: 100%; display: block; opacity: 0; transition: opacity .8s; }
.hero-gl.on { opacity: 1; }
.hero-inner { position: relative; z-index: 2; padding: 64px 16px 56px; pointer-events: none; }
.hero-inner a, .hero-inner button { pointer-events: auto; }
.hero h1 { font-size: clamp(30px, 5.5vw, 52px); line-height: 1.15; margin: 14px 0 14px; letter-spacing: -.02em; max-width: 720px; }
.hero h1 em { font-style: normal; background: linear-gradient(90deg, #5ee0d0, #a48bff 55%, #ffb36b); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero p { color: #c4cae0; font-size: 17px; max-width: 600px; margin: 0 0 22px; }
.live-pill {
  display: inline-flex; align-items: center; gap: 8px; font-size: 13px; padding: 4px 12px 4px 10px;
  border-radius: 999px; background: rgba(255, 255, 255, .08); border: 1px solid rgba(255, 255, 255, .16);
}
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: #3ddc97; box-shadow: 0 0 0 0 rgba(61, 220, 151, .6); animation: pulse 2s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 8px rgba(61, 220, 151, 0); } 100% { box-shadow: 0 0 0 0 rgba(61, 220, 151, 0); } }
.hero-cta { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 26px; }
.cta {
  border-radius: 12px; padding: 10px 18px; font-weight: 600; font-size: 15px; cursor: pointer;
  border: 1px solid rgba(255, 255, 255, .22); background: rgba(255, 255, 255, .08); color: #fff;
}
.cta:hover { text-decoration: none; background: rgba(255, 255, 255, .16); }
.cta.main { background: #fff; color: #141a33; border-color: #fff; }
.cta.main:hover { background: #e7ebff; }
.ticker { font-size: 14px; color: #c4cae0; min-height: 22px; margin-bottom: 18px; }
.ticker a { color: #fff; font-weight: 600; display: inline-block; transition: opacity .3s, transform .3s; }
.ticker a.out { opacity: 0; transform: translateY(6px); }
.subject-stats { display: flex; flex-wrap: wrap; gap: 10px; }
.subject-stat {
  display: flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 12px; cursor: pointer;
  background: rgba(255, 255, 255, .06); border: 1px solid rgba(255, 255, 255, .12); color: #eef1fb; font-size: 14px;
}
.subject-stat:hover { background: rgba(255, 255, 255, .14); }
.subject-stat b { font-size: 18px; font-variant-numeric: tabular-nums; }
.subject-stat .bar { width: 4px; height: 22px; border-radius: 2px; }
@media (prefers-reduced-motion: reduce) { .live-dot { animation: none; } .ticker a { transition: none; } }

.section-title { font-size: 22px; margin: 32px 0 16px; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.chip {
  border: 1px solid var(--border); background: var(--surface); border-radius: 999px;
  padding: 6px 14px; cursor: pointer; font-size: 14px;
}
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); display: flex; flex-direction: column; overflow: hidden;
  color: var(--text); transition: transform .15s, border-color .15s;
}
.card:hover { transform: translateY(-2px); border-color: var(--accent); text-decoration: none; }
.card-art { height: 150px; position: relative; border-bottom: 1px solid var(--border); }
.card-art canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.card-badges { position: absolute; top: 10px; left: 10px; right: 10px; display: flex; justify-content: space-between; pointer-events: none; }
.badge-gl { font-size: 11px; font-weight: 700; letter-spacing: .04em; padding: 2px 7px; border-radius: 6px; background: rgba(20, 26, 51, .78); color: #9ff0e4; }
.card-foot { display: flex; justify-content: space-between; align-items: center; font-size: 13px; padding-top: 4px; }
.card-foot .go { color: var(--accent); font-weight: 600; transition: transform .15s; }
.card:hover .card-foot .go { transform: translateX(4px); }
.card-foot .lv { color: var(--muted); }

.toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.toolbar .filters { margin: 0; }
.chip .count { font-size: 12px; opacity: .7; margin-left: 4px; font-variant-numeric: tabular-nums; }
.tools-right { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.toolbar .seg { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--surface); }
.toolbar .seg button { border: 0; background: none; padding: 6px 12px; cursor: pointer; font-size: 13px; color: var(--muted); }
.toolbar .seg button[aria-pressed="true"] { background: var(--accent-soft); color: var(--text); font-weight: 600; }
.toolbar .search {
  border: 1px solid var(--border); border-radius: 10px; padding: 7px 12px; background: var(--surface);
  min-width: 200px; font-size: 14px;
}
.toolbar .search:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.result-note { color: var(--muted); font-size: 13px; margin: -6px 0 14px; }
.grid > .empty { text-align: center; color: var(--muted); padding: 40px 0; grid-column: 1 / -1; }
@media (max-width: 600px) { .toolbar .search { min-width: 0; flex: 1; } .tools-right { width: 100%; } }
.card-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.card h3 { margin: 0; font-size: 17px; }
.card p { margin: 0; color: var(--muted); font-size: 14px; flex: 1; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { font-size: 12px; padding: 2px 8px; border-radius: 6px; background: var(--surface-2); color: var(--muted); }
.tag.subj { color: #fff; }
.s-physics { background: var(--physics); }
.s-geography { background: var(--geography); }
.s-biology { background: var(--biology); }
.s-chemistry { background: var(--chemistry); }
.s-math { background: var(--math); }
.art-physics { background: color-mix(in srgb, var(--physics) 16%, var(--surface)); }
.art-geography { background: color-mix(in srgb, var(--geography) 16%, var(--surface)); }
.art-biology { background: color-mix(in srgb, var(--biology) 16%, var(--surface)); }
.art-chemistry { background: color-mix(in srgb, var(--chemistry) 16%, var(--surface)); }
.art-math { background: color-mix(in srgb, var(--math) 16%, var(--surface)); }

.faq details {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 18px; margin-bottom: 10px;
}
.faq summary { cursor: pointer; font-weight: 600; }
.faq details p { color: var(--muted); margin: 10px 0 0; }

footer { border-top: 1px solid var(--border); margin-top: 48px; padding: 24px 0; color: var(--muted); font-size: 14px; }

/* ---------- Lab pages ---------- */
.lab-head { padding: 20px 0 8px; }
.lab-head h1 { margin: 0 0 4px; font-size: clamp(22px, 4vw, 30px); }
.lab-head p { margin: 0; color: var(--muted); }
.lab-layout { display: grid; grid-template-columns: 1fr 300px; gap: 16px; padding: 16px 0; align-items: start; }
.lab-layout > * { min-width: 0; }
@media (max-width: 860px) { .lab-layout { grid-template-columns: 1fr; } }
.stage {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); position: relative; overflow: hidden; min-height: 360px;
}
.stage canvas { display: block; width: 100%; touch-action: none; }
.panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px; display: flex; flex-direction: column; gap: 14px;
}
.panel h2 { font-size: 15px; margin: 0; }
.panel .hint { font-size: 13px; color: var(--muted); margin: 0; }
.ctrl { display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
.ctrl .row { display: flex; justify-content: space-between; gap: 8px; }
.ctrl output { font-variant-numeric: tabular-nums; color: var(--muted); }
.ctrl input[type=range] { width: 100%; accent-color: var(--accent); }
.ctrl select { padding: 6px 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.btns { display: flex; flex-wrap: wrap; gap: 8px; }
.btn {
  border: 1px solid var(--border); background: var(--surface-2); border-radius: 8px;
  padding: 6px 12px; cursor: pointer; font-size: 14px;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); }
.readout {
  background: var(--surface-2); border-radius: 10px; padding: 10px 12px;
  font-size: 14px; font-variant-numeric: tabular-nums;
}
.notes { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 20px; margin-bottom: 16px; }
.notes h2 { font-size: 17px; margin: 0 0 8px; }
.notes p, .notes li { color: var(--muted); }
.quiz { display: flex; flex-direction: column; gap: 8px; }
.quiz .q { font-weight: 600; font-size: 14px; }
.quiz .opts { display: flex; flex-direction: column; gap: 6px; }
.quiz .opts button { text-align: left; }
.quiz .ok { border-color: var(--geography); background: color-mix(in srgb, var(--geography) 18%, var(--surface)); }
.quiz .bad { border-color: #d64545; background: color-mix(in srgb, #d64545 16%, var(--surface)); }
