:root {
  --ink: #211b3c;
  --muted: #7b7398;
  --line: #e8e3f4;
  --purple-900: #3a2da3;
  --purple-700: #5340c3;
  --purple-500: #6b52da;
  --violet-50: #f4f1ff;
  --yellow: #f5c542;
  --yellow-deep: #eab326;
  --green: #2c9a5b;
  --green-bg: #eaf8f0;
  --red: #cf4444;
  --red-bg: #fdf0f0;
  --bg: #f7f5fc;
  --card: #ffffff;
  --shadow: 0 12px 32px rgba(65, 48, 145, 0.08);
  --radius: 20px;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: #eae6f7;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: default;
}

button:focus-visible,
input:focus-visible,
summary:focus-visible {
  outline: 3px solid rgba(97, 74, 212, 0.32);
  outline-offset: 2px;
}

.app {
  width: 100%;
  max-width: 760px;
  min-height: 100vh;
  margin: 0 auto;
  background: var(--bg);
  position: relative;
  overflow-x: hidden;
}

.screen {
  min-height: 100vh;
}

@media (min-width: 860px) {
  body {
    background:
      radial-gradient(circle at 12% 8%, rgba(119, 91, 220, 0.2), transparent 32%),
      radial-gradient(circle at 88% 12%, rgba(245, 197, 66, 0.13), transparent 30%),
      #ece8f8;
    padding: 24px 0;
  }

  .app {
    min-height: calc(100vh - 48px);
    border-radius: 30px;
    overflow: hidden;
    box-shadow: 0 28px 70px rgba(55, 39, 130, 0.2);
  }

  .screen {
    min-height: calc(100vh - 48px);
  }
}

/* ---------- home ---------- */

.hero {
  position: relative;
  overflow: hidden;
  padding: 30px 22px 28px;
  color: #fff;
  background: linear-gradient(155deg, #4033ae 0%, #5340c5 52%, #7057dc 100%);
}

.hero::after {
  content: "";
  position: absolute;
  width: 240px;
  height: 240px;
  right: -100px;
  top: -130px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
}

.hero::before {
  content: "";
  position: absolute;
  width: 130px;
  height: 130px;
  left: -55px;
  bottom: -80px;
  border-radius: 50%;
  background: rgba(255, 214, 94, 0.12);
}

.hero-kicker {
  position: relative;
  z-index: 1;
  font-size: 11px;
  letter-spacing: 0.18em;
  opacity: 0.68;
}

.hero h1 {
  position: relative;
  z-index: 1;
  margin: 9px 0 8px;
  font-size: 27px;
  line-height: 1.28;
  letter-spacing: 0.02em;
  font-weight: 750;
}

.hero-sub {
  position: relative;
  z-index: 1;
  margin: 0;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.74);
}

.hero-sub strong {
  color: #ffe18a;
  font-weight: 650;
}

.home-main {
  display: grid;
  gap: 14px;
  padding: 18px 16px max(36px, env(safe-area-inset-bottom));
}

.bank-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.bank-tile {
  min-height: 76px;
  padding: 13px 13px 12px;
  text-align: left;
  color: #4d4183;
  background: #ebe6fa;
  border: 1.5px solid transparent;
  border-radius: 16px;
  transition: background 0.18s ease, border-color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}

.bank-tile:active {
  transform: scale(0.985);
}

.bank-tile.active {
  color: #372b86;
  background: #fff;
  border-color: #6650d5;
  box-shadow: 0 9px 20px rgba(82, 61, 180, 0.14);
}

.bank-title {
  display: block;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.35;
}

.bank-sub {
  display: block;
  margin-top: 5px;
  font-size: 11px;
  line-height: 1.45;
  color: #7a70a4;
}

.bank-tile.active .bank-sub {
  color: #6a5cb1;
}

