:root {
  color-scheme: light;
  --paper: #fbfaf4;
  --surface: #ffffff;
  --ink: #172522;
  --muted: #52615d;
  --line: #cbd5d0;
  --accent: #006b62;
  --accent-dark: #004b45;
  --accent-soft: #e4f2ef;
  --focus: #d77900;
  --success: #155f3d;
  --success-soft: #e7f4ec;
  --error: #9b271f;
  --error-soft: #faece9;
  --hint: #714b00;
  --hint-soft: #fff4d6;
  font-family: "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
  font-size: 112.5%;
  line-height: 1.65;
}

* {
  box-sizing: border-box;
}

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

body {
  min-width: 0;
  margin: 0;
  color: var(--ink);
  background: var(--paper);
}

button,
input,
select {
  font: inherit;
}

button,
select,
input[type="text"] {
  min-height: 3rem;
  border: 2px solid var(--ink);
  border-radius: 0.35rem;
  background: var(--surface);
  color: var(--ink);
}

button {
  padding: 0.55rem 1rem;
  font-weight: 700;
  cursor: pointer;
}

button:hover {
  background: var(--accent-soft);
}

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

.primary-button {
  border-color: var(--accent-dark);
  background: var(--accent);
  color: #ffffff;
}

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

:where(a, button, input, select, summary):focus-visible,
[tabindex="-1"]:focus-visible {
  outline: 4px solid var(--focus);
  outline-offset: 4px;
}

[hidden] {
  display: none !important;
}

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

.skip-link {
  position: fixed;
  z-index: 10;
  top: 0.5rem;
  left: 0.5rem;
  transform: translateY(-200%);
  padding: 0.65rem 1rem;
  border: 3px solid var(--ink);
  background: var(--surface);
  color: var(--ink);
  font-weight: 700;
}

.skip-link:focus {
  transform: none;
}

.page-width {
  width: min(100% - 2rem, 52rem);
  margin-inline: auto;
}

.site-header {
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.header-inner {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 2rem;
  padding-block: 1.5rem;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 7vw, 3.4rem);
  line-height: 1.05;
  letter-spacing: -0.04em;
}

h2 {
  font-size: clamp(1.55rem, 5vw, 2.25rem);
  line-height: 1.25;
}

h3 {
  font-size: 1.2rem;
}

