:root {
  color-scheme: light;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-soft: #f7f9f8;
  --ink: #20252a;
  --muted: #7b838c;
  --line: #e4e7ea;
  --green: #22a06b;
  --green-dark: #168156;
  --green-soft: #eaf8f1;
  --red: #e05252;
  --red-soft: #fff0f0;
  --orange: #f39a32;
  --drawer: 268px;
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
}

* {
  box-sizing: border-box;
}

.icon-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.icon {
  width: 1.15em;
  height: 1.15em;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--bg);
}

button,
input,
select {
  font: inherit;
}

input,
select,
textarea {
  font-size: 16px;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.hidden {
  display: none !important;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
}

.primary,
.secondary,
.ghost,
.danger {
  min-height: 46px;
  border-radius: 8px;
  padding: 0 18px;
  font-weight: 800;
}

.icon-button,
.label-with-icon,
.heading-with-icon {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.primary {
  color: #fff;
  background: var(--green);
}

.primary:hover {
  background: var(--green-dark);
}

.secondary {
  color: var(--green-dark);
  border: 1px solid #bde3d0;
  background: var(--green-soft);
}

.ghost {
  color: var(--muted);
  border: 1px solid var(--line);
  background: #fff;
}

.danger {
  color: var(--red);
  border: 1px solid #f2c5c5;
  background: var(--red-soft);
}

.field {
  display: grid;
  gap: 8px;
  margin: 18px 0;
  color: #606871;
  font-size: 13px;
  font-weight: 700;
}

.field input {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  color: var(--ink);
  border: 1px solid #d8dde1;
  border-radius: 8px;
  background: #fff;
  outline: none;
}

.field input:focus,
.category-picker select:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(34, 160, 107, 0.12);
}

.gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 22px;
  background: #f4f8f6;
}

.gate-card {
  width: min(440px, 100%);
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 20px 60px rgba(32, 37, 42, 0.09);
}

.brand-seal {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  margin-bottom: 20px;
  border-radius: 8px;
  color: #fff;
  background: var(--green);
  font-family: "Songti SC", "Noto Serif CJK SC", serif;
  font-size: 27px;
  font-weight: 900;
}

.brand-seal.small {
  width: 38px;
  height: 38px;
  margin: 0;
  font-size: 20px;
}

.gate h1 {
  margin: 0 0 10px;
  font-family: "Songti SC", "Noto Serif CJK SC", serif;
  font-size: 30px;
}

.gate p {
  color: var(--muted);
  line-height: 1.65;
}

.gate-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.form-error,
.choice-error {
  min-height: 20px;
  color: var(--red) !important;
  font-size: 13px;
  font-weight: 700;
}

.app-shell {
  min-height: 100vh;
}

.app-drawer {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 30;
  width: var(--drawer);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 22px 16px;
  border-right: 1px solid var(--line);
  background: var(--surface);
}

.drawer-brand,
.profile-block {
  display: flex;
  align-items: center;
  gap: 11px;
}

.drawer-brand {
  padding: 0 7px 24px;
}

.drawer-brand strong,
.drawer-brand span,
.profile-block strong,
.profile-block span {
  display: block;
}

.drawer-brand strong {
  font-size: 17px;
}

.drawer-brand span,
.profile-block span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.drawer-close {
  display: none;
  width: 40px;
  height: 40px;
  place-items: center;
  margin-left: auto;
  color: var(--muted);
  background: transparent;
  font-size: 22px;
}

.profile-block {
  margin-bottom: 18px;
  padding: 13px;
  border-radius: 8px;
  background: var(--surface-soft);
}

.profile-avatar {
  display: grid;
  place-items: center;
  flex: 0 0 38px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  color: var(--green-dark);
  background: #dff3e9;
  font-weight: 900;
}

.drawer-nav {
  display: grid;
  gap: 5px;
}

.nav-section-label {
  margin: 12px 8px 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
}

.nav-section-label:first-child {
  margin-top: 0;
}

.nav-item {
  width: 100%;
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 10px;
  align-items: center;
  padding: 11px;
  border-radius: 8px;
  color: var(--ink);
  text-align: left;
  background: transparent;
}

.nav-item:hover {
  background: var(--surface-soft);
}

.nav-item.active {
  color: var(--green-dark);
  background: var(--green-soft);
}

.nav-item strong,
.nav-item small {
  display: block;
}

