:root {
  --ink: #16213d;
  --muted: #5e6880;
  --paper: #ffffff;
  --background: #f4f6fb;
  --line: #dce1ec;
  --blue: #3056d3;
  --blue-dark: #1e3d9f;
  --blue-soft: #edf2ff;
  --violet: #7357d9;
  --green: #17855e;
  --green-soft: #eaf8f1;
  --amber: #ad6811;
  --amber-soft: #fff6df;
  --red: #b33745;
  --red-soft: #fff0f2;
  --shadow: 0 14px 40px rgba(27, 38, 78, 0.1);
  --radius: 22px;
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--background); }

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 7% 3%, rgba(48, 86, 211, 0.09), transparent 29rem),
    radial-gradient(circle at 95% 0%, rgba(115, 87, 217, 0.08), transparent 25rem),
    var(--background);
  font-family: Inter, "Segoe UI", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  font-size: 18px;
  line-height: 1.55;
}

button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.app-shell { max-width: 1560px; margin: 0 auto; padding: 28px 32px 40px; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}

.brand-wrap { display: flex; align-items: center; gap: 18px; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 62px;
  height: 62px;
  flex: 0 0 62px;
  border-radius: 19px;
  color: #fff;
  background: linear-gradient(145deg, var(--blue), var(--violet));
  font-family: Georgia, "Times New Roman", serif;
  font-size: 35px;
  font-weight: 700;
  box-shadow: 0 10px 25px rgba(48, 86, 211, 0.25);
}

h1 { margin: 0; font-size: clamp(28px, 3vw, 42px); line-height: 1.12; letter-spacing: -0.025em; }
#app-subtitle { margin: 5px 0 0; color: var(--muted); font-size: 17px; }
.top-actions { display: flex; align-items: center; gap: 12px; }
.language-switch { display: flex; padding: 4px; border: 1px solid var(--line); border-radius: 14px; background: #fff; }
.lang-button {
  min-width: 62px;
  padding: 9px 13px;
  border: 0;
  border-radius: 10px;
  color: var(--muted);
  background: transparent;
  font-weight: 800;
  cursor: pointer;
}
.lang-button.is-active { color: #fff; background: var(--blue); }

.section-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  padding: 9px;
  margin-bottom: 20px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255,255,255,0.85);
  box-shadow: 0 8px 28px rgba(27, 38, 78, 0.05);
}
.section-tab {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 11px;
  min-height: 58px;
  padding: 10px 16px;
  border: 0;
  border-radius: 14px;
  color: var(--muted);
  background: transparent;
  font-size: 19px;
  font-weight: 800;
  cursor: pointer;
}
.section-tab.is-active { color: var(--blue-dark); background: var(--blue-soft); }
.tab-icon { opacity: .65; font-size: 13px; letter-spacing: .06em; }
.tab-count { padding: 2px 9px; border-radius: 999px; background: rgba(48,86,211,.11); font-size: 14px; }

.main-layout { display: grid; grid-template-columns: 270px minmax(0, 1fr); gap: 20px; align-items: start; }
.sidebar, .question-panel, .results-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: var(--shadow);
}
.sidebar { position: sticky; top: 18px; padding: 18px; }
.score-card { padding: 14px 14px 16px; border-radius: 16px; background: #f7f8fc; }
.score-row { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 7px; color: var(--muted); font-size: 15px; }
.score-row strong { color: var(--ink); }
.progress-track { height: 8px; margin-top: 13px; overflow: hidden; border-radius: 99px; background: #dfe4f0; }
.progress-track span { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--blue), var(--violet)); transition: width .25s ease; }
#progress-text { margin: 7px 0 0; color: var(--muted); font-size: 14px; }
.question-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 7px; margin-top: 17px; }
.question-jump {
  aspect-ratio: 1;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--muted);
  background: #fff;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}
