:root {
  --bg: #f7f2e8;
  --surface: #fffdf8;
  --surface-strong: #ffffff;
  --ink: #2d2924;
  --muted: #7f756b;
  --line: #e7dccd;
  --line-strong: #d9c7b4;
  --accent: #bd6a3d;
  --accent-strong: #9e4f2d;
  --accent-soft: #f3dfcf;
  --green: #287a4a;
  --green-soft: #e7f3eb;
  --red: #b53d32;
  --red-soft: #fae8e4;
  --blue: #386d8f;
  --shadow: 0 18px 50px rgba(57, 43, 28, 0.08);
}

* {
  box-sizing: border-box;
}

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

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  font-family:
    "Microsoft YaHei",
    "PingFang SC",
    "Hiragino Sans GB",
    "Noto Sans CJK SC",
    system-ui,
    sans-serif;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.7), rgba(255, 255, 255, 0)),
    var(--bg);
  overflow-x: hidden;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

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

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

.home-view,
.practice-view {
  display: grid;
  gap: 18px;
}

.home-hero,
.panel,
.question-card,
.empty-state,
.practice-header {
  border: 1px solid rgba(147, 109, 77, 0.18);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.92);
  box-shadow: var(--shadow);
}

.home-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 420px);
  gap: 24px;
  align-items: end;
  padding: 30px;
}

.eyebrow,
.section-kicker {
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.eyebrow {
  margin-bottom: 6px;
}

h1 {
  font-size: clamp(36px, 6vw, 62px);
  font-weight: 780;
  line-height: 1.02;
}

.hero-subtitle {
  max-width: 620px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.7;
}

.top-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.top-stat,
.stat-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.top-stat {
  min-height: 76px;
  padding: 12px 14px;
}

.top-stat span,
.stat-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.top-stat strong {
  display: block;
  margin-top: 8px;
  font-size: 28px;
  line-height: 1;
}

.home-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(300px, 0.85fr);
  gap: 16px;
  align-items: start;
}

.panel {
  padding: 18px;
}

.mode-panel {
  grid-row: span 2;
}

.panel-heading {
  margin-bottom: 14px;
}

.panel-heading h2,
.settings-panel h2,
.practice-heading h2 {
  font-size: 20px;
  line-height: 1.2;
}

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

.mode-button {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  min-height: 126px;
  width: 100%;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--surface-strong);
  text-align: left;
  transition:
    border-color 160ms ease,
    background 160ms ease,
    transform 160ms ease,
    box-shadow 160ms ease;
}

.mode-button:hover {
  border-color: rgba(189, 106, 61, 0.5);
  background: #fff8f1;
  box-shadow: 0 14px 34px rgba(57, 43, 28, 0.08);
  transform: translateY(-2px);
}

.mode-button.is-active {
  border-color: rgba(189, 106, 61, 0.68);
  background: var(--accent-soft);
}

.mode-button strong {
  display: block;
  margin-bottom: 9px;
  font-size: 20px;
  line-height: 1.2;
}

.mode-button small {
  display: block;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.mode-button em {
  display: grid;
  min-width: 44px;
  min-height: 34px;
  place-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  color: var(--accent-strong);
  background: rgba(255, 255, 255, 0.72);
  font-size: 13px;
  font-style: normal;
  font-weight: 800;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

.stat-card {
  min-height: 76px;
  padding: 13px;
}

.stat-card strong {
  display: block;
  margin-top: 9px;
  font-size: 26px;
  line-height: 1;
}

.settings-panel {
  display: grid;
  gap: 14px;
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
}

.toggle-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.practice-view {
  width: min(920px, 100%);
  margin: 0 auto;
  min-width: 0;
}

.practice-header {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 16px;
}

.practice-heading p {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 13px;
}

.progress-pill {
  justify-self: end;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--accent-strong);
  background: #fff7ef;
  font-size: 14px;
  font-weight: 800;
  white-space: nowrap;
}

.practice-area {
  display: grid;
  gap: 14px;
  min-width: 0;
}

.question-card {
  padding: 28px;
  min-width: 0;
}

.question-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}

.question-meta span {
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.68);
  font-size: 13px;
  font-weight: 700;
}

.question-stem {
  margin-bottom: 22px;
  font-size: clamp(21px, 2.5vw, 30px);
  font-weight: 740;
  line-height: 1.5;
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: break-all;
  white-space: normal;
}

.option-list {
  display: grid;
  gap: 11px;
}

.option-button {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  width: 100%;
  min-height: 62px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--surface-strong);
  text-align: left;
  transition:
    border-color 150ms ease,
    background 150ms ease,
    transform 150ms ease;
}

.option-button:hover:not(:disabled) {
  border-color: var(--line-strong);
  transform: translateY(-1px);
}

.option-button.is-selected {
  border-color: rgba(189, 106, 61, 0.72);
  background: #fff2e8;
}

.option-button.is-correct {
  border-color: rgba(40, 122, 74, 0.4);
  background: var(--green-soft);
}

