/* CSCA Math Lab — styles */
:root {
  --bg: #f4f5fb;
  --bg-2: #eceefa;
  --surface: #ffffff;
  --surface-2: #f7f8fd;
  --surface-3: #eef0fa;
  --text: #141a2e;
  --text-2: #3f4763;
  --muted: #6b7390;
  --line: #e3e6f2;
  --line-2: #d3d8ea;
  --accent: #4f46e5;
  --accent-soft: #eceafe;
  --accent-2: #0d9488;
  --accent-2-soft: #e2f5f2;
  --ok: #15803d;
  --ok-soft: #e6f6ec;
  --err: #c81e1e;
  --err-soft: #fdeaea;
  --warn: #b45309;
  --warn-soft: #fdf3e3;
  --flag: #d97706;
  --shadow-sm: 0 1px 2px rgba(20, 26, 46, .05);
  --shadow: 0 8px 24px -12px rgba(20, 26, 46, .18), 0 2px 6px rgba(20, 26, 46, .04);
  --shadow-lg: 0 24px 60px -24px rgba(20, 26, 46, .3);
  --r-sm: 10px;
  --r: 14px;
  --r-lg: 20px;
  --font: "Inter", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial,
          "Microsoft YaHei", "PingFang SC", "Noto Sans SC", "Noto Sans", sans-serif;
  --mono: "Cascadia Mono", "JetBrains Mono", Consolas, "SFMono-Regular", ui-monospace, monospace;
}

[data-theme="dark"] {
  --bg: #0d1120;
  --bg-2: #0a0e1a;
  --surface: #161b2d;
  --surface-2: #1c2237;
  --surface-3: #232a42;
  --text: #edf0fa;
  --text-2: #c3c9dd;
  --muted: #8e96b3;
  --line: #262d45;
  --line-2: #333b57;
  --accent: #8b87ff;
  --accent-soft: #262352;
  --accent-2: #34d0bf;
  --accent-2-soft: #10312f;
  --ok: #4ade80;
  --ok-soft: #10301d;
  --err: #f87171;
  --err-soft: #38161a;
  --warn: #fbbf24;
  --warn-soft: #33270c;
  --flag: #fbbf24;
  --shadow: 0 10px 30px -18px rgba(0, 0, 0, .8), 0 2px 6px rgba(0, 0, 0, .3);
  --shadow-lg: 0 30px 70px -30px rgba(0, 0, 0, .9);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background:
    radial-gradient(1000px 500px at 12% -10%, rgba(79, 70, 229, .10), transparent 60%),
    radial-gradient(900px 480px at 100% 0%, rgba(13, 148, 136, .10), transparent 55%),
    var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
  min-height: 100vh;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }

::selection { background: var(--accent); color: #fff; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  backdrop-filter: blur(14px);
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1280px; margin: 0 auto;
  display: flex; align-items: center; gap: 18px;
  padding: 10px 22px; min-height: 64px;
}
.brand { display: flex; align-items: center; gap: 11px; text-decoration: none; color: inherit; flex-shrink: 0; border: 0; background: transparent; padding: 0; text-align: left; }
.brand-name { display: block; }
.brand-mark {
  width: 38px; height: 38px; flex: 0 0 38px;
  display: grid; place-items: center;
}
.brand-mark svg { width: 38px; height: 38px; display: block; border-radius: 11px; box-shadow: 0 8px 18px -10px rgba(27, 27, 75, .75); }
.brand-name { font-weight: 750; font-size: 16px; letter-spacing: -.2px; line-height: 1.15; }
.brand-tag { display: block; font-size: 11px; color: var(--muted); letter-spacing: .2px; }

