/* 禁用双击缩放 */
html, body {
  touch-action: manipulation;
}

:root {
  color-scheme: dark;
  --bg: #151515;
  --panel: #1c1c1e;
  --panel-2: #22262d;
  --line: #2b2b2d;
  --text: #b9b9bd;
  --strong: #e6e6e8;
  --muted: #7b7b82;
  --blue: #3d7cff;
  --blue-soft: #23344d;
  --green: #135d3d;
  --green-bright: #1c8f5a;
  --red: #722829;
  --red-bright: #aa3b3b;
}

* {
  box-sizing: border-box;
}

html,
body {
  overflow-x: hidden;
  min-height: 100%;
  margin: 0;
  background: #0f0f10;
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
}

button {
  border: 0;
  color: inherit;
  font: inherit;
  background: transparent;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.hidden {
  display: none !important;
}

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

.view {
  min-height: 100vh;
  overflow-x: hidden;
}

.home-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: calc(18px + env(safe-area-inset-top)) 20px 14px;
  background: #101011;
  border-bottom: 1px solid #171719;
}

.app-title {
  color: var(--strong);
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 0;
}

.app-subtitle {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

.ghost-btn {
  width: 44px;
  height: 44px;
  color: #9b9ba1;
  font-size: 30px;
}

.grade-tabs {
  display: grid;
  grid-template-columns: repeat(5, max-content);
  gap: 24px;
  width: 100%;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  padding: 12px 18px 8px;
  border-bottom: 1px solid #242426;
  background: #181819;
  scrollbar-width: none;
}

.grade-tabs::-webkit-scrollbar {
  display: none;
}

.grade-tabs button {
  position: relative;
  min-width: 48px;
  height: 44px;
  color: #74747a;
  font-size: 21px;
  font-weight: 700;
  white-space: nowrap;
}

.grade-tabs button span {
  position: absolute;
  top: -6px;
  left: 50%;
  transform: translateX(-50%);
  padding: 1px 6px;
  border-radius: 8px;
  background: #ff6b22;
  color: #fff;
  font-size: 10px;
}

.grade-tabs .active {
  color: var(--strong);
}

.grade-tabs .active::after {
  content: "";
  position: absolute;
  right: 16px;
  bottom: -6px;
  left: 16px;
  height: 5px;
  border-radius: 999px;
  background: #1d4b93;
}

.type-tabs {
  display: flex;
  gap: 14px;
  padding: 18px 18px 14px;
}

.type-tabs button {
  padding: 8px 13px;
  border-radius: 12px;
  background: #101011;
  color: #a8a8ad;
  font-size: 18px;
  font-weight: 700;
}

.type-tabs .active {
  color: #347bff;
}

.subject-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 18px 18px 20px;
  border-bottom: 1px solid #2a2a2d;
}

.subject-row {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.chevron {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #244d86;
  color: #8cbcff;
}

.subject-name {
  color: #c9c9ce;
  font-size: 23px;
  font-weight: 700;
}

.subject-meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.subject-progress,
.chapter-stat {
  display: grid;
  gap: 8px;
  justify-items: end;
  flex: 0 0 96px;
  color: #a0a0a6;
  font-size: 14px;
  font-weight: 700;
}

.bar,
.mini-bar {
  position: relative;
  width: 88px;
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: #303033;
}

.bar i,
.mini-bar i,
.mini-bar b {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  background: var(--green-bright);
}

.mini-bar b {
  left: auto;
  right: 0;
  background: var(--red-bright);
}

.chapter-list {
  padding-bottom: calc(86px + env(safe-area-inset-bottom));
}

.chapter-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 96px;
  gap: 12px;
  align-items: center;
  width: 100%;
  min-height: 74px;
  padding: 0 14px 0 54px;
  border-bottom: 1px solid #29292c;
  text-align: left;
  background: #1b1b1d;
}

