:root {
  --bg: #f6f2e9;
  --card: #fffdf7;
  --ink: #24302d;
  --muted: #6f7975;
  --green: #2f6f5e;
  --green-soft: #e4f1ec;
  --line: #e4dac9;
  --orange: #b96b2c;
  --red: #a94442;
  --blue: #3b5f6c;
  --shadow: 0 14px 32px rgba(67, 52, 32, 0.1);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: linear-gradient(180deg, #f7f3ea 0%, #efe7d8 100%);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.container {
  width: min(100%, 840px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px 14px 30px;
}

.header {
  padding: 18px 6px 14px;
}

h1 {
  margin: 0 0 6px;
  font-size: 30px;
  font-weight: 950;
  line-height: 1.15;
  letter-spacing: 0.2px;
}

h2 {
  margin: 18px 0 12px;
  font-size: 25px;
  line-height: 1.3;
}

.subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.7;
}

.screen {
  display: none;
}

.screen.active {
  display: block;
}

.card {
  margin: 14px 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--card);
  box-shadow: var(--shadow);
}

.inner-card {
  min-height: 280px;
}

.practice-tabs {
  display: flex;
  gap: 8px;
  margin: 0 0 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.practice-tab {
  appearance: none;
  padding: 8px 12px;
  border: 0;
  border-radius: 12px;
  color: var(--muted);
  background: transparent;
  font-size: 15px;
  font-weight: 850;
  cursor: pointer;
}

.practice-tab.active {
  color: var(--green);
  background: var(--green-soft);
}

.practice-panel {
  display: none;
}

.practice-panel.active {
  display: block;
}

.label {
  display: block;
  margin: 10px 0 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.section-label {
  margin-top: 18px;
}

.choice-grid,
.action-grid,
.filter-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.choice-card,
.button {
  min-width: 0;
  min-height: 50px;
  padding: 14px 12px;
  border: 1px solid #e3dacb;
  border-radius: 18px;
  color: var(--ink);
  background: #fff;
  box-shadow: 0 4px 0 rgba(47, 111, 94, 0.12);
  font-size: 16px;
  font-weight: 850;
  cursor: pointer;
}

.choice-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  text-align: left;
  line-height: 1.45;
  color: #fff;
  background: var(--green);
  border-color: var(--green);
  box-shadow: 0 4px 0 rgba(47, 111, 94, 0.22);
}

.choice-card b,
.choice-card small {
  display: block;
}

.choice-card small {
  margin-top: 3px;
  font-size: 12px;
  font-weight: 700;
  opacity: 0.78;
}

.choice-arrow {
  display: none;
}

.type-grid .choice-card {
  justify-content: center;
  color: #fff;
  background: var(--blue);
  border-color: var(--blue);
  box-shadow: 0 4px 0 rgba(59, 95, 108, 0.18);
  text-align: center;
}

.type-grid .choice-arrow {
  display: none;
}

.choice-card:active,
.button:active {
  transform: translateY(1px);
}

.choice-card:focus-visible,
.button:focus-visible,
.practice-tab:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(47, 111, 94, 0.2);
  outline-offset: 2px;
}

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

.button.soft {
  color: var(--green);
  background: var(--green-soft);
  border-color: #bddbd1;
}

.button.warn {
  color: var(--orange);
  background: #fff6e9;
  border-color: #ecd0a8;
}

.button.danger {
  color: var(--red);
  background: #fff0ef;
  border-color: #ecc2c0;
}

.button.full {
  width: 100%;
  margin: 12px 0 6px;
}

.button.small {
  min-height: 38px;
  padding: 9px 10px;
  border-radius: 14px;
  font-size: 14px;
}

.button:disabled {
  opacity: 0.48;
  cursor: not-allowed;
}

.section-actions {
  margin-top: 12px;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 16px;
}

.metric {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  text-align: center;
}

.metric-icon {
  display: none;
}

.metric b {
  display: block;
  color: var(--green);
  font-size: 20px;
}

.metric small {
  color: var(--muted);
  font-size: 12px;
}

.notice {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid #efd4ad;
  border-radius: 18px;
  color: var(--muted);
  background: #fff6e9;
  font-size: 13px;
  line-height: 1.7;
}

.error-notice {
  color: var(--red);
  background: #fff0ef;
  border-color: #ecc2c0;
}

select,
input {
  width: 100%;
  min-height: 50px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  outline: none;
  color: var(--ink);
  background: #fff;
  font-size: 16px;
}

.field {
  display: block;
}

.practice-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.progress-wrap {
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.progress-track {
  width: min(220px, 55%);
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8e1d4;
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--green);
  transition: width 0.2s ease;
}

.pill-row {
  margin-top: 14px;
}

.type-pill,
.chapter-pill {
  display: inline-block;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
}

.type-pill {
  margin-right: 6px;
  color: var(--green);
  background: var(--green-soft);
}

.chapter-pill {
  color: var(--orange);
  background: #fff6e9;
}

.question-content {
  margin: 16px 0 12px;
  font-size: 22px;
  font-weight: 900;
  line-height: 1.55;
}

.content-block {
  margin: 0 0 10px;
}

.content-block:last-child {
  margin-bottom: 0;
}

.question-image,
.formula-image {
  display: block;
  max-width: 100%;
  object-fit: contain;
  background: #fff;
}

.question-image {
  width: 100%;
  max-height: 420px;
  margin: 10px 0;
  border: 1px solid var(--line);
  border-radius: 16px;
}