.nav { display: flex; align-items: center; gap: 4px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav-btn {
  border: 1px solid transparent; background: transparent; color: var(--text-2);
  padding: 8px 13px; border-radius: 10px; font-size: 13.5px; font-weight: 600;
  white-space: nowrap; transition: background .15s, color .15s;
}
.nav-btn:hover { background: var(--surface-2); color: var(--text); }
.nav-btn.active { background: var(--accent-soft); color: var(--accent); border-color: color-mix(in srgb, var(--accent) 22%, transparent); }

.topbar-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.icon-btn {
  width: 36px; height: 36px; display: grid; place-items: center;
  border-radius: 10px; border: 1px solid var(--line); background: var(--surface);
  color: var(--text-2); font-size: 15px; transition: .15s;
}
.icon-btn:hover { border-color: var(--line-2); background: var(--surface-2); }

/* language switcher */
.langbox { position: relative; }
.lang-trigger {
  display: flex; align-items: center; gap: 8px;
  border: 1px solid var(--line); background: var(--surface);
  padding: 7px 11px; border-radius: 10px; font-size: 12.5px; font-weight: 600; color: var(--text-2);
}
.lang-trigger:hover { border-color: var(--line-2); }
.lang-label { white-space: nowrap; }
.lang-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent-2); }
.lang-pop {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 60;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); box-shadow: var(--shadow-lg);
  padding: 14px; width: 268px;
}
.lang-pop h4 { margin: 0 0 2px; font-size: 11px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); }
.lang-pop .hint { font-size: 11.5px; color: var(--muted); margin: 0 0 10px; }
.lang-row { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line); background: var(--surface-2); color: var(--text-2);
  border-radius: 999px; padding: 5px 11px; font-size: 12.5px; font-weight: 600;
  transition: .15s; display: inline-flex; align-items: center; gap: 6px;
}
.chip:hover { border-color: var(--line-2); color: var(--text); }
.chip.on { background: var(--accent-soft); color: var(--accent); border-color: color-mix(in srgb, var(--accent) 35%, transparent); }
.chip .x { font-size: 10px; opacity: .7; }

/* ---------- layout ---------- */
.container { max-width: 1280px; margin: 0 auto; padding: 26px 22px 72px; }
.view { animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 26px; letter-spacing: -.7px; }
.page-head p { margin: 5px 0 0; color: var(--muted); font-size: 14px; max-width: 760px; }

.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-sidebar { grid-template-columns: 320px minmax(0, 1fr); align-items: start; }

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--shadow-sm);
}
.card-pad { padding: 20px; }
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 20px; border-bottom: 1px solid var(--line);
}
.card-head h2, .card-head h3 { margin: 0; font-size: 15px; letter-spacing: -.2px; }
.card-head .sub { font-size: 12px; color: var(--muted); margin: 2px 0 0; }

