:root {
  color-scheme: light;
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-soft: #f9fafb;
  --text: #18212f;
  --muted: #667085;
  --line: #d9e0ea;
  --primary: #2563eb;
  --primary-soft: #e8f0ff;
  --green: #059669;
  --green-soft: #e9f7f0;
  --amber: #b7791f;
  --amber-soft: #fff4d8;
  --red: #dc2626;
  --red-soft: #fff0f0;
  --shadow: 0 16px 42px rgba(24, 33, 47, 0.08);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  letter-spacing: 0;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 28px;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 0 14px;
  border-bottom: 1px solid var(--line);
}

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

.brand-mark {
  width: 58px;
  height: 58px;
  flex: 0 0 auto;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1 {
  margin: 0;
  font-size: clamp(24px, 5vw, 36px);
  line-height: 1.1;
}

h2 {
  margin: 0;
  font-size: 24px;
}

h3 {
  margin: 0;
  font-size: 22px;
  line-height: 1.45;
}

.header-stats,
.status-strip {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.stat-pill,
.chip {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.chip.blue {
  border-color: #bed1ff;
  background: var(--primary-soft);
  color: var(--primary);
}

.chip.green {
  border-color: #bce7d1;
  background: var(--green-soft);
  color: var(--green);
}

.chip.amber {
  border-color: #f0d58e;
  background: var(--amber-soft);
  color: var(--amber);
}

.chip.red {
  border-color: #f3b7b7;
  background: var(--red-soft);
  color: var(--red);
}

.tabs {
  display: flex;
  gap: 8px;
  margin: 18px 0;
}

.tab,
.button,
.link-button,
.segmented button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-weight: 800;
}

.tab {
  min-width: 110px;
  padding: 0 18px;
}

.tab.is-active,
.segmented button.is-active {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

.view {
  display: none;
}

.view.is-active {
  display: block;
}

.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin: 8px 0 14px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.76);
}

.toolbar.stacked {
  align-items: stretch;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 160px;
}

.field.grow {
  flex: 1 1 240px;
}

.field span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding: 0 12px;
}

input:focus,
select:focus,
button:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.22);
  outline-offset: 2px;
}

.button {
  padding: 0 16px;
}

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

.button.secondary {
  background: var(--surface-soft);
}

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

.button.warn {
  border-color: #efd083;
  background: var(--amber-soft);
  color: var(--amber);
}

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

.button.is-active {
  box-shadow: inset 0 0 0 2px currentColor;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(2, minmax(112px, 1fr));
  gap: 8px;
  min-width: 240px;
}

.question-area {
  margin-top: 16px;
}

.question-card {
  min-height: 360px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.card-topline {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 18px;
}

.counter {
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.hint-row,
.action-row,
.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.hint-row {
  margin: 18px 0 4px;
}

.action-row {
  margin-top: 22px;
}

.answer-box,
.feedback-box,
.empty-state,
.exam-panel {
  border-radius: var(--radius);
}

.answer-box,
.feedback-box {
  margin-top: 18px;
  padding: 16px;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  line-height: 1.75;
}

.answer-box.is-hidden {
  color: var(--muted);
}

.answer-box strong,
.feedback-box strong {
  display: block;
  margin-bottom: 6px;
}

.feedback-box.correct {
  border-color: #a8dfc1;
  background: var(--green-soft);
}

.feedback-box.wrong {
  border-color: #efb1b1;
  background: var(--red-soft);
}

.option-list {
  display: grid;
  gap: 10px;
  margin-top: 20px;
}

.option-row {
  display: grid;
  grid-template-columns: 24px 34px minmax(0, 1fr);
  align-items: start;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.option-row input {
  width: 20px;
  height: 20px;
  min-height: 20px;
  margin-top: 2px;
}

.option-key {
  font-weight: 900;
  color: var(--primary);
}

.option-text {
  line-height: 1.6;
}

.source-text {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.65;
}

.favorite-button {
  min-width: 46px;
  padding: 0 10px;
}

.favorite-button.is-active {
  border-color: #f0c15d;
  background: var(--amber-soft);
  color: var(--amber);
}

.exam-panel {
  display: none;
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  background: var(--surface);
}

.exam-panel.is-visible {
  display: block;
}

.wrong-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.jump-button {
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  color: var(--text);
  font-weight: 800;
}

.empty-state {
  padding: 28px;
  border: 1px dashed var(--line);
  color: var(--muted);
  text-align: center;
}

.app-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 14px;
}

.link-button {
  min-height: 36px;
  padding: 0 12px;
  background: transparent;
  color: var(--red);
}

.link-button.is-pending {
  border-color: #efaaaa;
  background: var(--red-soft);
}

.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 20;
  max-width: min(380px, calc(100vw - 32px));
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--text);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 160ms ease, transform 160ms ease;
  pointer-events: none;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 820px) {
  .app-shell {
    width: min(100% - 20px, 1180px);
    padding-top: 14px;
  }

  .app-header,
  .section-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .header-stats,
  .status-strip {
    justify-content: flex-start;
  }

  .toolbar,
  .tabs {
    gap: 10px;
  }

  .tab,
  .field,
  .segmented,
  .toolbar > .button {
    width: 100%;
  }

  .card-topline {
    align-items: flex-start;
    flex-direction: column;
  }

  .card-topline .meta-row {
    width: 100%;
    justify-content: flex-start;
  }

  .action-row .button {
    flex: 1 1 100%;
  }

  .favorite-button {
    width: auto;
    min-width: 76px;
  }

  .question-card {
    min-height: 420px;
    padding: 18px;
  }

  .option-row {
    grid-template-columns: 24px 30px minmax(0, 1fr);
  }
}