.nav-item strong {
  margin-bottom: 3px;
  font-size: 14px;
}

.nav-item small {
  color: var(--muted);
  font-size: 11px;
}

.nav-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  color: #69727b;
  background: #eef1f2;
  font-size: 17px;
  font-weight: 900;
}

.nav-item.active .nav-mark {
  color: #fff;
  background: var(--green);
}

.drawer-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: auto;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.drawer-summary div {
  padding: 10px;
  border-radius: 8px;
  background: var(--surface-soft);
}

.drawer-summary span,
.drawer-summary strong {
  display: block;
}

.drawer-summary span {
  color: var(--muted);
  font-size: 11px;
}

.drawer-summary span,
.stat-grid span {
  display: flex;
  align-items: center;
  gap: 5px;
}

.drawer-summary strong {
  margin-top: 3px;
  font-size: 18px;
}

.workspace {
  min-height: 100vh;
  margin-left: var(--drawer);
}

.mobile-header {
  height: 64px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
}

.mobile-header > div {
  flex: 1;
}

.mobile-header strong,
.mobile-header span {
  display: block;
}

.mobile-header > div > span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.menu-button {
  display: none;
  width: 40px;
  height: 40px;
  padding: 9px;
  border-radius: 8px;
  background: var(--surface-soft);
}

.menu-button .icon {
  width: 22px;
  height: 22px;
}

.streak-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 10px;
  border-radius: 999px;
  color: #a65f13;
  background: #fff3df;
  font-size: 12px;
  font-weight: 800;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

#view-practice {
  width: min(900px, calc(100% - 48px));
  margin: 0 auto;
  padding: 20px 0 118px;
}

.practice-toolbar {
  display: grid;
  grid-template-columns: 360px minmax(260px, 1fr);
  gap: 12px;
  margin-bottom: 10px;
}

.type-switch {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  padding: 4px;
  border-radius: 8px;
  background: #e9ecee;
}

.type-tab {
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 6px;
  color: #68717a;
  background: transparent;
  font-size: 14px;
  font-weight: 800;
}

.type-tab.active {
  color: var(--green-dark);
  background: #fff;
  box-shadow: 0 2px 7px rgba(32, 37, 42, 0.08);
}