.chapter-title {
  min-width: 0;
  overflow: hidden;
  color: #a9a9af;
  font-size: 19px;
  line-height: 1.35;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.bottom-tabs {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  border-top: 1px solid #252528;
  background: rgba(20, 20, 21, 0.96);
}

.bottom-tabs button {
  display: grid;
  gap: 3px;
  place-items: center;
  color: #7e7e84;
  font-size: 22px;
}

.bottom-tabs span {
  font-size: 12px;
}

.bottom-tabs .active {
  color: #3684ff;
}

.nav-header,
.quiz-top {
  display: grid;
  grid-template-columns: 48px 1fr 70px;
  align-items: center;
  min-height: calc(68px + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 16px 0;
  background: #171719;
}

.back-btn {
  color: #a9a9af;
  font-size: 42px;
  line-height: 1;
}

.nav-title,
.quiz-title {
  color: #c8c8cd;
  text-align: center;
  font-size: 24px;
  font-weight: 800;
}

.nav-subtitle,
.quiz-chapter {
  padding: 0 18px 18px;
  color: #8b8b92;
  text-align: center;
  font-size: 17px;
  background: #171719;
}

.pill-btn {
  height: 34px;
  border: 1px solid #26395e;
  border-radius: 999px;
  color: #477bdc;
}

.redo-wrap {
  position: relative;
}

.redo-menu {
  position: absolute;
  top: 42px;
  right: 0;
  z-index: 5;
  display: grid;
  min-width: 116px;
  overflow: hidden;
  border: 1px solid #303044;
  border-radius: 10px;
  background: #202126;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.35);
}

.redo-menu button {
  height: 42px;
  padding: 0 14px;
  color: #c9c9d0;
  font-size: 14px;
  text-align: left;
}

.redo-menu button + button {
  border-top: 1px solid #303044;
}

.mode-panel {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  margin: 18px 18px 14px;
  overflow: hidden;
  border-radius: 16px;
  background: #171719;
}

.mode-main,
.mode-side {
  min-height: 64px;
  font-size: 18px;
  font-weight: 800;
}

.mode-main {
  background: #222b35;
  color: #dedee2;
}

.mode-side {
  color: #b9b9be;
  text-align: left;
  padding-left: 18px;
  line-height: 1.35;
}

.card-filters {
  display: grid;
  grid-template-columns: repeat(2, minmax(92px, 1fr));
  gap: 10px;
  max-width: 260px;
  margin: 0 auto;
  padding: 8px 18px 18px;
  border-bottom: 1px solid #28282b;
}

.card-filters button {
  height: 38px;
  border-radius: 999px;
  background: #222225;
  color: #9d9da4;
  font-size: 16px;
  font-weight: 800;
}

.card-filters .active {
  background: #23406f;
  color: #f0f5ff;
}

.answer-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 22px 22px;
  padding: 24px 20px 90px;
}

.answer-dot {
  aspect-ratio: 1;
  border-radius: 50%;
  background: #333336;
  color: #1c1c1e;
  font-size: 20px;
}

.answer-dot.right {
  background: var(--green);
}

.answer-dot.bad {
  background: var(--red);
}

.empty-card {
  grid-column: 1 / -1;
  padding: 60px 0;
  color: #8d8d94;
  text-align: center;
  font-size: 18px;
}

.card-summary {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  max-width: 520px;
  margin: 0 auto;
  padding: 14px 18px calc(18px + env(safe-area-inset-bottom));
  background: rgba(21, 21, 22, 0.96);
  color: #aaaab0;
  text-align: center;
  font-size: 15px;
}

.card-summary span {
  color: #21a36b;
}

.quiz-top {
  grid-template-columns: 48px 1fr 170px;
  background: #2f4979;
}

.quiz-tools {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  color: #0e1420;
  font-size: 12px;
  text-align: center;
}

.quiz-chapter {
  background: #050505;
}

.question-panel {
  padding: 24px 20px 176px;
}

.question-head {
  display: flex;
  justify-content: space-between;
  margin-bottom: 34px;
  color: #a9a9af;
  font-size: 18px;
  font-weight: 800;
}

.question-head span:first-child {
  padding-left: 10px;
  border-left: 5px solid #2d64c8;
}

#questionStem {
  margin: 0 0 34px;
  color: #cfcfd4;
  font-size: 24px;
  font-weight: 500;
  line-height: 1.55;
}

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