.selected-bank {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px;
  background: var(--card);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.selected-bank h2 {
  margin: 0;
  font-size: 19px;
  line-height: 1.3;
}

.selected-bank p {
  margin: 5px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.type-summary {
  max-width: 48%;
  padding: 7px 10px;
  color: #5a48b0;
  background: var(--violet-50);
  border-radius: 12px;
  font-size: 10.5px;
  line-height: 1.55;
  text-align: right;
}

.mode-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.mode-tab {
  padding: 12px 6px;
  color: #5e5487;
  background: #f0ecfb;
  border: 1px solid #e0daf2;
  border-radius: 14px;
  font-size: 14px;
  font-weight: 650;
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}

.mode-tab.active {
  color: #3d2f00;
  background: var(--yellow);
  border-color: var(--yellow);
  box-shadow: 0 7px 16px rgba(210, 160, 16, 0.24);
}

.mode-hint {
  margin: -4px 2px 0;
  font-size: 11.5px;
  line-height: 1.6;
  color: #857ca0;
}

.tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pill {
  padding: 8px 13px;
  color: #5e5487;
  background: #fff;
  border: 1px solid #e0daf2;
  border-radius: 999px;
  font-size: 12px;
  line-height: 1.4;
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}

.pill.active {
  color: #fff;
  background: var(--purple-700);
  border-color: var(--purple-700);
}

.pill-quiet {
  color: #857ca0;
}

.progress-card {
  padding: 14px 16px;
  background: var(--card);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.progress-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 9px;
  font-size: 12px;
  color: var(--muted);
}

.progress-track {
  height: 8px;
  overflow: hidden;
  background: #eeeaf9;
  border-radius: 999px;
}

.progress-track span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #f6ca4a, #efb621);
  border-radius: inherit;
  transition: width 0.25s ease;
}

.progress-card p {
  margin: 9px 0 0;
  font-size: 11px;
  color: #8d84a8;
}

.start-btn {
  width: 100%;
  padding: 15px;
  color: #fff;
  background: linear-gradient(135deg, #4b39bd, #6a50df);
  border: 0;
  border-radius: 16px;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.02em;
  box-shadow: 0 12px 24px rgba(76, 55, 190, 0.3);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.start-btn:active {
  transform: translateY(1px);
  box-shadow: 0 7px 16px rgba(76, 55, 190, 0.28);
}

.link-btn {
  justify-self: center;
  padding: 2px 6px;
  color: #6f61a7;
  background: none;
  border: 0;
  font-size: 12px;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.footnote {
  margin: 6px 2px 0;
  font-size: 10.5px;
  line-height: 1.75;
  text-align: center;
  color: #9a92b0;
}

/* ---------- quiz ---------- */

.quiz-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 17px 16px 14px;
  color: #fff;
  background: linear-gradient(150deg, #4033ae 0%, #5742c8 60%, #6b53da 100%);
}

.icon-btn {
  flex: 0 0 38px;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  padding: 0 0 3px;
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  font-size: 27px;
  line-height: 1;
}

.quiz-title {
  flex: 1;
  min-width: 0;
}

.quiz-title h1 {
  margin: 0;
  overflow: hidden;
  font-size: 17px;
  font-weight: 700;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.quiz-title p {
  margin: 3px 0 0;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.68);
}

.ghost-btn {
  padding: 8px 13px;
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.38);
  border-radius: 999px;
  font-size: 12px;
  white-space: nowrap;
}

.quiz-progress {
  height: 5px;
  background: #e3ddf4;
}

.quiz-progress span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #f6ca4a, #efb621);
  transition: width 0.25s ease;
}

.quiz-main {
  padding: 16px 14px max(32px, env(safe-area-inset-bottom));
}

.question-card {
  padding: 18px 16px;
  background: var(--card);
  border-radius: 22px;
  box-shadow: var(--shadow);
}

.q-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
}

.tag {
  padding: 4px 9px;
  color: #6558a6;
  background: #f0edfa;
  border-radius: 999px;
  font-size: 10.5px;
  line-height: 1.4;
}

.tag.type {
  color: #523ec2;
  background: #e9e2ff;
  font-weight: 650;
}

.q-index {
  margin-left: auto;
  color: #9991af;
  font-size: 11px;
}

.stem {
  margin: 15px 0 16px;
  font-size: 17px;
  font-weight: 650;
  line-height: 1.65;
  white-space: pre-line;
  word-break: break-word;
}

.options {
  display: grid;
  gap: 10px;
}

.option {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  padding: 12px 13px;
  color: #2e2749;
  text-align: left;
  background: #fff;
  border: 1.5px solid #e6e1f1;
  border-radius: 15px;
  font-size: 15px;
  line-height: 1.55;
  transition: border-color 0.16s ease, background 0.16s ease;
}

.option:not(:disabled):active {
  background: #f8f5ff;
}

.option .key {
  flex: 0 0 30px;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  color: #746b93;
  background: #f1eff7;
  border-radius: 50%;
  font-size: 13px;
  font-weight: 700;
}

.option .text {
  flex: 1;
  min-width: 0;
  padding-top: 4px;
  word-break: break-word;
}

.option.selected {
  background: #f2eeff;
  border-color: #5e48cf;
}

.option.selected .key {
  color: #fff;
  background: #5e48cf;
}

.option.correct {
  background: var(--green-bg);
  border-color: #35a767;
}

.option.correct .key {
  color: #fff;
  background: var(--green);
}

.option.wrong {
  background: var(--red-bg);
  border-color: #d95a5a;
}

.option.wrong .key {
  color: #fff;
  background: var(--red);
}

.option:disabled {
  opacity: 1;
}

.judge-options {
  grid-template-columns: 1fr 1fr;
}

.judge-option .key {
  font-size: 16px;
}

.fill-box {
  display: grid;
  gap: 10px;
}

.fill-input {
  width: 100%;
  padding: 13px 14px;
  color: var(--ink);
  background: #fbfaff;
  border: 1.5px solid #ded8ef;
  border-radius: 14px;
  font-size: 15px;
  outline: none;
}

.fill-input::placeholder {
  color: #aaa2c0;
}

.fill-input:focus {
  background: #fff;
  border-color: #5e48cf;
  box-shadow: 0 0 0 3px rgba(94, 72, 207, 0.12);
}

.input-hint {
  margin: 0;
  color: #938bab;
  font-size: 11px;
}

.answer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-top: 14px;
}