.formula-image {
  width: auto;
  max-height: 76px;
  margin: 6px auto;
  padding: 2px;
}

.math-inline {
  display: inline-block;
  max-width: 100%;
  vertical-align: -0.08em;
}

.math-display {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  max-width: 100%;
  margin: 10px 0;
  padding: 2px 0;
  overflow-x: auto;
  overflow-y: hidden;
  text-align: center;
}

.math-display .katex-display {
  display: inline-block;
  margin: 0 auto;
}

.option-list {
  margin: 8px 0;
}

.option {
  display: flex;
  width: 100%;
  min-height: 48px;
  align-items: flex-start;
  gap: 8px;
  margin: 8px 0;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  color: var(--ink);
  background: #fff;
  line-height: 1.55;
  text-align: left;
  cursor: pointer;
  transition: background 0.16s, border-color 0.16s, box-shadow 0.16s;
}

.option:hover:not(:disabled) {
  border-color: #9abeb0;
  background: #fbfefd;
}

.option-label {
  flex: none;
  color: var(--green);
  font-weight: 900;
}

.option.selected {
  border-color: var(--blue);
  background: #edf4f6;
  box-shadow: 0 0 0 2px rgba(59, 95, 108, 0.12);
}

.option.correct {
  border-color: #35a867;
  background: #e8f7ed;
  box-shadow: 0 0 0 2px rgba(53, 168, 103, 0.12);
}

.option.wrong {
  border-color: #e05252;
  background: #fff0f0;
  box-shadow: 0 0 0 2px rgba(224, 82, 82, 0.1);
}

.option:disabled {
  opacity: 1;
  cursor: default;
}

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

.judgment-option {
  justify-content: center;
  font-size: 19px;
  font-weight: 950;
}

.answer-feedback {
  min-height: 44px;
  margin: 10px 0 12px;
  padding: 10px 12px;
  border-radius: 14px;
  font-weight: 900;
  line-height: 1.55;
}

.answer-feedback.correct {
  color: #147a42;
  background: #e8f7ed;
  border: 1px solid #91d3aa;
}

.answer-feedback.wrong {
  color: #b92f2f;
  background: #fff0f0;
  border: 1px solid #efaaaa;
}

.confirm-choice {
  margin: 4px 0 8px;
}

.answer-panel {
  display: none;
  margin-top: 12px;
  padding: 14px;
  border: 1px solid #cfe3db;
  border-radius: 18px;
  background: #f8fbf9;
  font-size: 16px;
  line-height: 1.7;
}

.answer-panel.show {
  display: block;
}

.answer-section h3 {
  margin: 0 0 8px;
  color: var(--green);
  font-size: 16px;
}

.answer-section.analysis {
  margin-top: 18px;
}

.answer-section.analysis h3 {
  color: #b35f18;
}

.meta {
  margin-top: 12px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.list-summary {
  margin: 16px 0 8px;
  color: var(--muted);
  font-size: 13px;
}

.list-item {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 9px 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  color: var(--ink);
  background: #fff;
  text-align: left;
  cursor: pointer;
}

.list-item b,
.list-item small {
  display: block;
}

.list-item small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.excluded-item {
  cursor: default;
}

.restore-button {
  flex: none;
  padding: 8px 12px;
  border: 1px solid #bddbd1;
  border-radius: 12px;
  color: var(--green);
  background: var(--green-soft);
  font-weight: 850;
  cursor: pointer;
}

.inline-empty {
  padding: 30px 10px;
  color: var(--muted);
  line-height: 1.7;
  text-align: center;
}

.footer-info {
  width: 100%;
  margin: 18px 0 4px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 20px;
  color: var(--muted);
  background: rgba(255, 253, 247, 0.72);
  font-size: 13px;
  line-height: 1.8;
  text-align: center;
}

.footer-info b {
  color: var(--green);
}

.copy-wechat {
  padding: 0;
  border: 0;
  color: var(--green);
  background: transparent;
  font: inherit;
  font-weight: 900;
  text-decoration: underline;
  cursor: pointer;
}

.creator {
  margin-top: 5px;
  color: var(--green);
  font-size: 15px;
  font-weight: 950;
}

.dialog {
  width: min(390px, calc(100vw - 32px));
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 24px;
  color: var(--ink);
  background: var(--card);
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.25);
}

.dialog::backdrop {
  background: rgba(0, 0, 0, 0.42);
}

.dialog h2 {
  margin: 0 0 8px;
  font-size: 20px;
}

.dialog p {
  margin: 8px 0 14px;
  color: var(--muted);
  line-height: 1.7;
}

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

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 20;
  max-width: min(360px, calc(100vw - 40px));
  padding: 11px 15px;
  border-radius: 14px;
  color: #fff;
  background: #24302d;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.2);
  font-size: 14px;
  font-weight: 800;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity 0.16s, transform 0.16s;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 620px) {
  .container {
    padding: 12px 12px 30px;
  }

  .header {
    padding: 14px 4px 10px;
  }

  h1 {
    font-size: 27px;
  }

  .choice-grid,
  .action-grid,
  .filter-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .button,
  .choice-card {
    padding: 12px 10px;
    font-size: 15px;
  }

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

  .question-content {
    font-size: 20px;
  }

  .practice-toolbar {
    align-items: flex-start;
  }

  .progress-wrap {
    min-width: 0;
  }

  .progress-track {
    width: 100%;
  }

}