.option-button.is-incorrect {
  border-color: rgba(181, 61, 50, 0.48);
  background: var(--red-soft);
}

.option-button.is-muted {
  opacity: 0.64;
}

.option-key {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 8px;
  color: var(--accent-strong);
  background: #f8eadc;
  font-weight: 800;
}

.option-button.is-correct .option-key {
  color: var(--green);
  background: rgba(40, 122, 74, 0.12);
}

.option-button.is-incorrect .option-key {
  color: var(--red);
  background: rgba(181, 61, 50, 0.12);
}

.option-text {
  min-width: 0;
  padding-top: 4px;
  overflow-wrap: anywhere;
  line-height: 1.65;
}

.feedback-panel {
  margin-top: 20px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.76);
}

.feedback-heading {
  margin-bottom: 14px;
}

.result-badge {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 800;
}

.result-badge.is-correct {
  color: var(--green);
  background: var(--green-soft);
}

.result-badge.is-wrong {
  color: var(--red);
  background: var(--red-soft);
}

.answer-detail {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 0;
}

.answer-detail div {
  min-width: 0;
}

.answer-detail .full-row {
  grid-column: 1 / -1;
}

.answer-detail dt {
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
}

.answer-detail dd {
  margin: 0;
  overflow-wrap: anywhere;
  line-height: 1.6;
}

.action-bar,
.sub-action-bar {
  display: flex;
  align-items: center;
  gap: 10px;
}

.action-bar {
  justify-content: flex-end;
  margin-top: 22px;
}

.sub-action-bar {
  justify-content: flex-end;
  margin-top: 12px;
}

.button,
.link-button {
  min-height: 42px;
  border-radius: 8px;
  font-weight: 760;
}

.button {
  padding: 0 16px;
  border: 1px solid transparent;
}

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

.button-primary:hover:not(:disabled) {
  background: var(--accent-strong);
}

.button-primary:disabled {
  color: #9a8d80;
  background: #eaded2;
}

.button-ghost {
  color: var(--ink);
  border-color: var(--line);
  background: var(--surface-strong);
}

.button-ghost:hover:not(:disabled) {
  border-color: var(--line-strong);
  background: #fff7ef;
}

.button-danger {
  color: var(--red);
  border-color: rgba(181, 61, 50, 0.24);
  background: var(--red-soft);
}

.button-danger:hover {
  border-color: rgba(181, 61, 50, 0.44);
}

.link-button {
  padding: 0 4px;
  border: 0;
  color: var(--blue);
  background: transparent;
}

.link-button:hover {
  text-decoration: underline;
}

.empty-state {
  min-height: 360px;
  padding: 48px 28px;
  display: grid;
  place-content: center;
  text-align: center;
}

.empty-state h2 {
  margin-bottom: 10px;
  font-size: 24px;
}

.empty-state p {
  max-width: 520px;
  color: var(--muted);
  line-height: 1.7;
}

.toast {
  position: fixed;
  top: 18px;
  left: 50%;
  z-index: 10;
  max-width: min(480px, calc(100% - 32px));
  padding: 12px 16px;
  border: 1px solid rgba(189, 106, 61, 0.28);
  border-radius: 8px;
  color: var(--accent-strong);
  background: #fffaf4;
  box-shadow: var(--shadow);
  transform: translateX(-50%);
}

[hidden] {
  display: none !important;
}

@media (max-width: 900px) {
  .app-shell {
    width: min(100% - 24px, 760px);
    padding-top: 20px;
  }

  .home-hero,
  .home-grid {
    grid-template-columns: 1fr;
  }

  .mode-panel {
    grid-row: auto;
  }

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

  .progress-pill {
    align-self: start;
  }
}

@media (max-width: 620px) {
  .app-shell {
    width: min(100% - 16px, 100%);
    padding: 12px 0 28px;
  }

  body.is-practice .app-shell {
    width: 100%;
    max-width: 100%;
    padding-right: 8px;
    padding-left: 8px;
  }

  body.is-practice .practice-view,
  body.is-practice .practice-area,
  body.is-practice .question-card {
    width: 100%;
    max-width: 100%;
  }

  .home-hero,
  .panel,
  .question-card,
  .practice-header {
    padding: 14px;
  }

  .top-stats,
  .stats-grid,
  .mode-list,
  .answer-detail {
    grid-template-columns: 1fr;
  }

  .mode-button {
    min-height: 100px;
    padding: 15px;
  }

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

  .progress-pill {
    justify-self: stretch;
    text-align: center;
  }

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

  .question-stem {
    width: min(280px, 100%);
    max-width: 100%;
    font-size: 19px;
  }

  .option-button {
    grid-template-columns: 34px minmax(0, 1fr);
    min-height: 58px;
    padding: 12px;
  }

  .action-bar {
    display: grid;
    grid-template-columns: 1fr;
  }

  .button {
    width: 100%;
    min-height: 46px;
  }

  .sub-action-bar {
    align-items: stretch;
    flex-direction: column;
  }
}