.self-actions {
  justify-content: flex-start;
}

.btn {
  padding: 11px 16px;
  color: #5c5285;
  background: #fff;
  border: 1px solid #ded8ef;
  border-radius: 13px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
  transition: background 0.16s ease, border-color 0.16s ease;
}

.btn:not(:disabled):active {
  background: #f6f3fe;
}

.btn.primary {
  color: #fff;
  background: #5540c8;
  border-color: #5540c8;
}

.btn.primary:not(:disabled):active {
  background: #4633b0;
}

.btn.ghost {
  color: #71669a;
  background: transparent;
}

.btn:disabled {
  opacity: 0.45;
}

.answer-box {
  margin-top: 14px;
  padding: 13px 14px;
  background: #f4f1ff;
  border: 1px solid #e3dcff;
  border-radius: 14px;
}

.answer-box h3 {
  margin: 0 0 7px;
  color: #6c5bb5;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.06em;
}

.answer-text {
  color: #312a54;
  font-size: 14px;
  line-height: 1.8;
  white-space: pre-line;
  word-break: break-word;
}

.explanation {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed #e6dff4;
}

.explanation h4 {
  margin: 0 0 6px;
  color: #7a70a0;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.06em;
}

.explanation p {
  margin: 0;
  color: #5c5478;
  font-size: 13px;
  line-height: 1.8;
  white-space: pre-line;
  word-break: break-word;
}

.feedback {
  margin-top: 14px;
  padding: 13px 14px;
  border: 1px solid;
  border-radius: 14px;
}

.feedback.correct {
  background: var(--green-bg);
  border-color: #c4ebd3;
}

.feedback.wrong {
  background: var(--red-bg);
  border-color: #f2d2d2;
}

.feedback h3 {
  margin: 0 0 5px;
  font-size: 14px;
  font-weight: 700;
}

.feedback.correct h3 {
  color: #23834f;
}

.feedback.wrong h3 {
  color: #b73636;
}

.feedback p {
  margin: 5px 0 0;
  color: #4f476b;
  font-size: 13px;
  line-height: 1.75;
  white-space: pre-line;
  word-break: break-word;
}

.feedback .explain {
  color: #675e82;
}

.subjective-hint {
  margin-top: 4px;
  padding: 12px 14px;
  color: #7a7198;
  background: #f8f6fe;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.65;
}

.quiz-nav {
  display: grid;
  grid-template-columns: 1fr 1.45fr;
  gap: 10px;
  margin-top: 16px;
}

.quiz-nav .btn {
  padding: 14px;
  border-radius: 15px;
  font-size: 15px;
}