/* ---------- hero ---------- */
.hero {
  position: relative; overflow: hidden;
  border-radius: 26px; padding: 34px 34px 30px; margin-bottom: 20px;
  background:
    radial-gradient(700px 300px at 85% -40%, rgba(13, 148, 136, .35), transparent 60%),
    radial-gradient(600px 320px at 0% 120%, rgba(124, 58, 237, .35), transparent 60%),
    linear-gradient(135deg, #1b1b4b 0%, #312e81 50%, #164e63 100%);
  color: #fff;
  box-shadow: var(--shadow-lg);
}
.hero::after {
  content: ""; position: absolute; inset: 0;
  background-image: radial-gradient(rgba(255, 255, 255, .16) 1px, transparent 1px);
  background-size: 22px 22px; opacity: .35; pointer-events: none;
  mask-image: linear-gradient(120deg, #000, transparent 70%);
}
.hero h1 { margin: 0 0 8px; font-size: clamp(24px, 3.2vw, 36px); letter-spacing: -1px; line-height: 1.12; }
.hero p { margin: 0; max-width: 620px; color: rgba(255, 255, 255, .82); font-size: 14.5px; }
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 22px; position: relative; z-index: 1; }
.hero .btn.primary { background: #fff; color: #1e1b4b; border-color: #fff; box-shadow: 0 10px 24px -12px rgba(0, 0, 0, .6); }
.hero .btn.primary:hover { background: #f1f3ff; }
.hero .btn.ghost { background: rgba(255, 255, 255, .1); border-color: rgba(255, 255, 255, .3); color: #fff; }
.hero .btn.ghost:hover { background: rgba(255, 255, 255, .18); }
.hero-facts { display: flex; gap: 22px; flex-wrap: wrap; margin-top: 26px; position: relative; z-index: 1; }
.hero-fact strong { display: block; font-size: 20px; letter-spacing: -.5px; }
.hero-fact span { font-size: 11.5px; text-transform: uppercase; letter-spacing: .9px; color: rgba(255, 255, 255, .65); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 1px solid var(--line-2); background: var(--surface); color: var(--text);
  padding: 9px 16px; border-radius: 11px; font-size: 13.5px; font-weight: 650;
  transition: transform .06s, box-shadow .15s, background .15s, border-color .15s;
  text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: var(--muted); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 8px 20px -10px color-mix(in srgb, var(--accent) 80%, transparent); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.teal { background: var(--accent-2); border-color: var(--accent-2); color: #fff; }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.danger { color: var(--err); border-color: color-mix(in srgb, var(--err) 30%, transparent); background: var(--err-soft); }
.btn.small { padding: 6px 11px; font-size: 12.5px; border-radius: 9px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- stats ---------- */
.stat { padding: 18px; border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-sm); }
.stat-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.stat-label { font-size: 11.5px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); font-weight: 650; }
.stat-value { font-size: 30px; font-weight: 760; letter-spacing: -1.2px; margin-top: 8px; line-height: 1; }
.stat-value small { font-size: 14px; font-weight: 600; color: var(--muted); letter-spacing: 0; }
.stat-note { font-size: 12px; color: var(--muted); margin-top: 6px; }
.stat-ico { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: var(--surface-3); font-size: 14px; }

.ring { --p: 0; --c: var(--accent); width: 74px; height: 74px; border-radius: 50%; display: grid; place-items: center; background: conic-gradient(var(--c) calc(var(--p) * 1%), var(--surface-3) 0); }
.ring > div { width: 58px; height: 58px; border-radius: 50%; background: var(--surface); display: grid; place-items: center; font-size: 14px; font-weight: 750; }

/* ---------- progress bars & tables ---------- */
.bar { display: block; height: 7px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.bar.thin { height: 5px; }

.preset { text-align: left; padding: 16px; cursor: pointer; transition: .15s; }
.preset:hover { border-color: color-mix(in srgb, var(--accent) 45%, transparent); transform: translateY(-1px); box-shadow: var(--shadow); }
.preset.active { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.builder-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); align-items: start; }

.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .7px; color: var(--muted); padding: 8px 12px; border-bottom: 1px solid var(--line); font-weight: 650; }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--line); }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }

.topic-list { display: flex; flex-direction: column; gap: 13px; }
.topic-row { display: grid; grid-template-columns: minmax(120px, 1.4fr) 2.4fr 46px; gap: 14px; align-items: center; }
.topic-row .tname { font-size: 13px; font-weight: 600; }
.topic-row .tpct { text-align: right; font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- filters / forms ---------- */
.field { margin-bottom: 18px; }
.field:last-child { margin-bottom: 0; }
.field > label, .field-label { display: block; font-size: 11.5px; text-transform: uppercase; letter-spacing: .7px; color: var(--muted); font-weight: 700; margin-bottom: 8px; }
.check { display: flex; align-items: center; gap: 9px; padding: 6px 0; font-size: 13.5px; cursor: pointer; }
.check input { accent-color: var(--accent); width: 15px; height: 15px; }
.pill-group { display: flex; flex-wrap: wrap; gap: 6px; }
.pill {
  border: 1px solid var(--line); background: var(--surface-2); color: var(--text-2);
  border-radius: 9px; padding: 6px 11px; font-size: 12.5px; font-weight: 600;
}
.pill.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.input, .select, .textarea {
  width: 100%; padding: 9px 12px; border-radius: 10px;
  border: 1px solid var(--line-2); background: var(--surface); font-size: 13.5px;
}
.input:focus, .select:focus, .textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 35%, transparent); outline-offset: 1px; border-color: var(--accent); }
.select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 30px; }
.textarea { resize: vertical; min-height: 74px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 0; font-size: 13.5px; }
.switch input { width: 38px; height: 22px; appearance: none; background: var(--surface-3); border-radius: 999px; position: relative; transition: .18s; cursor: pointer; border: 1px solid var(--line-2); }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--surface); box-shadow: var(--shadow-sm); transition: .18s; }
.switch input:checked { background: var(--accent); border-color: var(--accent); }
.switch input:checked::after { transform: translateX(16px); }

