:root {
    --ink: #1e2a44; --muted: #4d5b73; --line: #c5d4ea; --paper: #e7eef8; --card: #fff;
    --navy: #1f4e9a; --gold: #e8b931; --ok: #1d7a46; --ok-bg: #e8f6ee;
    --bad: #a33b3b; --bad-bg: #fdecec; --miss: #8a5a00; --miss-bg: #fff6df;
  }
  * { box-sizing: border-box; }
  html { scroll-behavior: smooth; }
  body {
    margin: 0; color: var(--ink);
    font: 17px/1.65 "Microsoft YaHei", "PingFang SC", "Noto Sans SC", sans-serif;
    background:
      radial-gradient(circle at 6% -4%, rgba(79, 134, 232, .45), transparent 34%),
      radial-gradient(circle at 98% 8%, rgba(31, 78, 154, .22), transparent 32%),
      radial-gradient(circle at 72% 108%, rgba(232, 185, 49, .22), transparent 26%),
      repeating-linear-gradient(0deg, transparent, transparent 31px, rgba(31, 78, 154, .045) 32px),
      repeating-linear-gradient(90deg, transparent, transparent 31px, rgba(31, 78, 154, .045) 32px),
      var(--paper);
  }
  header.top { background: linear-gradient(90deg, #243e86, #3f6fd4 58%, #2d56b0); color: #fff8f2; border-bottom: 4px solid var(--gold); }
  a.back { display: inline-block; margin-bottom: 6px; color: #ffe29a; font-weight: 700; font-size: 15px; text-decoration: none; }
  a.back:hover { text-decoration: underline; }
  .top-inner, .wrap { max-width: 1080px; margin: 0 auto; padding: 0 18px; }
  .top-inner { padding: 16px 18px 14px; }
  .brand small { display: block; letter-spacing: .14em; color: #ffe29a; font-weight: 700; font-size: 13px; }
  .brand strong { font-size: 26px; font-weight: 800; }
  .brand p { margin: 4px 0 0; color: #e7eef8; font-size: 15px; }
  .tabs { display: flex; gap: 8px; flex-wrap: wrap; padding: 0 0 14px; }
  .tabs button {
    appearance: none; border: 0; cursor: pointer; background: rgba(255,255,255,.14); color: #fff;
    border-radius: 999px; padding: 8px 16px; font: inherit; font-weight: 700; font-size: 16px;
  }
  .tabs button[aria-selected="true"] { background: var(--gold); color: #1e2a44; }
  .formula { margin: 16px auto 0; max-width: 1080px; padding: 0 18px; }
  .formula div {
    background: #fff; border: 2px solid var(--line); border-radius: 14px; padding: 10px 16px;
    font-weight: 700; color: var(--navy); box-shadow: 0 8px 18px rgba(31, 78, 154, .08);
  }
  main { padding: 8px 0 40px; }
  section[hidden] { display: none !important; }
  h2 { color: var(--navy); font-size: 28px; margin: 18px 0 8px; }
  h3 { color: var(--navy); font-size: 20px; margin: 18px 0 8px; }
  .rule { width: 64px; height: 4px; background: var(--gold); border-radius: 4px; margin: 8px 0 12px; }
  .card, .q, .case, .lesson {
    background: var(--card); border: 2px solid var(--line); border-radius: 18px;
    padding: 16px 18px; margin: 12px 0; box-shadow: 0 12px 28px rgba(31, 78, 154, .08);
  }
  .lesson h3 { margin-top: 0; }
  .kicker { color: var(--navy); font-weight: 800; margin: 10px 0 4px; }
  .en-lesson { color: #243e86; background: #f4f7fb; border-left: 4px solid #1f4e9a; border-radius: 12px; padding: 10px 12px; margin: 4px 0 10px; }
  .grid3, .grid2 { display: grid; gap: 12px; }
  .grid3 { grid-template-columns: repeat(3, 1fr); }
  .grid2 { grid-template-columns: 1fr 1fr; }
  .card h3 { margin-top: 0; }
  .card ol, .card ul, .lesson ul { margin: 8px 0 0; padding-left: 1.2em; }
  .note, .warn { border-radius: 14px; padding: 12px 14px; margin: 12px 0; }
  .note { background: #eef3fb; border: 1px solid var(--line); }
  .warn { background: #fff6df; border: 1px solid #e6c56a; }
  .warn strong { color: var(--miss); }
  table { width: 100%; border-collapse: collapse; font-size: 15px; background: #fff; }
  th, td { border: 1px solid var(--line); padding: 8px 10px; vertical-align: top; text-align: left; }
  th { background: var(--navy); color: #fff; }
  tr:nth-child(even) td { background: #f4f7fb; }
  .scroll { overflow-x: auto; border-radius: 14px; border: 2px solid var(--line); }
  .steps { counter-reset: step; list-style: none; padding: 0; }
  .steps li { display: grid; grid-template-columns: 46px 1fr; gap: 10px; align-items: start; margin: 10px 0; }
  .steps b {
    width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; color: #fff;
    background: linear-gradient(160deg, #6aa2ff, #1f4e9a);
  }
  .chips, .case-nav, .actions { display: flex; gap: 8px; flex-wrap: wrap; }
  .chips { margin: 8px 0 4px; }
  .chips button, .case-nav button, .actions button, .send { font: inherit; cursor: pointer; border-radius: 999px; padding: 7px 14px; font-weight: 700; }
  .chips button, .case-nav button { border: 2px solid var(--line); background: #fff; color: var(--navy); }
  .chips button[aria-pressed="true"], .case-nav button[aria-pressed="true"] { background: var(--navy); color: #fff; border-color: var(--navy); }
  .q-head { display: flex; justify-content: space-between; gap: 10px; }
  .tag { flex: none; font-size: 13px; font-weight: 800; color: var(--navy); background: #eef3fb; border-radius: 999px; padding: 2px 10px; }
  .stem { font-weight: 700; margin: 8px 0; }
  .opt {
    display: flex; gap: 10px; width: 100%; text-align: left; margin: 8px 0; padding: 10px 12px;
    border-radius: 12px; border: 2px solid var(--line); background: #fff; color: var(--ink); font: inherit; cursor: pointer;
  }
  .opt .k { flex: none; width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; font-weight: 800; color: #fff; background: var(--navy); }
  .opt[aria-pressed="true"] { border-color: var(--navy); background: #eef3fb; }
  .opt.good { border-color: var(--ok); background: var(--ok-bg); }
  .opt.bad { border-color: var(--bad); background: var(--bad-bg); }
  .opt.miss { border-color: var(--miss); background: var(--miss-bg); }
  .opt:disabled { cursor: default; }
  .actions { margin-top: 8px; }
  .actions button.primary { background: var(--navy); color: #fff; border: 0; }
  .actions button.ghost { background: #fff; color: var(--navy); border: 2px solid var(--line); }
  .actions button:disabled { opacity: .45; cursor: not-allowed; }
  .explain { margin-top: 10px; padding: 10px 12px; border-radius: 12px; background: #f7f9fc; border: 1px solid var(--line); }
  .explain .judge { font-weight: 800; }
  .explain .judge.ok { color: var(--ok); }
  .explain .judge.no { color: var(--bad); }
  .meta { color: var(--muted); font-size: 14px; }
  .facts { background: #f7f9fc; border-radius: 12px; padding: 10px 12px; }
  .facts p { margin: 6px 0; }
  footer { background: linear-gradient(90deg, #243e86, #3f6fd4); color: #e7eef8; text-align: center; padding: 18px 12px 22px; font-size: 14px; }
  .chat {
    background: #fff; border: 2px solid var(--line); border-radius: 18px; min-height: 280px; max-height: 520px;
    overflow: auto; padding: 14px; box-shadow: 0 12px 28px rgba(31, 78, 154, .08);
  }
  .bubble { max-width: 92%; margin: 10px 0; padding: 10px 12px; border-radius: 14px; white-space: pre-wrap; }
  .bubble.me { margin-left: auto; background: #eef3fb; border: 1px solid var(--line); }
  .bubble.bot { background: #fff8e8; border: 1px solid #e6c56a; }
  .askbar { display: flex; gap: 8px; margin-top: 12px; align-items: flex-end; }
  .askbar textarea {
    flex: 1; min-height: 74px; resize: vertical; border: 2px solid var(--line); border-radius: 14px;
    padding: 10px 12px; font: inherit; color: var(--ink);
  }
  .send { height: 44px; padding: 0 18px; background: var(--navy); color: #fff; border: 0; }
  .band { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 8px 0 4px; }
  .band article { background: #fff; border: 2px solid var(--line); border-radius: 14px; padding: 10px 12px; margin: 0; box-shadow: none; }
  .band strong { display: block; color: var(--navy); font-size: 18px; }
  .band span, .pipe span { display: block; color: var(--ink); font-size: 14px; margin-top: 4px; }
  .pipe { list-style: none; display: flex; gap: 18px; margin: 8px 0 12px; padding: 0; }
  .pipe li { flex: 1; min-width: 0; background: #fff; border: 2px solid var(--line); border-radius: 14px; padding: 12px; position: relative; }
  .pipe li:not(:last-child)::after { content: ""; position: absolute; right: -13px; top: 28px; width: 8px; height: 8px; border-top: 3px solid var(--navy); border-right: 3px solid var(--navy); transform: rotate(45deg); }
  .pipe i { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 8px; background: var(--navy); color: #fff; font-style: normal; font-weight: 800; margin-bottom: 6px; }
  .pipe strong { display: block; color: var(--navy); }
  @media (max-width: 800px) {
    .grid3, .grid2, .band { grid-template-columns: 1fr; }
    .pipe { display: flex; flex-direction: column; }
    .pipe li:not(:last-child)::after { right: auto; left: 22px; top: auto; bottom: -14px; transform: rotate(135deg); }
    .brand strong { font-size: 22px; }
    h2 { font-size: 24px; }
    .askbar { flex-direction: column; align-items: stretch; }
  }
  .tabbar { position: sticky; top: 0; z-index: 6; background: linear-gradient(90deg, #243e86, #3f6fd4 58%, #2d56b0); border-bottom: 4px solid var(--gold); box-shadow: 0 8px 18px rgba(31, 78, 154, .18); }
  .tabbar .tabs { position: static; background: transparent; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding: 10px 18px 12px; }
  .tabbar a.back { display: inline-flex; align-items: center; margin: 0 8px 0 0; padding: 8px 16px; border-radius: 999px; background: #ffe29a; color: #1e2a44; font-weight: 800; font-size: 16px; text-decoration: none; }
  .tabbar a.back:hover { background: #fff; text-decoration: none; }
  .teach-board { background: #fff; border: 2px solid var(--line); border-radius: 18px; padding: 14px 16px 8px; margin: 8px 0 16px; box-shadow: 0 12px 28px rgba(31, 78, 154, .08); }
  .teach-board > h2 { margin-top: 4px; }
  .em-blue { color: #1f4e9a; font-weight: 800; }
  .em-red { color: #a33b3b; font-weight: 800; }
  .em-green { color: #1d7a46; font-weight: 800; }
  .em-gold { color: #8a5a00; font-weight: 800; background: #fff6df; border-radius: 6px; padding: 0 4px; }
  .ladder { list-style: none; margin: 8px 0; padding: 0; display: grid; gap: 8px; }
  .ladder li { display: grid; grid-template-columns: 36px 1fr; gap: 10px; align-items: start; background: #f4f7fb; border-radius: 12px; padding: 8px 10px; }
  .ladder b { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; color: #fff; background: #1f4e9a; }
  .ladder strong { color: #1f4e9a; }
  .fig { margin: 10px 0; padding: 10px 12px; border-radius: 14px; background: #f7f9fc; border: 1px dashed #8eabd4; }
  .fig-title { font-weight: 800; color: #1f4e9a; margin-bottom: 8px; }
  .flow { display: flex; flex-wrap: wrap; gap: 8px; align-items: stretch; }
  .flow .node { flex: 1 1 140px; background: #fff; border: 2px solid #1f4e9a; border-radius: 12px; padding: 8px 10px; position: relative; }
  .flow .node b { display: block; color: #1f4e9a; }
  .flow .node span { display: block; font-size: 14px; }
  .flow .node:not(:last-child)::after { content: "→"; position: absolute; right: -14px; top: 12px; color: #1f4e9a; font-weight: 800; }
  .koujue, .sum, .story { border-radius: 12px; padding: 10px 12px; margin: 10px 0; }
  .koujue { background: #fffdf6; border-left: 6px solid #e8b931; }
  .koujue p, .sum p, .story { margin: 4px 0 0; }
  .sum { background: #e8f6ee; border-left: 6px solid #1d7a46; }
  .story { background: #eef3fb; border-left: 6px solid #1f4e9a; }
  td.go { color: #1d7a46; font-weight: 800; }
  td.hot { color: #a33b3b; font-weight: 800; }
  .quiz-set { flex-basis: 100%; display: grid; gap: 8px; margin-top: 4px; padding: 10px 12px; border-radius: 14px; background: #f7f9fc; border: 1px solid var(--line); }
  .quiz-set .row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
  .quiz-set select, .quiz-set button { font: inherit; font-weight: 700; }
  .quiz-set select { border: 2px solid var(--line); border-radius: 999px; padding: 6px 12px; color: var(--navy); background: #fff; }
  .quiz-set .hint { margin: 0; }
  @media (max-width: 800px) {
    .flow .node:not(:last-child)::after { content: none; }
  }