.question-jump:hover { border-color: var(--blue); color: var(--blue); }
.question-jump.is-current { border-color: var(--blue); color: #fff; background: var(--blue); }
.question-jump.is-correct { border-color: #99d7bd; color: var(--green); background: var(--green-soft); }
.question-jump.is-wrong { border-color: #f0b4bd; color: var(--red); background: var(--red-soft); }
.question-jump.is-current.is-correct, .question-jump.is-current.is-wrong { outline: 3px solid rgba(48,86,211,.2); }
.offline-note { margin: 16px 4px 0; color: var(--muted); font-size: 13px; line-height: 1.45; }

.question-panel { min-height: 650px; padding: clamp(26px, 4vw, 54px); }
.question-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.eyebrow { color: var(--blue); font-size: 15px; font-weight: 900; letter-spacing: .04em; text-transform: uppercase; }
.meta-pill { padding: 5px 11px; border-radius: 999px; color: #59459f; background: #f0edfc; font-size: 14px; font-weight: 800; }
.meta-pill.difficulty { color: var(--amber); background: var(--amber-soft); }
#question-topic { margin: 18px 0 12px; font-size: clamp(24px, 3vw, 34px); line-height: 1.2; }
.question-prompt { max-width: 1120px; font-size: clamp(22px, 2.2vw, 30px); font-weight: 700; line-height: 1.65; overflow-wrap: anywhere; }
.answer-instruction { margin: 25px 0 12px; color: var(--muted); font-size: 16px; font-weight: 800; }

.venn-figure {
  width: min(500px, 100%);
  margin: 22px 0 4px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fbfcff;
}
.venn-figure svg { display: block; width: 100%; height: auto; }
.venn-universe { fill: #fff; stroke: #8792aa; stroke-width: 2; }
.venn-fill { fill: #6f8ff0; opacity: .8; }
.venn-outline { fill: none; stroke: #26395f; stroke-width: 3; }
.venn-labels { fill: #16213d; font: 700 21px Georgia, "Times New Roman", serif; }

.graph-figure,
.matrix-figure {
  width: min(820px, 100%);
  margin: 24px 0 6px;
  padding: 14px 16px 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: linear-gradient(180deg, #fcfdff, #f7f9ff);
}
.graph-figure figcaption,
.matrix-figure figcaption {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 15px;
  font-weight: 800;
  text-align: center;
}
.graph-figure svg { display: block; width: 100%; height: auto; }
.graph-edge line {
  stroke: #26395f;
  stroke-width: 3;
  stroke-linecap: round;
}
.graph-edge marker path,
.graph-figure marker path { fill: #26395f; }
.edge-label {
  paint-order: stroke;
  stroke: #fff;
  stroke-width: 8px;
  stroke-linejoin: round;
  fill: #111b33;
  font: 700 19px "Cambria Math", Cambria, "Times New Roman", serif;
  text-anchor: middle;
  dominant-baseline: central;
}
.graph-node circle {
  fill: #fff;
  stroke: var(--blue);
  stroke-width: 4;
  filter: drop-shadow(0 2px 2px rgba(35,55,100,.16));
}
.graph-node.is-root circle {
  stroke: var(--violet);
  stroke-width: 6;
}
.graph-node text {
  fill: #101b35;
  font: 800 18px "Cambria Math", Cambria, "Times New Roman", serif;
  font-style: normal;
  text-anchor: middle;
  dominant-baseline: middle;
}
.graph-gallery {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  max-width: 920px;
  margin-top: 24px;
}
.graph-gallery .graph-figure {
  width: 100%;
  margin: 0;
  padding: 9px;
}
.graph-gallery .graph-node text { font-size: 15px; }
.matrix-scroll {
  overflow-x: auto;
  padding: 2px 2px 8px;
  scrollbar-color: #8fa4dd #e7ebf5;
}
.weight-matrix {
  min-width: 560px;
  margin: 0 auto;
  border-collapse: collapse;
  color: var(--ink);
  background: #fff;
  font-size: clamp(16px, 1.5vw, 21px);
  text-align: center;
}
.weight-matrix th,
.weight-matrix td {
  min-width: 62px;
  padding: 9px 12px;
  border: 1px solid #9ea8bb;
}
.weight-matrix thead th,
.weight-matrix tbody th {
  color: var(--blue-dark);
  background: #edf2ff;
  font-weight: 900;
}
.weight-matrix .math {
  margin: 0;
  white-space: nowrap;
}

.option-list { display: grid; gap: 12px; max-width: 1120px; }
.option {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  gap: 15px;
  align-items: start;
  padding: 17px 19px;
  border: 2px solid var(--line);
  border-radius: 16px;
  background: #fff;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease, transform .15s ease;
}
.option:hover { transform: translateY(-1px); border-color: #aebde9; background: #fafbff; }
.option.is-selected { border-color: var(--blue); background: var(--blue-soft); }
.option-control {
  display: grid;
  place-items: center;
  width: 27px;
  height: 27px;
  margin-top: 2px;
  border: 2px solid #abb4c7;
  border-radius: 50%;
  color: #fff;
  background: #fff;
  font-size: 16px;
  font-weight: 900;
}
.option[data-type="multi"] .option-control { border-radius: 7px; }
.option.is-selected .option-control { border-color: var(--blue); background: var(--blue); }
.option-text { min-width: 0; font-size: clamp(18px, 1.65vw, 23px); overflow-wrap: anywhere; }
.option input { position: absolute; opacity: 0; pointer-events: none; }

.answer-input {
  width: min(420px, 100%);
  padding: 16px 18px;
  border: 2px solid var(--line);
  border-radius: 14px;
  color: var(--ink);
  background: #fff;
  font-size: 22px;
  outline: 0;
}
.answer-input:focus { border-color: var(--blue); box-shadow: 0 0 0 4px rgba(48,86,211,.1); }

.button {
  min-height: 48px;
  padding: 11px 19px;
  border: 0;
  border-radius: 13px;
  font-weight: 850;
  cursor: pointer;
}
.button:disabled { opacity: .45; cursor: not-allowed; }
.button-primary { color: #fff; background: linear-gradient(135deg, var(--blue), var(--blue-dark)); box-shadow: 0 8px 18px rgba(48,86,211,.22); }
.button-secondary { color: var(--blue-dark); background: var(--blue-soft); }
.button-ghost { border: 1px solid var(--line); color: var(--muted); background: #fff; }
.question-actions { margin-top: 20px; }
.pager { display: flex; justify-content: space-between; gap: 14px; margin-top: 28px; padding-top: 22px; border-top: 1px solid var(--line); }

.feedback { max-width: 1120px; margin-top: 22px; padding: 20px 22px; border: 1px solid; border-radius: 17px; }
.feedback.correct { border-color: #9edabd; background: var(--green-soft); }
.feedback.almost { border-color: #f0c476; background: var(--amber-soft); }
.feedback.incorrect { border-color: #f0b4bd; background: var(--red-soft); }
.feedback h3 { margin: 0 0 7px; font-size: 23px; }
.feedback p { margin: 8px 0 0; font-size: 18px; }
.feedback-label { color: var(--muted); font-weight: 850; }

.math {
  display: inline-block;
  margin: 0 .04em;
  font-family: "Cambria Math", Cambria, "STIX Two Math", "Times New Roman", serif;
  font-size: 1.08em;
  font-style: normal;
  font-weight: 500;
  letter-spacing: 0;
  white-space: normal;
  overflow-wrap: anywhere;
}
.math sub, .math sup { font-size: .68em; line-height: 0; }

.results-panel { grid-column: 1 / -1; padding: clamp(28px, 5vw, 64px); }
.results-hero { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 30px; align-items: center; }
.results-kicker { color: var(--blue); font-weight: 900; }
.results-hero h2 { margin: 7px 0 8px; font-size: clamp(31px, 4vw, 50px); line-height: 1.1; }
.results-hero p { max-width: 800px; margin: 0; color: var(--muted); font-size: 19px; }
.result-ring {
  display: grid;
  place-items: center;
  width: 155px;
  height: 155px;
  border-radius: 50%;
  color: var(--blue-dark);
  background: radial-gradient(circle at center, #fff 59%, transparent 60%), conic-gradient(var(--blue) var(--angle), #e5e9f3 0);
  font-size: 31px;
  font-weight: 900;
}
.summary-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin: 32px 0; }
.summary-card { padding: 21px; border-radius: 17px; background: #f7f8fc; }
.summary-card span { display: block; color: var(--muted); font-size: 14px; font-weight: 800; }
.summary-card strong { display: block; margin-top: 5px; font-size: 24px; }
.seminar-results { display: grid; gap: 12px; }
.seminar-result { display: grid; grid-template-columns: minmax(210px, 1fr) 2fr auto; gap: 15px; align-items: center; }
.seminar-name { font-weight: 750; }
.seminar-bar { height: 11px; overflow: hidden; border-radius: 99px; background: #e2e6ef; }
.seminar-bar span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--blue), var(--violet)); }
.seminar-score { min-width: 58px; text-align: right; font-weight: 850; }
.results-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 30px; }

@media (max-width: 900px) {
  .app-shell { padding: 18px; }
  .topbar { align-items: flex-start; }
  .top-actions { flex-direction: column; align-items: stretch; }
  .main-layout { grid-template-columns: 1fr; }
  .sidebar { position: static; }
  .question-grid { grid-template-columns: repeat(10, 1fr); }
  .offline-note { display: none; }
  .question-panel { min-height: auto; }
  .results-panel { grid-column: auto; }
  .summary-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 620px) {
  body { font-size: 17px; }
  .app-shell { padding: 12px; }
  .topbar { display: grid; }
  .top-actions { flex-direction: row; justify-content: space-between; }
  .brand-mark { width: 54px; height: 54px; flex-basis: 54px; }
  .section-tab { gap: 6px; padding: 8px; font-size: 16px; }
  .tab-icon { display: none; }
  .main-layout { gap: 12px; }
  .sidebar { padding: 14px; }
  .question-grid { grid-template-columns: repeat(9, 1fr); gap: 5px; }
  .question-jump { border-radius: 7px; font-size: 11px; }
  .question-panel { padding: 22px 18px; }
  .question-prompt { font-size: 21px; }
  .option { grid-template-columns: 27px minmax(0, 1fr); padding: 14px; }
  .summary-grid { grid-template-columns: 1fr 1fr; }
  .results-hero { grid-template-columns: 1fr; }
  .result-ring { width: 130px; height: 130px; }
  .seminar-result { grid-template-columns: 1fr auto; }
  .seminar-bar { grid-column: 1 / -1; grid-row: 2; }
  .graph-gallery { grid-template-columns: 1fr; }
  .graph-figure, .matrix-figure { padding: 9px; }
  .weight-matrix th, .weight-matrix td { min-width: 52px; padding: 7px 9px; }
}

@media print {
  body { background: #fff; }
  .top-actions, .section-tabs, .sidebar, .question-actions, .pager, .results-actions { display: none !important; }
  .main-layout { display: block; }
  .question-panel, .results-panel { border: 0; box-shadow: none; }
}