.quiz-nav .primary {
  background: linear-gradient(135deg, #4b39bd, #6a50df);
  border: 0;
  box-shadow: 0 9px 18px rgba(76, 55, 190, 0.22);
}

.quiz-footnote {
  margin: 12px 0 0;
  color: #9a92b0;
  font-size: 10.5px;
  text-align: center;
}

/* ---------- results ---------- */

.result-main {
  display: grid;
  gap: 14px;
  padding: 16px 14px max(36px, env(safe-area-inset-bottom));
}

.score-card,
.summary-card {
  padding: 24px 18px;
  text-align: center;
  background: var(--card);
  border-radius: 22px;
  box-shadow: var(--shadow);
}

.score-ring {
  position: relative;
  width: 124px;
  height: 124px;
  display: grid;
  place-items: center;
  margin: 0 auto 12px;
  background: conic-gradient(#f2c23e calc(var(--score) * 1%), #f0ecfa 0);
  border-radius: 50%;
}

.score-ring::before {
  content: "";
  position: absolute;
  inset: 9px;
  background: #fff;
  border-radius: 50%;
}

.score-ring strong {
  position: relative;
  margin-top: 4px;
  font-size: 38px;
  line-height: 1;
}

.score-ring span {
  position: absolute;
  z-index: 1;
  margin-top: 52px;
  color: #8d84a8;
  font-size: 11px;
}

.score-card h2 {
  margin: 0 0 7px;
  font-size: 17px;
}

.score-card p,
.summary-card p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.65;
}

.summary-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

.summary-stats div {
  padding: 13px 8px;
  background: #f6f3ff;
  border-radius: 14px;
}

.summary-stats strong {
  display: block;
  color: #4e3abc;
  font-size: 23px;
  line-height: 1.2;
}

.summary-stats span {
  display: block;
  margin-top: 3px;
  color: #857ca0;
  font-size: 11px;
}

.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

.result-actions .btn {
  flex: 1 1 130px;
  padding: 13px 14px;
  text-align: center;
}

.result-actions .primary {
  background: linear-gradient(135deg, #4b39bd, #6a50df);
  border: 0;
}

.review-section {
  display: grid;
  gap: 10px;
}

.review-section h2 {
  margin: 4px 2px 0;
  font-size: 15px;
}

.review-list {
  display: grid;
  gap: 9px;
}

.review-item {
  padding: 13px 14px;
  background: #fff;
  border: 1px solid #eee9f7;
  border-radius: 14px;
}

.review-item summary {
  cursor: pointer;
  color: #3a3256;
  font-size: 13px;
  line-height: 1.6;
  word-break: break-word;
}

.review-body {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed #e8e2f4;
}

.review-body p {
  margin: 5px 0 0;
  color: #655d7f;
  font-size: 12px;
  line-height: 1.7;
  white-space: pre-line;
  word-break: break-word;
}

.review-more {
  margin: 2px;
  color: #938bab;
  font-size: 11px;
  text-align: center;
}

.all-right {
  margin: 18px 0;
  color: #2c9a5b;
  font-size: 14px;
  text-align: center;
}

/* ---------- misc ---------- */

.loading,
.error-screen {
  padding: 48px 22px;
  text-align: center;
  color: #6b6385;
}

.error-screen h1 {
  margin: 0 0 12px;
  font-size: 22px;
}

.error-screen p {
  font-size: 13px;
  line-height: 1.7;
}

.error-screen pre {
  overflow: auto;
  padding: 12px;
  color: #8b3a3a;
  background: #fdf0f0;
  border-radius: 10px;
  font-size: 11px;
  text-align: left;
}

.error-screen code {
  padding: 2px 5px;
  background: #eeeaf9;
  border-radius: 5px;
  font-size: 11px;
}

.error-tip {
  color: #8d84a8;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 50;
  max-width: 82vw;
  padding: 10px 17px;
  color: #fff;
  background: rgba(35, 28, 60, 0.93);
  border-radius: 999px;
  font-size: 13px;
  line-height: 1.5;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) translateY(12px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 380px) {
  .hero h1 {
    font-size: 24px;
  }

  .home-main,
  .quiz-main,
  .result-main {
    padding-left: 12px;
    padding-right: 12px;
  }

  .stem {
    font-size: 16px;
  }

  .option {
    font-size: 14px;
  }

  .selected-bank {
    align-items: flex-start;
    flex-direction: column;
  }

  .type-summary {
    max-width: none;
    text-align: left;
  }
}