.eyebrow,
.step-label {
  margin-bottom: 0.3rem;
  color: var(--accent-dark);
  font-size: 0.85rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.header-note {
  max-width: 15rem;
  margin-bottom: 0;
  color: var(--muted);
  text-align: right;
}

main {
  min-height: 65vh;
  padding-block: clamp(2rem, 6vw, 4rem);
}

.section-heading {
  max-width: 42rem;
  margin-bottom: 2rem;
}

.section-heading > :last-child {
  margin-bottom: 0;
}

.setup-form {
  padding-block: 1.5rem;
  border-block: 1px solid var(--line);
}

fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

legend,
.field-row > label {
  margin-bottom: 0.75rem;
  font-weight: 800;
}

.book-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.book-option {
  display: flex;
  min-height: 5.5rem;
  gap: 0.75rem;
  align-items: flex-start;
  padding: 1rem;
  border: 2px solid var(--line);
  border-radius: 0.4rem;
  background: var(--surface);
  cursor: pointer;
}

.book-option:has(input:checked) {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 2px var(--accent);
}

.book-option input {
  width: 1.3rem;
  height: 1.3rem;
  margin: 0.25rem 0 0;
  accent-color: var(--accent);
}

.book-option strong,
.book-option small {
  display: block;
}

.book-option small {
  margin-top: 0.2rem;
  color: var(--muted);
}

.field-row {
  display: grid;
  max-width: 34rem;
  margin-top: 1.5rem;
}

select,
input[type="text"] {
  width: 100%;
  padding: 0.55rem 0.7rem;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.summary-section {
  margin-top: 3rem;
}

.summary-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 1px solid var(--line);
}

.text-button {
  min-height: 2.5rem;
  padding: 0.25rem 0.5rem;
  border: 0;
  background: transparent;
  color: var(--accent-dark);
  text-decoration: underline;
}

.practice-meta {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  color: var(--muted);
  font-weight: 700;
}

.question-sheet {
  padding-top: 1.5rem;
  border-top: 5px solid var(--accent);
}

.question-context {
  margin-block: 1.5rem;
}

.formula-visual {
  margin-block: 1rem;
  font-family: "Segoe UI", "Microsoft YaHei", sans-serif;
  font-size: clamp(1.7rem, 8vw, 3rem);
  font-weight: 750;
  letter-spacing: 0.03em;
}

.choice-list {
  display: grid;
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.choice-option {
  display: flex;
  min-height: 3.25rem;
  align-items: center;
  gap: 0.75rem;
  padding: 0.55rem 0.75rem;
  border: 2px solid var(--line);
  border-radius: 0.35rem;
  background: var(--surface);
  cursor: pointer;
}

.choice-option:has(input:checked) {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.choice-option input {
  width: 1.35rem;
  height: 1.35rem;
  flex: 0 0 auto;
  accent-color: var(--accent);
}

.answer-help {
  margin-top: 0.4rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.form-message,
.feedback {
  margin-top: 1rem;
  padding: 0.8rem 1rem;
  border-left: 5px solid currentColor;
}

.error-message {
  color: var(--error);
  background: var(--error-soft);
}

.hint-message {
  color: var(--hint);
  background: var(--hint-soft);
}

.feedback[data-state="correct"] {
  color: var(--success);
  background: var(--success-soft);
}

.feedback[data-state="incorrect"] {
  color: var(--error);
  background: var(--error-soft);
}

.feedback h3,
.feedback p:last-child,
.form-message {
  margin-bottom: 0;
}

.data-wrap {
  max-width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 26rem;
  border-collapse: collapse;
  background: var(--surface);
}

caption {
  margin-bottom: 0.5rem;
  font-weight: 800;
  text-align: left;
}

th,
td {
  padding: 0.65rem;
  border: 1px solid var(--ink);
  text-align: center;
}

th {
  background: var(--accent-soft);
}

.bar-chart {
  display: grid;
  gap: 0.65rem;
  margin-block: 1rem;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(4.5rem, 8rem) minmax(8rem, 1fr) 3rem;
  gap: 0.6rem;
  align-items: center;
}

.bar-track {
  height: 1.35rem;
  border: 1px solid var(--ink);
  background: var(--surface);
}

.bar-fill {
  height: 100%;
  background: var(--accent);
}

.result-summary {
  margin-bottom: 2.5rem;
  padding-block: 1rem;
  border-block: 1px solid var(--line);
}

.result-list,
.history-list {
  padding-left: 1.5rem;
}

.result-list > li,
.history-list > li {
  padding-block: 1rem;
  border-bottom: 1px solid var(--line);
}

.result-status {
  font-weight: 800;
}

.site-footer {
  padding-block: 1.25rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.9rem;
}

.site-footer p {
  margin-bottom: 0;
}

@media (max-width: 40rem) {
  .header-inner,
  .practice-meta,
  .summary-heading {
    display: block;
  }

  .header-note {
    margin-top: 0.75rem;
    text-align: left;
  }

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

  .summary-heading {
    padding-bottom: 0.75rem;
  }

  .bar-row {
    grid-template-columns: minmax(4rem, 6rem) minmax(6rem, 1fr) 2.5rem;
  }
}

@media (max-width: 24rem) {
  .page-width {
    width: min(100% - 1rem, 52rem);
  }

  .button-row > button {
    width: 100%;
  }
}

@media (forced-colors: active) {
  .primary-button,
  .bar-fill {
    forced-color-adjust: none;
  }

  .book-option:has(input:checked),
  .choice-option:has(input:checked) {
    outline: 3px solid Highlight;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
  }
}