.category-picker {
  position: relative;
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 48px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.category-picker span {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.category-picker select {
  min-width: 0;
  flex: 1;
  border: 0;
  color: var(--ink);
  background: transparent;
  font-weight: 700;
  outline: none;
}

.practice-context {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 3px 14px;
  color: var(--muted);
  font-size: 12px;
}

.practice-context span:first-child {
  color: var(--green-dark);
  font-weight: 800;
}

.practice-context span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.practice-context .icon {
  width: 14px;
  height: 14px;
}

.context-action {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 28px;
  margin-left: auto;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: #5f6972;
  background: #fff;
  font-size: 12px;
  font-weight: 800;
}

.question-card {
  min-height: 560px;
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 8px 28px rgba(32, 37, 42, 0.05);
}

.question-card.loading {
  color: #7a838c;
}

.question-meta {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 18px;
}

.question-meta span {
  padding: 5px 8px;
  border-radius: 5px;
  color: #66717a;
  background: #f0f2f3;
  font-size: 11px;
  font-weight: 800;
}

.question-meta span:first-child {
  color: var(--green-dark);
  background: var(--green-soft);
}

.favorite-button {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  margin-left: auto;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: #9aa2aa;
  background: #fff;
}

.favorite-button.active {
  color: #d28a18;
  border-color: #f3d7a7;
  background: #fff6e6;
}

.favorite-button.active .icon {
  fill: currentColor;
}

#question-stem {
  margin: 0 0 26px;
  font-size: 25px;
  line-height: 1.55;
  font-weight: 700;
}

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

.option {
  min-height: 62px;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  gap: 13px;
  align-items: center;
  padding: 13px 16px;
  border: 1px solid #dfe3e6;
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  line-height: 1.55;
  transition: border-color 120ms ease, background 120ms ease;
}

.option.skeleton {
  grid-template-columns: 34px 1fr;
  pointer-events: none;
  border-color: #edf0f1;
  background: #fafbfb;
}

.option.skeleton .option-key,
.option.skeleton span:last-child {
  overflow: hidden;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, #edf0f1 0%, #f7f9f8 46%, #edf0f1 100%);
  background-size: 220% 100%;
  animation: loading-shimmer 1.1s ease-in-out infinite;
}

.option.skeleton .option-key {
  width: 32px;
  height: 32px;
}

.option.skeleton span:last-child {
  width: min(78%, 420px);
  height: 16px;
}

@keyframes loading-shimmer {
  from {
    background-position: 120% 0;
  }

  to {
    background-position: -120% 0;
  }
}

.option-text {
  min-width: 0;
}

.option-result {
  display: none;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.option-explanation {
  display: none;
  grid-column: 2 / -1;
  margin-top: 2px;
  padding-top: 9px;
  border-top: 1px solid rgba(34, 160, 107, 0.16);
  color: #315a47;
  line-height: 1.72;
  font-size: 14px;
}

.explanation-copy {
  display: block;
  min-width: 0;
}

.option:hover {
  border-color: #9bd6bb;
  background: #fbfefc;
}

.option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.option-key {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 1px solid #d7dcdf;
  border-radius: 50%;
  color: #64707a;
  font-weight: 900;
}

.option:has(input:checked) {
  border-color: var(--green);
  background: var(--green-soft);
}

.option:has(input:checked) .option-key {
  color: #fff;
  border-color: var(--green);
  background: var(--green);
}

.option.correct {
  border-color: var(--green);
  background: var(--green-soft);
  box-shadow: inset 0 0 0 1px rgba(34, 160, 107, 0.16);
}

.option.correct.with-explanation {
  align-items: start;
}

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

.option.wrong,
.option.wrong:has(input:checked) {
  color: #7a1f1f;
  border-color: #d92d20;
  background: #fff1f0;
  box-shadow: inset 0 0 0 1px rgba(217, 45, 32, 0.24);
}

.option.wrong .option-key,
.option.wrong:has(input:checked) .option-key {
  color: #fff;
  border-color: #d92d20;
  background: #d92d20;
}

.option.correct .option-result,
.option.wrong .option-result {
  display: inline-flex;
  align-items: center;
}

.option.correct.with-explanation .option-explanation {
  display: block;
}

.option.correct .option-result {
  color: var(--green-dark);
  background: #d8f2e6;
}

.option.wrong .option-result {
  color: #b42318;
  background: #ffd8d5;
}

.feedback {
  margin: -8px 0 18px;
  padding: 17px;
  border-radius: 8px;
  color: #315a47;
  background: var(--green-soft);
  line-height: 1.75;
}

.feedback.bad {
  color: #804444;
  background: var(--red-soft);
}

.feedback strong {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 7px;
}

.feedback strong .icon {
  width: 21px;
  height: 21px;
}

.answer-dock {
  position: fixed;
  z-index: 10;
  left: var(--drawer);
  right: 0;
  bottom: 0;
  min-height: 84px;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 20px;
  padding: 14px max(28px, calc((100vw - var(--drawer) - 900px) / 2));
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.97);
  backdrop-filter: blur(12px);
}

.answer-button {
  min-width: 210px;
}

.content-view {
  width: min(960px, calc(100% - 48px));
  margin: 0 auto;
  padding: 34px 0 60px;
}

.content-header {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: end;
  margin-bottom: 24px;
}

.content-header h1 {
  margin: 0 0 6px;
  font-size: 30px;
}

.content-header p:last-child {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.mistake-list.full {
  display: grid;
  gap: 10px;
}

.mistake-row {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.mistake-row strong,
.mistake-row span {
  display: block;
}

.mistake-row strong {
  margin-bottom: 7px;
  line-height: 1.55;
}

.mistake-row span {
  color: var(--muted);
  font-size: 12px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.stat-grid div,
.progress-card,
.analysis-card,
.bank-card,
.settings-card {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.stat-grid span,
.stat-grid strong {
  display: block;
}

.stat-grid span .icon {
  width: 15px;
  height: 15px;
}

.stat-grid span {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
}

.stat-grid strong {
  margin-top: 5px;
  font-size: 28px;
}

.progress-card,
.analysis-card,
.bank-card,
.settings-card {
  margin-top: 14px;
}

.progress-card > div:first-child,
.bank-card > div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.progress-card span,
.bank-card span,
.bank-card p,
.settings-card p {
  color: var(--muted);
  font-size: 13px;
}

.progress-line {
  height: 8px;
  margin-top: 14px;
  overflow: hidden;
  border-radius: 999px;
  background: #edf0f1;
}

.progress-line i {
  display: block;
  width: 0;
  height: 100%;
  background: var(--green);
}

.analysis-card h2,
.bank-card h2 {
  margin: 0 0 14px;
  font-size: 17px;
}

.heading-with-icon .icon {
  color: var(--green);
}

.label-with-icon .icon {
  color: var(--green-dark);
}

.category-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.category-row {
  padding: 12px;
  border-radius: 8px;
  background: var(--surface-soft);
}

.category-row strong,
.category-row span {
  display: block;
}

.category-row span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.empty-copy {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.settings-card {
  max-width: 620px;
}

.danger-zone {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
}

.danger-zone strong {
  display: block;
  margin-bottom: 4px;
}

.drawer-overlay {
  display: none;
}

@media (max-width: 900px) {
  :root {
    --drawer: 0px;
  }

  .app-drawer {
    width: min(310px, 86vw);
    padding-top: max(18px, env(safe-area-inset-top));
    transform: translateX(-102%);
    box-shadow: 16px 0 40px rgba(32, 37, 42, 0.2);
    transition: transform 180ms ease;
  }

  .app-drawer.open {
    transform: translateX(0);
  }

  .drawer-close {
    display: grid;
  }

  .drawer-overlay {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: block;
    visibility: hidden;
    opacity: 0;
    background: rgba(16, 22, 19, 0.4);
    transition: opacity 180ms ease, visibility 180ms ease;
  }

  .drawer-overlay.open {
    visibility: visible;
    opacity: 1;
  }

  .workspace {
    margin-left: 0;
  }

  .mobile-header {
    position: sticky;
    top: 0;
    z-index: 9;
    height: 60px;
    padding: 0 14px;
  }

  .menu-button {
    display: block;
  }

  #view-practice,
  .content-view {
    width: 100%;
    padding-left: 14px;
    padding-right: 14px;
  }

  .practice-toolbar {
    grid-template-columns: 1fr;
  }

  .answer-dock {
    left: 0;
    min-height: 76px;
    padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  }
}

@media (max-width: 600px) {
  .streak-chip {
    max-width: 82px;
    white-space: nowrap;
  }

  #view-practice {
    padding-top: 12px;
    padding-bottom: 100px;
  }

  .practice-toolbar {
    gap: 9px;
    margin-bottom: 7px;
  }

  .type-switch {
    padding: 3px;
  }

  .type-tab {
    min-height: 42px;
  }

  .category-picker {
    min-height: 46px;
  }

  .practice-context {
    gap: 8px;
    overflow: hidden;
    white-space: nowrap;
  }

  .practice-context span:nth-of-type(3) {
    display: none;
  }

  .context-action {
    flex: 0 0 auto;
    max-width: 92px;
    overflow: hidden;
  }

  .question-card {
    min-height: calc(100vh - 260px);
    padding: 20px 16px;
    box-shadow: none;
  }

  .question-meta {
    margin-bottom: 14px;
  }

  #question-stem {
    margin-bottom: 20px;
    font-size: 20px;
    line-height: 1.55;
  }

  .options {
    gap: 9px;
  }

  .option {
    min-height: 58px;
    grid-template-columns: 32px minmax(0, 1fr);
    gap: 11px;
    padding: 12px;
    font-size: 15px;
  }

  .option-result {
    grid-column: 2;
    width: fit-content;
    margin-top: -2px;
  }

  .option-explanation {
    grid-column: 2;
    padding-top: 8px;
  }

  .feedback {
    font-size: 14px;
  }

  .answer-dock {
    gap: 10px;
  }

  .answer-button {
    width: 100%;
    min-width: 0;
    min-height: 52px;
    font-size: 16px;
  }

  .content-view {
    padding-top: 24px;
  }

  .content-header {
    display: grid;
    align-items: stretch;
  }

  .content-header h1 {
    font-size: 25px;
  }

  .content-header .primary {
    width: 100%;
  }

  .stat-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .stat-grid div {
    padding: 16px;
  }

  .category-list {
    grid-template-columns: 1fr;
  }

  .danger-zone {
    display: grid;
  }

  .danger-zone button {
    width: 100%;
  }

  .gate-card {
    padding: 24px 20px;
  }

  .gate-actions {
    grid-template-columns: 1fr;
  }
}