/* ---------- question card ---------- */
.qcard { padding: 24px; }
.qtop { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.badges { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.badge { font-size: 11px; font-weight: 700; letter-spacing: .3px; padding: 3px 9px; border-radius: 999px; background: var(--surface-3); color: var(--text-2); }
.badge.topic { background: var(--accent-soft); color: var(--accent); }
.badge.d1 { background: var(--ok-soft); color: var(--ok); }
.badge.d2 { background: var(--warn-soft); color: var(--warn); }
.badge.d3 { background: var(--err-soft); color: var(--err); }
.badge.id { font-family: var(--mono); font-weight: 600; color: var(--muted); background: transparent; border: 1px solid var(--line); }

.lang-block { margin: 0 0 12px; }
.lang-tag { display: inline-block; font-size: 9.5px; font-weight: 800; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); margin-bottom: 3px; }
.qtext { margin: 0; font-size: 17px; line-height: 1.55; letter-spacing: -.1px; overflow-wrap: anywhere; }
.qtext.zh { font-size: 17.5px; }

.opts { display: flex; flex-direction: column; gap: 9px; margin-top: 20px; }
.opt {
  display: flex; align-items: flex-start; gap: 12px; width: 100%; text-align: left;
  border: 1px solid var(--line-2); background: var(--surface); border-radius: 12px;
  padding: 12px 14px; font-size: 15px; transition: .13s; color: var(--text);
}
.opt:hover:not(:disabled) { border-color: var(--accent); background: var(--accent-soft); }
.opt .k {
  flex: 0 0 24px; height: 24px; border-radius: 7px; display: grid; place-items: center;
  background: var(--surface-3); font-size: 12px; font-weight: 750; color: var(--text-2);
}
.opt .ol { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.opt.selected { border-color: var(--accent); background: var(--accent-soft); }
.opt.selected .k { background: var(--accent); color: #fff; }
.opt.correct { border-color: var(--ok); background: var(--ok-soft); }
.opt.correct .k { background: var(--ok); color: #fff; }
.opt.wrong { border-color: var(--err); background: var(--err-soft); }
.opt.wrong .k { background: var(--err); color: #fff; }
.opt:disabled { cursor: default; opacity: .95; }
.opt .mark { margin-left: auto; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; }

.solution { margin-top: 18px; border: 1px solid var(--line); background: var(--surface-2); border-radius: 12px; padding: 14px 16px; }
.solution h4 { margin: 0 0 6px; font-size: 11.5px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); }
.solution p { margin: 0 0 6px; font-size: 13.5px; color: var(--text-2); }
.solution p:last-child { margin-bottom: 0; }
.solution .tag { font-family: var(--mono); font-size: 10px; color: var(--muted); margin-right: 6px; }

.open-box { margin-top: 18px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); }
.open-box .row { flex-wrap: nowrap; }
.open-box input { font-size: 15px; }
.open-box .btn { flex: 0 0 auto; }
.verdict { margin-top: 10px; font-size: 13px; font-weight: 650; }
.verdict.ok { color: var(--ok); }
.verdict.err { color: var(--err); }
.verdict.warn { color: var(--warn); font-weight: 550; }
.verdict.muted { color: var(--muted); font-weight: 500; }
.steps { margin: 4px 0 0; padding-left: 20px; font-size: 13.5px; color: var(--text-2); }
.steps li { margin: 4px 0; }
@media (max-width: 560px) {
  .open-box .row { flex-wrap: wrap; }
  .open-box .btn { width: 100%; }
}

.qfoot { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); }

/* ---------- exam ---------- */
.exam-shell { display: grid; grid-template-columns: minmax(0, 1fr) 268px; gap: 18px; align-items: start; }
.timer {
  display: flex; align-items: center; gap: 10px; font-variant-numeric: tabular-nums;
  font-weight: 750; font-size: 19px; letter-spacing: -.3px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 9px 14px;
}
.timer.warn { color: var(--warn); background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.timer.danger { color: var(--err); background: var(--err-soft); border-color: color-mix(in srgb, var(--err) 30%, transparent); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .65; } }
.exam-status { display: flex; gap: 7px; }
.navigator { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.nav-cell {
  aspect-ratio: 1; border-radius: 8px; border: 1px solid var(--line);
  background: var(--surface-2); font-size: 12px; font-weight: 650; color: var(--text-2);
  display: grid; place-items: center; position: relative; padding: 0;
}
.nav-cell:hover { border-color: var(--accent); }
.nav-cell.answered { background: var(--accent-soft); color: var(--accent); border-color: color-mix(in srgb, var(--accent) 35%, transparent); }
.nav-cell.current { outline: 2px solid var(--accent); outline-offset: 1px; }
.nav-cell.flagged::after { content: ""; position: absolute; top: 2px; right: 2px; width: 0; height: 0; border-top: 7px solid var(--flag); border-left: 7px solid transparent; }
.legend { display: flex; flex-direction: column; gap: 7px; font-size: 12px; color: var(--muted); margin-top: 14px; }
.legend span { display: flex; align-items: center; gap: 7px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

.results-hero { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 26px; align-items: center; }
.score-big { font-size: 46px; font-weight: 800; letter-spacing: -2px; line-height: 1; }
.score-sub { color: var(--muted); font-size: 13px; margin-top: 4px; }

/* ---------- builder ---------- */
.bank-list { max-height: 560px; overflow-y: auto; display: flex; flex-direction: column; gap: 7px; padding-right: 4px; }
.bank-item { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--line); border-radius: 11px; padding: 10px 11px; background: var(--surface-2); }
.bank-item .txt { flex: 1; min-width: 0; }
.bank-item .q { font-size: 12.5px; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.bank-item .m { font-size: 10.5px; color: var(--muted); margin-top: 4px; text-transform: uppercase; letter-spacing: .4px; }
.bank-item.added { border-color: color-mix(in srgb, var(--accent-2) 45%, transparent); background: var(--accent-2-soft); }
.mini-add { flex: 0 0 26px; height: 26px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--surface); font-weight: 700; color: var(--accent); display: grid; place-items: center; padding: 0; }
.mini-add:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.sel-item { display: flex; gap: 9px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 12.5px; }
.sel-item:last-child { border-bottom: 0; }
.sel-item .ord { width: 22px; height: 22px; border-radius: 7px; background: var(--surface-3); display: grid; place-items: center; font-size: 11px; font-weight: 700; flex: 0 0 22px; }
.sel-item .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sel-item .pts-input { width: 52px; padding: 3px 6px; text-align: center; border-radius: 7px; border: 1px solid var(--line); background: var(--surface); font-size: 12px; }

/* ---------- reference ---------- */
.ref-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.formula { border: 1px solid var(--line); border-radius: 11px; padding: 11px 13px; background: var(--surface-2); }
.formula .fn { font-size: 12px; font-weight: 700; color: var(--text-2); }
.formula .fx { font-family: var(--mono); font-size: 12.5px; color: var(--text); margin-top: 5px; line-height: 1.5; overflow-wrap: anywhere; }
.formula .fl { font-size: 10px; color: var(--muted); margin-top: 4px; }
.formula-ex { margin-top: 8px; }
.formula-ex summary { cursor: pointer; font-size: 11px; font-weight: 700; color: var(--accent); }
.formula-ex .fx { margin-top: 6px; background: var(--surface); border-radius: 8px; padding: 7px 9px; }
.formula .btn { margin-top: 8px; }
.theory-title { margin: 0 0 6px; font-size: 20px; letter-spacing: -.4px; }
.theory-def { margin: 0 0 16px; color: var(--text-2); font-size: 14px; }
.theory-lang { margin-bottom: 10px; }
.theory-lang .theory-def { margin: 4px 0 0; }
.theory-lang .theory-mistake { margin: 4px 0 0; }
.theory-h { margin: 0 0 8px; font-size: 11px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); }
.theory-mistake { margin-top: 14px; }
.cat-sub { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.cat-sub:last-child { border-bottom: 0; }
.cat-sub-name { font-size: 13.5px; font-weight: 600; }
.source-place { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.source-place:last-child { border-bottom: 0; }
.source-line { font-size: 13px; color: var(--text-2); margin-bottom: 4px; }
.official-list { margin: 0; padding-left: 18px; }
.official-list li { margin-bottom: 6px; font-size: 13.5px; color: var(--text-2); }
.my-task { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.my-task:last-child { border-bottom: 0; }
.my-task-q { font-size: 13.5px; font-weight: 600; }
.gloss-wrap { overflow-x: auto; }
.gloss td { vertical-align: top; }
.gloss .zh { font-size: 15px; font-weight: 650; }
.gloss .py { color: var(--muted); font-size: 12px; font-style: italic; }

/* ---------- misc ---------- */
.chip-row { display: flex; gap: 6px; flex-wrap: wrap; }
.empty { text-align: center; padding: 40px 20px; color: var(--muted); font-size: 13.5px; }
.empty .big { font-size: 30px; margin-bottom: 8px; opacity: .5; }
.notice { border-radius: 11px; padding: 11px 14px; font-size: 13px; border: 1px solid; display: flex; gap: 9px; align-items: flex-start; }
.notice.ok { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 25%, transparent); }
.notice.warn { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 25%, transparent); }
.notice.info { background: var(--accent-soft); color: var(--accent); border-color: color-mix(in srgb, var(--accent) 22%, transparent); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: var(--mono); }
.hr { height: 1px; background: var(--line); margin: 16px 0; border: 0; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.spacer { flex: 1; }

.modal-backdrop {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center;
  background: rgba(10, 14, 26, .55); backdrop-filter: blur(4px); padding: 20px;
  animation: fade .18s ease;
}
.modal { width: min(560px, 100%); background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-lg); border: 1px solid var(--line); max-height: 86vh; overflow: auto; }
.modal.wide { width: min(720px, 100%); }
.modal-head { padding: 18px 22px 0; display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.modal-head h3 { margin: 0; font-size: 18px; letter-spacing: -.3px; }
.modal-body { padding: 14px 22px 20px; font-size: 13.5px; color: var(--text-2); }
.modal-foot { padding: 0 22px 20px; display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.kbd { font-family: var(--mono); font-size: 11px; border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 5px; padding: 1px 5px; background: var(--surface-2); color: var(--text-2); }

.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(10px);
  background: #101426; color: #fff; border-radius: 11px; padding: 10px 18px;
  font-size: 13px; z-index: 200; opacity: 0; pointer-events: none; transition: .2s;
  box-shadow: 0 16px 40px -12px rgba(0, 0, 0, .6);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

/* ---------- demo payment ---------- */
.pay-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.pay-price { font-size: 30px; font-weight: 800; letter-spacing: -1px; margin-top: 2px; }
.pay-price small { font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: 0; }
.demo-tag {
  padding: 4px 10px; border-radius: 999px; font-size: 10px; font-weight: 800; letter-spacing: .8px;
  text-transform: uppercase; color: var(--warn); background: var(--warn-soft);
  border: 1px solid color-mix(in srgb, var(--warn) 25%, transparent); white-space: nowrap;
}
.pay-methods { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pay-method {
  display: flex; flex-direction: column; gap: 2px; padding: 10px 6px; border-radius: 10px;
  border: 1px solid var(--line-2); background: var(--surface-2); cursor: pointer;
  font-size: 11.5px; color: var(--text-2); text-align: center;
}
.pay-method b { font-size: 12.5px; }
.pay-method span { font-size: 10px; color: var(--muted); }
.pay-method.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.pay-method.on span { color: var(--accent); opacity: .75; }
.pay-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 4px; }
.pay-row label { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .7px; color: var(--muted); font-weight: 700; margin: 10px 0 5px; }
.pay-qr { display: grid; place-items: center; padding: 6px 0 2px; }
.pay-qr svg { width: 190px; height: 190px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.pay-processing { text-align: center; padding: 26px 0; color: var(--muted); font-size: 13px; }
.spinner { width: 28px; height: 28px; margin: 0 auto 10px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: pay-spin 1s linear infinite; }
@keyframes pay-spin { to { transform: rotate(360deg); } }
.pay-success { text-align: center; padding: 10px 0 4px; }
.pay-success .icon { width: 54px; height: 54px; margin: 0 auto 10px; border-radius: 50%; display: grid; place-items: center; background: var(--ok-soft); color: var(--ok); font-size: 26px; font-weight: 800; }
.pay-success h3 { margin: 0 0 4px; font-size: 18px; }
.pay-success p { margin: 0; color: var(--muted); font-size: 13px; }
.pay-amount { font-size: 26px; font-weight: 800; letter-spacing: -.8px; margin-top: 10px; }
.pay-error { margin-top: 10px; padding: 8px 10px; border-radius: 8px; background: var(--err-soft); color: var(--err); font-size: 12.5px; display: none; }
.pay-error.on { display: block; }
.pay-promo { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); }
.pay-plans { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 14px; }.pay-plan {
  display: flex; flex-direction: column; gap: 2px; text-align: left; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface-2); border-radius: 12px; padding: 10px 9px;
}
.pay-plan.on { border-color: var(--accent); background: var(--accent-soft); }
.pay-plan b { font-size: 11px; color: var(--muted); font-weight: 600; }
.pay-plan span { font-size: 16px; font-weight: 800; letter-spacing: -.3px; }
.pay-plan small { font-size: 10.5px; color: var(--muted); }
.auth-wrap { min-height: 70vh; display: grid; place-items: center; padding: 20px 0; }
.auth-card { width: min(420px, 100%); }
.auth-card h1 { margin: 0 0 4px; font-size: 24px; letter-spacing: -.5px; }
.install-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-bottom: 14px; padding: 12px 14px; border-radius: 14px;
  background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
}
.install-banner .btn { flex: 0 0 auto; }
@media (max-width: 560px) { .pay-plans { grid-template-columns: 1fr 1fr; } }

.hero-split { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, .7fr); gap: 24px; align-items: center; }
.hero-main { min-width: 0; }
.partner-card {
  position: relative; display: block; max-width: 270px; margin-left: auto;
  border-radius: 18px; overflow: hidden; background: #fff;
  box-shadow: 0 8px 22px rgba(15, 23, 42, .12); isolation: isolate;
}
.partner-card::before {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 64px;
  background: linear-gradient(180deg, rgba(255,255,255,.95) 10%, rgba(255,255,255,0) 100%);
  pointer-events: none; z-index: 1;
}
.partner-card::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 96px;
  background: linear-gradient(0deg, rgba(255,255,255,.97) 18%, rgba(255,255,255,0) 100%);
  pointer-events: none; z-index: 1;
}
.partner-card:hover { box-shadow: 0 10px 26px rgba(15, 23, 42, .18); }
.partner-cover { display: block; width: 100%; height: auto; }
.partner-logo { position: absolute; top: 10px; left: 12px; height: 40px; width: auto; z-index: 2; }
.pb-slogan {
  position: absolute; left: 14px; right: 14px; bottom: 13px; z-index: 2;
  font-size: 20px; font-weight: 800; line-height: 1.15; color: #0B1B3A;
  text-shadow: 0 0 12px rgba(255,255,255,.95), 0 1px 2px rgba(255,255,255,.95);
}

/* ---------- responsive ---------- */
@media (max-width: 1080px) {
  .g-sidebar { grid-template-columns: 1fr; }
  .builder-grid { grid-template-columns: 1fr; }
  .exam-shell { grid-template-columns: 1fr; }
  .exam-shell aside .card { margin-top: 0; }
  .navigator { grid-template-columns: repeat(10, 1fr); }
}
@media (max-width: 860px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g3 { grid-template-columns: 1fr; }
  .g2, .ref-grid { grid-template-columns: 1fr; }
  .hero-split { grid-template-columns: 1fr; }
  .brand-tag { display: none; }
  .topbar-inner { min-height: 56px; padding: 8px 14px; gap: 10px; }
  .container { padding: 18px 14px 60px; }
  .hero { padding: 24px; border-radius: 20px; }
  .results-hero { grid-template-columns: 1fr; gap: 14px; }
  .navigator { grid-template-columns: repeat(8, 1fr); }
  .topic-row { grid-template-columns: 1fr 1fr 44px; gap: 8px; }
}
@media (max-width: 560px) {
  .g4 { grid-template-columns: 1fr; }
  .page-head h1 { font-size: 21px; }
  .qtext { font-size: 15.5px; }
  .opt { font-size: 14px; }
  .topbar-right .icon-btn[data-act="theme"] { display: none; }
  .nav-btn { padding: 7px 10px; font-size: 12.5px; }
  .cl.extra { display: none; }
  .lang-trigger { padding: 7px 9px; }
  .brand-name { font-size: 14px; }
  .card-pad, .qcard { padding: 16px; }
  .hero-facts { gap: 14px; }
}

@media (max-width: 640px) {
  html { -webkit-text-size-adjust: 100%; }
  body { padding-bottom: env(safe-area-inset-bottom); }
  .topbar-inner { flex-wrap: wrap; row-gap: 6px; }
  .nav { order: 3; flex: 1 0 100%; margin-top: 2px; padding-bottom: 2px; -webkit-overflow-scrolling: touch; }
  .nav-btn { flex: 0 0 auto; min-height: 36px; }
  .brand { min-width: 0; }
  .topbar-right { margin-left: auto; }
  .container { padding: 14px 12px calc(56px + env(safe-area-inset-bottom)); }
  .page-head { flex-direction: column; align-items: stretch; gap: 10px; }
  .page-head h1 { font-size: 20px; }
  .hero { padding: 18px; border-radius: 18px; }
  .hero h1 { font-size: 25px; }
  .card-head { padding: 14px; }
  .card-pad, .qcard { padding: 14px; }
  .g2, .g3, .g4, .ref-grid { grid-template-columns: 1fr; }
  .navigator { grid-template-columns: repeat(5, 1fr); }
  .modal, .modal.wide { width: calc(100vw - 16px); max-width: none; max-height: 92vh; }
  .modal-body { padding: 14px; }
  .table { font-size: 12px; }
  .card-pad { overflow-x: auto; }
  .btn { min-height: 38px; }
  .icon-btn { min-width: 36px; min-height: 36px; }
  .qtop { flex-wrap: wrap; gap: 8px; }
  .qtop .row { width: 100%; justify-content: flex-end; }
  .qfoot .row { width: 100%; }
  .qfoot .btn { flex: 1 1 auto; }
  .exam-status { width: 100%; justify-content: space-between; flex-wrap: wrap; }
  .timer { font-size: 16px; padding: 7px 10px; }
  .row { flex-wrap: wrap; }
  .partner-logo { height: 34px; top: 9px; left: 11px; }
  .pb-slogan { font-size: 17px; left: 12px; right: 12px; bottom: 11px; }
  .partner-card { max-width: 320px; margin: 0 auto; }
  .open-box .row { flex-wrap: wrap; }
}

@media print {
  .topbar, .nav, .topbar-right, .hero-actions, .btn, .icon-btn { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; }
}
