:root {
  --ink: #253041;
  --muted: #687386;
  --paper: #fff7de;
  --card: #fffefa;
  --line: #eadfbf;
  --teal: #2aa7a1;
  --teal-dark: #11736e;
  --orange: #ff7a45;
  --yellow: #ffd766;
  --green: #3abf7a;
  --red: #e25555;
  --blue: #5ba7ff;
  --pink: #ff8fb3;
  --purple: #8c7bff;
  --shadow: rgba(91, 80, 45, .12);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 12%, rgba(255, 215, 102, .28) 0 68px, transparent 69px),
    radial-gradient(circle at 92% 10%, rgba(91, 167, 255, .18) 0 72px, transparent 73px),
    radial-gradient(circle at 85% 72%, rgba(255, 143, 179, .2) 0 90px, transparent 91px),
    linear-gradient(180deg, #eaf8ff 0, #fff7de 280px, #fffaf0 100%);
}
body.modal-open { overflow: hidden; }
body.locked { min-height: 100vh; overflow: hidden; }
body.locked header, body.locked main, body.locked footer { filter: blur(4px); pointer-events: none; user-select: none; }
button, input, textarea { font: inherit; }
button { cursor: pointer; border-radius: 14px; transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease, background .12s ease; }
button:hover:not(:disabled) { transform: translateY(-1px); }
.auth-screen { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 18px; background: linear-gradient(135deg, rgba(42,167,161,.96), rgba(91,167,255,.88)); }
body:not(.locked) .auth-screen { display: none; }
.auth-card { width: min(380px, 100%); background: var(--card); border: 2px solid rgba(255,255,255,.75); box-shadow: 0 24px 70px rgba(0,0,0,.22); padding: 24px; border-radius: 28px; }
.auth-kicker { margin: 0 0 6px; color: var(--teal); font-size: 12px; font-weight: 900; letter-spacing: .08em; }
.auth-card h2 { font-size: 24px; margin-bottom: 8px; }
.auth-note { margin: 0 0 16px; color: var(--muted); line-height: 1.6; }
.auth-card input { width: 100%; border: 2px solid var(--line); background: white; padding: 11px 12px; outline: 0; border-radius: 16px; }
.auth-card input:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(13,119,116,.12); }
.auth-submit { width: 100%; margin-top: 12px; }
.auth-error { min-height: 18px; margin: 10px 0 0; color: var(--red); font-size: 12px; font-weight: 800; }
.hero {
  color: white;
  padding: 10px max(18px, calc((100vw - 1440px)/2));
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(circle at 18% 20%, rgba(255,255,255,.24) 0 26px, transparent 27px),
    radial-gradient(circle at 72% 12%, rgba(255,215,102,.26) 0 34px, transparent 35px),
    linear-gradient(115deg, #1b8fcb 0%, #20aaa2 48%, #7c65e8 100%);
  border-bottom: 5px solid rgba(255,255,255,.38);
}
.hero::after { content: ""; position: absolute; inset: auto 0 -28px; height: 58px; background: radial-gradient(circle, rgba(255,255,255,.72) 0 16px, transparent 17px) 0 0/64px 38px; opacity: .75; pointer-events: none; }
.hero-bar { min-height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.brand { display: flex; align-items: center; min-width: 0; position: relative; z-index: 1; }
.brand::before { content: ""; width: 42px; height: 42px; margin-right: 12px; border-radius: 16px; background: linear-gradient(135deg, var(--yellow), var(--orange)); box-shadow: inset 0 -5px 0 rgba(255,255,255,.28), 0 8px 18px rgba(0,0,0,.12); transform: rotate(-8deg); flex: none; }
.eyebrow { color: var(--orange); letter-spacing: .14em; font-weight: 800; font-size: 10px; margin: 0 0 5px; }
h1 { font: 900 clamp(20px, 2vw, 29px)/1.1 "PingFang SC", "Microsoft YaHei", sans-serif; margin: 0; letter-spacing: -.03em; white-space: nowrap; text-shadow: 0 2px 0 rgba(0,0,0,.08); }
h1 em { color: var(--yellow); font-style: normal; }
.slogan { color: white; margin: 4px 0 0; font: 600 12px/1.35 Georgia, "Songti SC", serif; }
.intro { color: rgba(255,255,255,.82); line-height: 1.4; margin: 2px 0 0; font-size: 10px; }
.hero-actions { display: flex; align-items: center; justify-content: end; gap: 14px; position: relative; z-index: 1; }
.hero-range { min-width: 154px; }
.hero-range label { display: block; color: rgba(255,255,255,.78); font-size: 10px; font-weight: 800; margin-bottom: 5px; text-align: center; }
.hero-range .chips { justify-content: center; flex-wrap: nowrap; }
.hero-range .chip { border-color: rgba(255,255,255,.45); background: rgba(255,255,255,.18); color: white; padding: 4px 9px; }
.hero-range .chip.active { background: var(--yellow); border-color: var(--yellow); color: #6f4a00; }
.hero-stats { display: grid; grid-template-columns: repeat(3, auto); gap: 24px; margin: 0; justify-content: end; }
.stat { padding: 6px 9px; border-radius: 16px; background: rgba(255,255,255,.14); }
.stat strong { display: block; font-size: 19px; color: white; }.stat span { font-size: 10px; color: rgba(255,255,255,.78); white-space: nowrap; }
.reset-progress { border: 1px solid rgba(255,255,255,.52); background: rgba(255,255,255,.18); color: white; padding: 7px 10px; font-size: 12px; font-weight: 800; white-space: nowrap; }
.reset-progress:hover { background: rgba(255,255,255,.28); border-color: rgba(255,255,255,.8); }
main { max-width: 1440px; margin: 10px auto 0; padding: 0 18px 28px; position: relative; z-index: 2; }
.panel { background: rgba(255,254,250,.94); border: 2px solid rgba(255,255,255,.85); box-shadow: 0 14px 30px var(--shadow); border-radius: 24px; }
.controls { display: grid; grid-template-columns: 1.65fr .85fr 1.25fr; grid-template-areas: "level paper search" "type paper topic"; gap: 8px 12px; padding: 12px 14px; align-items: center; }
.level-control { grid-area: level; }
.type-control { grid-area: type; }
.paper-control { grid-area: paper; }
.topic-control-area { grid-area: topic; align-self: center; }
.search-control { grid-area: search; align-self: center; }
.control-group label, .search span, .paper-select span, .topic-control span { display: block; font-size: 10px; font-weight: 800; margin-bottom: 5px; color: var(--muted); }
.level-control, .type-control { display: flex; align-items: center; gap: 8px; }
.level-control label, .type-control label { margin: 0; min-width: 28px; color: var(--teal-dark); font-size: 12px; background: #e7fbf8; padding: 4px 7px; border-radius: 999px; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { border: 1px solid #e7d8a8; background: white; padding: 4px 8px; border-radius: 999px; color: var(--muted); font-size: 12px; box-shadow: inset 0 -2px 0 rgba(255,215,102,.18); }
.chip.active { background: linear-gradient(135deg, var(--teal), #56c7bb); border-color: var(--teal); color: white; box-shadow: 0 4px 10px rgba(42,167,161,.2); }
.search input { width: 100%; border: 0; border-bottom: 2px solid var(--line); background: rgba(255,255,255,.72); padding: 6px 8px; outline: 0; font-size: 12px; border-radius: 12px 12px 6px 6px; }
.search input:focus { border-color: var(--teal); }
.paper-select select { width: 100%; border: 0; border-bottom: 2px solid var(--line); background: rgba(255,255,255,.72); padding: 6px 8px; outline: 0; color: var(--ink); font-size: 12px; border-radius: 12px 12px 6px 6px; }
.topic-picker { width: 100%; border: 1px solid #75cdc6; background: linear-gradient(135deg, #effffc, #fff7d7); color: var(--teal-dark); padding: 7px 10px; font-size: 12px; font-weight: 900; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; box-shadow: inset 0 -3px 0 rgba(42,167,161,.12); }
.topic-picker b { float: right; color: var(--orange); margin-left: 6px; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 8px; margin-bottom: 9px; }
h2 { margin: 0; font: 700 19px/1.2 Georgia, "Songti SC", serif; }
.text-button { border: 0; background: none; color: var(--teal); font-weight: 700; }
.text-button:disabled { opacity: .4; cursor: not-allowed; }
.topic-modal[hidden] { display: none; }
.topic-modal { position: fixed; inset: 0; z-index: 30; padding: 18px; background: rgba(37,48,65,.62); display: grid; place-items: start center; overflow: auto; }
.topic-modal-panel { width: min(980px, 100%); margin-top: 26px; padding: 14px; max-height: calc(100vh - 52px); overflow: hidden; display: grid; grid-template-rows: auto 1fr; }
.topic-modal-head { display: flex; align-items: start; justify-content: space-between; gap: 14px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.topic-summary { color: var(--muted); font-size: 12px; margin: 4px 0 0; }
.topic-modal-actions { display: flex; align-items: center; gap: 8px; }
.topic-close { width: 30px; height: 30px; border: 1px solid var(--line); background: white; color: var(--ink); font-size: 24px; line-height: 1; border-radius: 50%; }
.topic-map { display: flex; gap: 6px; flex-wrap: wrap; max-height: calc(100vh - 165px); overflow: auto; padding: 12px 3px 2px 0; align-content: flex-start; }
.topic { border: 1px solid var(--line); background: white; padding: 6px 9px; color: var(--ink); font-size: 12px; border-radius: 999px; }
.topic b { color: var(--orange); margin-left: 5px; }.topic.active { border-color: var(--orange); background: #fff3e9; }
.workspace { display: grid; grid-template-columns: 245px 1fr; gap: 12px; margin-top: 12px; align-items: start; }
.sidebar { padding: 12px; position: sticky; top: 8px; max-height: calc(100vh - 16px); overflow: hidden; }
.question-list { overflow: auto; max-height: calc(100vh - 72px); display: grid; gap: 2px; padding-right: 3px; }
.question-link { border: 1px solid transparent; background: transparent; text-align: left; padding: 7px 8px; color: var(--muted); display: flex; gap: 7px; align-items: center; font-size: 11px; border-radius: 14px; }
.question-link:hover, .question-link.active { background: #eefcff; border-color: #bde9f0; color: var(--ink); }
.question-link.done .dot { background: var(--green); }.question-link.wrong .dot { background: var(--red); }
.dot { width: 7px; height: 7px; background: var(--yellow); border-radius: 50%; flex: none; box-shadow: 0 0 0 3px rgba(255,215,102,.18); }
.question-card { min-height: 520px; padding: 22px 28px; }
.meta { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 14px; }
.badge { padding: 4px 8px; background: #eafaff; color: #237498; font-weight: 800; font-size: 10px; border-radius: 999px; }
.badge.warn { background: #fff0dc; color: #98541d; }
.badge.muted { background: #eeeae1; color: var(--muted); }
.prompt { white-space: pre-wrap; font: 500 14px/1.65 "SFMono-Regular", Consolas, "PingFang SC", monospace; overflow-wrap: anywhere; }
.question-image { margin: 14px 0 2px; padding: 8px; border: 2px dashed #f0c85a; background: white; max-height: 420px; overflow: auto; border-radius: 18px; }
.question-image figcaption { margin-bottom: 10px; color: var(--muted); font-size: 12px; font-weight: 800; }
.question-image img { display: block; width: 100%; height: auto; }
.answer-area { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.options { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 6px; }
.option { border: 1px solid var(--line); background: white; padding: 8px 10px; text-align: left; box-shadow: inset 0 -3px 0 rgba(255,215,102,.14); }
.option.selected { border-color: var(--teal); background: #edf7f5; box-shadow: 0 5px 12px rgba(42,167,161,.16); }
.option:disabled, textarea:disabled { cursor: default; opacity: .65; }
textarea { width: 100%; min-height: 100px; border: 1px solid var(--line); padding: 10px; resize: vertical; }
.primary { border: 0; background: linear-gradient(135deg, var(--orange), #ff9f43); color: white; font-weight: 800; padding: 8px 14px; margin-top: 10px; box-shadow: 0 7px 14px rgba(255,122,69,.22); }
.primary:disabled { opacity: .45; cursor: not-allowed; }
.secondary { border: 1px solid var(--teal); background: white; color: var(--teal); font-weight: 800; padding: 7px 11px; margin-top: 10px; }
.reveal { margin-top: 14px; border-left: 5px solid var(--teal); background: #effffc; padding: 12px 14px; border-radius: 16px; }
.reveal.wrong { border-color: var(--red); background: #fff0ed; }
.reveal h3 { margin: 0 0 6px; font-size: 15px; }.reveal p { white-space: pre-wrap; line-height: 1.6; margin-bottom: 0; }
.question-nav { display: grid; grid-template-columns: 132px 1fr 132px; gap: 10px; align-items: center; margin-top: 18px; padding-top: 12px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; font-weight: 700; }
.question-nav span { justify-self: center; }
.nav-button { width: 132px; min-height: 34px; border: 1px solid var(--line); background: white; color: var(--ink); padding: 7px 11px; font-weight: 800; text-align: center; }
.nav-button:first-child { justify-self: start; }
.nav-button:last-child { justify-self: end; }
.nav-button:hover:not(:disabled) { border-color: var(--teal); color: var(--teal); }
.nav-button:disabled { opacity: .35; cursor: not-allowed; }
.source { display: inline-block; color: var(--teal); margin-top: 9px; font-weight: 700; font-size: 12px; }
.image-button { border: 0; background: transparent; padding: 0; }
.image-modal { position: fixed; inset: 0; z-index: 20; padding: 24px; background: rgba(9,25,25,.82); display: grid; place-items: center; }
.image-modal-panel { width: min(1100px, 100%); max-height: calc(100vh - 48px); overflow: auto; background: white; box-shadow: 0 24px 70px rgba(0,0,0,.35); }
.image-modal-head { position: sticky; top: 0; z-index: 1; display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; background: var(--teal-dark); color: white; }
.image-modal-head button { border: 0; background: transparent; color: white; font-size: 28px; line-height: 1; }
.image-modal img { display: block; width: 100%; height: auto; }
.empty { color: var(--muted); padding: 60px 0; text-align: center; }
footer { padding: 14px; text-align: center; color: var(--muted); font-size: 10px; }
@media (max-width: 1100px) {
  .hero-bar { align-items: flex-start; flex-direction: column; gap: 8px; }
  .hero-actions { justify-content: start; }
  .hero-stats { justify-content: start; }
  .controls { grid-template-columns: 1fr 1fr; grid-template-areas: "level level" "type type" "paper search" "paper topic"; }
}
@media (max-width: 850px) {
  .brand { align-items: flex-start; }
  h1 { white-space: normal; }
  .hero-actions { width: 100%; align-items: stretch; justify-content: space-between; gap: 8px; }
  .hero-range { min-width: 128px; }
  .hero-stats { flex: 1; grid-template-columns: repeat(3, 1fr); gap: 7px; }
  .controls, .workspace { grid-template-columns: 1fr; }
  .topic-modal { padding: 10px; }
  .topic-modal-panel { margin-top: 10px; max-height: calc(100vh - 20px); }
  .topic-map { max-height: calc(100vh - 155px); }
  .sidebar { position: static; max-height: 280px; }
  .question-list { max-height: 190px; grid-template-columns: repeat(2,1fr); }
  .options { grid-template-columns: 1fr; }
  .question-nav { grid-template-columns: 1fr 1fr; }
  .question-nav span { display: none; }
  .nav-button { width: 100%; }
  .question-card { padding: 18px; }
}