.options.b-options {
  grid-template-columns: repeat(auto-fit, minmax(54px, 1fr));
  gap: 18px;
  margin-top: 28px;
}

.choice {
  display: grid;
  grid-template-columns: 42px 28px 1fr;
  align-items: center;
  width: 100%;
  min-height: 54px;
  color: #bdbdc2;
  text-align: left;
  font-size: 23px;
  line-height: 1.4;
}

.choice span {
  width: 30px;
  height: 30px;
  border: 1px solid #606067;
  border-radius: 50%;
}

.choice.picked span {
  border-color: #4d8cff;
  box-shadow: inset 0 0 0 8px #4d8cff;
}

.choice.correct span {
  border-color: var(--green-bright);
  background: var(--green-bright);
}

.choice.wrong span {
  border-color: var(--red-bright);
  background: var(--red-bright);
}

.b-choice {
  display: grid;
  grid-template-columns: 1fr;
  min-height: 58px;
  place-items: center;
}

.b-choice span {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border: 1px solid #606067;
  border-radius: 50%;
  color: #bdbdc2;
  font-size: 20px;
  font-weight: 800;
}

.b-choice.picked span {
  border-color: #4d8cff;
  box-shadow: inset 0 0 0 13px #4d8cff;
  color: #fff;
}

.b-choice.correct span {
  border-color: var(--green-bright);
  background: var(--green-bright);
  color: #111;
}

.b-choice.wrong span {
  border-color: var(--red-bright);
  background: var(--red-bright);
  color: #111;
}

.submit-btn {
  display: block;
  min-width: 156px;
  height: 58px;
  margin: 68px auto 0;
  border-radius: 8px;
  background: #2d2d2f;
  color: #9b9ba1;
  font-size: 20px;
  font-weight: 800;
}

.submit-btn:not(:disabled) {
  background: #335fa8;
  color: #fff;
}

.result,
.group-box {
  margin-top: 24px;
  padding: 16px;
  border-radius: 12px;
  background: #202023;
  color: #bdbdc2;
  line-height: 1.8;
}

.group-box {
  margin: 0 0 28px;
}

.shared-options {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  color: #a9a9af;
  font-size: 20px;
  line-height: 1.45;
}

.shared-options p {
  margin: 0;
}

.shared-options b {
  display: inline-block;
  min-width: 28px;
  color: #c8c8ce;
}

.result strong {
  color: #78b7ff;
}

.result p,
.group-box p {
  margin: 8px 0 0;
}

.group-tag {
  color: #78b7ff;
  font-weight: 800;
}

.answer-line {
  color: #3fce87;
}

.quiz-bottom {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  display: grid;
  grid-template-columns: 1fr 1.15fr 1fr;
  gap: 10px;
  max-width: 520px;
  margin: 0 auto;
  padding: 12px 14px calc(14px + env(safe-area-inset-bottom));
  border-top: 1px solid #27272a;
  background: rgba(19, 19, 20, 0.97);
}

.quiz-bottom button {
  display: block;
  height: 46px;
  border-radius: 8px;
  background: #252527;
  color: #b5b5bb;
  font-size: 16px;
  font-weight: 800;
}

.quiz-bottom button:disabled {
  opacity: 0.38;
  cursor: default;
}

.quiz-bottom .primary {
  background: #335fa8;
  color: #fff;
}

.review-mode-btn.active {
  background: #17613f;
  color: #fff;
}

.empty {
  padding: 32px 18px;
  color: #aaa;
}

@media (min-width: 700px) {
  body {
    background: #080809;
  }

  .app-shell,
  .bottom-tabs,
  .card-summary,
  .quiz-bottom {
    box-shadow: 0 0 0 1px #252528;
  }
}

@media (max-width: 390px) {
  .chapter-title {
    font-size: 17px;
  }

  .choice {
    font-size: 20px;
  }

  #questionStem {
    font-size: 22px;
  }

  .answer-grid {
    gap: 22px 20px;
  }
}
